This commit is contained in:
Oscar
2025-06-08 23:43:22 +03:00
parent a6f2e43c49
commit 160429eae6
34 changed files with 5219 additions and 1905 deletions

View File

@@ -0,0 +1,54 @@
namespace Sandbox.Gravity;
public sealed class InteractTeleporter : Component, Component.ITriggerListener
{
[Property] public GameObject ToPosGameObject { get; set; }
[Property, Sync] public List<Dedugan> Players { get; set; } = new();
public void OnTriggerEnter( Collider other )
{
var otherEntity = other.GameObject;
if ( otherEntity.Components.TryGet<Dedugan>( out var controller ) )
{
Players.Add( controller );
}
}
public void OnTriggerExit( Collider other )
{
var otherEntity = other.GameObject;
if ( otherEntity.Components.TryGet<Dedugan>( out var controller ) )
{
Players.Remove( controller );
}
}
public void TeleportAll()
{
foreach ( var controller in Players )
{
Teleport( controller );
}
}
[Rpc.Broadcast]
public void Teleport( Dedugan controller )
{
controller.OverrideGravity = WorldRotation.Down;
controller.GameObject.WorldPosition = ToPosGameObject.WorldPosition;
controller.EyeAngles = new Angles( 0, ToPosGameObject.WorldRotation.Yaw(), 0 ).ToRotation();
controller.Renderer.LocalRotation = new Angles( 0, ToPosGameObject.WorldRotation.Yaw(), 0 ).ToRotation();
}
[Rpc.Broadcast]
public void Teleport( Dedugan controller, Vector3 toPos )
{
controller.OverrideGravity = WorldRotation.Down;
controller.GameObject.WorldPosition = toPos;
controller.EyeAngles = new Angles( 0, ToPosGameObject.WorldRotation.Yaw(), 0 ).ToRotation();
controller.Renderer.LocalRotation = new Angles( 0, ToPosGameObject.WorldRotation.Yaw(), 0 ).ToRotation();
}
}

View File

@@ -12,8 +12,6 @@ public sealed class Teleporter : Component, Component.ITriggerListener
// [Property] public bool ResetGravity { get; set; } = false;
// [Property] public bool NormalGravity { get; set; } = true;
[Property] public GravityType gravityType { get; set; } = GravityType.Down;
public void OnTriggerEnter( Collider other )