38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using Sandbox;
|
|
|
|
namespace VeloX;
|
|
|
|
|
|
public abstract partial class VeloXBase : Component
|
|
{
|
|
[Sync] public WaterState WaterState { get; set; }
|
|
[Sync] public bool IsEngineOnFire { get; set; }
|
|
[Sync, Range( 0, 1 ), Property] public float Brake { get; set; }
|
|
[Sync( SyncFlags.Interpolate ), Range( 0, 1 ), Property] public float Throttle { get; set; }
|
|
|
|
[Property] public Vector3 AngularDrag { get; set; } = new( -0.1f, -0.1f, -3 );
|
|
[Property] public float Mass { get; set; } = 900;
|
|
[Property, Group( "Components" )] public Rigidbody Body { get; protected set; }
|
|
[Property, Group( "Components" )] public Collider Collider { get; protected set; }
|
|
|
|
[Sync( SyncFlags.Interpolate )] public Angles SteerAngle { get; set; }
|
|
|
|
public Vector3 LocalVelocity;
|
|
public float ForwardSpeed;
|
|
public float TotalSpeed;
|
|
|
|
protected override void OnFixedUpdate()
|
|
{
|
|
if ( !IsDriver )
|
|
return;
|
|
|
|
LocalVelocity = WorldTransform.PointToLocal( WorldPosition + Body.Velocity );
|
|
ForwardSpeed = LocalVelocity.x;
|
|
TotalSpeed = LocalVelocity.Length;
|
|
Body.PhysicsBody.Mass = Mass;
|
|
|
|
PhysicsSimulate();
|
|
}
|
|
|
|
}
|