void DoCheck() { bool isReleased; #if POOLMANAGER isReleased = !PoolManager.Pools[group.Value].IsSpawned(gameObject.Value.transform); #else PoolDataController pdc = gameObject.Value.GetComponent <PoolDataController>(); isReleased = pdc != null ? pdc.claimed : false; #endif if (!storeResult.IsNone) { storeResult.Value = isReleased; } if (isReleased) { Fsm.Event(isTrue); } else { Fsm.Event(isFalse); } }
void Update() { switch (mCurState) { case State.Inactive: break; case State.Spawn: Transform t = EntityManager.instance.Spawn(type, null, null, null, useSpawnFX); mPoolController = t.GetComponentInChildren <PoolDataController>(); Vector3 pos = transform.position; t.position = new Vector3(pos.x, pos.y, t.position.z); PlanetAttachStatic pa = t.GetComponentInChildren <PlanetAttachStatic>(); if (pa != null) { pa.RefreshPos(); } ChangeState(State.SpawnWait); break; case State.SpawnWait: if (mPoolController != null) { if (mPoolController.claimed) { if (mCurTime >= delayRespawn) { ChangeState(State.Spawn); } else { mCurTime += Time.deltaTime; } } } else { ChangeState(State.Spawn); } break; } }
public void Release(Transform t) { PoolDataController pdc = t.GetComponent <PoolDataController>(); if (pdc != null) { FactoryData dat; if (mFactory.TryGetValue(pdc.factoryKey, out dat)) { pdc.claimed = true; dat.Release(t); } } else //not in the pool, just kill it { Object.Destroy(t.gameObject); } }
void ChangeState(State state) { mCurState = state; mCurTime = 0.0f; switch(state) { case State.Inactive: if(mPoolController != null) { //hm... mPoolController = null; } break; case State.Spawn: break; case State.SpawnWait: break; } }
public void Expand(int num) { for (int i = 0; i < num; i++) { //PoolDataController Transform t = (Transform)Object.Instantiate(template); t.parent = poolHolder; PoolDataController pdc = t.GetComponent <PoolDataController>(); if (pdc == null) { pdc = t.gameObject.AddComponent <PoolDataController>(); } pdc.factoryKey = template.name; t.gameObject.SetActiveRecursively(false); available.Add(t); } }
void ChangeState(State state) { mCurState = state; mCurTime = 0.0f; switch (state) { case State.Inactive: if (mPoolController != null) { //hm... mPoolController = null; } break; case State.Spawn: break; case State.SpawnWait: break; } }
void OnDestroy() { mPoolController = null; }
void Update() { switch(mCurState) { case State.Inactive: break; case State.Spawn: Transform t = EntityManager.instance.Spawn(type, null, null, null, useSpawnFX); mPoolController = t.GetComponentInChildren<PoolDataController>(); Vector3 pos = transform.position; t.position = new Vector3(pos.x, pos.y, t.position.z); PlanetAttachStatic pa = t.GetComponentInChildren<PlanetAttachStatic>(); if(pa != null) { pa.RefreshPos(); } ChangeState(State.SpawnWait); break; case State.SpawnWait: if(mPoolController != null) { if(mPoolController.claimed) { if(mCurTime >= delayRespawn) { ChangeState(State.Spawn); } else { mCurTime += Time.deltaTime; } } } else { ChangeState(State.Spawn); } break; } }
void OnDestroy() { mPoolController = null; }