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