Skip to content

Commit

Permalink
cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stilnat committed Oct 27, 2024
1 parent 242b310 commit 82e0820
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,6 @@ protected override void OnDestroyed()
UnsubscribeFromEvents();
}

private void SubscribeToEvents()
{
_movementController.OnSpeedChangeEvent += UpdateMovement;
InstanceFinder.TimeManager.OnTick += HandleNetworkTick;
}

private void HandleGunAim(object sender, bool isAiming)
{
if (isAiming)
{
// Get the index of the layer named "UpperBody"
_animator.SetBool("Aim", true);
}
else
{
_animator.SetBool("Aim", false);
}
}

private void UnsubscribeFromEvents()
{
_movementController.OnSpeedChangeEvent -= UpdateMovement;
}

private void UpdateMovement(float speed)
{
bool isMoving = speed != 0;
float currentSpeed = _animator.GetFloat(SS3D.Systems.Entities.Data.Animations.Humanoid.MovementSpeed);
float newLerpModifier = isMoving ? _lerpMultiplier : (_lerpMultiplier * 3);
speed = Mathf.Lerp(currentSpeed, speed, Time.deltaTime * newLerpModifier);

_animator.SetFloat(SS3D.Systems.Entities.Data.Animations.Humanoid.MovementSpeed, speed);
}

public void Sit(bool sitState)
{
_animator.SetBool("Sit", sitState);
Expand Down Expand Up @@ -129,5 +95,39 @@ private void HandleNetworkTick()
{
_animator.SetFloat("AngleAimMove", (_movementController.InputAimAngle / 360f) + 0.5f);
}

private void SubscribeToEvents()
{
_movementController.OnSpeedChangeEvent += UpdateMovement;
InstanceFinder.TimeManager.OnTick += HandleNetworkTick;
}

private void HandleGunAim(object sender, bool isAiming)
{
if (isAiming)
{
// Get the index of the layer named "UpperBody"
_animator.SetBool("Aim", true);
}
else
{
_animator.SetBool("Aim", false);
}
}

private void UnsubscribeFromEvents()
{
_movementController.OnSpeedChangeEvent -= UpdateMovement;
}

private void UpdateMovement(float speed)
{
bool isMoving = speed != 0;
float currentSpeed = _animator.GetFloat(SS3D.Systems.Entities.Data.Animations.Humanoid.MovementSpeed);
float newLerpModifier = isMoving ? _lerpMultiplier : (_lerpMultiplier * 3);
speed = Mathf.Lerp(currentSpeed, speed, Time.deltaTime * newLerpModifier);

_animator.SetFloat(SS3D.Systems.Entities.Data.Animations.Humanoid.MovementSpeed, speed);
}
}
}
1 change: 1 addition & 0 deletions Assets/Scripts/SS3D/Systems/Inventory/Containers/Hand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public void Awake()

public override void CreateSourceInteractions(IInteractionTarget[] targets, List<InteractionEntry> entries)
{
// todo : hands should not handle sit interactions, ass should, but the interaction controller needs some changes to handle interaction sources other than hands
base.CreateSourceInteractions(targets, entries);
IInteractionTarget target = targets.FirstOrDefault(x => x?.GameObject.GetComponent<Sittable>());

Expand Down

0 comments on commit 82e0820

Please sign in to comment.