feat: add EP in pooling system.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user