26 lines
708 B
C#
26 lines
708 B
C#
using Sandbox;
|
|
|
|
|
|
public sealed class Teleporter : Component, Component.ITriggerListener
|
|
{
|
|
[Property] public GameObject ToPosGameObject { 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, 180, 0 ).ToRotation();
|
|
controller.Renderer.LocalRotation = new Angles( 0, 180, 0 ).ToRotation();
|
|
}
|
|
}
|
|
}
|