コード例 #1
0
ファイル: TSVeinsRenderer.cs プロジェクト: lujiawen/OpenRA
        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);
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: EditorDefaultBrush.cs プロジェクト: sg6162eq/OpenRA
 public void Do()
 {
     resourceContents = resourceLayer.GetResource(cell);
     resourceLayer.ClearResources(cell);
 }
コード例 #4
0
 public CellResource(CPos cell, ResourceLayerContents oldResourceTile, string newResourceType)
 {
     Cell            = cell;
     OldResourceTile = oldResourceTile;
     NewResourceType = newResourceType;
 }