First project upload
This commit is contained in:
@@ -60,7 +60,7 @@ public class CashBagSpawner : MonoBehaviour
|
||||
|
||||
// ─── Runtime ─────────────────────────────────────────────
|
||||
private ObjectPool _pool;
|
||||
private readonly List<CashBag> _activeBags = new List<CashBag>();
|
||||
private readonly List<CashMag> _activeBags = new List<CashMag>();
|
||||
private readonly HashSet<int> _occupiedSpawnPoints = new HashSet<int>(); // tracks which spawn points have an active bag
|
||||
private readonly Dictionary<int, float> _spawnPointCooldowns = new Dictionary<int, float>(); // prevents same-point reuse
|
||||
private const float SPAWN_POINT_COOLDOWN = 8f; // seconds before a freed point can be reused
|
||||
@@ -204,8 +204,8 @@ public class CashBagSpawner : MonoBehaviour
|
||||
bagObj = Instantiate(cashBagPrefab, spawnPos, Quaternion.identity);
|
||||
}
|
||||
|
||||
CashBag bag = bagObj.GetComponent<CashBag>();
|
||||
if (bag == null) bag = bagObj.AddComponent<CashBag>();
|
||||
CashMag bag = bagObj.GetComponent<CashMag>();
|
||||
if (bag == null) bag = bagObj.AddComponent<CashMag>();
|
||||
|
||||
// Apply zone-based value multiplier — contested bags are worth MORE
|
||||
float zoneMultiplier = GetZoneValueMultiplier(zone);
|
||||
@@ -526,7 +526,7 @@ public class CashBagSpawner : MonoBehaviour
|
||||
private bool IsPositionValid(Vector3 pos)
|
||||
{
|
||||
// Check distance from active bags (using EntityRegistry — zero alloc)
|
||||
var bags = EntityRegistry<CashBag>.GetAll();
|
||||
var bags = EntityRegistry<CashMag>.GetAll();
|
||||
for (int i = 0; i < bags.Count; i++)
|
||||
{
|
||||
if (bags[i] != null && Vector3.Distance(pos, bags[i].transform.position) < minSpawnDistance)
|
||||
@@ -553,7 +553,7 @@ public class CashBagSpawner : MonoBehaviour
|
||||
|
||||
// ─── Event Handlers ──────────────────────────────────────
|
||||
|
||||
private void OnBagDespawned(CashBag bag)
|
||||
private void OnBagDespawned(CashMag bag)
|
||||
{
|
||||
_activeBags.Remove(bag);
|
||||
ReleaseSpawnPoint(bag);
|
||||
@@ -584,7 +584,7 @@ public class CashBagSpawner : MonoBehaviour
|
||||
}
|
||||
|
||||
/// <summary>Called when a bag is collected (legacy API for compatibility).</summary>
|
||||
public void OnBagCollected(CashBag bag)
|
||||
public void OnBagCollected(CashMag bag)
|
||||
{
|
||||
// Legacy API: only remove if bag is truly gone (inactive).
|
||||
// Don't remove carried bags — they're still in play.
|
||||
@@ -600,7 +600,7 @@ public class CashBagSpawner : MonoBehaviour
|
||||
/// Free the spawn point closest to a removed bag so it can be reused.
|
||||
/// Applies a cooldown so the same point isn't immediately reused.
|
||||
/// </summary>
|
||||
private void ReleaseSpawnPoint(CashBag bag)
|
||||
private void ReleaseSpawnPoint(CashMag bag)
|
||||
{
|
||||
if (bag == null || spawnPoints == null) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user