private void CreateMap(float[] map) { var mapSize = map.Length; var mapArchetype = _entityManager.CreateArchetype(typeof(MapSettings)); var tileArchetype = _entityManager.CreateArchetype(typeof(MovementCost)); var tiles = new NativeArray <Entity>(mapSize, Allocator.Temp); _entityManager.CreateEntity(tileArchetype, tiles); var mapEntity = _entityManager.CreateEntity(mapArchetype); for (int i = 0; i < mapSize; i++) { _entityManager.SetComponentData(tiles[i], new MovementCost { Cost = map[i] }); } var blitableTiles = new BlitableArray <Entity>(); blitableTiles.Allocate(tiles, Allocator.Temp); if (TargetSystem.HasSingleton <MapSettings>() == false) { TargetSystem.EntityManager.CreateEntity(typeof(MapSettings)); TargetSystem.SetSingleton(new MapSettings { MapEdgeSize = EdgeSize(mapSize), Tiles = blitableTiles }); } }
public void NoMap_NoTile() { var entity = SetMouseInput(float2.zero); if (TargetSystem.HasSingleton <MapSettings>() == false) { TargetSystem.SetSingleton(new MapSettings() { MapEdgeSize = 5 }); } Update(); var tileUnderMouse = _entityManager.GetComponentData <TileUnderMouse>(entity); AreEqual(new Entity(), tileUnderMouse.Tile); False(_entityManager.Exists(tileUnderMouse.Tile)); }