public CirclePacker(FLOAT2 mPackingCenter, float mMinSeparation) { this.circles = PoolListCopyable <Circle> .Spawn(10); this.mPackingCenter = mPackingCenter; this.mMinSeparation = mMinSeparation; }
public void Initialize() { if (this.globalEventLogicItems == null) { this.globalEventLogicItems = PoolListCopyable <GlobalEventFrameItem> .Spawn(10); } if (this.globalEventLogicEvents == null) { this.globalEventLogicEvents = PoolHashSetCopyable <long> .Spawn(); } }
public static void Recycle <T, TCopy>(ref ListCopyable <T> item, TCopy copy) where TCopy : IArrayElementCopy <T> { if (item != null) { for (int i = 0; i < item.Count; ++i) { copy.Recycle(item[i]); } PoolListCopyable <T> .Recycle(ref item); } }
public static void Copy <T, TCopy>(ListCopyable <T> fromArr, ref ListCopyable <T> arr, TCopy copy) where TCopy : IArrayElementCopy <T> { if (fromArr == null) { if (arr != null) { for (int i = 0; i < arr.Count; ++i) { copy.Recycle(arr[i]); } PoolListCopyable <T> .Recycle(ref arr); } arr = null; return; } if (arr == null || fromArr.Count != arr.Count) { if (arr != null) { ArrayUtils.Recycle(ref arr, copy); } arr = PoolListCopyable <T> .Spawn(fromArr.Count); } var cnt = arr.Count; for (int i = 0; i < fromArr.Count; ++i) { var isDefault = i >= cnt; T item = (isDefault ? default : arr[i]); copy.Copy(fromArr[i], ref item); if (isDefault == true) { arr.Add(item); } else { arr[i] = item; } } }
public void Register(ref FiltersArchetypeStorage storageRef, bool freeze, bool restore) { this.RegisterPluginsModuleForEntity(); if (storageRef.isCreated == false) { storageRef = new FiltersArchetypeStorage(); storageRef.Initialize(World.ENTITIES_CACHE_CAPACITY); storageRef.SetFreeze(freeze); } if (freeze == false) { if (this.sharedEntity.generation == 0 && this.sharedEntityInitialized == false) { // Create shared entity which should store shared components this.sharedEntity = this.AddEntity(); } this.sharedEntityInitialized = true; } if (restore == true) { this.BeginRestoreEntities(); // Update entities cache var list = PoolListCopyable <Entity> .Spawn(World.ENTITIES_CACHE_CAPACITY); if (this.ForEachEntity(list) == true) { for (var i = 0; i < list.Count; ++i) { ref var item = ref list[i]; // This call resets FilterData.dataVersions[item.id] to true which might create state desynchronization // in case entity hadn't been updated on the previous tick. FilterData seems to have its state already // stored within the main state, so it's possible that this call is not needed at all. //this.UpdateFiltersOnFilterCreate(item); this.CreateEntityPlugins(item, false); } } PoolListCopyable <Entity> .Recycle(ref list); this.EndRestoreEntities(); }
public static void Copy <T>(ListCopyable <T> fromArr, ref ListCopyable <T> arr) where T : struct { if (fromArr == null) { if (arr != null) { PoolListCopyable <T> .Recycle(ref arr); } arr = null; return; } if (arr == null) { arr = PoolListCopyable <T> .Spawn(fromArr.Count); } arr.CopyFrom(fromArr); }
public void DeInitialize() { PoolListCopyable <GlobalEventFrameItem> .Recycle(ref this.globalEventLogicItems); PoolHashSetCopyable <long> .Recycle(ref this.globalEventLogicEvents); }
public void Dispose() { PoolListCopyable <Circle> .Recycle(ref this.circles); }