Fix item removed being called one too many times, fix Pulver movement
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Input
|
||||
// --- Movement State ---
|
||||
private Vector3 targetPosition;
|
||||
private Vector3 directMoveVelocity; // default is Vector3.zero
|
||||
private bool isHolding;
|
||||
internal bool isHolding;
|
||||
private Vector2 lastHoldPosition;
|
||||
private Coroutine pathfindingDragCoroutine;
|
||||
private float pathfindingDragUpdateInterval = 0.1f; // Interval in seconds
|
||||
@@ -28,6 +28,10 @@ namespace Input
|
||||
private Transform artTransform;
|
||||
private SpriteRenderer spriteRenderer;
|
||||
|
||||
// --- Last direct movement direction ---
|
||||
private Vector3 _lastDirectMoveDir = Vector3.right;
|
||||
public Vector3 LastDirectMoveDir => _lastDirectMoveDir;
|
||||
|
||||
// --- MoveToAndNotify State ---
|
||||
public delegate void ArrivedAtTargetHandler();
|
||||
private Coroutine moveToCoroutine;
|
||||
@@ -184,6 +188,9 @@ namespace Input
|
||||
adjustedMove = toTarget;
|
||||
}
|
||||
transform.position += adjustedMove;
|
||||
|
||||
// Cache the last direct movement direction
|
||||
_lastDirectMoveDir = directMoveVelocity.normalized;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Interactions
|
||||
{
|
||||
if (itemToSlot == null)
|
||||
{
|
||||
_currentlySlottedItemData = null;
|
||||
_currentlySlottedItemObject = null;
|
||||
_currentlySlottedItemData = null;
|
||||
}
|
||||
else
|
||||
@@ -115,12 +115,11 @@ namespace Interactions
|
||||
itemToSlot.SetActive(false);
|
||||
itemToSlot.transform.SetParent(null);
|
||||
SetSlottedObject(itemToSlot);
|
||||
|
||||
_currentlySlottedItemData = itemToSlotData;
|
||||
if (clearFollowerHeldItem)
|
||||
{
|
||||
FollowerController.ClearHeldItem();
|
||||
}
|
||||
}
|
||||
if (clearFollowerHeldItem)
|
||||
{
|
||||
FollowerController.ClearHeldItem();
|
||||
}
|
||||
UpdateSlottedSprite();
|
||||
|
||||
@@ -141,5 +140,17 @@ namespace Interactions
|
||||
Interactable.BroadcastInteractionComplete(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_currentlySlottedItemObject != null)
|
||||
{
|
||||
Debug.Log($"[ItemSlot] Slotted item: {_currentlySlottedItemObject.name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("[ItemSlot] No item slotted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class FollowerController: MonoBehaviour
|
||||
/// </summary>
|
||||
public float manualMoveSmooth = 8f;
|
||||
|
||||
private GameObject _playerRef;
|
||||
private Transform _playerTransform;
|
||||
private AIPath _playerAIPath;
|
||||
private AIPath _aiPath;
|
||||
@@ -59,6 +60,8 @@ public class FollowerController: MonoBehaviour
|
||||
public event FollowerPickupHandler OnPickupReturned;
|
||||
private Coroutine _pickupCoroutine;
|
||||
|
||||
private Input.PlayerTouchController _playerTouchController;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_aiPath = GetComponent<AIPath>();
|
||||
@@ -183,8 +186,10 @@ public class FollowerController: MonoBehaviour
|
||||
GameObject playerObj = GameObject.FindGameObjectWithTag("Player");
|
||||
if (playerObj != null)
|
||||
{
|
||||
_playerRef = playerObj;
|
||||
_playerTransform = playerObj.transform;
|
||||
_playerAIPath = playerObj.GetComponent<AIPath>();
|
||||
_playerTouchController = playerObj.GetComponent<Input.PlayerTouchController>();
|
||||
if (_playerAIPath != null)
|
||||
{
|
||||
_playerMaxSpeed = _playerAIPath.maxSpeed;
|
||||
@@ -196,6 +201,7 @@ public class FollowerController: MonoBehaviour
|
||||
{
|
||||
_playerTransform = null;
|
||||
_playerAIPath = null;
|
||||
_playerTouchController = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +228,11 @@ public class FollowerController: MonoBehaviour
|
||||
moveDir = _playerAIPath.velocity.normalized;
|
||||
_lastMoveDir = moveDir;
|
||||
}
|
||||
else if (_playerTouchController != null && _playerTouchController.isHolding && _playerTouchController.LastDirectMoveDir.sqrMagnitude > 0.01f)
|
||||
{
|
||||
moveDir = _playerTouchController.LastDirectMoveDir;
|
||||
_lastMoveDir = moveDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
moveDir = _lastMoveDir;
|
||||
|
||||
Reference in New Issue
Block a user