public void DelayFreeByLiveId(List <int> liveIds, EntityFreeOptions freeOptions) { foreach (int liveId in liveIds) { uniqueIdsToUnload.Add(GetEntityByLiveId(liveId).UniqueId); } }
public void Free(List <int> liveIds, EntityFreeOptions freeOptions) { foreach (int liveId in liveIds) { // These could be invalid now (because removing one removed another). Handle that. Entity toRemove = entityPool[liveId]; if (toRemove.LiveId != InvalidEntityLiveId) { Free(entityPool[liveId], freeOptions); } } }
public void Free(Entity t, EntityFreeOptions freeOptions) { /* * if (freeOptions == EntityFreeOptions.Deep) * { * Component transformChildrenComponent = GetComponent(t, ComponentTypeIds.TransformChildren); * if (transformChildrenComponent != null) * { * FreeEntityChildren(t, (TransformChildren)transformChildrenComponent); * } * }*/ // Call this before removing its components, since event handlers may need // to inspect its components (for instance, seeing what objects it owns) if (RemovingEntityEvent != null) { RemovingEntityEvent(t); } RemoveFreedEntityFromSystems(t); RemoveComponentsForEntity(t); int uniqueId = t.UniqueId; // Swap with the empty one at partitionIndex short liveId = t.LiveId; short rosterIndex = inverseRoster[liveId]; short tempLiveId = liveIdRoster[rosterIndex]; Debug.Assert(tempLiveId == liveId); short movedLiveId = liveIdRoster[partitionIndex - 1]; liveIdRoster[rosterIndex] = movedLiveId; liveIdRoster[partitionIndex - 1] = tempLiveId; // Update the inverse roster. inverseRoster[liveId] = -1; // Now points to nowhere inverseRoster[movedLiveId] = rosterIndex; // Set in valid ids: t.LiveId = -1; t.OwnerUniqueId = -1; t.UniqueId = -1; t.ComponentTypesBitField = 0; partitionIndex--; // This essentially does the "de-alloc" uniqueIdToEntity.Remove(uniqueId); //t.Reset(); }
public void Free(int liveId, EntityFreeOptions freeOptions) { Free(entityPool[liveId], freeOptions); }
public void DelayFreeByLiveId(int liveId, EntityFreeOptions freeOptions) { uniqueIdsToUnload.Add(GetEntityByLiveId(liveId).UniqueId); }