StyleCop clean OpenRA.Mods.RA

This commit is contained in:
Matthias Mailänder
2015-01-04 16:49:45 +01:00
parent 2691f16a81
commit 1b0e3a7a7f
39 changed files with 414 additions and 398 deletions

View File

@@ -37,8 +37,8 @@ namespace OpenRA.Mods.RA.Traits
public class OreRefinery : ITick, IAcceptOre, INotifyKilled, INotifySold, INotifyCapture, INotifyOwnerChanged, IExplodeModifier, ISync
{
readonly Actor self;
readonly OreRefineryInfo Info;
PlayerResources PlayerResources;
readonly OreRefineryInfo info;
PlayerResources playerResources;
int currentDisplayTick = 0;
int currentDisplayValue = 0;
@@ -48,16 +48,16 @@ namespace OpenRA.Mods.RA.Traits
[Sync] bool preventDock = false;
public bool AllowDocking { get { return !preventDock; } }
public CVec DeliverOffset { get { return Info.DockOffset; } }
public CVec DeliverOffset { get { return info.DockOffset; } }
public virtual Activity DockSequence(Actor harv, Actor self) { return new RAHarvesterDockSequence(harv, self, Info.DockAngle); }
public virtual Activity DockSequence(Actor harv, Actor self) { return new RAHarvesterDockSequence(harv, self, info.DockAngle); }
public OreRefinery(Actor self, OreRefineryInfo info)
{
this.self = self;
Info = info;
PlayerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
currentDisplayTick = Info.TickRate;
this.info = info;
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
currentDisplayTick = info.TickRate;
}
public IEnumerable<TraitPair<Harvester>> GetLinkedHarvesters()
@@ -66,12 +66,12 @@ namespace OpenRA.Mods.RA.Traits
.Where(a => a.Trait.LinkedProc == self);
}
public bool CanGiveOre(int amount) { return PlayerResources.CanGiveResources(amount); }
public bool CanGiveOre(int amount) { return playerResources.CanGiveResources(amount); }
public void GiveOre(int amount)
{
PlayerResources.GiveResources(amount);
if (Info.ShowTicks)
playerResources.GiveResources(amount);
if (info.ShowTicks)
currentDisplayValue += amount;
}
@@ -93,12 +93,12 @@ namespace OpenRA.Mods.RA.Traits
dockedHarv = null;
}
if (Info.ShowTicks && currentDisplayValue > 0 && --currentDisplayTick <= 0)
if (info.ShowTicks && currentDisplayValue > 0 && --currentDisplayTick <= 0)
{
var temp = currentDisplayValue;
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(temp), 30)));
currentDisplayTick = Info.TickRate;
currentDisplayTick = info.TickRate;
currentDisplayValue = 0;
}
}
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.RA.Traits
foreach (var harv in GetLinkedHarvesters())
harv.Trait.UnlinkProc(harv.Actor, self);
PlayerResources = newOwner.PlayerActor.Trait<PlayerResources>();
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
}
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)

View File

@@ -12,8 +12,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.Common;
using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits
@@ -38,13 +38,13 @@ namespace OpenRA.Mods.RA.Traits
public int RepairersHash { get { return Repairers.Aggregate(0, (code, player) => code ^ Sync.HashPlayer(player)); } }
public List<Player> Repairers = new List<Player>();
Health Health;
readonly Health health;
public bool RepairActive = false;
public RepairableBuilding(Actor self, RepairableBuildingInfo info)
: base(info)
{
Health = self.Trait<Health>();
health = self.Trait<Health>();
}
public void RepairBuilding(Actor self, Player player)
@@ -91,8 +91,8 @@ namespace OpenRA.Mods.RA.Traits
var buildingValue = self.GetSellValue();
// The cost is the same regardless of the amount of people repairing
var hpToRepair = Math.Min(Info.RepairStep, Health.MaxHP - Health.HP);
var cost = Math.Max(1, (hpToRepair * Info.RepairPercent * buildingValue) / (Health.MaxHP * 100));
var hpToRepair = Math.Min(Info.RepairStep, health.MaxHP - health.HP);
var cost = Math.Max(1, (hpToRepair * Info.RepairPercent * buildingValue) / (health.MaxHP * 100));
// TakeCash will return false if the player can't pay, and will stop him from contributing this Tick
var activePlayers = Repairers.Count(player => player.PlayerActor.Trait<PlayerResources>().TakeCash(cost));
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.RA.Traits
// to the length of the array
self.InflictDamage(self, -(hpToRepair * Info.RepairBonuses[activePlayers - 1] / 100), null);
if (Health.DamageState == DamageState.Undamaged)
if (health.DamageState == DamageState.Undamaged)
{
Repairers.Clear();
RepairActive = false;