Move more traits from Mods.RA to Mods.Common
This commit is contained in:
@@ -106,10 +106,13 @@
|
||||
<Compile Include="Scripting\Properties\PowerProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\ResourceProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\UpgradeProperties.cs" />
|
||||
<Compile Include="Traits\AppearsOnRadar.cs" />
|
||||
<Compile Include="Traits\BlocksBullets.cs" />
|
||||
<Compile Include="Traits\Buildable.cs" />
|
||||
<Compile Include="Traits\Buildings\BaseProvider.cs" />
|
||||
<Compile Include="Traits\Buildings\DeadBuildingState.cs" />
|
||||
<Compile Include="Traits\Buildings\LineBuild.cs" />
|
||||
<Compile Include="Traits\Buildings\LineBuildNode.cs" />
|
||||
<Compile Include="Traits\Buildings\RallyPoint.cs" />
|
||||
<Compile Include="Traits\Burns.cs" />
|
||||
<Compile Include="Traits\CustomBuildTimeValue.cs" />
|
||||
@@ -141,6 +144,7 @@
|
||||
<Compile Include="Traits\Power\RequiresPower.cs" />
|
||||
<Compile Include="Traits\Power\ScalePowerWithHealth.cs" />
|
||||
<Compile Include="Traits\ProvidesRadar.cs" />
|
||||
<Compile Include="Traits\RadarColorFromTerrain.cs" />
|
||||
<Compile Include="Traits\Render\RenderEditorOnly.cs" />
|
||||
<Compile Include="Traits\Render\RenderFlare.cs" />
|
||||
<Compile Include="Traits\Render\RenderNameTag.cs" />
|
||||
|
||||
48
OpenRA.Mods.Common/Traits/AppearsOnRadar.cs
Normal file
48
OpenRA.Mods.Common/Traits/AppearsOnRadar.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class AppearsOnRadarInfo : ITraitInfo
|
||||
{
|
||||
public readonly bool UseLocation = false;
|
||||
|
||||
public object Create(ActorInitializer init) { return new AppearsOnRadar(this); }
|
||||
}
|
||||
|
||||
public class AppearsOnRadar : IRadarSignature
|
||||
{
|
||||
AppearsOnRadarInfo info;
|
||||
|
||||
public AppearsOnRadar(AppearsOnRadarInfo info) { this.info = info; }
|
||||
|
||||
public IEnumerable<CPos> RadarSignatureCells(Actor self)
|
||||
{
|
||||
if (info.UseLocation)
|
||||
return new CPos[] { self.Location };
|
||||
else
|
||||
return self.OccupiesSpace.OccupiedCells().Select(c => c.First);
|
||||
}
|
||||
|
||||
public Color RadarSignatureColor(Actor self)
|
||||
{
|
||||
var mod = self.TraitsImplementing<IRadarColorModifier>().FirstOrDefault();
|
||||
if (mod != null)
|
||||
return mod.RadarColorOverride(self);
|
||||
|
||||
return self.Owner.Color.RGB;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
OpenRA.Mods.Common/Traits/Buildings/LineBuild.cs
Normal file
26
OpenRA.Mods.Common/Traits/Buildings/LineBuild.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Place the second actor in line to build more of the same at once (used for walls).")]
|
||||
public class LineBuildInfo : TraitInfo<LineBuild>
|
||||
{
|
||||
[Desc("The maximum allowed length of the line.")]
|
||||
public readonly int Range = 5;
|
||||
|
||||
[Desc("LineBuildNode 'Types' to attach to.")]
|
||||
public readonly string[] NodeTypes = { "wall" };
|
||||
}
|
||||
|
||||
public class LineBuild {}
|
||||
}
|
||||
23
OpenRA.Mods.Common/Traits/Buildings/LineBuildNode.cs
Normal file
23
OpenRA.Mods.Common/Traits/Buildings/LineBuildNode.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("LineBuild actors attach to LineBuildNodes.")]
|
||||
public class LineBuildNodeInfo : TraitInfo<LineBuildNode>
|
||||
{
|
||||
[Desc("This actor is of LineBuild 'NodeType'...")]
|
||||
public readonly string[] Types = { "wall" };
|
||||
}
|
||||
|
||||
public class LineBuildNode {}
|
||||
}
|
||||
34
OpenRA.Mods.Common/Traits/RadarColorFromTerrain.cs
Normal file
34
OpenRA.Mods.Common/Traits/RadarColorFromTerrain.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class RadarColorFromTerrainInfo : ITraitInfo
|
||||
{
|
||||
public readonly string Terrain;
|
||||
public object Create( ActorInitializer init ) { return new RadarColorFromTerrain(init.self,Terrain); }
|
||||
}
|
||||
|
||||
public class RadarColorFromTerrain : IRadarColorModifier
|
||||
{
|
||||
Color c;
|
||||
|
||||
public RadarColorFromTerrain(Actor self, string terrain)
|
||||
{
|
||||
c = self.World.TileSet[self.World.TileSet.GetTerrainIndex(terrain)].Color;
|
||||
}
|
||||
|
||||
public bool VisibleOnRadar(Actor self) { return true; }
|
||||
public Color RadarColorOverride(Actor self) { return c; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user