diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2023-07-30 02:45:36 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2023-07-30 02:45:36 +0100 |
| commit | 914512435d37d9f1e1ea4c045afd4ec5612b7534 (patch) | |
| tree | aca7ae248159ad9dd6bf5ec09c4f6b2b4eb92848 /code/pawn/component/AnimatorComponent.cs | |
| parent | d599275439cd35e0d3e3146e39be809df55459bd (diff) | |
Replace movement controllers
Diffstat (limited to 'code/pawn/component/AnimatorComponent.cs')
| -rw-r--r-- | code/pawn/component/AnimatorComponent.cs | 26 |
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();
+ }
+ }
+}
|
