diff options
Diffstat (limited to 'code/pawn/component/movement')
| -rw-r--r-- | code/pawn/component/movement/BaseController.cs | 9 | ||||
| -rw-r--r-- | code/pawn/component/movement/PlayerController.cs | 34 |
2 files changed, 39 insertions, 4 deletions
diff --git a/code/pawn/component/movement/BaseController.cs b/code/pawn/component/movement/BaseController.cs index 0b92c75..02c0be1 100644 --- a/code/pawn/component/movement/BaseController.cs +++ b/code/pawn/component/movement/BaseController.cs @@ -3,7 +3,12 @@ namespace MurderGame;
//TODO make spectatro a controller
-public class BaseController : EntityComponent<Player>
+public abstract class BaseController
{
- public Player Player { get; set; }
+ public virtual float SpeedMultiplier { get; set; } = 1;
+
+ public abstract void Simulate(Player player);
+
+ public abstract bool HasEvent(string eventName);
+
}
diff --git a/code/pawn/component/movement/PlayerController.cs b/code/pawn/component/movement/PlayerController.cs index 2c9a9b9..f2658af 100644 --- a/code/pawn/component/movement/PlayerController.cs +++ b/code/pawn/component/movement/PlayerController.cs @@ -18,6 +18,9 @@ public class PlayerController : EntityComponent<Player> Vector3 LadderNormal;
+ TimeSince TimeSinceFootstep;
+ bool FootstepFoot;
+
bool Grounded => Entity.GroundEntity.IsValid();
public void Simulate( Player player )
@@ -43,13 +46,40 @@ public class PlayerController : EntityComponent<Player> if (zVel < -500)
{
var damageInfo = DamageInfo.Generic( Math.Abs((float)(zVel * 0.05)) );
- Entity.TakeDamage( damageInfo );
Entity.PlaySound( "fall" );
+ var trace = Trace.Ray( Entity.Position, Entity.Position + Vector3.Down * 20f )
+ .Radius( 1f )
+ .Ignore( Entity )
+ .Run();
+ if (trace.Hit)
+ {
+ trace.Surface.DoFootstep( Entity, trace, FootstepFoot ? 1 : 0, 70f );
+ }
+ Entity.TakeDamage( damageInfo );
return;
}
}
- var sprintMultiplier = TeamOperations.CanSprint( team ) ? (Input.Down( "run" ) ? 2.5f : 1f) : 1f;
+ var isSprinting = TeamOperations.CanSprint( team ) && Input.Down( "run" );
+ var footstepTimeThreshold = isSprinting ? 0.2 : 0.3;
+
+ if (moveVector.Length > 0 && TimeSinceFootstep > footstepTimeThreshold)
+ {
+ var trace = Trace.Ray( Entity.Position, Entity.Position + Vector3.Down * 20f )
+ .Radius( 1f )
+ .Ignore( Entity )
+ .Run();
+
+ if (trace.Hit)
+ {
+ FootstepFoot = !FootstepFoot;
+
+ trace.Surface.DoFootstep( Entity, trace, FootstepFoot ? 1 : 0, 40f );
+
+ TimeSinceFootstep = 0;
+ }
+ }
+ var sprintMultiplier = (isSprinting ? 2.5f : 1f);
Entity.Velocity = Accelerate( Entity.Velocity, moveVector.Normal, moveVector.Length, SpeedMultiplier * 200.0f * sprintMultiplier, 7.5f );
Entity.Velocity = ApplyFriction( Entity.Velocity, 4.0f );
|
