StyleCop clean OpenRA.Game
This commit is contained in:
0
OpenRA.Game/Traits/BodyOrientation.cs
Executable file → Normal file
0
OpenRA.Game/Traits/BodyOrientation.cs
Executable file → Normal file
@@ -20,13 +20,13 @@ namespace OpenRA.Traits
|
||||
|
||||
public class CreatesShroud : ITick, ISync
|
||||
{
|
||||
CreatesShroudInfo Info;
|
||||
CreatesShroudInfo info;
|
||||
[Sync] CPos cachedLocation;
|
||||
[Sync] bool cachedDisabled;
|
||||
|
||||
public CreatesShroud(CreatesShroudInfo info)
|
||||
{
|
||||
Info = info;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
@@ -43,6 +43,6 @@ namespace OpenRA.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public WRange Range { get { return cachedDisabled ? WRange.Zero : Info.Range; } }
|
||||
public WRange Range { get { return cachedDisabled ? WRange.Zero : info.Range; } }
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,12 @@ namespace OpenRA.Traits
|
||||
public class DrawLineToTarget : IPostRenderSelection, INotifySelected, INotifyBecomingIdle
|
||||
{
|
||||
Actor self;
|
||||
DrawLineToTargetInfo Info;
|
||||
DrawLineToTargetInfo info;
|
||||
List<Target> targets;
|
||||
Color c;
|
||||
int lifetime;
|
||||
|
||||
public DrawLineToTarget(Actor self, DrawLineToTargetInfo info) { this.self = self; this.Info = info; }
|
||||
public DrawLineToTarget(Actor self, DrawLineToTargetInfo info) { this.self = self; this.info = info; }
|
||||
|
||||
public void SetTarget(Actor self, Target target, Color c, bool display)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Traits
|
||||
this.c = c;
|
||||
|
||||
if (display)
|
||||
lifetime = Info.Ticks;
|
||||
lifetime = info.Ticks;
|
||||
}
|
||||
|
||||
public void SetTargets(Actor self, List<Target> targets, Color c, bool display)
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Traits
|
||||
this.c = c;
|
||||
|
||||
if (display)
|
||||
lifetime = Info.Ticks;
|
||||
lifetime = info.Ticks;
|
||||
}
|
||||
|
||||
public void Selected(Actor a)
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Traits
|
||||
return;
|
||||
|
||||
// Reset the order line timeout.
|
||||
lifetime = Info.Ticks;
|
||||
lifetime = info.Ticks;
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr)
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public class HealthInit : IActorInit<float>
|
||||
{
|
||||
[FieldFromYamlKey] public readonly float value = 1f;
|
||||
[FieldFromYamlKey] readonly float value = 1f;
|
||||
public HealthInit() { }
|
||||
public HealthInit(float init) { value = init; }
|
||||
public float Value(World world) { return value; }
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public class DeveloperMode : IResolveOrder, ISync
|
||||
{
|
||||
DeveloperModeInfo Info;
|
||||
DeveloperModeInfo info;
|
||||
[Sync] public bool FastCharge;
|
||||
[Sync] public bool AllTech;
|
||||
[Sync] public bool FastBuild;
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public DeveloperMode(DeveloperModeInfo info)
|
||||
{
|
||||
Info = info;
|
||||
this.info = info;
|
||||
FastBuild = info.FastBuild;
|
||||
FastCharge = info.FastCharge;
|
||||
DisableShroud = info.DisableShroud;
|
||||
@@ -85,7 +85,7 @@ namespace OpenRA.Traits
|
||||
|
||||
case "DevGiveCash":
|
||||
{
|
||||
var amount = order.ExtraData != 0 ? (int)order.ExtraData : Info.Cash;
|
||||
var amount = order.ExtraData != 0 ? (int)order.ExtraData : info.Cash;
|
||||
self.Trait<PlayerResources>().GiveCash(amount);
|
||||
break;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
foreach (var a in self.World.ActorsWithTrait<ISeedableResource>())
|
||||
{
|
||||
for (var i = 0; i < Info.ResourceGrowth; i++)
|
||||
for (var i = 0; i < info.ResourceGrowth; i++)
|
||||
a.Trait.Seed(a.Actor);
|
||||
}
|
||||
|
||||
|
||||
0
OpenRA.Game/Traits/Player/FrozenActorLayer.cs
Executable file → Normal file
0
OpenRA.Game/Traits/Player/FrozenActorLayer.cs
Executable file → Normal file
@@ -19,21 +19,21 @@ namespace OpenRA.Traits
|
||||
{
|
||||
[Desc("The prefix for the resulting player palettes")]
|
||||
public readonly string BaseName = "highlight";
|
||||
|
||||
|
||||
public object Create(ActorInitializer init) { return new PlayerHighlightPalette(init.self.Owner, this); }
|
||||
}
|
||||
|
||||
|
||||
public class PlayerHighlightPalette : ILoadsPalettes
|
||||
{
|
||||
readonly Player owner;
|
||||
readonly PlayerHighlightPaletteInfo info;
|
||||
|
||||
|
||||
public PlayerHighlightPalette(Player owner, PlayerHighlightPaletteInfo info)
|
||||
{
|
||||
this.owner = owner;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
|
||||
public void LoadPalettes(WorldRenderer wr)
|
||||
{
|
||||
var argb = (uint)Color.FromArgb(128, owner.Color.RGB).ToArgb();
|
||||
|
||||
@@ -24,17 +24,17 @@ namespace OpenRA.Traits
|
||||
|
||||
public class PlayerResources : ITick, ISync
|
||||
{
|
||||
const float displayCashFracPerFrame = .07f;
|
||||
const int displayCashDeltaPerFrame = 37;
|
||||
readonly Player Owner;
|
||||
int AdviceInterval;
|
||||
const float DisplayCashFracPerFrame = .07f;
|
||||
const int DisplayCashDeltaPerFrame = 37;
|
||||
readonly Player owner;
|
||||
int adviceInterval;
|
||||
|
||||
public PlayerResources(Actor self, PlayerResourcesInfo info)
|
||||
{
|
||||
Owner = self.Owner;
|
||||
owner = self.Owner;
|
||||
|
||||
Cash = self.World.LobbyInfo.GlobalSettings.StartingCash;
|
||||
AdviceInterval = info.AdviceInterval;
|
||||
adviceInterval = info.AdviceInterval;
|
||||
}
|
||||
|
||||
[Sync] public int Cash;
|
||||
@@ -108,7 +108,7 @@ namespace OpenRA.Traits
|
||||
nextCashTickTime--;
|
||||
|
||||
ResourceCapacity = self.World.ActorsWithTrait<IStoreResources>()
|
||||
.Where(a => a.Actor.Owner == Owner)
|
||||
.Where(a => a.Actor.Owner == owner)
|
||||
.Sum(a => a.Trait.Capacity);
|
||||
|
||||
if (Resources > ResourceCapacity)
|
||||
@@ -118,53 +118,52 @@ namespace OpenRA.Traits
|
||||
{
|
||||
if (Resources > 0.8 * ResourceCapacity)
|
||||
{
|
||||
Sound.PlayNotification(self.World.Map.Rules, Owner, "Speech", "SilosNeeded", Owner.Country.Race);
|
||||
Sound.PlayNotification(self.World.Map.Rules, owner, "Speech", "SilosNeeded", owner.Country.Race);
|
||||
AlertSilo = true;
|
||||
}
|
||||
else
|
||||
AlertSilo = false;
|
||||
|
||||
nextSiloAdviceTime = AdviceInterval;
|
||||
nextSiloAdviceTime = adviceInterval;
|
||||
}
|
||||
|
||||
var diff = Math.Abs(Cash - DisplayCash);
|
||||
var move = Math.Min(Math.Max((int)(diff * displayCashFracPerFrame),
|
||||
displayCashDeltaPerFrame), diff);
|
||||
|
||||
var move = Math.Min(Math.Max((int)(diff * DisplayCashFracPerFrame), DisplayCashDeltaPerFrame), diff);
|
||||
|
||||
if (DisplayCash < Cash)
|
||||
{
|
||||
DisplayCash += move;
|
||||
playCashTickUp(self);
|
||||
PlayCashTickUp(self);
|
||||
}
|
||||
else if (DisplayCash > Cash)
|
||||
{
|
||||
DisplayCash -= move;
|
||||
playCashTickDown(self);
|
||||
PlayCashTickDown(self);
|
||||
}
|
||||
|
||||
diff = Math.Abs(Resources - DisplayResources);
|
||||
move = Math.Min(Math.Max((int)(diff * displayCashFracPerFrame),
|
||||
displayCashDeltaPerFrame), diff);
|
||||
move = Math.Min(Math.Max((int)(diff * DisplayCashFracPerFrame),
|
||||
DisplayCashDeltaPerFrame), diff);
|
||||
|
||||
if (DisplayResources < Resources)
|
||||
{
|
||||
DisplayResources += move;
|
||||
playCashTickUp(self);
|
||||
PlayCashTickUp(self);
|
||||
}
|
||||
else if (DisplayResources > Resources)
|
||||
{
|
||||
DisplayResources -= move;
|
||||
playCashTickDown(self);
|
||||
PlayCashTickDown(self);
|
||||
}
|
||||
}
|
||||
|
||||
public void playCashTickUp(Actor self)
|
||||
|
||||
public void PlayCashTickUp(Actor self)
|
||||
{
|
||||
if (Game.Settings.Sound.CashTicks)
|
||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", "CashTickUp", self.Owner.Country.Race);
|
||||
}
|
||||
|
||||
public void playCashTickDown(Actor self)
|
||||
|
||||
public void PlayCashTickDown(Actor self)
|
||||
{
|
||||
if (Game.Settings.Sound.CashTicks && nextCashTickTime == 0)
|
||||
{
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace OpenRA.Traits
|
||||
|
||||
public class RevealsShroud : ITick, ISync
|
||||
{
|
||||
RevealsShroudInfo Info;
|
||||
RevealsShroudInfo info;
|
||||
[Sync] CPos cachedLocation;
|
||||
|
||||
public RevealsShroud(RevealsShroudInfo info)
|
||||
{
|
||||
Info = info;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
@@ -39,6 +39,6 @@ namespace OpenRA.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public WRange Range { get { return Info.Range; } }
|
||||
public WRange Range { get { return info.Range; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace OpenRA.Traits
|
||||
public class SelectionDecorations : IPostRenderSelection
|
||||
{
|
||||
// depends on the order of pips in TraitsInterfaces.cs!
|
||||
static readonly string[] pipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray", "pip-blue", "pip-ammo", "pip-ammoempty" };
|
||||
static readonly string[] tagStrings = { "", "tag-fake", "tag-primary" };
|
||||
static readonly string[] PipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray", "pip-blue", "pip-ammo", "pip-ammoempty" };
|
||||
static readonly string[] TagStrings = { "", "tag-fake", "tag-primary" };
|
||||
|
||||
public SelectionDecorationsInfo Info;
|
||||
Actor self;
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Traits
|
||||
yield break;
|
||||
|
||||
var pipImages = new Animation(self.World, "pips");
|
||||
pipImages.PlayRepeating(pipStrings[0]);
|
||||
pipImages.PlayRepeating(PipStrings[0]);
|
||||
|
||||
var pipSize = pipImages.Image.size.ToInt2();
|
||||
var pipxyBase = basePosition + new int2(1 - pipSize.X / 2, -(3 + pipSize.Y / 2));
|
||||
@@ -101,7 +101,7 @@ namespace OpenRA.Traits
|
||||
pipxyOffset.Y -= pipSize.Y;
|
||||
}
|
||||
|
||||
pipImages.PlayRepeating(pipStrings[(int)pip]);
|
||||
pipImages.PlayRepeating(PipStrings[(int)pip]);
|
||||
pipxyOffset += new int2(pipSize.X, 0);
|
||||
|
||||
yield return new UISpriteRenderable(pipImages.Image, pipxyBase + pipxyOffset, 0, pal, 1f);
|
||||
@@ -126,7 +126,7 @@ namespace OpenRA.Traits
|
||||
if (tag == TagType.None)
|
||||
continue;
|
||||
|
||||
tagImages.PlayRepeating(tagStrings[(int)tag]);
|
||||
tagImages.PlayRepeating(TagStrings[(int)tag]);
|
||||
var pos = basePosition + tagxyOffset - (0.5f * tagImages.Image.size).ToInt2();
|
||||
yield return new UISpriteRenderable(tagImages.Image, pos, 0, pal, 1f);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
@@ -240,7 +241,9 @@ namespace OpenRA.Traits
|
||||
|
||||
public class TraitInfo<T> : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } }
|
||||
|
||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1302:InterfaceNamesMustBeginWithI", Justification = "Not a real interface, but more like a tag.")]
|
||||
public interface Requires<T> where T : class, ITraitInfo { }
|
||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1302:InterfaceNamesMustBeginWithI", Justification = "Not a real interface, but more like a tag.")]
|
||||
public interface UsesInit<T> where T : IActorInit { }
|
||||
|
||||
public interface INotifySelected { void Selected(Actor self); }
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace OpenRA.Traits
|
||||
void Invalidate()
|
||||
{
|
||||
var oldHash = Hash;
|
||||
Hash = Sync.hash_player(self.Owner) + self.World.WorldTick * 3;
|
||||
Hash = Sync.HashPlayer(self.Owner) + self.World.WorldTick * 3;
|
||||
|
||||
// Invalidate may be called multiple times in one world tick, which is decoupled from rendering.
|
||||
if (oldHash == Hash)
|
||||
|
||||
Reference in New Issue
Block a user