int[] CalculateCellIndices(ResourceLayerContents contents, CPos cell) { if (contents.Type != info.ResourceType || contents.Density == 0) { return(null); } var ramp = world.Map.Ramp[cell]; switch (ramp) { case 1: return(Ramp1Indices); case 2: return(Ramp2Indices); case 3: return(Ramp3Indices); case 4: return(Ramp4Indices); default: return(contents.Density == maxDensity ? HeavyIndices : LightIndices); } }
public void UpdateCell(CPos cell) { var uv = cell.ToMPos(Map); if (!Map.Resources.Contains(uv)) { return; } var tile = Map.Resources[uv]; var t = Tiles[uv]; var newTile = ResourceLayerContents.Empty; var newTerrain = byte.MaxValue; if (Resources.TryGetValue(tile.Type, out ResourceType type)) { newTile = new ResourceLayerContents { Type = type, Density = tile.Index }; newTerrain = Tileset.GetTerrainIndex(type.Info.TerrainType); } // Nothing has changed if (newTile.Type == t.Type && newTile.Density == t.Density) { return; } UpdateNetWorth(t.Type, t.Density, newTile.Type, newTile.Density); Tiles[uv] = newTile; Map.CustomTerrain[uv] = newTerrain; CellChanged?.Invoke(cell, type); }
public void Do() { resourceContents = resourceLayer.GetResource(cell); resourceLayer.ClearResources(cell); }
public CellResource(CPos cell, ResourceLayerContents oldResourceTile, string newResourceType) { Cell = cell; OldResourceTile = oldResourceTile; NewResourceType = newResourceType; }