feat: add EP in pooling system.

This commit is contained in:
Tungdv
2026-05-12 17:45:28 +07:00
parent 6cebb9079d
commit 0eb1706801
15 changed files with 125 additions and 30 deletions
+3 -2
View File
@@ -145,6 +145,7 @@ public partial class CECGameRun : ITickable
{
BMLogger.LogWarning("CECGameRun::LoadPrefabs, Loading prefabs from Resources. Consider using Addressables for better performance and memory management.");
_playerPrefab = Resources.Load<GameObject>(AddressResourceConfig.PlayerPrefab);
PrefabPoolManager.Instance.InitPool(_playerPrefab);
_monsterPrefab = Resources.Load<GameObject>(AddressResourceConfig.MonsterPrefab);
PrefabPoolManager.Instance.InitPool(_monsterPrefab, defaultCapacity: 200, maxSize: 250);
_npcServerPrefab = Resources.Load<GameObject>(AddressResourceConfig.NpcServerPrefab);
@@ -386,7 +387,7 @@ public partial class CECGameRun : ITickable
}
CECPlayer.InitStaticRes();
m_pHostPlayer = ObjectSpawner.Instance.InstantiateObject(_playerPrefab, setThisAsParent: true).AddComponent<CECHostPlayer>();
m_pHostPlayer = PrefabPoolManager.Instance.Spawn(_playerPrefab, Vector3.zero, Quaternion.identity, ObjectSpawner.Instance.transform).AddComponent<CECHostPlayer>();
m_pHostPlayer.InitCharacter(info);
if (m_pHostPlayer != null)
@@ -453,7 +454,7 @@ public partial class CECGameRun : ITickable
Debug.LogError("null prefab");
return null;
}
GameObject character = ObjectSpawner.Instance.InstantiateObject(_playerPrefab, setThisAsParent: true);
GameObject character = PrefabPoolManager.Instance.Spawn(_playerPrefab, Vector3.zero, Quaternion.identity, ObjectSpawner.Instance.transform);
return character.gameObject;
}
+7 -1
View File
@@ -258,6 +258,12 @@ namespace BrewMonster
{
UnregisterPlayerEventHandlers();
}
private void OnDisable()
{
UnregisterPlayerEventHandlers();
}
public bool IsAnimationExist(string animationName)
{
var exists = namedAnimancer.States.TryGet("ActionName", out var existingState) ? true : false;
@@ -395,4 +401,4 @@ namespace BrewMonster
return true;
}
}
}
}