private void FindValidPoints(int index, NativeList <float> freePointList, NativeList <float> blockedPointList, NativeMultiHashMap <int, RaycastHit> hits) { if (hits.ContainsKey(index)) { NativeMultiHashMap <int, RaycastHit> .Enumerator tempHits = hits.GetValuesForKey(index); tempHits.MoveNext(); //The Top most point is always free freePointList.Add(tempHits.Current.point.y); Vector3 prevPoint = tempHits.Current.point; while (tempHits.MoveNext()) { RaycastHit currentHit = tempHits.Current; if (currentHit.point.y + playerHeight > prevPoint.y) { blockedPointList.Add(currentHit.point.y); } else { freePointList.Add(currentHit.point.y); } prevPoint = currentHit.point; } } }
public StateGroup(int length, NativeMultiHashMap <Node, State> .Enumerator copyFrom, Allocator allocator) { _states = new NativeList <State>(length, allocator); while (copyFrom.MoveNext()) { _states.Add(copyFrom.Current); } }
private static void RemoveTreeFromSegment([ReadOnly] NativeMultiHashMap <uint2, TreeHashNode> hashTable, uint2 idx, RoadSegment roadSegment, EntityCommandBuffer.ParallelWriter ecb, int sortKey, Environment env) { NativeMultiHashMap <uint2, TreeHashNode> .Enumerator enumerator = hashTable.GetValuesForKey(idx); while (enumerator.MoveNext()) { if (Distance.FromPointToLineSegmentSquared(enumerator.Current.position, roadSegment.initial, roadSegment.final) < env.roadWidth * env.roadWidth) { ecb.AddComponent <TreeIntersectsRoadTag>(sortKey + 1, enumerator.Current.entity); } } }
internal void Update <T>(T enumerator, NativeMultiHashMap <Entity, Entity> .Enumerator removals, float4x4 ltwInv) where T : System.Collections.Generic.IEnumerator <Insertion> { DestroyedTriangles.Clear(); V.Clear(); var removed = false; while (removals.MoveNext()) { RemoveConstraint(removals.Current); removed = true; } if (removed) { RemoveRefinements(); } while (enumerator.MoveNext()) { var op = enumerator.Current; var ltw = math.mul(ltwInv, op.Ltw); switch (op.Type) { case InsertionType.Insert: C.Clear(); Insert(op.Vertices, 0, op.Amount, op.Obstacle, ltw); SearchDisturbances(); break; case InsertionType.BulkInsert: var start = 0; for (int i = 0; i < op.Amount; i++) { var amount = op.Amounts[i]; C.Clear(); Insert(op.Vertices, start, amount, Entity.Null, ltw); start += amount; SearchDisturbances(); } break; default: throw new ArgumentOutOfRangeException(); } } LocalRefinement(); }
public void Execute() { for (var i = 0; i < adjTileLinksKeys.Length; ++i) { GridPosition tileKey = adjTileLinksKeys[i]; NativeMultiHashMap <GridPosition, TileLink> .Enumerator tileLinksEnumerator = adjTileLinksMap.GetValuesForKey(tileKey); tileLinksEnumerator.MoveNext(); TileLink curTileLink = tileLinksEnumerator.Current; Entity tile = ecbWriter.Instantiate(curTileLink.tile); var offset = new float3(0f, 0.3f, 0f); var tileTranslation = new Translation { Value = tileKey + offset }; TileBuffer tileBuffer = TileBuffer.Empty; do { curTileLink = tileLinksEnumerator.Current; tileBuffer[(curTileLink.index + 3) % 6] = curTileLink.tile; } while (tileLinksEnumerator.MoveNext()); var tileCmpnt = new TileComponent { Position = tileKey, State = 0, AdjacentTiles = tileBuffer }; ecbWriter.SetComponent(tile, tileCmpnt); ecbWriter.SetComponent(tile, tileTranslation); ecbWriter.SetSharedComponent( tile, GridGenerationComponent.OuterNodeLinkingPhase ); } }
protected override void Consume() { NativeMultiHashMap <Entity, TestEffectContext> effects = _effects; Entities.WithReadOnly(effects).ForEach((ref Entity targetEntity, ref TestResource resource) => { NativeMultiHashMap <Entity, TestEffectContext> .Enumerator effectEnumerator = effects.GetValuesForKey(targetEntity); while (effectEnumerator.MoveNext()) { resource.Value -= effectEnumerator.Current.Effect.Value; } }).WithBurst() .ScheduleParallel(); }
public void Execute() { while (EffectCommandEnumerator.MoveNext()) { string n1 = ""; string n2 = ""; if (EntityNames.Exists(EffectCommandEnumerator.Current.Emitter)) { ref BlobString e1 = ref EntityNames[EffectCommandEnumerator.Current.Emitter].Value.Value.str; n1 = e1.ToString(); } if (EntityNames.Exists(EffectCommandEnumerator.Current.Target)) { ref BlobString e2 = ref EntityNames[EffectCommandEnumerator.Current.Target].Value.Value.str; n2 = e2.ToString(); }
protected override void Consume() { NativeMultiHashMap <Entity, TestEmptyEffectContext> effects = _effects; Entities.WithReadOnly(effects).ForEach((ref Entity targetEntity /* YOUR CODE : component on the target that are nedded to apply the effect*/) => { NativeMultiHashMap <Entity, TestEmptyEffectContext> .Enumerator effectEnumerator = effects.GetValuesForKey(targetEntity); while (effectEnumerator.MoveNext()) { // YOUR CODE : Consume the effect } }).WithBurst() .ScheduleParallel(); }
protected override void Consume() { NativeMultiHashMap <Entity, Effect2Context> effects = _effects; Entities.WithReadOnly(effects).ForEach((ref Entity entity, ref Health health, ref Armor armor) => { NativeMultiHashMap <Entity, Effect2Context> .Enumerator effectEnumerator = effects.GetValuesForKey(entity); Health hp = health; while (effectEnumerator.MoveNext()) { hp.Value -= effectEnumerator.Current.AttackPower * effectEnumerator.Current.Effect.Value / armor.Value; } health = hp; }).WithBurst() .ScheduleParallel(); }
public void Execute() { NativeMultiHashMapIterator <int> iterator; NativeArray <int> keys = bucketEntityMap.GetKeyArray(Allocator.Temp); int entityIndex = 0; int bucketIndex = 0; float nearestDistance = StaticValues.NEIGHBOUR_RADIUS; float distance = -1; int nearestEntity = 0; for (int i = 0; i < keys.Length; i++) { bucketIndex = keys[i]; if (bucketEntityMap.TryGetFirstValue(bucketIndex, out entityIndex, out iterator)) { do { float3 ownPos = positions[entityIndex]; nearestEntity = entityIndex; NativeMultiHashMap <int, int> .Enumerator e = bucketEntityMap.GetValuesForKey(bucketIndex); while (e.MoveNext()) { int nextEntIdx = e.Current; if (nextEntIdx != entityIndex) { float3 compPos = positions[nextEntIdx]; distance = math.distancesq(ownPos, compPos); if (distance < StaticValues.NEIGHBOUR_RADIUS) { nearestEntity = math.select(nearestEntity, nextEntIdx, distance < nearestDistance); nearestDistance = math.select(nearestDistance, distance, distance < nearestDistance); } } } float3 dirToNearest = positions[entityIndex] - positions[nearestEntity]; float3 ownFwd = math.forward(rotations[entityIndex]); float3 newValue = math.lerp(ownFwd, dirToNearest, separationValues[entityIndex]); entityTargetDirection.TryAdd(entityIndex, newValue); nearestDistance = StaticValues.NEIGHBOUR_RADIUS; }while (bucketEntityMap.TryGetNextValue(out entityIndex, ref iterator)); } } }
public void Execute(int i) { Entity tileKey = nodes[i]; NativeMultiHashMap <Entity, TileLink> .Enumerator tileLinksEnumerator = nodesTileLinksMap.GetValuesForKey(tileKey); TileBuffer tileBuffer = tileComponentLookup[tileKey] .AdjacentTiles.Clone(); while (tileLinksEnumerator.MoveNext()) { TileLink curTilelink = tileLinksEnumerator.Current; tileBuffer[curTilelink.index] = curTilelink.adjTile; } tileBufferMapWriter.TryAdd(tileKey, tileBuffer); }
public void Execute() { while (Iter.MoveNext()) { } }
public bool MoveNext() => _iter.MoveNext();