public void CopyFrom(ListCopyable <T> other) { this.Count = other.Count; this.Capacity = other.Capacity; this.isValueType = other.isValueType; ArrayUtils.Copy(other.innerArray, ref this.innerArray); }
protected ListCopyable <Node> AstarSearch(Graph graph, ListCopyable <Node> visited, Node startNode, Node endNode, Constraint constraint, int threadIndex) { var openList = PoolQueue <Node> .Spawn(10); startNode.startToCurNodeLen[threadIndex] = 0f; openList.Enqueue(startNode); startNode.isOpened[threadIndex] = true; while (openList.Count > 0) { var node = openList.Dequeue(); node.isClosed[threadIndex] = true; visited.Add(node); if (node.index == endNode.index) { PoolQueue <Node> .Recycle(ref openList); return(this.RetracePath(threadIndex, endNode)); } var neighbors = node.GetConnections(); foreach (var conn in neighbors) { if (conn.index < 0) { continue; } var neighbor = graph.nodes[conn.index]; if (neighbor.isClosed[threadIndex] == true) { continue; } if (neighbor.IsSuitable(constraint) == false) { continue; } float ng = node.startToCurNodeLen[threadIndex] + conn.cost; if (neighbor.isOpened[threadIndex] == false || ng < neighbor.startToCurNodeLen[threadIndex]) { neighbor.startToCurNodeLen[threadIndex] = ng; neighbor.parent[threadIndex] = node; if (neighbor.isOpened[threadIndex] == false) { openList.Enqueue(neighbor); visited.Add(neighbor); neighbor.isOpened[threadIndex] = true; } } } } PoolQueue <Node> .Recycle(ref openList); return(null); }
public void Recycle(ref ListCopyable <T> value) { if (value != null) { PoolListCopyable <T> .Recycle(ref value); } }
public static ListCopyable <Vector3> Bezier(ListCopyable <Vector3> points, int subdivisions = 2, float tangentLength = 0.5f) { subdivisions = Mathf.Max(subdivisions, 0); var segmentsCount = 1 << subdivisions; var outputPoints = PoolListCopyable <Vector3> .Spawn(points.Count *segmentsCount + 1); for (int i = 0; i < points.Count - 1; i++) { var t1 = (points[i + 1] - points[i == 0 ? i : i - 1]) * tangentLength; var t2 = (points[i] - points[i == points.Count - 2 ? i + 1 : i + 2]) * tangentLength; var p0 = points[i]; var p1 = p0 + t1; var p2 = points[i + 1]; var p3 = p2 + t2; for (int j = 0; j < segmentsCount; j++) { outputPoints.Add(CubicBezier(p0, p1, p3, p2, (float)j / segmentsCount)); } } outputPoints.Add(points[points.Count - 1]); return(outputPoints); }
public void GetNodesInBounds(ListCopyable <Node> result, Bounds bounds) { if (this.graphs != null) { for (int i = 0; i < this.graphs.Count; ++i) { this.graphs[i].GetNodesInBounds(result, bounds); } } }
public void Initialize() { if (this.globalEventLogicItems == null) { this.globalEventLogicItems = PoolListCopyable <GlobalEventFrameItem> .Spawn(10); } if (this.globalEventLogicEvents == null) { this.globalEventLogicEvents = PoolHashSetCopyable <long> .Spawn(); } }
public bool MoveNext() { ListCopyable <T> list = this._list; if ((uint)this._index >= (uint)list.Count) { return(false); } this._current = list.innerArray[this._index]; ++this._index; return(true); }
public void AddRange(ListCopyable <T> items) { var arrayLength = items.Count; this.EnsureCapacity(this.Count + arrayLength + 1); System.Array.Copy(items.innerArray.arr, 0, this.innerArray.arr, this.Count, arrayLength); this.Count += arrayLength; /*for (var i = 0; i < arrayLength; i++) { * this.innerArray.arr[this.Count++] = items[i]; * }*/ }
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]); } PoolList <T> .Recycle(ref item); } }
public void GetNodesInBounds(ListCopyable <Node> result, Bounds bounds, Constraint constraint) { if (this.graphs != null) { for (int i = 0; i < this.graphs.Count; ++i) { if (constraint.graphMask >= 0 && (constraint.graphMask & (1 << this.graphs[i].index)) == 0) { continue; } this.graphs[i].GetNodesInBounds(result, bounds, constraint); } } }
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 Add(IView view) { if (this.mainView == null) { this.mainView = view; } else { if (this.otherViews == null) { this.otherViews = PoolList <IView> .Spawn(1); } this.otherViews.Add(view); } this.isNotEmpty = true; }
public static void Copy <T>(ListCopyable <T> fromArr, ref ListCopyable <T> arr) where T : struct { if (fromArr == null) { if (arr != null) { PoolList <T> .Recycle(ref arr); } arr = null; return; } if (arr == null) { arr = PoolList <T> .Spawn(fromArr.Count); } arr.CopyFrom(fromArr); }
internal Enumerator(ListCopyable <T> list) { this._list = list; this._index = 0; this._current = default(T); }
public void CopyTo(ListCopyable <T> target) { System.Array.Copy(this.innerArray.arr, 0, target.innerArray.arr, 0, this.Count); target.Count = this.Count; target.Capacity = this.Capacity; }
public abstract void GetNodesInBounds(ListCopyable <Node> output, Bounds bounds, Constraint constraint);
public abstract void GetNodesInBounds(ListCopyable <Node> output, Bounds bounds);
public static void Recycle(ListCopyable <TValue> dic) { PoolListCopyable <TValue> .pool.Recycle(dic); }
public bool MoveNext() { if (FiltersArchetype.FiltersArchetypeStorage.CheckStaticShared(this.filterData.data.containsShared, this.filterData.data.notContainsShared) == false) { return(false); } var onChanged = this.filterData.data.onChanged; var changedTracked = onChanged.Count; var connectedFilters = this.filterData.data.connectedFilters; var connectedTracked = connectedFilters.Count; while (true) { if (this.archIndex >= this.archetypes.Count) { return(false); } ++this.index; ref var arch = ref this.allArchetypes[this.archetypes[this.archIndex]]; if (this.index >= arch.entitiesArr.Count) { ++this.archIndex; if (this.archIndex < this.archetypes.Count) { this.arr = this.allArchetypes[this.archetypes[this.archIndex]].entitiesArr; } this.index = -1; continue; } var entityId = this.arr[this.index]; this.current = this.filterData.storage.GetEntityById(entityId); if (connectedTracked > 0) { // Check if all custom filters contains connected entity var found = true; for (int i = 0, cnt = connectedTracked; i < cnt; ++i) { var connectedFilter = connectedFilters[i]; if (connectedFilter.filter.Contains(connectedFilter.get.Invoke(this.current)) == false) { found = false; break; } } if (found == false) { continue; } } if (changedTracked > 0) { // Check if any component has changed on this entity var hasChanged = false; for (int i = 0, cnt = changedTracked; i < cnt; ++i) { var typeId = onChanged[i]; var reg = Worlds.current.currentState.structComponents.list.arr[typeId]; if (reg.HasChanged(entityId) == true) { hasChanged = true; break; } } if (hasChanged == false) { continue; } } return(true); }
public static void Recycle(ref ListCopyable <TValue> dic) { PoolListCopyable <TValue> .pool.Recycle(dic); dic = null; }
public void Set(ListCopyable <T> value) { this.dataObject.Set(value); }
public DataList(ListCopyable <T> data) { this.dataObject = new DataObject <ListCopyable <T>, DataListProvider <T> >(data); }
public override void Update(BufferArray <Views> list, float deltaTime, bool hasChanged) { if (this.world.settings.useJobsForViews == false || this.world.settings.viewsSettings.unityGameObjectProviderDisableJobs == true) { return; } if (list.isNotEmpty == true) { if (hasChanged == true) { if (this.tempList == null) { this.tempList = PoolList <MonoBehaviourView> .Spawn(list.Length); } var changed = false; //ArrayUtils.Resize(list.Length - 1, ref this.currentTransforms); var k = 0; for (int i = 0, length = list.Length; i < length; ++i) { var item = list.arr[i]; if (item.isNotEmpty == false) { continue; } for (int j = 0, count = item.Length; j < count; ++j) { var view = item[j] as MonoBehaviourView; if (view == null) { continue; } if (view.applyStateJob == true && view.entity.IsAlive() == true) { changed |= ArrayUtils.Resize(k, ref this.currentTransforms); var isNew = false; if (k >= this.tempList.Count) { this.tempList.Add(view); this.currentTransforms.arr[k] = view.transform; isNew = true; } var tempItem = this.tempList[k]; if (isNew == true || tempItem.prefabSourceId != view.prefabSourceId || tempItem.creationTick != view.creationTick || tempItem.entity != view.entity) { this.tempList[k] = view; this.currentTransforms.arr[k] = view.transform; changed = true; } ++k; } } } if (this.currentTransformArray.isCreated == false) { this.currentTransformArray = new TransformAccessArray(k); } if (changed == true) { this.currentTransformArray.SetTransforms(this.currentTransforms.arr); //if (UnityGameObjectProvider.resultList != null) PoolList<MonoBehaviourView>.Recycle(ref UnityGameObjectProvider.resultList); //var result = PoolList<MonoBehaviourView>.Spawn(this.tempList.Count); //result.AddRange(this.tempList); UnityGameObjectProvider.resultList = this.tempList; UnityGameObjectProvider.resultCount = k; } } if (UnityGameObjectProvider.resultCount > 0 && this.currentTransformArray.isCreated == true) { var job = new Job() { deltaTime = deltaTime, length = UnityGameObjectProvider.resultCount }; var handle = job.Schedule(this.currentTransformArray); handle.Complete(); } } }
public void GetNodesInBounds(ListCopyable <Node> output, UnityEngine.Bounds bounds) { this.pathfindingEntity.GetComponent <PathfindingInstance>().pathfinding.GetNodesInBounds(output, bounds); }
public void Clone(ListCopyable <T> from, ref ListCopyable <T> to) { to = PoolListCopyable <T> .Spawn(from.Capacity); to.CopyFrom(from); }
public static void Recycle(ref ListCopyable <TValue> dic) { Pools.current.PoolRecycle(ref dic); }