[Player][Interactions] Refactor common settings to be in the Game Settings SO. Update follow paramters and pathfinding for Pulver

This commit is contained in:
Michal Pikulski
2025-09-04 11:12:19 +02:00
parent 65d8be6cf2
commit 5d395ba4f4
8 changed files with 185 additions and 103 deletions

View File

@@ -38,12 +38,10 @@ public class Pickup : MonoBehaviour
void OnDrawGizmos()
{
// Get stop distance from GameManager or default
float playerStopDistance = GameManager.Instance != null ? GameManager.Instance.PlayerStopDistance : 1.0f;
// Draw stop distance circle around pickup
// Use GameManager for playerStopDistance
float playerStopDistance = GameManager.Instance.PlayerStopDistance;
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(transform.position, playerStopDistance);
// Draw stop point (where player is told to move)
GameObject playerObj = GameObject.FindGameObjectWithTag("Player");
if (playerObj != null)
{
@@ -58,8 +56,11 @@ public class Pickup : MonoBehaviour
{
if (itemData != null)
{
if (iconRenderer != null)
if (iconRenderer != null && itemData.mapSprite != null)
{
iconRenderer.sprite = itemData.mapSprite;
// Removed scaling logic, just set sprite
}
gameObject.name = itemData.itemName;
// Optionally update other fields, e.g. description
}
@@ -69,7 +70,6 @@ public class Pickup : MonoBehaviour
{
if (pickupInProgress) return;
pickupInProgress = true;
// Find player and follower controllers
var playerObj = GameObject.FindGameObjectWithTag("Player");
var followerObj = GameObject.FindGameObjectWithTag("Pulver");
if (playerObj == null || followerObj == null)
@@ -86,20 +86,17 @@ public class Pickup : MonoBehaviour
pickupInProgress = false;
return;
}
// Get settings from GameManager
float playerStopDistance = GameManager.Instance != null ? GameManager.Instance.PlayerStopDistance : 1.0f;
float followerPickupDelay = GameManager.Instance != null ? GameManager.Instance.FollowerPickupDelay : 0.2f;
// Subscribe to player arrival event
// Use GameManager for playerStopDistance and followerPickupDelay
float playerStopDistance = GameManager.Instance.PlayerStopDistance;
float followerPickupDelay = GameManager.Instance.FollowerPickupDelay;
void OnPlayerArrived()
{
playerController.OnArrivedAtTarget -= OnPlayerArrived;
// After player arrives, dispatch follower after delay
StartCoroutine(DispatchFollower());
}
System.Collections.IEnumerator DispatchFollower()
{
yield return new WaitForSeconds(followerPickupDelay);
// Subscribe to follower events
followerController.OnPickupArrived += OnFollowerArrived;
followerController.OnPickupReturned += OnFollowerReturned;
followerController.GoToPointAndReturn(transform.position, playerObj.transform);
@@ -107,7 +104,6 @@ public class Pickup : MonoBehaviour
void OnFollowerArrived()
{
followerController.OnPickupArrived -= OnFollowerArrived;
// Optionally: play pickup animation, etc.
}
void OnFollowerReturned()
{