From 311e347ad2fc26c5684d28ebee75872bb0866051 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 26 Dec 2014 22:10:52 +0100 Subject: [PATCH] Style fixes --- OpenRA.Mods.Common/Traits/Buildings/Building.cs | 12 +++++++----- .../Traits/Buildings/BuildingUtils.cs | 7 +++---- OpenRA.Mods.Common/Traits/Buildings/FreeActor.cs | 16 ++++++++-------- .../Traits/Render/RenderBuilding.cs | 2 +- .../Traits/Render/WithHarvestAnimation.cs | 4 ++-- .../Warheads/CreateResourceWarhead.cs | 3 +-- .../Warheads/DestroyResourceWarhead.cs | 1 - OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs | 2 +- OpenRA.Mods.RA/Traits/Buildings/BridgeHut.cs | 2 +- 9 files changed, 24 insertions(+), 25 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Buildings/Building.cs b/OpenRA.Mods.Common/Traits/Buildings/Building.cs index ced2d3f429..145d56a5a4 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Building.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Building.cs @@ -17,13 +17,13 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Remove this trait to limit base-walking by cheap or defensive buildings.")] - public class GivesBuildableAreaInfo : TraitInfo {} - public class GivesBuildableArea {} + public class GivesBuildableAreaInfo : TraitInfo { } + public class GivesBuildableArea { } public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, UsesInit { [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.")] public readonly int Adjacent = 2; [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))) return bp.Actor; } + return null; } @@ -64,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits var buildingMaxBounds = Dimensions; var buildingTraits = world.Map.Rules.Actors[buildingName].Traits; - if (buildingTraits.Contains() && !(buildingTraits.Get().HasMinibib)) + if (buildingTraits.Contains() && !buildingTraits.Get().HasMinibib) buildingMaxBounds += new CVec(0, 1); var scanStart = world.Map.Clamp(topLeft - new CVec(Adjacent, Adjacent)); @@ -130,7 +131,7 @@ namespace OpenRA.Mods.Common.Traits this.topLeft = init.Get(); 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(); 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) Sound.PlayToPlayer(self.Owner, s, self.CenterPosition); } + public void OnTransform(Actor self) { } public void AfterTransform(Actor self) { } } diff --git a/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs b/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs index a06b0bad6d..21d039816e 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs @@ -66,10 +66,9 @@ namespace OpenRA.Mods.Common.Traits // Cell contains an actor. Is it the type we want? if (world.ActorsWithTrait().Any(a => - ( - a.Actor.Location == cell && - a.Actor.Info.Traits.Get().Types.Intersect(lbi.NodeTypes).Any() - ))) + (a.Actor.Location == cell && + a.Actor.Info.Traits.Get() + .Types.Intersect(lbi.NodeTypes).Any()))) dirs[d] = i; // Cell contains actor of correct type else dirs[d] = -1; // Cell is blocked by another actor type diff --git a/OpenRA.Mods.Common/Traits/Buildings/FreeActor.cs b/OpenRA.Mods.Common/Traits/Buildings/FreeActor.cs index d273d6ade7..4ec3454057 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/FreeActor.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/FreeActor.cs @@ -28,14 +28,14 @@ namespace OpenRA.Mods.Common.Traits [Desc("Which direction the unit should face.")] 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 FreeActor(ActorInitializer init, FreeActorInfo info) { - if (init.Contains() && !init.Get().value) + if (init.Contains() && !init.Get().ActorValue) return; init.self.World.AddFrameEndTask(w => @@ -57,16 +57,16 @@ namespace OpenRA.Mods.Common.Traits public class FreeActorInit : IActorInit { [FieldFromYamlKey] - public readonly bool value = true; + public readonly bool ActorValue = true; public FreeActorInit() { } - public FreeActorInit(bool init) { value = init; } - public bool Value(World world) { return value; } + public FreeActorInit(bool init) { ActorValue = init; } + public bool Value(World world) { return ActorValue; } } public class ParentActorInit : IActorInit { - public readonly Actor value; - public ParentActorInit(Actor parent) { value = parent; } - public Actor Value(World world) { return value; } + public readonly Actor ActorValue; + public ParentActorInit(Actor parent) { ActorValue = parent; } + public Actor Value(World world) { return ActorValue; } } } diff --git a/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs b/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs index 9841792c75..1380d7dff5 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderBuilding.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits { 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 Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition) { diff --git a/OpenRA.Mods.Common/Traits/Render/WithHarvestAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithHarvestAnimation.cs index 7c3a00585c..2354c03930 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithHarvestAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithHarvestAnimation.cs @@ -8,8 +8,8 @@ */ #endregion -using OpenRA.Graphics; using OpenRA.Activities; +using OpenRA.Graphics; using OpenRA.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 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; return delta.Y + delta.Z + offset; diff --git a/OpenRA.Mods.Common/Warheads/CreateResourceWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateResourceWarhead.cs index 852dba3414..44c84d3637 100644 --- a/OpenRA.Mods.Common/Warheads/CreateResourceWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateResourceWarhead.cs @@ -26,7 +26,6 @@ namespace OpenRA.Mods.Common.Warheads public readonly string AddsResourceType = null; // TODO: Allow maximum resource splatter to be defined. (Per tile, and in total). - public override void DoImpact(Target target, Actor firedBy, IEnumerable damageModifiers) { if (string.IsNullOrEmpty(AddsResourceType)) @@ -34,7 +33,7 @@ namespace OpenRA.Mods.Common.Warheads var world = firedBy.World; var targetTile = world.Map.CellContaining(target.CenterPosition); - var resLayer = world.WorldActor.Trait(); + var resLayer = world.WorldActor.Trait(); var minRange = (Size.Length > 1 && Size[1] > 0) ? Size[1] : 0; var allCells = world.Map.FindTilesInAnnulus(targetTile, minRange, Size[0]); diff --git a/OpenRA.Mods.Common/Warheads/DestroyResourceWarhead.cs b/OpenRA.Mods.Common/Warheads/DestroyResourceWarhead.cs index 94368d7804..15ff1d1704 100644 --- a/OpenRA.Mods.Common/Warheads/DestroyResourceWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/DestroyResourceWarhead.cs @@ -23,7 +23,6 @@ namespace OpenRA.Mods.Common.Warheads public readonly int[] Size = { 0, 0 }; // TODO: Allow maximum resource removal to be defined. (Per tile, and in total). - public override void DoImpact(Target target, Actor firedBy, IEnumerable damageModifiers) { var world = firedBy.World; diff --git a/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs index a0dd30dfb8..f03c354527 100644 --- a/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs @@ -15,8 +15,8 @@ using System.Linq; using OpenRA.Graphics; using OpenRA.Mods.Common.Traits; using OpenRA.Mods.RA; -using OpenRA.Mods.RA.Traits; using OpenRA.Mods.RA.Orders; +using OpenRA.Mods.RA.Traits; using OpenRA.Network; using OpenRA.Primitives; using OpenRA.Traits; diff --git a/OpenRA.Mods.RA/Traits/Buildings/BridgeHut.cs b/OpenRA.Mods.RA/Traits/Buildings/BridgeHut.cs index a29f299fba..c8749909c3 100644 --- a/OpenRA.Mods.RA/Traits/Buildings/BridgeHut.cs +++ b/OpenRA.Mods.RA/Traits/Buildings/BridgeHut.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Traits public BridgeHut(ActorInitializer init) { - Bridge = init.Get().value.Trait(); + Bridge = init.Get().ActorValue.Trait(); Bridge.AddHut(this); FirstBridge = Bridge.Enumerate(0, true).Last(); }