using Sandbox; using System; namespace VeloX; public abstract partial class VeloXBase : Component { [Sync, Change( nameof( OnEngineIgnitionChange ) )] public bool EngineIgnition { get; set; } private void OnEngineIgnitionChange( bool oldvalue, bool newvalue ) { if ( newvalue ) Engine?.StartEngine(); else Engine?.StopEngine(); } [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 ( IsProxy ) return; LocalVelocity = WorldTransform.PointToLocal( WorldPosition + Body.Velocity ); ForwardSpeed = LocalVelocity.x; TotalSpeed = LocalVelocity.Length; Body.PhysicsBody.Mass = Mass; FixedUpdate(); } protected virtual void FixedUpdate() { UpdateInput(); PhysicsSimulate(); } }