This commit is contained in:
opti1337 2024-10-30 13:33:29 +03:00
parent 6f0f0f3023
commit cb9cf36c58
4 changed files with 22 additions and 31 deletions

View File

@ -4,7 +4,7 @@ using System;
/// Used to control the Citizen animation state. You don't have to use this to animate your citizen avatar, but our
/// aim is to put everything you need in this class, so you can easily see what variables are available.
/// </summary>
[Title( "Animation Helper" )]
[Title( "[KPTL] Animation Helper" )]
[Category( "KPTL" )]
[Icon( "directions_run" )]
public sealed class AnimationHelper : Component, Component.ExecuteInEditor

View File

@ -4,7 +4,7 @@ using Sandbox.Utility;
namespace Sandbox;
[Title( "Connect" )]
[Title( "[KPTL] Connect" )]
[Category( "KPTL" )]
[Icon( "electrical_services" )]
public sealed class KPTLConnect : Component, Component.INetworkListener

View File

@ -20,8 +20,6 @@ public sealed class Kal : Component
[Property] [Range(200f, 500f, 20f)] public float JumpStrength { get; set; } = 350f;
[Sync] public Angles EyeAngles { get; set; }
// [Sync] public bool IsDucking { get; set; }
// [Sync] public bool IsRunning { get; set; }
protected override void OnStart()
{
@ -47,10 +45,10 @@ public sealed class Kal : Component
if ( Network.IsOwner )
{
var wishDirection = Input.AnalogMove.Normal * Rotation.FromYaw( EyeAngles.yaw );
var IsDucking = Input.Down( "Duck" );
var IsRunning = Input.Down( "Run" );
var wishSpeed = IsDucking ? DuckSpeed :
IsRunning ? RunSpeed : WalkSpeed;
var isDucking = Input.Down( "Duck" );
var isRunning = Input.Down( "Run" );
var wishSpeed = isDucking ? DuckSpeed :
isRunning ? RunSpeed : WalkSpeed;
Controller.WishVelocity = wishDirection * wishSpeed;
@ -63,10 +61,10 @@ public sealed class Kal : Component
}
if ( !AnimationHelper.IsValid() ) return;
AnimationHelper.DuckLevel = IsDucking ? 1f : 0f;
AnimationHelper.DuckLevel = isDucking ? 1f : 0f;
}
AnimationHelper.WithWishVelocity(Controller.WishVelocity);
AnimationHelper.WithVelocity(Controller.Velocity);
AnimationHelper.IsGrounded = Controller.IsOnGround;

View File

@ -10,26 +10,18 @@ public sealed class RagdollController : Component
// Sensible Indexes
// 3 - HEad
public void Toggle()
{
bool enable = !bodyPhysics.Enabled;
bodyPhysics.Enabled = enable;
bodyPhysics.MotionEnabled = enable;
bodyRenderer.UseAnimGraph = !enable;
}
public void EnableRagdoll()
[Sync]
private bool Enabled
{
bool enable = true;
bodyPhysics.Enabled = enable;
bodyPhysics.MotionEnabled = enable;
bodyRenderer.UseAnimGraph = !enable;
}
public void DisableRagdoll()
{
bool enable = false;
get => bodyPhysics.Enabled;
set
{
Log.Info(value);
bodyPhysics.Enabled = value;
bodyPhysics.MotionEnabled = value;
bodyRenderer.UseAnimGraph = !value;
}
}
void UpdateBody()
@ -114,9 +106,10 @@ public sealed class RagdollController : Component
{
if ( Network.IsOwner )
{
if(Input.Pressed( "Ragdoll" ))
if (Input.Pressed( "Ragdoll" ))
{
Toggle();
Log.Info(123123);
Enabled = !Enabled;
}
}