diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2023-08-06 17:21:45 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2023-08-06 17:21:45 +0100 |
| commit | 0bba89a7858ce091f485e04284f853e1f7f304af (patch) | |
| tree | 89ba42616e0f245cc84c96cc5b353eea117057d0 /code/pawn/component/FootprintTrackerComponent.cs | |
| parent | 87d74b50bf443bf199be05bd03afdca6ece082ff (diff) | |
Diffstat (limited to 'code/pawn/component/FootprintTrackerComponent.cs')
| -rw-r--r-- | code/pawn/component/FootprintTrackerComponent.cs | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/code/pawn/component/FootprintTrackerComponent.cs b/code/pawn/component/FootprintTrackerComponent.cs index 7a396d1..bc5fdc6 100644 --- a/code/pawn/component/FootprintTrackerComponent.cs +++ b/code/pawn/component/FootprintTrackerComponent.cs @@ -4,27 +4,39 @@ using Sandbox; namespace MurderGame;
public class FootprintTrackerComponent : EntityComponent<Player>, ISingletonComponent
-{
- private TimeSince TimeSinceFootstep = 0;
+{
private bool FootstepLeft = true;
+ private TimeSince TimeSinceFootstep = 0;
public void Simulate( IClient cl )
{
- if (!Game.IsClient || TimeSinceFootstep < 0.25) return;
+ if ( !Game.IsClient || TimeSinceFootstep < 0.25 )
+ {
+ return;
+ }
+
TimeSinceFootstep = 0;
FootstepLeft = !FootstepLeft;
-
- var bystanders = Game.Clients.Where(c => (c.Pawn as Player)?.Team is Team.Bystander or Team.Detective);
-
- foreach (var bystander in bystanders)
+
+ var bystanders = Game.Clients.Where( c => (c.Pawn as Player)?.Team is Team.Bystander or Team.Detective );
+
+ foreach ( var bystander in bystanders )
{
- if (bystander.Pawn is not Player player) continue;
- if (player.Velocity.Length < 1) continue;
+ if ( bystander.Pawn is not Player player )
+ {
+ continue;
+ }
+
+ if ( player.Velocity.Length < 1 )
+ {
+ continue;
+ }
+
var start = player.Position + Vector3.Up;
var end = start + Vector3.Down * 20;
-
+
var tr = Trace.Ray( start, end )
- .Size( 2)
+ .Size( 2 )
.WithAnyTags( "solid" )
.Ignore( Entity )
.Run();
@@ -39,13 +51,12 @@ public class FootprintTrackerComponent : EntityComponent<Player>, ISingletonComp : "materials/right_shoe_footprint.vmat";
var _ = new Footprint
{
- SpriteMaterial = Material.Load(material),
+ SpriteMaterial = Material.Load( material ),
SpriteScale = 24f,
- Position = player.Position + (Vector3.Up * 1f),
- Rotation = Rotation.LookAt(player.Velocity, tr.Normal).RotateAroundAxis( tr.Normal, 270 ),
+ Position = player.Position + Vector3.Up * 1f,
+ Rotation = Rotation.LookAt( player.Velocity, tr.Normal ).RotateAroundAxis( tr.Normal, 270 ),
Color = player.Color
};
}
}
-
}
|
