aboutsummaryrefslogtreecommitdiffstats
path: root/code/pawn/component/AnimatorComponent.cs
diff options
context:
space:
mode:
Diffstat (limited to 'code/pawn/component/AnimatorComponent.cs')
-rw-r--r--code/pawn/component/AnimatorComponent.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/code/pawn/component/AnimatorComponent.cs b/code/pawn/component/AnimatorComponent.cs
new file mode 100644
index 0000000..6b27b15
--- /dev/null
+++ b/code/pawn/component/AnimatorComponent.cs
@@ -0,0 +1,26 @@
+using Sandbox;
+
+namespace MurderGame;
+
+public class AnimatorComponent : EntityComponent<Player>, ISingletonComponent
+{
+ public void Simulate()
+ {
+ var helper = new CitizenAnimationHelper( Entity );
+ var player = Entity;
+
+ helper.WithVelocity( Entity.Velocity );
+ helper.WithLookAt( Entity.EyePosition + Entity.EyeRotation.Forward * 100 );
+ helper.HoldType = CitizenAnimationHelper.HoldTypes.None;
+ helper.IsGrounded = Entity.GroundEntity.IsValid();
+ helper.DuckLevel = MathX.Lerp( helper.DuckLevel, player.Controller.HasTag( "ducked" ) ? 1 : 0, Time.Delta * 10.0f );
+ helper.VoiceLevel = (Game.IsClient && player.Client.IsValid()) ? player.Client.Voice.LastHeard < 0.5f ? player.Client.Voice.CurrentLevel : 0.0f : 0.0f;
+ helper.IsClimbing = player.Controller.HasTag( "climbing" );
+ helper.IsSwimming = player.GetWaterLevel() >= 0.5f;
+
+ if ( Entity.Controller.HasEvent( "jump" ) )
+ {
+ helper.TriggerJump();
+ }
+ }
+}