/// <summary> /// Run by a SpawnPool when it is destroyed /// </summary> internal void SelfDestruct() { // Go through both lists and destroy everything foreach (Transform inst in this._despawned) { if (inst != null && this.spawnPool != null) // Tear-down-time protection { this.spawnPool.DestroyInstance(inst.gameObject); } } foreach (Transform inst in this._spawned) { if (inst != null && this.spawnPool != null) // Tear-down-time protection { this.spawnPool.DestroyInstance(inst.gameObject); } } this._spawned.Clear(); this._despawned.Clear(); // Probably overkill but no harm done this.prefab = null; this.prefabGO = null; this.spawnPool = null; }
/// <summary> /// 初始化 /// </summary> /// <param name="arr"></param> /// <param name="parent"></param> /// <returns></returns> public IEnumerator Init(GameObjectPoolEntity[] arr, Transform parent) { int len = arr.Length; for (int i = 0; i < len; i++) { GameObjectPoolEntity entity = arr[i]; if (entity.Pool != null) { UnityEngine.Object.Destroy(entity.Pool.gameObject); yield return(null); entity.Pool = null; } //创建对象池 PathologicalGames.SpawnPool pool = PathologicalGames.PoolManager.Pools.Create(entity.PoolName); pool.group.parent = parent; pool.group.localPosition = Vector3.zero; entity.Pool = pool; m_SpawnPoolDic[entity.PoolId] = entity; } }
public void Call(PathologicalGames.SpawnPool param0) { func.BeginPCall(); func.Push(param0); func.PCall(); func.EndPCall(); }
// Use this for initialization void Start() { //create a new zone spawn pool if we have not been provided withone if (this.zonePool == null) { string zonePoolName = "Zones"; if (!PathologicalGames.PoolManager.Pools.ContainsKey(zonePoolName)) { PathologicalGames.PoolManager.Pools.Create(zonePoolName); } this.zonePool = PathologicalGames.PoolManager.Pools [zonePoolName]; } }
static int CreateCharacterPool(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 4 && TypeChecker.CheckTypes(L, typeof(Logic.Pool.Controller.PoolController), typeof(string), typeof(string), typeof(bool))) { Logic.Pool.Controller.PoolController obj = (Logic.Pool.Controller.PoolController)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); string arg1 = ToLua.ToString(L, 3); bool arg2 = LuaDLL.lua_toboolean(L, 4); PathologicalGames.SpawnPool o = obj.CreateCharacterPool(arg0, arg1, arg2); ToLua.Push(L, o); return(1); } else if (count == 5 && TypeChecker.CheckTypes(L, typeof(Logic.Pool.Controller.PoolController), typeof(string), typeof(string), typeof(bool), typeof(System.Action <PathologicalGames.SpawnPool>))) { Logic.Pool.Controller.PoolController obj = (Logic.Pool.Controller.PoolController)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); string arg1 = ToLua.ToString(L, 3); bool arg2 = LuaDLL.lua_toboolean(L, 4); System.Action <PathologicalGames.SpawnPool> arg3 = null; LuaTypes funcType5 = LuaDLL.lua_type(L, 5); if (funcType5 != LuaTypes.LUA_TFUNCTION) { arg3 = (System.Action <PathologicalGames.SpawnPool>)ToLua.ToObject(L, 5); } else { LuaFunction func = ToLua.ToLuaFunction(L, 5); arg3 = DelegateFactory.CreateDelegate(typeof(System.Action <PathologicalGames.SpawnPool>), func) as System.Action <PathologicalGames.SpawnPool>; } obj.CreateCharacterPool(arg0, arg1, arg2, arg3); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: Logic.Pool.Controller.PoolController.CreateCharacterPool")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetPool(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); Logic.Pool.Controller.PoolController obj = (Logic.Pool.Controller.PoolController)ToLua.CheckObject(L, 1, typeof(Logic.Pool.Controller.PoolController)); string arg0 = ToLua.CheckString(L, 2); PathologicalGames.SpawnPool o = obj.GetPool(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int CreatePool(IntPtr L) { try { ToLua.CheckArgsCount(L, 4); Logic.Pool.Controller.PoolController obj = (Logic.Pool.Controller.PoolController)ToLua.CheckObject(L, 1, typeof(Logic.Pool.Controller.PoolController)); string arg0 = ToLua.CheckString(L, 2); string arg1 = ToLua.CheckString(L, 3); bool arg2 = LuaDLL.luaL_checkboolean(L, 4); PathologicalGames.SpawnPool o = obj.CreatePool(arg0, arg1, arg2); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/** * Attempts to spawns a copy of spawnable from pool at the center of the SpawnAreaBehavior's collider rotated by initRot. * * @return the transform of the spawned object, null if unsuccessful */ public Transform spawn(PathologicalGames.SpawnPool pool, Transform spawnable, Vector3 initRot) { Transform thingSpawned = pool.Spawn(spawnable); if (thingSpawned != null && !this.canSpawn(thingSpawned.GetComponent <Collider>())) { //failed to fit the object, despawn it! pool.Despawn(thingSpawned); thingSpawned = null; } else { Vector3 oldPos = thingSpawned.position; Vector3 oldRot = thingSpawned.eulerAngles; Vector3 newPos = this.GetComponent <Collider>().bounds.center; Vector3 newRot = initRot; if (thingSpawned.GetComponent <Rigidbody>()) { //check the constraints and reset the new coords to old coords where contraints are set RigidbodyConstraints c = thingSpawned.GetComponent <Rigidbody>().constraints; newPos.x = (c & RigidbodyConstraints.FreezePositionX) == RigidbodyConstraints.FreezePositionX ? oldPos.x : newPos.x; newPos.y = (c & RigidbodyConstraints.FreezePositionY) == RigidbodyConstraints.FreezePositionY ? oldPos.y : newPos.y; newPos.z = (c & RigidbodyConstraints.FreezePositionZ) == RigidbodyConstraints.FreezePositionZ ? oldPos.z : newPos.z; newRot.x = (c & RigidbodyConstraints.FreezeRotationX) == RigidbodyConstraints.FreezeRotationX ? oldRot.x : newRot.x; newRot.y = (c & RigidbodyConstraints.FreezeRotationY) == RigidbodyConstraints.FreezeRotationY ? oldRot.y : newRot.y; newRot.z = (c & RigidbodyConstraints.FreezeRotationZ) == RigidbodyConstraints.FreezeRotationZ ? oldRot.z : newRot.z; } thingSpawned.position = newPos; thingSpawned.Rotate(newRot); } return(thingSpawned); //if we've not yet returned, we've failed so return null }
internal void SelfDestruct() { this.prefab = null; this.prefabGO = null; this.spawnPool = null; foreach (PrefabPool.DespawnedItem current in this._despawned) { if (current != null) { UnityEngine.Object.Destroy(current.transform.gameObject); } } foreach (Transform current2 in this._spawned) { if (current2 != null) { UnityEngine.Object.Destroy(current2.gameObject); } } this._spawned.Clear(); this._despawned.Clear(); }
/// <summary> /// If using PoolManager this will provide the pool name for despawn. /// </summary> protected void OnSpawned(SpawnPool spawnPool) { this.poolName = spawnPool.poolName; }