diff --git a/OpenRA.Game/Traits/Building.cs b/OpenRA.Game/Traits/Building.cs index 634e568cf6..6b261c49e6 100644 --- a/OpenRA.Game/Traits/Building.cs +++ b/OpenRA.Game/Traits/Building.cs @@ -169,6 +169,10 @@ namespace OpenRA.Traits public Color RadarSignatureColor(Actor self) { + var mod = self.traits.WithInterface().FirstOrDefault(); + if (mod != null) + return mod.RadarColorOverride(self); + return self.Owner.Color; } } diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 081452cf1a..59d953af26 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -61,6 +61,11 @@ namespace OpenRA.Traits Color RadarSignatureColor(Actor self); } + public interface IRadarSignatureModifier + { + Color RadarColorOverride(Actor self); + } + public interface IOccupySpace { int2 TopLeft { get; } diff --git a/OpenRA.Game/Traits/Unit.cs b/OpenRA.Game/Traits/Unit.cs index f237ef7250..aacfd22896 100755 --- a/OpenRA.Game/Traits/Unit.cs +++ b/OpenRA.Game/Traits/Unit.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Drawing; +using System.Linq; namespace OpenRA.Traits { @@ -43,6 +44,10 @@ namespace OpenRA.Traits public Color RadarSignatureColor(Actor self) { + var mod = self.traits.WithInterface().FirstOrDefault(); + if (mod != null) + return mod.RadarColorOverride(self); + return self.Owner.Color; } } diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 6ccbe28e0c..e8df225b99 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -208,6 +208,7 @@ + diff --git a/OpenRA.Mods.RA/RadarColorFromTerrain.cs b/OpenRA.Mods.RA/RadarColorFromTerrain.cs new file mode 100644 index 0000000000..4cfd1b9610 --- /dev/null +++ b/OpenRA.Mods.RA/RadarColorFromTerrain.cs @@ -0,0 +1,37 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see LICENSE. + */ +#endregion + +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using OpenRA.FileFormats; + +namespace OpenRA.Traits +{ + public class RadarColorFromTerrainInfo : ITraitInfo + { + public readonly string Terrain; + public object Create( ActorInitializer init ) { return new RadarColorFromTerrain(init.self,Terrain); } + } + + public class RadarColorFromTerrain : IRadarSignatureModifier + { + Color c; + public RadarColorFromTerrain(Actor self, string terrain) + { + c = self.World.TileSet.Terrain[terrain].Color; + } + + public Color RadarColorOverride(Actor self) + { + return c; + } + } +} \ No newline at end of file diff --git a/mods/cnc/defaults.yaml b/mods/cnc/defaults.yaml index 6de5223218..cd4ad3a140 100644 --- a/mods/cnc/defaults.yaml +++ b/mods/cnc/defaults.yaml @@ -151,7 +151,8 @@ Building: Footprint: __ x_ Dimensions: 2,2 - + RadarColorFromTerrain: + Terrain: Tree ^Rock: Category: Building Valued: @@ -161,6 +162,9 @@ Building: Footprint: __ x_ Dimensions: 2,2 + RadarColorFromTerrain: + Terrain: Tree + ^Husk: Category: Vehicle Unit: @@ -187,4 +191,6 @@ DestroyedSound: xplobig4.aud Footprint: ______ ______ ______ ______ Dimensions: 6,4 - HP: 1000 \ No newline at end of file + HP: 1000 + RadarColorFromTerrain: + Terrain: Road \ No newline at end of file diff --git a/mods/cnc/trees.yaml b/mods/cnc/trees.yaml index 62a4cf09a0..e286b027cd 100644 --- a/mods/cnc/trees.yaml +++ b/mods/cnc/trees.yaml @@ -7,6 +7,8 @@ SPLIT2: Valued: Description: Blossom Tree -Selectable: + RadarColorFromTerrain: + Terrain: Ore SPLIT3: Inherits: ^Building @@ -17,6 +19,8 @@ SPLIT3: Valued: Description: Blossom Tree -Selectable: + RadarColorFromTerrain: + Terrain: Ore ROCK1: Inherits: ^Rock diff --git a/mods/ra/defaults.yaml b/mods/ra/defaults.yaml index 7b8516ae91..24b26d6d14 100644 --- a/mods/ra/defaults.yaml +++ b/mods/ra/defaults.yaml @@ -143,6 +143,8 @@ Building: Footprint: x Dimensions: 1,1 + RadarColorFromTerrain: + Terrain: Tree ^Husk: Category: Vehicle @@ -169,4 +171,6 @@ Building: Footprint: ____ ____ Dimensions: 4,2 - HP: 1000 \ No newline at end of file + HP: 1000 + RadarColorFromTerrain: + Terrain: Road \ No newline at end of file diff --git a/mods/ra/trees.yaml b/mods/ra/trees.yaml index 80ebda8b6c..1c7ecf7d27 100644 --- a/mods/ra/trees.yaml +++ b/mods/ra/trees.yaml @@ -125,6 +125,8 @@ MINE: Valued: Description: Ore Mine SeedsResource: + RadarColorFromTerrain: + Terrain: Ore BOXES01: Inherits: ^Tree