Correct bridge / tree / mine color

This commit is contained in:
Paul Chote
2010-07-22 19:49:27 +12:00
parent 5f36933837
commit f7212ef757
9 changed files with 71 additions and 3 deletions

View File

@@ -169,6 +169,10 @@ namespace OpenRA.Traits
public Color RadarSignatureColor(Actor self)
{
var mod = self.traits.WithInterface<IRadarSignatureModifier>().FirstOrDefault();
if (mod != null)
return mod.RadarColorOverride(self);
return self.Owner.Color;
}
}

View File

@@ -61,6 +61,11 @@ namespace OpenRA.Traits
Color RadarSignatureColor(Actor self);
}
public interface IRadarSignatureModifier
{
Color RadarColorOverride(Actor self);
}
public interface IOccupySpace
{
int2 TopLeft { get; }

View File

@@ -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<IRadarSignatureModifier>().FirstOrDefault();
if (mod != null)
return mod.RadarColorOverride(self);
return self.Owner.Color;
}
}

View File

@@ -208,6 +208,7 @@
<Compile Include="Activities\TransformIntoActor.cs" />
<Compile Include="PaletteFromCurrentTheatre.cs" />
<Compile Include="Widgets\Delegates\OrderButtonsChromeDelegate.cs" />
<Compile Include="RadarColorFromTerrain.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -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;
}
}
}

View File

@@ -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:
@@ -188,3 +192,5 @@
Footprint: ______ ______ ______ ______
Dimensions: 6,4
HP: 1000
RadarColorFromTerrain:
Terrain: Road

View File

@@ -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

View File

@@ -143,6 +143,8 @@
Building:
Footprint: x
Dimensions: 1,1
RadarColorFromTerrain:
Terrain: Tree
^Husk:
Category: Vehicle
@@ -170,3 +172,5 @@
Footprint: ____ ____
Dimensions: 4,2
HP: 1000
RadarColorFromTerrain:
Terrain: Road

View File

@@ -125,6 +125,8 @@ MINE:
Valued:
Description: Ore Mine
SeedsResource:
RadarColorFromTerrain:
Terrain: Ore
BOXES01:
Inherits: ^Tree