blob: bc5fdc6f3b87125aa45d79cbd0f948831397d158 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
using System.Linq;
using Sandbox;
namespace MurderGame;
public class FootprintTrackerComponent : EntityComponent<Player>, ISingletonComponent
{
private bool FootstepLeft = true;
private TimeSince TimeSinceFootstep = 0;
public void Simulate( IClient cl )
{
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 )
{
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 )
.WithAnyTags( "solid" )
.Ignore( Entity )
.Run();
if ( !tr.Hit )
{
continue;
}
var material = FootstepLeft
? "materials/left_shoe_footprint.vmat"
: "materials/right_shoe_footprint.vmat";
var _ = new Footprint
{
SpriteMaterial = Material.Load( material ),
SpriteScale = 24f,
Position = player.Position + Vector3.Up * 1f,
Rotation = Rotation.LookAt( player.Velocity, tr.Normal ).RotateAroundAxis( tr.Normal, 270 ),
Color = player.Color
};
}
}
}
|