Add LightFootedEffect and StatusManager for player capabilities management
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Core.Domain.Status;
|
||||
using KBCore.Refs;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -24,6 +25,7 @@ namespace Infrastructure.Unity
|
||||
private Vector2 _moveInput;
|
||||
|
||||
public Rigidbody Rigidbody => rb;
|
||||
public StatusManager Status { get; private set; }
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -44,11 +46,17 @@ namespace Infrastructure.Unity
|
||||
private void Awake()
|
||||
{
|
||||
_actions = new InputSystem_Actions();
|
||||
Status = new StatusManager();
|
||||
|
||||
rb.freezeRotation = true;
|
||||
rb.useGravity = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Status.Tick(Time.deltaTime);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
HandleMovement();
|
||||
@@ -57,6 +65,8 @@ namespace Infrastructure.Unity
|
||||
|
||||
private void HandleMovement()
|
||||
{
|
||||
var currentSpeed = moveSpeed * Status.CurrentCapabilities.SpeedMultiplier;
|
||||
|
||||
var targetVelocity = Vector3.zero;
|
||||
var snapAxis = Vector3.zero;
|
||||
|
||||
@@ -64,12 +74,12 @@ namespace Infrastructure.Unity
|
||||
{
|
||||
if (Mathf.Abs(_moveInput.x) > Mathf.Abs(_moveInput.y))
|
||||
{
|
||||
targetVelocity = new Vector3(_moveInput.x > 0 ? moveSpeed : -moveSpeed, 0, 0);
|
||||
targetVelocity = new Vector3(_moveInput.x > 0 ? currentSpeed : -currentSpeed, 0, 0);
|
||||
snapAxis = Vector3.forward;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetVelocity = new Vector3(0, 0, _moveInput.y > 0 ? moveSpeed : -moveSpeed);
|
||||
targetVelocity = new Vector3(0, 0, _moveInput.y > 0 ? currentSpeed : -currentSpeed);
|
||||
snapAxis = Vector3.right;
|
||||
}
|
||||
}
|
||||
@@ -107,6 +117,8 @@ namespace Infrastructure.Unity
|
||||
|
||||
private void DetectGround()
|
||||
{
|
||||
if (!Status.CurrentCapabilities.CanTriggerDecay) return;
|
||||
|
||||
if (Physics.Raycast(transform.position, Vector3.down, out var hit, groundCheckDistance, tileLayer))
|
||||
{
|
||||
if (hit.collider.TryGetComponent<TileViewAdapter>(out var tileAdapter))
|
||||
|
||||
Reference in New Issue
Block a user