public bool Deregister(GameObject _object) { if (_object == null || !Enabled) { return(false); } ICECreatureEntity _entity = _object.GetComponent <ICECreatureEntity>(); if (_entity != null) { OnGroupMessage -= _entity.Message.ReceiveGroupMessage; } if (SuspendedObjects.Count > 0) { SuspendedObjects.Remove(_object); } if (ActiveObjects.Count > 0) { return(ActiveObjects.Remove(_object)); } else { return(false); } }
/// <summary> /// Add all the objects in ObjectsToAdd to ActiveObjects, then update ActiveObjects before deleting objects in ObjectsToRemove /// </summary> /// <param name="elapsedGameTime">The seconds that have elapsed since the last update loop</param> public override void Update(float elapsedGameTime) { // Always call the super class' function - it will deal with whether it should run it itself base.Update(elapsedGameTime); // Add the objects and then clear the list - it is only a temporary holder ActiveObjects.AddRange(ObjectsToAdd); ObjectsToAdd.Clear(); // Loop through the active object foreach (T obj in ActiveObjects) { if (obj.ShouldUpdate) { // Update the object obj.Update(elapsedGameTime); } } // Remove all the objects that are no longer alive ActiveObjects.RemoveAll(x => x.IsAlive == false); // Remove all the objects we have marked to remove foreach (T obj in ObjectsToRemove) { ActiveObjects.Remove(obj); } ObjectsToRemove.Clear(); // Clear the list - it is only a temporary holder }
public void PoolEnemyObject(GameObject enemyGameObject) { //Debug.LogError("Pooling " + enemyGameObject.GetInstanceID() + enemyGameObject.GetComponent("Enemy").GetType()); enemyGameObject.SetActive(false); ActiveObjects.Remove(enemyGameObject); InactiveObjects.Add(enemyGameObject); }
/// <summary> /// Удалить активный объект с карты /// </summary> /// <param name="Id">Идентификатор объекта</param> public void RemoveActiveObject(Guid Id) { MapActiveObjectState ActiveObject = GetActiveObjectById(Id); DeAttachActiveObject(ActiveObject); ActiveObjects.Remove(Id); }
private void _Despawn(GameObject toDespawn) { toDespawn.SetActive(false); toDespawn.transform.parent = Holder.transform; ActiveObjects.Remove(toDespawn); InactiveObjects.Add(toDespawn); }
public bool DestroyObject(GameObject go) { var resObj = ActiveObjects.FirstOrDefault(x => x.SourceObject == go); if (resObj != null) { ActiveObjects.Remove(resObj); return(true); } return(false); }
public void Insert(GameObject gameObject) { gameObject.transform.DOKill(); if (gameObject.activeInHierarchy) { gameObject.SetActive(false); } PooledObject obj = poolObjectLookup[gameObject]; ActiveObjects.Remove(obj); Push(obj); }
public void Reset() { (Globals.ActiveScene.ActiveObjects.First(x => x is Player) as Player).Reset(PlayerStart); AquiredCoins = 0; ActiveObjects.ForEach(x => { if (!(x is Coin)) return; ActiveObjects.Remove(x); }); ActiveObjects.AddRange(GetCoins()); }
public void DestroyItem(GameObject _object) { if (_object == null && EntityGameObject != _object) { return; } SuspendedObjects.Remove(_object); ActiveObjects.Remove(_object); if (!CompareByID(_object.GetInstanceID())) { CreatureRegister.Destroy(_object); } }
/// <summary> /// 对象关闭时登记 /// </summary> public static void OnObjectClose(IService obj) { Logger.Information("[服务关闭] {0}", obj.ServiceName); bool can; lock (ActiveObjects) { ActiveObjects.Remove(obj); } can = ActiveObjects.Count == 0; if (can) { ActiveSemaphore.Release(); //发出完成信号 } }
/// <summary> /// Remove the specified _object by using the UseSoftRespawn option of the ReferenceGroup. If UseSoftRespawn /// is active the specified _object will be moved from the ActiveObjects list to the SuspendedObjects list and /// its values will be adjusted to the default values, otherwise if UseSoftRespawn is disabled the specified /// _object will be finally destroyed. /// </summary> /// <param name="_object">Object.</param> public bool Remove(GameObject _object) { if (_object == null) { return(false); } if (UseSoftRespawn) { //Debug.Log( "ReferenceGroupObject.Remove: " + _object.name ); _object.transform.position = Vector3.zero; _object.transform.rotation = Quaternion.identity; _object.SetActive(false); if (ActiveObjects.Count > 0) { return(ActiveObjects.Remove(_object)); } SuspendedObjects.Add(_object); ICECreatureEntity _entity = _object.GetComponent <ICECreatureEntity>(); // if the object is an ICE entity we have to adapt the parent according to it's hierarchy settings if (_entity != null && _entity.UseHierarchyManagement) { _object.transform.SetParent(UpdateGroupParent(), true); } //TODO: CreatureRegister.DetachFromTransform( _object ); } else { DestroyItem(_object); } return(true); }
public void ReturnObject(GameObject obj) { obj.SetActive(false); ActiveObjects.Remove(obj); AvailableObjects.Add(obj); }
public void PoolBullets(GameObject enemyGameObject) { enemyGameObject.SetActive(false); ActiveObjects.Remove(enemyGameObject); InactiveObjects.Add(enemyGameObject); }