Ejemplo n.º 1
0
        public void Insert(IPartitionObject obj)
        {
            if (obj.CurrentPartitionTile != null)
            {
                SpatialPartitionManager.Remove(obj);
            }

            lock (tileLock) {
                Type type = obj.PartitionObjectType;
                if (PartitionObjects.TryGetValue(type, out QuickList <IPartitionObject> list))
                {
                    list.Add(obj);
                }
                else
                {
                    QuickList <IPartitionObject> newList = new QuickList <IPartitionObject> {
                        obj
                    };
                    PartitionObjects.Add(type, newList);
                }
                obj.CurrentPartitionTile = this;
                if (obj is IPartitionObjectExtended ext)
                {
                    ext.InsertedIntoPartition(this);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Unregisters a GameObject from the engine.
 /// </summary>
 /// <param name="go">GameObject which was destroyed.</param>
 /// <param name="destroyed">If the GameObject was destroyed.</param>
 internal static void RemoveGameObject(GameObject go, bool destroyed = false)
 {
     lock (gameObjectHandlerLock) {
         DynamicGameObjects.Remove(go);
         CurrentScene.GameObjectsToRemove.Add(go);
         SpatialPartitionManager.Remove(go);
         if (destroyed)
         {
             AllGameObjects.Remove(go);
         }
         go.AddedToGameManager = false;
         EngineUtility.TransformHierarchyDirty = true;
     }
 }