Add files via upload

This commit is contained in:
celisej567
2021-08-05 17:54:51 +03:00
committed by GitHub
parent d58ad89d11
commit 76b55e2a87
57 changed files with 5632 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
using Sandbox;
[Library( "ent_thruster" )]
public partial class ThrusterEntity : Prop, IUse
{
public float Force = 1000.0f;
public bool Massless = false;
public PhysicsBody TargetBody;
[Net]
public bool Enabled { get; set; } = true;
[Event.Physics.PostStep]
public virtual void OnPostPhysicsStep()
{
if ( IsServer && Enabled )
{
if ( TargetBody.IsValid() )
{
TargetBody.ApplyForceAt( Position, Rotation.Down * (Massless ? Force * TargetBody.Mass : Force) );
}
else if ( PhysicsBody.IsValid() )
{
PhysicsBody.ApplyForce( Rotation.Down * (Massless ? Force * PhysicsBody.Mass : Force) );
}
}
}
public bool IsUsable( Entity user )
{
return true;
}
public bool OnUse( Entity user )
{
Enabled = !Enabled;
return false;
}
protected override void OnDestroy()
{
base.OnDestroy();
if ( IsClient )
{
KillEffects();
}
}
}