Style fixes

This commit is contained in:
reaperrr
2014-12-26 22:10:52 +01:00
parent d074fb4471
commit 311e347ad2
9 changed files with 24 additions and 25 deletions

View File

@@ -17,13 +17,13 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Remove this trait to limit base-walking by cheap or defensive buildings.")] [Desc("Remove this trait to limit base-walking by cheap or defensive buildings.")]
public class GivesBuildableAreaInfo : TraitInfo<GivesBuildableArea> {} public class GivesBuildableAreaInfo : TraitInfo<GivesBuildableArea> { }
public class GivesBuildableArea {} public class GivesBuildableArea { }
public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, UsesInit<LocationInit> public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, UsesInit<LocationInit>
{ {
[Desc("Where you are allowed to place the building (Water, Clear, ...)")] [Desc("Where you are allowed to place the building (Water, Clear, ...)")]
public readonly string[] TerrainTypes = {}; public readonly string[] TerrainTypes = { };
[Desc("The range to the next building it can be constructed. Set it higher for walls.")] [Desc("The range to the next building it can be constructed. Set it higher for walls.")]
public readonly int Adjacent = 2; public readonly int Adjacent = 2;
[Desc("x means space it blocks, _ is a part that is passable by actors.")] [Desc("x means space it blocks, _ is a part that is passable by actors.")]
@@ -51,6 +51,7 @@ namespace OpenRA.Mods.Common.Traits
if (target.IsInRange(center, WRange.FromCells(bp.Trait.Info.Range))) if (target.IsInRange(center, WRange.FromCells(bp.Trait.Info.Range)))
return bp.Actor; return bp.Actor;
} }
return null; return null;
} }
@@ -64,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
var buildingMaxBounds = Dimensions; var buildingMaxBounds = Dimensions;
var buildingTraits = world.Map.Rules.Actors[buildingName].Traits; var buildingTraits = world.Map.Rules.Actors[buildingName].Traits;
if (buildingTraits.Contains<BibInfo>() && !(buildingTraits.Get<BibInfo>().HasMinibib)) if (buildingTraits.Contains<BibInfo>() && !buildingTraits.Get<BibInfo>().HasMinibib)
buildingMaxBounds += new CVec(0, 1); buildingMaxBounds += new CVec(0, 1);
var scanStart = world.Map.Clamp(topLeft - new CVec(Adjacent, Adjacent)); var scanStart = world.Map.Clamp(topLeft - new CVec(Adjacent, Adjacent));
@@ -130,7 +131,7 @@ namespace OpenRA.Mods.Common.Traits
this.topLeft = init.Get<LocationInit, CPos>(); this.topLeft = init.Get<LocationInit, CPos>();
this.Info = info; this.Info = info;
occupiedCells = FootprintUtils.UnpathableTiles( self.Info.Name, Info, TopLeft ) occupiedCells = FootprintUtils.UnpathableTiles(self.Info.Name, Info, TopLeft)
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); .Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
CenterPosition = init.world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(init.world, Info); CenterPosition = init.world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(init.world, Info);
@@ -184,6 +185,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var s in Info.UndeploySounds) foreach (var s in Info.UndeploySounds)
Sound.PlayToPlayer(self.Owner, s, self.CenterPosition); Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
} }
public void OnTransform(Actor self) { } public void OnTransform(Actor self) { }
public void AfterTransform(Actor self) { } public void AfterTransform(Actor self) { }
} }

View File

@@ -66,10 +66,9 @@ namespace OpenRA.Mods.Common.Traits
// Cell contains an actor. Is it the type we want? // Cell contains an actor. Is it the type we want?
if (world.ActorsWithTrait<LineBuildNode>().Any(a => if (world.ActorsWithTrait<LineBuildNode>().Any(a =>
( (a.Actor.Location == cell &&
a.Actor.Location == cell && a.Actor.Info.Traits.Get<LineBuildNodeInfo>()
a.Actor.Info.Traits.Get<LineBuildNodeInfo>().Types.Intersect(lbi.NodeTypes).Any() .Types.Intersect(lbi.NodeTypes).Any())))
)))
dirs[d] = i; // Cell contains actor of correct type dirs[d] = i; // Cell contains actor of correct type
else else
dirs[d] = -1; // Cell is blocked by another actor type dirs[d] = -1; // Cell is blocked by another actor type

View File

@@ -28,14 +28,14 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Which direction the unit should face.")] [Desc("Which direction the unit should face.")]
public readonly int Facing = 0; public readonly int Facing = 0;
public object Create( ActorInitializer init ) { return new FreeActor(init, this); } public object Create(ActorInitializer init) { return new FreeActor(init, this); }
} }
public class FreeActor public class FreeActor
{ {
public FreeActor(ActorInitializer init, FreeActorInfo info) public FreeActor(ActorInitializer init, FreeActorInfo info)
{ {
if (init.Contains<FreeActorInit>() && !init.Get<FreeActorInit>().value) if (init.Contains<FreeActorInit>() && !init.Get<FreeActorInit>().ActorValue)
return; return;
init.self.World.AddFrameEndTask(w => init.self.World.AddFrameEndTask(w =>
@@ -57,16 +57,16 @@ namespace OpenRA.Mods.Common.Traits
public class FreeActorInit : IActorInit<bool> public class FreeActorInit : IActorInit<bool>
{ {
[FieldFromYamlKey] [FieldFromYamlKey]
public readonly bool value = true; public readonly bool ActorValue = true;
public FreeActorInit() { } public FreeActorInit() { }
public FreeActorInit(bool init) { value = init; } public FreeActorInit(bool init) { ActorValue = init; }
public bool Value(World world) { return value; } public bool Value(World world) { return ActorValue; }
} }
public class ParentActorInit : IActorInit<Actor> public class ParentActorInit : IActorInit<Actor>
{ {
public readonly Actor value; public readonly Actor ActorValue;
public ParentActorInit(Actor parent) { value = parent; } public ParentActorInit(Actor parent) { ActorValue = parent; }
public Actor Value(World world) { return value; } public Actor Value(World world) { return ActorValue; }
} }
} }

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public readonly bool PauseOnLowPower = false; public readonly bool PauseOnLowPower = false;
public override object Create(ActorInitializer init) { return new RenderBuilding(init, this);} public override object Create(ActorInitializer init) { return new RenderBuilding(init, this); }
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition) public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
{ {

View File

@@ -8,8 +8,8 @@
*/ */
#endregion #endregion
using OpenRA.Graphics;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
public void MovingToRefinery(Actor self, CPos targetCell, Activity next) { } public void MovingToRefinery(Actor self, CPos targetCell, Activity next) { }
public void MovementCancelled(Actor self) { } public void MovementCancelled(Actor self) { }
static public int ZOffsetFromCenter(Actor self, WPos pos, int offset) public static int ZOffsetFromCenter(Actor self, WPos pos, int offset)
{ {
var delta = self.CenterPosition - pos; var delta = self.CenterPosition - pos;
return delta.Y + delta.Z + offset; return delta.Y + delta.Z + offset;

View File

@@ -26,7 +26,6 @@ namespace OpenRA.Mods.Common.Warheads
public readonly string AddsResourceType = null; public readonly string AddsResourceType = null;
// TODO: Allow maximum resource splatter to be defined. (Per tile, and in total). // TODO: Allow maximum resource splatter to be defined. (Per tile, and in total).
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers) public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
{ {
if (string.IsNullOrEmpty(AddsResourceType)) if (string.IsNullOrEmpty(AddsResourceType))
@@ -34,7 +33,7 @@ namespace OpenRA.Mods.Common.Warheads
var world = firedBy.World; var world = firedBy.World;
var targetTile = world.Map.CellContaining(target.CenterPosition); var targetTile = world.Map.CellContaining(target.CenterPosition);
var resLayer = world.WorldActor.Trait<ResourceLayer>(); var resLayer = world.WorldActor.Trait<ResourceLayer>();
var minRange = (Size.Length > 1 && Size[1] > 0) ? Size[1] : 0; var minRange = (Size.Length > 1 && Size[1] > 0) ? Size[1] : 0;
var allCells = world.Map.FindTilesInAnnulus(targetTile, minRange, Size[0]); var allCells = world.Map.FindTilesInAnnulus(targetTile, minRange, Size[0]);

View File

@@ -23,7 +23,6 @@ namespace OpenRA.Mods.Common.Warheads
public readonly int[] Size = { 0, 0 }; public readonly int[] Size = { 0, 0 };
// TODO: Allow maximum resource removal to be defined. (Per tile, and in total). // TODO: Allow maximum resource removal to be defined. (Per tile, and in total).
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers) public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
{ {
var world = firedBy.World; var world = firedBy.World;

View File

@@ -15,8 +15,8 @@ using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA; using OpenRA.Mods.RA;
using OpenRA.Mods.RA.Traits;
using OpenRA.Mods.RA.Orders; using OpenRA.Mods.RA.Orders;
using OpenRA.Mods.RA.Traits;
using OpenRA.Network; using OpenRA.Network;
using OpenRA.Primitives; using OpenRA.Primitives;
using OpenRA.Traits; using OpenRA.Traits;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Traits
public BridgeHut(ActorInitializer init) public BridgeHut(ActorInitializer init)
{ {
Bridge = init.Get<ParentActorInit>().value.Trait<Bridge>(); Bridge = init.Get<ParentActorInit>().ActorValue.Trait<Bridge>();
Bridge.AddHut(this); Bridge.AddHut(this);
FirstBridge = Bridge.Enumerate(0, true).Last(); FirstBridge = Bridge.Enumerate(0, true).Last();
} }