Fix map editor radar ignoring color from terrain

This commit is contained in:
Nikita Pozdeev
2020-06-14 22:31:10 +04:00
committed by Matthias Mailänder
parent 4fe7daa85e
commit cb41be113a
3 changed files with 16 additions and 6 deletions

View File

@@ -19,17 +19,22 @@ namespace OpenRA.Mods.Common.Traits.Radar
[FieldLoader.Require]
public readonly string Terrain;
public override object Create(ActorInitializer init) { return new RadarColorFromTerrain(init.Self, Terrain); }
public Color GetColorFromTerrain(World world)
{
var tileSet = world.Map.Rules.TileSet;
return tileSet[tileSet.GetTerrainIndex(Terrain)].Color;
}
public override object Create(ActorInitializer init) { return new RadarColorFromTerrain(init.Self, this); }
}
public class RadarColorFromTerrain : IRadarColorModifier
{
Color c;
readonly Color c;
public RadarColorFromTerrain(Actor self, string terrain)
public RadarColorFromTerrain(Actor self, RadarColorFromTerrainInfo info)
{
var tileSet = self.World.Map.Rules.TileSet;
c = tileSet[tileSet.GetTerrainIndex(terrain)].Color;
c = info.GetColorFromTerrain(self.World);
}
public bool VisibleOnRadar(Actor self) { return true; }

View File

@@ -316,7 +316,7 @@ namespace OpenRA.Mods.Common.Traits
{
foreach (var previewsForCell in cellMap)
foreach (var preview in previewsForCell.Value)
destinationBuffer.Add(Pair.New(previewsForCell.Key, preview.Owner.Color));
destinationBuffer.Add(Pair.New(previewsForCell.Key, preview.RadarColor));
}
public EditorActorPreview this[string id]

View File

@@ -15,6 +15,7 @@ using System.IO;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits.Radar;
using OpenRA.Primitives;
using OpenRA.Traits;
@@ -49,6 +50,7 @@ namespace OpenRA.Mods.Common.Traits
readonly TooltipInfoBase tooltip;
IActorPreview[] previews;
readonly ActorReference reference;
public readonly Color RadarColor;
public EditorActorPreview(WorldRenderer worldRenderer, string id, ActorReference reference, PlayerReference owner)
{
@@ -75,6 +77,9 @@ namespace OpenRA.Mods.Common.Traits
var subCellInit = reference.GetOrDefault<SubCellInit>();
var subCell = subCellInit != null ? subCellInit.Value : SubCell.Any;
var radarColorInfo = Info.TraitInfoOrDefault<RadarColorFromTerrainInfo>();
RadarColor = radarColorInfo == null ? owner.Color : radarColorInfo.GetColorFromTerrain(world);
if (ios != null)
Footprint = ios.OccupiedCells(Info, location, subCell);
else