public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityInIndex) { NativeArray <Entity> linkingTilesArray = chunk.GetNativeArray(entityTypeHandle); NativeArray <TileComponent> tileComponentArray = chunk.GetNativeArray(tileComponentTypeHandle); for (var i = 0; i < chunk.Count; ++i) { Entity tile = linkingTilesArray[i]; TileComponent tileComponent = tileComponentArray[i]; for (var j = 0; j < 6; ++j) { Entity adjTile = tileComponent.AdjacentTiles[j]; if (adjTile != Entity.Null) { var tileLink = new TileLink { tile = adjTile, index = (j + 3) % 6, adjTile = tile }; centerNodesMapWriter.Add(adjTile, tileLink); } } } }
public void MoveAlongTileLink() { if (TileLink != null && TileLink.Head == this) { Player.Move(TileLink.Tail); TileLink.Destroy(); //destroy tile's tilelink TileLink.Tail._tileLink = null; //destroy this tile's tilelink _tileLink = null; } }
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() { 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 ); } }
public void Execute(int i) { Entity tile = centerNodes[i]; TileBuffer tileBuffer = tileBufferMap[tile]; for (var j = 0; j < 6; ++j) { Entity adjTileN0 = tileBuffer[j]; Entity adjTileN1 = tileBuffer[(j + 1) % 6]; if (adjTileN1 == Entity.Null) { ++j; } else if (adjTileN0 == Entity.Null) { } else if (linkingTilesArray.Contains(adjTileN0) || linkingTilesArray.Contains(adjTileN1)) { var adjTileLinkN0 = new TileLink { tile = adjTileN0, index = (j + 2) % 6, adjTile = adjTileN1 }; var adjTileLinkN1 = new TileLink { tile = adjTileN1, index = (j + 5) % 6, adjTile = adjTileN0 }; outerNodesMapWriter.Add(adjTileN0, adjTileLinkN0); outerNodesMapWriter.Add(adjTileN1, adjTileLinkN1); } } }
//adds snake/ladder public void AddTileLink(TileLink link) { _tileLink = link; }