sas
This commit is contained in:
28
Code/Gravity/NormalGravityTrigger.cs
Normal file
28
Code/Gravity/NormalGravityTrigger.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Code/Gravity/Teleporter.cs
Normal file
31
Code/Gravity/Teleporter.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Sandbox;
|
||||
|
||||
|
||||
public sealed class Teleporter : Component, Component.ITriggerListener
|
||||
{
|
||||
[Property] public GameObject ToPosGameObject { get; set; }
|
||||
[Property] public GameObject Building { get; set; }
|
||||
|
||||
public void OnTriggerEnter( Collider other )
|
||||
{
|
||||
var otherEntity = other.GameObject;
|
||||
|
||||
Log.Info($"{otherEntity.Name} Телепорт");
|
||||
|
||||
if (otherEntity.Components.TryGet<Dedugan>(out var controller))
|
||||
{
|
||||
Log.Info($"{otherEntity.Name} вошел в зону телепорта");
|
||||
|
||||
otherEntity.WorldPosition = ToPosGameObject.WorldPosition;
|
||||
controller.OverrideGravity = Vector3.Down;
|
||||
|
||||
controller.EyeAngles = new Angles( 0, ToPosGameObject.WorldRotation.Yaw(), 0 ).ToRotation();
|
||||
controller.Renderer.LocalRotation = new Angles( 0, ToPosGameObject.WorldRotation.Yaw(), 0 ).ToRotation();
|
||||
|
||||
if ( Building != null )
|
||||
{
|
||||
Building.Enabled = !Building.Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user