From 914512435d37d9f1e1ea4c045afd4ec5612b7534 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Sun, 30 Jul 2023 02:45:36 +0100 Subject: Replace movement controllers --- code/pawn/component/AnimatorComponent.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 code/pawn/component/AnimatorComponent.cs (limited to 'code/pawn/component/AnimatorComponent.cs') 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, 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(); + } + } +} -- cgit v1.2.3-70-g09d2