29 lines
626 B
C#
29 lines
626 B
C#
using Sandbox;
|
|
|
|
public sealed class NormalGravityTrigger : Component, Component.ITriggerListener
|
|
{
|
|
[Property] public bool TriggerOnEnter { get; set; } = false;
|
|
|
|
public void OnTriggerEnter(Collider other)
|
|
{
|
|
if ( !TriggerOnEnter ) return;
|
|
|
|
var otherEntity = other.GameObject;
|
|
|
|
if (otherEntity.Components.TryGet<Dedugan>(out var controller))
|
|
{
|
|
controller.OverrideGravity = WorldRotation.Down;
|
|
}
|
|
}
|
|
|
|
public void OnTriggerExit(Collider other)
|
|
{
|
|
var otherEntity = other.GameObject;
|
|
|
|
if (otherEntity.Components.TryGet<Dedugan>(out var controller))
|
|
{
|
|
controller.OverrideGravity = Vector3.Zero;
|
|
}
|
|
}
|
|
}
|