Merge pull request #7246 from Hellhake/stylecop-ra

Fix StyleCop warnings in OpenRA.Mods.RA
This commit is contained in:
Matthias Mailänder
2015-01-02 16:38:22 +01:00
134 changed files with 261 additions and 267 deletions

View File

@@ -12,8 +12,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using AI.Fuzzy.Library; using AI.Fuzzy.Library;
using OpenRA.Mods.RA.Traits;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Mods.RA.Traits;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA.AI namespace OpenRA.Mods.RA.AI
@@ -201,6 +201,7 @@ namespace OpenRA.Mods.RA.AI
if (warhead != null) if (warhead != null)
sumOfDamage += warhead.Damage; sumOfDamage += warhead.Damage;
} }
return sumOfDamage; return sumOfDamage;
}); });
} }

View File

@@ -73,10 +73,9 @@ namespace OpenRA.Mods.RA.AI
HackyAI.BotDebug("AI: {0} is starting production of {1}".F(player, item.Name)); HackyAI.BotDebug("AI: {0} is starting production of {1}".F(player, item.Name));
world.IssueOrder(Order.StartProduction(queue.Actor, item.Name, 1)); world.IssueOrder(Order.StartProduction(queue.Actor, item.Name, 1));
} }
// Production is complete
else if (currentBuilding.Done) else if (currentBuilding.Done)
{ {
// Production is complete
// Choose the placement logic // Choose the placement logic
// HACK: HACK HACK HACK // HACK: HACK HACK HACK
var type = BuildingType.Building; var type = BuildingType.Building;

View File

@@ -735,6 +735,7 @@ namespace OpenRA.Mods.RA.AI
foreach (var kv in powers) foreach (var kv in powers)
{ {
var sp = kv.Value; var sp = kv.Value;
// Add power to dictionary if not in delay dictionary yet // Add power to dictionary if not in delay dictionary yet
if (!waitingPowers.ContainsKey(sp)) if (!waitingPowers.ContainsKey(sp))
waitingPowers.Add(sp, 0); waitingPowers.Add(sp, 0);
@@ -743,7 +744,7 @@ namespace OpenRA.Mods.RA.AI
waitingPowers[sp]--; waitingPowers[sp]--;
// If we have recently tried and failed to find a use location for a power, then do not try again until later // If we have recently tried and failed to find a use location for a power, then do not try again until later
var isDelayed = (waitingPowers[sp] > 0); var isDelayed = waitingPowers[sp] > 0;
if (sp.Ready && !isDelayed && powerDecisions.ContainsKey(sp.Info.OrderName)) if (sp.Ready && !isDelayed && powerDecisions.ContainsKey(sp.Info.OrderName))
{ {
var powerDecision = powerDecisions[sp.Info.OrderName]; var powerDecision = powerDecisions[sp.Info.OrderName];
@@ -780,7 +781,7 @@ namespace OpenRA.Mods.RA.AI
} }
} }
///<summary>Scans the map in chunks, evaluating all actors in each.</summary> /// <summary>Scans the map in chunks, evaluating all actors in each.</summary>
CPos? FindCoarseAttackLocationToSupportPower(SupportPowerInstance readyPower) CPos? FindCoarseAttackLocationToSupportPower(SupportPowerInstance readyPower)
{ {
CPos? bestLocation = null; CPos? bestLocation = null;
@@ -815,7 +816,7 @@ namespace OpenRA.Mods.RA.AI
return bestLocation; return bestLocation;
} }
///<summary>Detail scans an area, evaluating positions.</summary> /// <summary>Detail scans an area, evaluating positions.</summary>
CPos? FindFineAttackLocationToSupportPower(SupportPowerInstance readyPower, CPos checkPos, int extendedRange = 1) CPos? FindFineAttackLocationToSupportPower(SupportPowerInstance readyPower, CPos checkPos, int extendedRange = 1)
{ {
CPos? bestLocation = null; CPos? bestLocation = null;
@@ -829,11 +830,11 @@ namespace OpenRA.Mods.RA.AI
var checkRadius = powerDecision.CoarseScanRadius; var checkRadius = powerDecision.CoarseScanRadius;
var fineCheck = powerDecision.FineScanRadius; var fineCheck = powerDecision.FineScanRadius;
for (var i = (0 - extendedRange); i <= (checkRadius + extendedRange); i += fineCheck) for (var i = 0 - extendedRange; i <= (checkRadius + extendedRange); i += fineCheck)
{ {
var x = checkPos.X + i; var x = checkPos.X + i;
for (var j = (0 - extendedRange); j <= (checkRadius + extendedRange); j += fineCheck) for (var j = 0 - extendedRange; j <= (checkRadius + extendedRange); j += fineCheck)
{ {
var y = checkPos.Y + j; var y = checkPos.Y + j;
var pos = world.Map.CenterOfCell(new CPos(x, y)); var pos = world.Map.CenterOfCell(new CPos(x, y));

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA
[Desc("What support power does this decision apply to?")] [Desc("What support power does this decision apply to?")]
public readonly string OrderName = "AirstrikePowerInfoOrder"; public readonly string OrderName = "AirstrikePowerInfoOrder";
[Desc("What is the coarse scan radius of this power?","For finding the general target area, before doing a detail scan","Should be 10 or more to avoid lag")] [Desc("What is the coarse scan radius of this power?", "For finding the general target area, before doing a detail scan", "Should be 10 or more to avoid lag")]
public readonly int CoarseScanRadius = 20; public readonly int CoarseScanRadius = 20;
[Desc("What is the fine scan radius of this power?", "For doing a detailed scan in the general target area.", "Minimum is 1")] [Desc("What is the fine scan radius of this power?", "For doing a detailed scan in the general target area.", "Minimum is 1")]
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA
return ret; return ret;
} }
///<summary>Evaluates the attractiveness of a position according to all considerations</summary> /// <summary>Evaluates the attractiveness of a position according to all considerations</summary>
public int GetAttractiveness(WPos pos, Player firedBy) public int GetAttractiveness(WPos pos, Player firedBy)
{ {
var answer = 0; var answer = 0;
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.RA
return answer; return answer;
} }
///<summary>Evaluates the attractiveness of a group of actors according to all considerations</summary> /// <summary>Evaluates the attractiveness of a group of actors according to all considerations</summary>
public int GetAttractiveness(IEnumerable<Actor> actors, Player firedBy) public int GetAttractiveness(IEnumerable<Actor> actors, Player firedBy)
{ {
var answer = 0; var answer = 0;
@@ -95,10 +95,10 @@ namespace OpenRA.Mods.RA
public int GetNextScanTime(HackyAI ai) { return ai.random.Next(MinimumScanTimeInterval, MaximumScanTimeInterval); } public int GetNextScanTime(HackyAI ai) { return ai.random.Next(MinimumScanTimeInterval, MaximumScanTimeInterval); }
///<summary>Makes up part of a decision, describing how to evaluate a target.</summary> /// <summary>Makes up part of a decision, describing how to evaluate a target.</summary>
class Consideration class Consideration
{ {
public enum DecisionMetric { Health, Value, None }; public enum DecisionMetric { Health, Value, None }
[Desc("Against whom should this power be used?", "Allowed keywords: Ally, Neutral, Enemy")] [Desc("Against whom should this power be used?", "Allowed keywords: Ally, Neutral, Enemy")]
public readonly Stance Against = Stance.Enemy; public readonly Stance Against = Stance.Enemy;
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.RA
FieldLoader.Load(this, yaml); FieldLoader.Load(this, yaml);
} }
///<summary>Evaluates a single actor according to the rules defined in this consideration</summary> /// <summary>Evaluates a single actor according to the rules defined in this consideration</summary>
public int GetAttractiveness(Actor a, Stance stance, Player firedBy) public int GetAttractiveness(Actor a, Stance stance, Player firedBy)
{ {
if (stance != Against) if (stance != Against)
@@ -152,6 +152,7 @@ namespace OpenRA.Mods.RA
return Attractiveness; return Attractiveness;
} }
} }
return 0; return 0;
} }
} }

View File

@@ -37,6 +37,7 @@ namespace OpenRA.Mods.RA.Activities
if (info.Explosion != null) if (info.Explosion != null)
{ {
var weapon = self.World.Map.Rules.Weapons[info.Explosion.ToLowerInvariant()]; var weapon = self.World.Map.Rules.Weapons[info.Explosion.ToLowerInvariant()];
// Use .FromPos since this actor is killed. Cannot use Target.FromActor // Use .FromPos since this actor is killed. Cannot use Target.FromActor
weapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>()); weapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>());
} }

View File

@@ -46,6 +46,7 @@ namespace OpenRA.Mods.RA.Activities
else else
inner = Util.SequenceActivities(new Fly(self, target), new FlyTimed(ticksUntilTurn)); inner = Util.SequenceActivities(new Fly(self, target), new FlyTimed(ticksUntilTurn));
} }
inner = Util.RunActivity(self, inner); inner = Util.RunActivity(self, inner);
return this; return this;

View File

@@ -55,6 +55,7 @@ namespace OpenRA.Mods.RA.Activities
heli.UnReserve(); heli.UnReserve();
heli.Reservation = res.Reserve(dest, self, heli); heli.Reservation = res.Reserve(dest, self, heli);
} }
var exit = dest.Info.Traits.WithInterface<ExitInfo>().FirstOrDefault(); var exit = dest.Info.Traits.WithInterface<ExitInfo>().FirstOrDefault();
var offset = (exit != null) ? exit.SpawnOffset : WVec.Zero; var offset = (exit != null) ? exit.SpawnOffset : WVec.Zero;

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
var ret = InnerTick(self, attack); var ret = InnerTick(self, attack);
attack.IsAttacking = (ret == this); attack.IsAttacking = ret == this;
return ret; return ret;
} }

View File

@@ -19,11 +19,10 @@ namespace OpenRA.Mods.RA.Activities
{ {
public class DeliverResources : Activity public class DeliverResources : Activity
{ {
const int NextChooseTime = 100;
bool isDocking; bool isDocking;
int chosenTicks; int chosenTicks;
const int NextChooseTime = 100;
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (NextActivity != null) if (NextActivity != null)

View File

@@ -12,8 +12,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Effects; using OpenRA.Effects;
using OpenRA.Traits;
using OpenRA.Mods.RA.Traits; using OpenRA.Mods.RA.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities namespace OpenRA.Mods.RA.Activities
{ {

View File

@@ -77,6 +77,7 @@ namespace OpenRA.Mods.RA.Activities
}); });
} }
} }
return this; return this;
} }
} }

View File

@@ -69,6 +69,7 @@ namespace OpenRA.Mods.RA.Activities
var resType = resLayer.GetResource(loc); var resType = resLayer.GetResource(loc);
if (resType == null) return 1; if (resType == null) return 1;
// Can the harvester collect this kind of resource? // Can the harvester collect this kind of resource?
if (!harvInfo.Resources.Contains(resType.Info.Name)) return 1; if (!harvInfo.Resources.Contains(resType.Info.Name)) return 1;
@@ -81,8 +82,7 @@ namespace OpenRA.Mods.RA.Activities
return 0; return 0;
}) })
.FromPoint(self.Location) .FromPoint(self.Location));
);
if (path.Count == 0) if (path.Count == 0)
{ {

View File

@@ -18,7 +18,6 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities namespace OpenRA.Mods.RA.Activities
{ {
// assumes you have Minelayer on that unit // assumes you have Minelayer on that unit
class LayMines : Activity class LayMines : Activity
{ {
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
@@ -30,6 +29,7 @@ namespace OpenRA.Mods.RA.Activities
if (!limitedAmmo.HasAmmo()) if (!limitedAmmo.HasAmmo())
{ {
var info = self.Info.Traits.Get<MinelayerInfo>(); var info = self.Info.Traits.Get<MinelayerInfo>();
// rearm & repair at fix, then back out here to refill the minefield some more // rearm & repair at fix, then back out here to refill the minefield some more
var buildings = info.RearmBuildings; var buildings = info.RearmBuildings;
var rearmTarget = self.World.Actors.Where(a => self.Owner.Stances[a.Owner] == Stance.Ally var rearmTarget = self.World.Actors.Where(a => self.Owner.Stances[a.Owner] == Stance.Ally
@@ -56,16 +56,16 @@ namespace OpenRA.Mods.RA.Activities
if (ml.Minefield.Length > 0) if (ml.Minefield.Length > 0)
{ {
for (var n = 0; n < 20; n++) // dont get stuck forever here // dont get stuck forever here
for (var n = 0; n < 20; n++)
{ {
var p = ml.Minefield.Random(self.World.SharedRandom); var p = ml.Minefield.Random(self.World.SharedRandom);
if (ShouldLayMine(self, p)) if (ShouldLayMine(self, p))
return Util.SequenceActivities( movement.MoveTo(p, 0), this ); return Util.SequenceActivities(movement.MoveTo(p, 0), this);
} }
} }
// TODO: return somewhere likely to be safe (near fix) so we're not sitting out in the minefield. // TODO: return somewhere likely to be safe (near fix) so we're not sitting out in the minefield.
return new Wait(20); // nothing to do here return new Wait(20); // nothing to do here
} }

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA.Activities
mobile.IsMoving = false; mobile.IsMoving = false;
self.World.ActorMap.GetUnitsAt(mobile.toCell, mobile.toSubCell) self.World.ActorMap.GetUnitsAt(mobile.toCell, mobile.toSubCell)
.Except(new []{self}).Where(t => weapon.IsValidAgainst(t, self)) .Except(new[] { self }).Where(t => weapon.IsValidAgainst(t, self))
.Do(t => t.Kill(self)); .Do(t => t.Kill(self));
return NextActivity; return NextActivity;

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA
{ {
public class RAHarvesterDockSequence : Activity public class RAHarvesterDockSequence : Activity
{ {
enum State { Wait, Turn, Dock, Loop, Undock, Complete }; enum State { Wait, Turn, Dock, Loop, Undock, Complete }
readonly Actor proc; readonly Actor proc;
readonly int angle; readonly int angle;
@@ -82,10 +82,9 @@ namespace OpenRA.Mods.RA
base.Cancel(self); base.Cancel(self);
} }
public override IEnumerable<Target> GetTargets( Actor self ) public override IEnumerable<Target> GetTargets(Actor self)
{ {
yield return Target.FromActor(proc); yield return Target.FromActor(proc);
} }
} }
} }

View File

@@ -22,6 +22,7 @@ namespace OpenRA.Mods.RA.Activities
public class Teleport : Activity public class Teleport : Activity
{ {
const int maxCellSearchRange = Map.MaxTilesInCircleRange;
Actor teleporter; Actor teleporter;
CPos destination; CPos destination;
int? maximumDistance; int? maximumDistance;
@@ -29,8 +30,6 @@ namespace OpenRA.Mods.RA.Activities
bool screenFlash; bool screenFlash;
string sound; string sound;
const int maxCellSearchRange = Map.MaxTilesInCircleRange;
public Teleport(Actor teleporter, CPos destination, int? maximumDistance, bool killCargo, bool screenFlash, string sound) public Teleport(Actor teleporter, CPos destination, int? maximumDistance, bool killCargo, bool screenFlash, string sound)
{ {
if (maximumDistance > maxCellSearchRange) if (maximumDistance > maxCellSearchRange)
@@ -74,6 +73,7 @@ namespace OpenRA.Mods.RA.Activities
while (!cargo.IsEmpty(self)) while (!cargo.IsEmpty(self))
{ {
var a = cargo.Unload(self); var a = cargo.Unload(self);
// Kill all the units that are unloaded into the void // Kill all the units that are unloaded into the void
// Kill() handles kill and death statistics // Kill() handles kill and death statistics
a.Kill(teleporter); a.Kill(teleporter);

View File

@@ -74,6 +74,7 @@ namespace OpenRA.Mods.RA.Activities
foreach (var nbm in blocker.TraitsImplementing<INotifyBlockingMove>()) foreach (var nbm in blocker.TraitsImplementing<INotifyBlockingMove>())
nbm.OnNotifyBlockingMove(blocker, self); nbm.OnNotifyBlockingMove(blocker, self);
} }
return Util.SequenceActivities(new Wait(10), this); return Util.SequenceActivities(new Wait(10), this);
} }

View File

@@ -37,9 +37,9 @@ namespace OpenRA.Mods.RA.Traits
public readonly int FireDelay = 0; public readonly int FireDelay = 0;
[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")] [Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
public readonly WVec[] LocalOffset = {}; public readonly WVec[] LocalOffset = { };
[Desc("Muzzle yaw relative to turret or body.")] [Desc("Muzzle yaw relative to turret or body.")]
public readonly WAngle[] LocalYaw = {}; public readonly WAngle[] LocalYaw = { };
[Desc("Move the turret backwards when firing.")] [Desc("Move the turret backwards when firing.")]
public readonly WRange Recoil = WRange.Zero; public readonly WRange Recoil = WRange.Zero;
[Desc("Recoil recovery per-frame")] [Desc("Recoil recovery per-frame")]

View File

@@ -9,15 +9,14 @@
#endregion #endregion
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Traits; using System.Linq;
using OpenRA.Primitives;
using OpenRA.Mods.Common.Orders; using OpenRA.Mods.Common.Orders;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Traits; using OpenRA.Mods.RA.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -89,6 +88,7 @@ namespace OpenRA.Mods.RA
totalWeight = cargo.Sum(c => GetWeight(c)); totalWeight = cargo.Sum(c => GetWeight(c));
} }
facing = Exts.Lazy(self.TraitOrDefault<IFacing>); facing = Exts.Lazy(self.TraitOrDefault<IFacing>);
} }
@@ -329,6 +329,7 @@ namespace OpenRA.Mods.RA
foreach (var npe in self.TraitsImplementing<INotifyPassengerEntered>()) foreach (var npe in self.TraitsImplementing<INotifyPassengerEntered>())
npe.PassengerEntered(self, c); npe.PassengerEntered(self, c);
} }
initialized = true; initialized = true;
} }

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
[Desc("Amount of money awarded for capturing the actor.")] [Desc("Amount of money awarded for capturing the actor.")]
public readonly int CaptureAmount = 0; public readonly int CaptureAmount = 0;
public object Create (ActorInitializer init) { return new CashTrickler(this); } public object Create(ActorInitializer init) { return new CashTrickler(this); }
} }
class CashTrickler : ITick, ISync, INotifyCapture class CashTrickler : ITick, ISync, INotifyCapture

View File

@@ -59,6 +59,7 @@ namespace OpenRA.Mods.RA.Traits
wda.SpawnDeathAnimation(self, wda.Info.CrushedSequence, palette); wda.SpawnDeathAnimation(self, wda.Info.CrushedSequence, palette);
} }
self.Kill(crusher); self.Kill(crusher);
} }

View File

@@ -22,5 +22,5 @@ namespace OpenRA.Mods.RA
public readonly int Range = 5; public readonly int Range = 5;
} }
class DetectCloaked {} class DetectCloaked { }
} }

View File

@@ -16,8 +16,8 @@ namespace OpenRA.Mods.RA.Effects
{ {
class GpsSatellite : IEffect class GpsSatellite : IEffect
{ {
WPos pos;
readonly Animation anim; readonly Animation anim;
WPos pos;
public GpsSatellite(World world, WPos pos) public GpsSatellite(World world, WPos pos)
{ {
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Effects
anim.PlayRepeating("idle"); anim.PlayRepeating("idle");
} }
public void Tick( World world ) public void Tick(World world)
{ {
anim.Tick(); anim.Tick();
pos += new WVec(0, 0, 427); pos += new WVec(0, 0, 427);

View File

@@ -16,9 +16,9 @@ namespace OpenRA.Mods.RA.Effects
{ {
class SatelliteLaunch : IEffect class SatelliteLaunch : IEffect
{ {
int frame = 0;
readonly Animation doors; readonly Animation doors;
readonly WPos pos; readonly WPos pos;
int frame = 0;
public SatelliteLaunch(Actor a) public SatelliteLaunch(Actor a)
{ {
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Effects
pos = a.CenterPosition; pos = a.CenterPosition;
} }
public void Tick( World world ) public void Tick(World world)
{ {
doors.Tick(); doors.Tick();

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Effects
public readonly string Palette = "effect"; public readonly string Palette = "effect";
public readonly int BrightZaps = 1; public readonly int BrightZaps = 1;
public readonly int DimZaps = 2; public readonly int DimZaps = 2;
public IEffect Create(ProjectileArgs args) { return new TeslaZap( this, args ); } public IEffect Create(ProjectileArgs args) { return new TeslaZap(this, args); }
} }
class TeslaZap : IEffect class TeslaZap : IEffect
@@ -61,6 +61,7 @@ namespace OpenRA.Mods.RA.Effects
var pos = Args.GuidedTarget.IsValidFor(Args.SourceActor) ? Args.GuidedTarget.CenterPosition : Args.PassiveTarget; var pos = Args.GuidedTarget.IsValidFor(Args.SourceActor) ? Args.GuidedTarget.CenterPosition : Args.PassiveTarget;
zap = new TeslaZapRenderable(Args.Source, 0, pos - Args.Source, Info.Image, Info.BrightZaps, Info.DimZaps, Info.Palette); zap = new TeslaZapRenderable(Args.Source, 0, pos - Args.Source, Info.Image, Info.BrightZaps, Info.DimZaps, Info.Palette);
} }
yield return zap; yield return zap;
} }
} }

View File

@@ -48,7 +48,6 @@ namespace OpenRA.Mods.RA.Traits
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(), var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(),
new TypeDictionary { new OwnerInit(self.Owner), new LocationInit(self.Location) }); new TypeDictionary { new OwnerInit(self.Owner), new LocationInit(self.Location) });
if (info.AllowUnsuitableCell || IsSuitableCell(self, pilot)) if (info.AllowUnsuitableCell || IsSuitableCell(self, pilot))
{ {
if (cp.Z > 0) if (cp.Z > 0)

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Traits
var health = self.TraitOrDefault<Health>(); var health = self.TraitOrDefault<Health>();
var dudesValue = info.ValuePercent * cost; var dudesValue = info.ValuePercent * cost;
if (health != null) if (health != null)
dudesValue = dudesValue*health.HP / health.MaxHP; dudesValue = dudesValue * health.HP / health.MaxHP;
dudesValue /= 100; dudesValue /= 100;
var eligibleLocations = FootprintUtils.Tiles(self).ToList(); var eligibleLocations = FootprintUtils.Tiles(self).ToList();

View File

@@ -36,6 +36,7 @@ namespace OpenRA.Mods.RA.Traits
return (float)cap.CaptureProgressTime / (cap.Info.CaptureCompleteTime * 25); return (float)cap.CaptureProgressTime / (cap.Info.CaptureCompleteTime * 25);
} }
public Color GetColor() { return Color.Orange; } public Color GetColor() { return Color.Orange; }
} }
} }

View File

@@ -11,8 +11,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Effects;
using OpenRA.Primitives; using OpenRA.Primitives;
using OpenRA.Traits; using OpenRA.Traits;

View File

@@ -9,8 +9,8 @@
#endregion #endregion
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA
[Desc("Higher ranked units give higher bounties.")] [Desc("Higher ranked units give higher bounties.")]
public readonly int LevelMod = 125; public readonly int LevelMod = 125;
[Desc("Destroying creeps and enemies is rewarded.")] [Desc("Destroying creeps and enemies is rewarded.")]
public readonly Stance[] Stances = {Stance.Neutral, Stance.Enemy}; public readonly Stance[] Stances = { Stance.Neutral, Stance.Enemy };
} }
class GivesBounty : INotifyKilled class GivesBounty : INotifyKilled
@@ -49,6 +49,7 @@ namespace OpenRA.Mods.RA
if (!info.Stances.Contains(e.Attacker.Owner.Stances[self.Owner])) return; if (!info.Stances.Contains(e.Attacker.Owner.Stances[self.Owner])) return;
var cost = self.GetSellValue(); var cost = self.GetSellValue();
// 2 hundreds because of GetMultiplier and info.Percentage. // 2 hundreds because of GetMultiplier and info.Percentage.
var bounty = cost * GetMultiplier(self) * info.Percentage / 10000; var bounty = cost * GetMultiplier(self) * info.Percentage / 10000;

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
public class InvulnerabilityUpgrade : UpgradableTrait<InvulnerabilityUpgradeInfo>, IDamageModifier public class InvulnerabilityUpgrade : UpgradableTrait<InvulnerabilityUpgradeInfo>, IDamageModifier
{ {
public InvulnerabilityUpgrade(InvulnerabilityUpgradeInfo info) public InvulnerabilityUpgrade(InvulnerabilityUpgradeInfo info)
: base (info) { } : base(info) { }
public int GetDamageModifier(Actor attacker, DamageWarhead warhead) public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
{ {

View File

@@ -66,4 +66,3 @@ namespace OpenRA.Mods.RA
} }
} }
} }

View File

@@ -25,4 +25,3 @@ namespace OpenRA.Mods.RA
} }
} }
} }

View File

@@ -21,9 +21,8 @@ namespace OpenRA.Mods.RA
if (map.Bounds.Left == 0 || map.Bounds.Top == 0 if (map.Bounds.Left == 0 || map.Bounds.Top == 0
|| map.Bounds.Right == map.MapSize.X || map.Bounds.Bottom == map.MapSize.Y) || map.Bounds.Right == map.MapSize.X || map.Bounds.Bottom == map.MapSize.Y)
emitError("This map does not define a valid cordon.\n" emitError("This map does not define a valid cordon.\n"
+"A one cell (or greater) border is required on all four sides " + "A one cell (or greater) border is required on all four sides "
+"between the playable bounds and the map edges"); + "between the playable bounds and the map edges");
} }
} }
} }

View File

@@ -28,4 +28,3 @@ namespace OpenRA.Mods.RA
} }
} }
} }

View File

@@ -36,4 +36,3 @@ namespace OpenRA.Mods.RA
} }
} }
} }

View File

@@ -19,9 +19,7 @@ namespace OpenRA.Mods.RA
{ {
public void Run(Action<string> emitError, Action<string> emitWarning, Map map) public void Run(Action<string> emitError, Action<string> emitWarning, Map map)
{ {
var sequences = MiniYaml.MergeLiberal(map.SequenceDefinitions, var sequences = MiniYaml.MergeLiberal(map.SequenceDefinitions, Game.modData.Manifest.Sequences.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
Game.modData.Manifest.Sequences.Select(s => MiniYaml.FromFile(s))
.Aggregate(MiniYaml.MergeLiberal));
foreach (var actorInfo in map.Rules.Actors) foreach (var actorInfo in map.Rules.Actors)
foreach (var renderInfo in actorInfo.Value.Traits.WithInterface<RenderSimpleInfo>()) foreach (var renderInfo in actorInfo.Value.Traits.WithInterface<RenderSimpleInfo>())

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
if (traits.Length == 0) if (traits.Length == 0)
emitWarning("Actor {0} has no traits. Is this intended?".F(actorInfo.Key)); emitWarning("Actor {0} has no traits. Is this intended?".F(actorInfo.Key));
} }
catch(Exception e) catch (Exception e)
{ {
emitError("Actor {0} is not constructible; failure: {1}".F(actorInfo.Key, e.Message)); emitError("Actor {0} is not constructible; failure: {1}".F(actorInfo.Key, e.Message));
} }

View File

@@ -19,7 +19,6 @@ namespace OpenRA.Mods.RA.Orders
{ {
if (mi.Button != MouseButton.Left) if (mi.Button != MouseButton.Left)
world.CancelInputMode(); world.CancelInputMode();
else if (!world.ShroudObscures(xy)) else if (!world.ShroudObscures(xy))
{ {
world.CancelInputMode(); world.CancelInputMode();

View File

@@ -68,11 +68,11 @@ namespace OpenRA.Mods.RA.Orders
public class PowerDownOrderGenerator : GlobalButtonOrderGenerator<CanPowerDown> public class PowerDownOrderGenerator : GlobalButtonOrderGenerator<CanPowerDown>
{ {
public PowerDownOrderGenerator() : base( "powerdown", "PowerDown" ) { } public PowerDownOrderGenerator() : base("powerdown", "PowerDown") { }
} }
public class SellOrderGenerator : GlobalButtonOrderGenerator<Sellable> public class SellOrderGenerator : GlobalButtonOrderGenerator<Sellable>
{ {
public SellOrderGenerator() : base( "sell", "Sell" ) { } public SellOrderGenerator() : base("sell", "Sell") { }
} }
} }

View File

@@ -104,6 +104,7 @@ namespace OpenRA.Mods.RA.Orders
yield return r; yield return r;
var cells = new Dictionary<CPos, bool>(); var cells = new Dictionary<CPos, bool>();
// Linebuild for walls. // Linebuild for walls.
// Requires a 1x1 footprint // Requires a 1x1 footprint
if (rules.Actors[Building].Traits.Contains<LineBuildInfo>()) if (rules.Actors[Building].Traits.Contains<LineBuildInfo>())

View File

@@ -11,8 +11,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Traits;
using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.RA.Traits;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA
if (!inDropRange || cargo.IsEmpty(self)) if (!inDropRange || cargo.IsEmpty(self))
return; return;
if (droppedAt.Contains(self.Location) || checkForSuitableCell && !IsSuitableCell(cargo.Peek(self), self.Location)) if (droppedAt.Contains(self.Location) || (checkForSuitableCell && !IsSuitableCell(cargo.Peek(self), self.Location)))
return; return;
if (!self.World.Map.Contains(self.Location)) if (!self.World.Map.Contains(self.Location))

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
public EnterTransportTargeter(string order, int priority, public EnterTransportTargeter(string order, int priority,
Func<Actor, bool> canTarget, Func<Actor, bool> useEnterCursor, Func<Actor, bool> canTarget, Func<Actor, bool> useEnterCursor,
AlternateTransportsMode mode) AlternateTransportsMode mode)
: base (order, priority, canTarget, useEnterCursor) { this.mode = mode; } : base(order, priority, canTarget, useEnterCursor) { this.mode = mode; }
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{ {
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
public EnterTransportsTargeter(string order, int priority, public EnterTransportsTargeter(string order, int priority,
Func<Actor, bool> canTarget, Func<Actor, bool> useEnterCursor, Func<Actor, bool> canTarget, Func<Actor, bool> useEnterCursor,
AlternateTransportsMode mode) AlternateTransportsMode mode)
: base (order, priority, canTarget, useEnterCursor) { this.mode = mode; } : base(order, priority, canTarget, useEnterCursor) { this.mode = mode; }
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{ {
@@ -77,6 +77,7 @@ namespace OpenRA.Mods.RA
case AlternateTransportsMode.Always: case AlternateTransportsMode.Always:
break; break;
} }
return base.CanTargetActor(self, target, modifiers, ref cursor); return base.CanTargetActor(self, target, modifiers, ref cursor);
} }
} }

View File

@@ -76,4 +76,3 @@ namespace OpenRA.Mods.RA.Traits
} }
} }
} }

View File

@@ -68,4 +68,3 @@ namespace OpenRA.Mods.RA.Traits
} }
} }
} }

View File

@@ -40,7 +40,6 @@ namespace OpenRA.Mods.RA
if (queue == null) if (queue == null)
return; return;
var buildingInfo = unit.Traits.Get<BuildingInfo>(); var buildingInfo = unit.Traits.Get<BuildingInfo>();
if (order.OrderString == "LineBuild") if (order.OrderString == "LineBuild")

View File

@@ -37,6 +37,7 @@ namespace OpenRA.Mods.RA
return player.PlayerActor.Trait<PlayerResources>().Earned - earnedAtBeginningOfMinute; return player.PlayerActor.Trait<PlayerResources>().Earned - earnedAtBeginningOfMinute;
} }
} }
public Queue<int> EarnedSamples = new Queue<int>(100); public Queue<int> EarnedSamples = new Queue<int>(100);
int earnedAtBeginningOfMinute; int earnedAtBeginningOfMinute;
@@ -104,6 +105,7 @@ namespace OpenRA.Mods.RA
case "Pong": case "Pong":
return; return;
} }
if (order.OrderString.StartsWith("Dev")) if (order.OrderString.StartsWith("Dev"))
return; return;
OrderCount++; OrderCount++;
@@ -132,6 +134,7 @@ namespace OpenRA.Mods.RA
attackerStats.UnitsKilled++; attackerStats.UnitsKilled++;
defenderStats.UnitsDead++; defenderStats.UnitsDead++;
} }
if (self.HasTrait<Valued>()) if (self.HasTrait<Valued>())
{ {
var cost = self.Info.Traits.Get<ValuedInfo>().Cost; var cost = self.Info.Traits.Get<ValuedInfo>().Cost;

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA
[Desc("Actor can capture ProximityCapturable actors.")] [Desc("Actor can capture ProximityCapturable actors.")]
public class ProximityCaptorInfo : ITraitInfo public class ProximityCaptorInfo : ITraitInfo
{ {
public readonly string[] Types = {}; public readonly string[] Types = { };
public object Create(ActorInitializer init) { return new ProximityCaptor(this); } public object Create(ActorInitializer init) { return new ProximityCaptor(this); }
} }

View File

@@ -70,7 +70,8 @@ namespace OpenRA.Mods.RA
// no.. So find a new one // no.. So find a new one
var captor = GetInRange(self); var captor = GetInRange(self);
if (captor != null) // got one // got one
if (captor != null)
{ {
ChangeOwnership(self, captor); ChangeOwnership(self, captor);
return; return;

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.RA.Traits
public override void Tick(Actor self) public override void Tick(Actor self)
{ {
base.Tick(self); base.Tick(self);
if (isOpen && !self.World.ActorMap.GetUnitsAt(openExit).Any( a => a != self )) if (isOpen && !self.World.ActorMap.GetUnitsAt(openExit).Any(a => a != self))
{ {
isOpen = false; isOpen = false;
roof.PlayBackwardsThen(NormalizeSequence(self, "build-top"), roof.PlayBackwardsThen(NormalizeSequence(self, "build-top"),

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
class RenderHarvesterInfo : RenderUnitInfo, Requires<HarvesterInfo> class RenderHarvesterInfo : RenderUnitInfo, Requires<HarvesterInfo>
{ {
public readonly string[] ImagesByFullness = {"harv"}; public readonly string[] ImagesByFullness = { "harv" };
public override object Create(ActorInitializer init) { return new RenderHarvester(init.self, this); } public override object Create(ActorInitializer init) { return new RenderHarvester(init.self, this); }
} }

View File

@@ -11,8 +11,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Graphics; using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits namespace OpenRA.Mods.RA.Traits

View File

@@ -67,6 +67,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
buildComplete = false; buildComplete = false;
} }
public void Sold(Actor self) { } public void Sold(Actor self) { }
} }
} }

View File

@@ -87,6 +87,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
buildComplete = false; buildComplete = false;
} }
public void OnTransform(Actor self) { } public void OnTransform(Actor self) { }
public void AfterTransform(Actor self) { } public void AfterTransform(Actor self) { }

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA.Traits
if (!info.Recoils) if (!info.Recoils)
return t.Position(self); return t.Position(self);
var recoil = arms.Aggregate(WRange.Zero, (a,b) => a + b.Recoil); var recoil = arms.Aggregate(WRange.Zero, (a, b) => a + b.Recoil);
var localOffset = new WVec(-recoil, WRange.Zero, WRange.Zero); var localOffset = new WVec(-recoil, WRange.Zero, WRange.Zero);
var bodyOrientation = body.QuantizeOrientation(self, self.Orientation); var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);
var turretOrientation = body.QuantizeOrientation(self, t.LocalOrientation(self)); var turretOrientation = body.QuantizeOrientation(self, t.LocalOrientation(self));
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA.Traits
anim.ReplaceAnim(sequence); anim.ReplaceAnim(sequence);
} }
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

@@ -37,8 +37,7 @@ namespace OpenRA.Mods.RA.Traits
WRange.FromCells(self.Info.Traits.Get<DetectCloakedInfo>().Range), WRange.FromCells(self.Info.Traits.Get<DetectCloakedInfo>().Range),
0, 0,
Color.FromArgb(128, Color.LimeGreen), Color.FromArgb(128, Color.LimeGreen),
Color.FromArgb(96, Color.Black) Color.FromArgb(96, Color.Black));
);
} }
} }
} }

View File

@@ -88,4 +88,3 @@ namespace OpenRA.Mods.RA.Traits
} }
} }
} }

View File

@@ -42,8 +42,7 @@ namespace OpenRA.Mods.RA.Traits
range, range,
0, 0,
Color.FromArgb(128, Color.Yellow), Color.FromArgb(128, Color.Yellow),
Color.FromArgb(96, Color.Black) Color.FromArgb(96, Color.Black));
);
foreach (var a in w.ActorsWithTrait<RenderRangeCircle>()) foreach (var a in w.ActorsWithTrait<RenderRangeCircle>())
if (a.Actor.Owner == a.Actor.World.LocalPlayer) if (a.Actor.Owner == a.Actor.World.LocalPlayer)
@@ -76,8 +75,7 @@ namespace OpenRA.Mods.RA.Traits
attack.GetMaximumRange(), attack.GetMaximumRange(),
0, 0,
Color.FromArgb(128, Color.Yellow), Color.FromArgb(128, Color.Yellow),
Color.FromArgb(96, Color.Black) Color.FromArgb(96, Color.Black));
);
} }
} }
} }

View File

@@ -26,8 +26,7 @@ namespace OpenRA.Mods.RA.Traits
ai.Traits.Get<CreatesShroudInfo>().Range, ai.Traits.Get<CreatesShroudInfo>().Range,
0, 0,
Color.FromArgb(128, Color.Cyan), Color.FromArgb(128, Color.Cyan),
Color.FromArgb(96, Color.Black) Color.FromArgb(96, Color.Black));
);
foreach (var a in w.ActorsWithTrait<RenderShroudCircle>()) foreach (var a in w.ActorsWithTrait<RenderShroudCircle>())
if (a.Actor.Owner == a.Actor.World.LocalPlayer) if (a.Actor.Owner == a.Actor.World.LocalPlayer)
@@ -54,9 +53,7 @@ namespace OpenRA.Mods.RA.Traits
self.Info.Traits.Get<CreatesShroudInfo>().Range, self.Info.Traits.Get<CreatesShroudInfo>().Range,
0, 0,
Color.FromArgb(128, Color.Cyan), Color.FromArgb(128, Color.Cyan),
Color.FromArgb(96, Color.Black) Color.FromArgb(96, Color.Black));
);
} }
} }
} }

View File

@@ -44,23 +44,23 @@ namespace OpenRA.Mods.RA.Traits
target => CanRepairAt(target), _ => CanRepair()); } target => CanRepairAt(target), _ => CanRepair()); }
} }
public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued ) public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
{ {
if( order.OrderID == "Repair" ) if (order.OrderID == "Repair")
return new Order(order.OrderID, self, queued) { TargetActor = target.Actor }; return new Order(order.OrderID, self, queued) { TargetActor = target.Actor };
return null; return null;
} }
bool CanRepairAt( Actor target ) bool CanRepairAt(Actor target)
{ {
return self.Info.Traits.Get<RepairableInfo>().RepairBuildings.Contains( target.Info.Name ); return self.Info.Traits.Get<RepairableInfo>().RepairBuildings.Contains(target.Info.Name);
} }
bool CanRepair() bool CanRepair()
{ {
var li = self.TraitOrDefault<LimitedAmmo>(); var li = self.TraitOrDefault<LimitedAmmo>();
return (Health.DamageState > DamageState.Undamaged || (li != null && !li.FullAmmo()) ); return Health.DamageState > DamageState.Undamaged || (li != null && !li.FullAmmo());
} }
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Traits
[ActorReference] public readonly string[] Buildings = { "spen", "syrd" }; [ActorReference] public readonly string[] Buildings = { "spen", "syrd" };
public readonly int CloseEnough = 4; /* cells */ public readonly int CloseEnough = 4; /* cells */
public object Create( ActorInitializer init ) { return new RepairableNear( init.self, this ); } public object Create(ActorInitializer init) { return new RepairableNear(init.self, this); }
} }
class RepairableNear : IIssueOrder, IResolveOrder class RepairableNear : IIssueOrder, IResolveOrder
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Traits
readonly Actor self; readonly Actor self;
readonly RepairableNearInfo info; readonly RepairableNearInfo info;
public RepairableNear( Actor self, RepairableNearInfo info ) { this.self = self; this.info = info; } public RepairableNear(Actor self, RepairableNearInfo info) { this.self = self; this.info = info; }
public IEnumerable<IOrderTargeter> Orders public IEnumerable<IOrderTargeter> Orders
{ {
@@ -42,17 +42,17 @@ namespace OpenRA.Mods.RA.Traits
} }
} }
public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued ) public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
{ {
if( order.OrderID == "RepairNear" ) if (order.OrderID == "RepairNear")
return new Order(order.OrderID, self, queued) { TargetActor = target.Actor }; return new Order(order.OrderID, self, queued) { TargetActor = target.Actor };
return null; return null;
} }
bool CanRepairAt( Actor target ) bool CanRepairAt(Actor target)
{ {
return info.Buildings.Contains( target.Info.Name ); return info.Buildings.Contains(target.Info.Name);
} }
bool ShouldRepair() bool ShouldRepair()
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA.Traits
var target = Target.FromOrder(self.World, order); var target = Target.FromOrder(self.World, order);
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(movement.MoveWithinRange(target, new WRange(1024*info.CloseEnough))); self.QueueActivity(movement.MoveWithinRange(target, new WRange(1024 * info.CloseEnough)));
self.QueueActivity(new Repair(order.TargetActor)); self.QueueActivity(new Repair(order.TargetActor));
self.SetTargetLine(target, Color.Green, false); self.SetTargetLine(target, Color.Green, false);

View File

@@ -8,10 +8,10 @@
*/ */
#endregion #endregion
using Eluant;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Eluant;
using OpenRA; using OpenRA;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Effects; using OpenRA.Effects;

View File

@@ -8,9 +8,9 @@
*/ */
#endregion #endregion
using Eluant;
using System; using System;
using System.Linq; using System.Linq;
using Eluant;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;

View File

@@ -8,8 +8,8 @@
*/ */
#endregion #endregion
using OpenRA.Scripting;
using OpenRA.Mods.RA.Traits; using OpenRA.Mods.RA.Traits;
using OpenRA.Scripting;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA.Scripting namespace OpenRA.Mods.RA.Scripting

View File

@@ -11,8 +11,8 @@
using System; using System;
using System.Linq; using System.Linq;
using Eluant; using Eluant;
using OpenRA.Scripting;
using OpenRA.Mods.RA.Traits; using OpenRA.Mods.RA.Traits;
using OpenRA.Scripting;
namespace OpenRA.Mods.RA.Scripting namespace OpenRA.Mods.RA.Scripting
{ {

View File

@@ -8,10 +8,10 @@
*/ */
#endregion #endregion
using Eluant;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Eluant;
using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Scripting; using OpenRA.Mods.Common.Scripting;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA
[Sync] int damageTicks; [Sync] int damageTicks;
public SelfHealing(Actor self, SelfHealingInfo info) public SelfHealing(Actor self, SelfHealingInfo info)
: base (info) : base(info)
{ {
health = self.Trait<Health>(); health = self.Trait<Health>();
} }

View File

@@ -15,7 +15,6 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits namespace OpenRA.Mods.RA.Traits
{ {
[Desc("Actor can be sold")] [Desc("Actor can be sold")]
public class SellableInfo : UpgradableTraitInfo, ITraitInfo public class SellableInfo : UpgradableTraitInfo, ITraitInfo
{ {

View File

@@ -164,8 +164,7 @@ namespace OpenRA.Mods.RA.Traits
Info.BeaconPalettePrefix, Info.BeaconPalettePrefix,
Info.BeaconPoster, Info.BeaconPoster,
Info.BeaconPosterPalette, Info.BeaconPosterPalette,
() => 1 - ((distanceTestActor.CenterPosition - target).HorizontalLength - info.BeaconDistanceOffset.Range) * 1f / distance () => 1 - ((distanceTestActor.CenterPosition - target).HorizontalLength - info.BeaconDistanceOffset.Range) * 1f / distance);
);
w.Add(beacon); w.Add(beacon);
} }

View File

@@ -110,9 +110,7 @@ namespace OpenRA.Mods.RA.Traits
Info.BeaconPalettePrefix, Info.BeaconPalettePrefix,
Info.BeaconPoster, Info.BeaconPoster,
Info.BeaconPosterPalette, Info.BeaconPosterPalette,
() => missile.FractionComplete () => missile.FractionComplete);
);
Action removeBeacon = () => self.World.AddFrameEndTask(w => Action removeBeacon = () => self.World.AddFrameEndTask(w =>
{ {

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Traits
[ActorReference] [ActorReference]
[Desc("Troops to be delivered. They will be distributed between the planes if SquadSize > 1.")] [Desc("Troops to be delivered. They will be distributed between the planes if SquadSize > 1.")]
public string[] DropItems = { }; public readonly string[] DropItems = { };
[Desc("Risks stuck units when they don't have the Paratrooper trait.")] [Desc("Risks stuck units when they don't have the Paratrooper trait.")]
public readonly bool AllowImpassableCells = false; public readonly bool AllowImpassableCells = false;
@@ -184,8 +184,7 @@ namespace OpenRA.Mods.RA.Traits
Info.BeaconPalettePrefix, Info.BeaconPalettePrefix,
Info.BeaconPoster, Info.BeaconPoster,
Info.BeaconPosterPalette, Info.BeaconPosterPalette,
() => 1 - ((distanceTestActor.CenterPosition - target).HorizontalLength - info.BeaconDistanceOffset.Range) * 1f / distance () => 1 - ((distanceTestActor.CenterPosition - target).HorizontalLength - info.BeaconDistanceOffset.Range) * 1f / distance);
);
w.Add(beacon); w.Add(beacon);
} }

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Traits
public readonly string LongDesc = ""; public readonly string LongDesc = "";
public readonly bool AllowMultiple = false; public readonly bool AllowMultiple = false;
public readonly bool OneShot = false; public readonly bool OneShot = false;
public readonly string[] Prerequisites = {}; public readonly string[] Prerequisites = { };
public readonly string BeginChargeSound = null; public readonly string BeginChargeSound = null;
public readonly string EndChargeSound = null; public readonly string EndChargeSound = null;

View File

@@ -189,7 +189,8 @@ namespace OpenRA.Mods.RA.Traits
if (Manager.DevMode.FastCharge && RemainingTime > 25) if (Manager.DevMode.FastCharge && RemainingTime > 25)
RemainingTime = 25; RemainingTime = 25;
if (RemainingTime > 0) --RemainingTime; if (RemainingTime > 0)
--RemainingTime;
if (!notifiedCharging) if (!notifiedCharging)
{ {
power.Charging(power.self, Key); power.Charging(power.self, Key);

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Traits
bool isProne { get { return remainingProneTime > 0; } } bool isProne { get { return remainingProneTime > 0; } }
public bool IsModifyingSequence { get { return isProne; } } public bool IsModifyingSequence { get { return isProne; } }
public string SequencePrefix { get { return info.ProneSequencePrefix ; } } public string SequencePrefix { get { return info.ProneSequencePrefix; } }
public TakeCover(ActorInitializer init, TakeCoverInfo info) public TakeCover(ActorInitializer init, TakeCoverInfo info)
: base(init, info) : base(init, info)
@@ -46,7 +46,8 @@ namespace OpenRA.Mods.RA.Traits
public void Damaged(Actor self, AttackInfo e) public void Damaged(Actor self, AttackInfo e)
{ {
if (e.Damage > 0 && (e.Warhead == null || !e.Warhead.PreventProne)) /* Don't go prone when healed */ /* Don't go prone when healed */
if (e.Damage > 0 && (e.Warhead == null || !e.Warhead.PreventProne))
{ {
if (!isProne) if (!isProne)
localOffset = info.ProneOffset; localOffset = info.ProneOffset;

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Traits
var body = self.Trait<IBodyOrientation>(); var body = self.Trait<IBodyOrientation>();
// TODO: Carry orientation over from the parent instead of just facing // TODO: Carry orientation over from the parent instead of just facing
var bodyFacing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : 0; var bodyFacing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : 0;
facing = Turreted.GetInitialTurretFacing(init, 0); facing = Turreted.GetInitialTurretFacing(init, 0);
// Calculate final position // Calculate final position

View File

@@ -13,7 +13,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits namespace OpenRA.Mods.RA.Traits
{ {
[Desc("Tag trait for SupplyTruck: actors.")] [Desc("Tag trait for SupplyTruck: actors.")]
class AcceptsSuppliesInfo : TraitInfo<AcceptsSupplies> {} class AcceptsSuppliesInfo : TraitInfo<AcceptsSupplies> { }
class AcceptsSupplies {} class AcceptsSupplies { }
} }

View File

@@ -176,6 +176,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
SetPosition(self, self.World.Map.CenterOfCell(cell) + new WVec(0, 0, CenterPosition.Z)); SetPosition(self, self.World.Map.CenterOfCell(cell) + new WVec(0, 0, CenterPosition.Z));
} }
public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, pos); } public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, pos); }
public void AddedToWorld(Actor self) public void AddedToWorld(Actor self)

View File

@@ -70,6 +70,7 @@ namespace OpenRA.Mods.RA.Traits
return WVec.Zero; return WVec.Zero;
var dot = WVec.Dot(currentDir, repulsionForce) / length; var dot = WVec.Dot(currentDir, repulsionForce) / length;
// avoid stalling the plane // avoid stalling the plane
return dot >= 0 ? repulsionForce : WVec.Zero; return dot >= 0 ? repulsionForce : WVec.Zero;
} }

View File

@@ -114,10 +114,11 @@ namespace OpenRA.Mods.RA.Traits
{ {
if (!preventDock) if (!preventDock)
{ {
harv.QueueActivity(new CallFunc( () => dockedHarv = harv, false)); harv.QueueActivity(new CallFunc(() => dockedHarv = harv, false));
harv.QueueActivity(DockSequence(harv, self)); harv.QueueActivity(DockSequence(harv, self));
harv.QueueActivity(new CallFunc( () => dockedHarv = null, false)); harv.QueueActivity(new CallFunc(() => dockedHarv = null, false));
} }
harv.QueueActivity(new CallFunc(() => harv.Trait<Harvester>().ContinueHarvesting(harv))); harv.QueueActivity(new CallFunc(() => harv.Trait<Harvester>().ContinueHarvesting(harv)));
} }

View File

@@ -8,10 +8,10 @@
*/ */
#endregion #endregion
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Traits; using System.Linq;
using OpenRA.Mods.Common.Orders; using OpenRA.Mods.Common.Orders;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits namespace OpenRA.Mods.RA.Traits
{ {

View File

@@ -12,8 +12,8 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Effects;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits namespace OpenRA.Mods.RA.Traits
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Traits
public bool RepairActive = false; public bool RepairActive = false;
public RepairableBuilding(Actor self, RepairableBuildingInfo info) public RepairableBuilding(Actor self, RepairableBuildingInfo info)
: base (info) : base(info)
{ {
Health = self.Trait<Health>(); Health = self.Trait<Health>();
} }

View File

@@ -38,11 +38,10 @@ namespace OpenRA.Mods.RA.Traits
// NOTE: we really dont care about the GC eating DisposableActions that apply to a world *other* than // NOTE: we really dont care about the GC eating DisposableActions that apply to a world *other* than
// the one we're playing in. // the one we're playing in.
return new DisposableAction( return new DisposableAction(
() => { reservedFor = null; reservedForAircraft = null; }, () => { reservedFor = null; reservedForAircraft = null; },
() => Game.RunAfterTick( () => Game.RunAfterTick(
() => { if (Game.IsCurrentWorld( self.World )) throw new InvalidOperationException( () => { if (Game.IsCurrentWorld(self.World)) throw new InvalidOperationException(
"Attempted to finalize an undisposed DisposableAction. {0} ({1}) reserved {2} ({3})" "Attempted to finalize an undisposed DisposableAction. {0} ({1}) reserved {2} ({3})"
.F(forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID)); })); .F(forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID)); }));
} }

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Traits
CPos? lastPos; CPos? lastPos;
public Cloak(Actor self, CloakInfo info) public Cloak(Actor self, CloakInfo info)
: base (info) : base(info)
{ {
this.self = self; this.self = self;

View File

@@ -8,8 +8,8 @@
*/ */
#endregion #endregion
using System.Drawing;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Orders; using OpenRA.Mods.Common.Orders;
@@ -68,7 +68,6 @@ namespace OpenRA.Mods.RA.Traits
self.QueueActivity(new MoveAdjacentTo(self, target)); self.QueueActivity(new MoveAdjacentTo(self, target));
self.QueueActivity(new CallFunc(() => Explode(self))); self.QueueActivity(new CallFunc(() => Explode(self)));
} }
else if (order.OrderString == "Detonate") else if (order.OrderString == "Detonate")
Explode(self); Explode(self);
} }

View File

@@ -13,8 +13,8 @@ using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Orders; using OpenRA.Mods.Common.Orders;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Traits; using OpenRA.Traits;
@@ -47,6 +47,7 @@ namespace OpenRA.Mods.RA.Traits
IExplodeModifier, IOrderVoice, ISpeedModifier, ISync, IExplodeModifier, IOrderVoice, ISpeedModifier, ISync,
INotifyResourceClaimLost, INotifyIdle, INotifyBlockingMove INotifyResourceClaimLost, INotifyIdle, INotifyBlockingMove
{ {
readonly HarvesterInfo Info;
Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>(); Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>();
[Sync] public Actor OwnerLinkedProc = null; [Sync] public Actor OwnerLinkedProc = null;
@@ -56,7 +57,6 @@ namespace OpenRA.Mods.RA.Traits
public CPos? LastHarvestedCell = null; public CPos? LastHarvestedCell = null;
public CPos? LastOrderLocation = null; public CPos? LastOrderLocation = null;
[Sync] public int ContentValue { get { return contents.Sum(c => c.Key.ValuePerUnit * c.Value); } } [Sync] public int ContentValue { get { return contents.Sum(c => c.Key.ValuePerUnit * c.Value); } }
readonly HarvesterInfo Info;
bool idleSmart = true; bool idleSmart = true;
public Harvester(Actor self, HarvesterInfo info) public Harvester(Actor self, HarvesterInfo info)
@@ -118,8 +118,7 @@ namespace OpenRA.Mods.RA.Traits
from r in self.World.ActorsWithTrait<IAcceptOre>() from r in self.World.ActorsWithTrait<IAcceptOre>()
where r.Actor != ignore && r.Actor.Owner == self.Owner && IsAcceptableProcType(r.Actor) where r.Actor != ignore && r.Actor.Owner == self.Owner && IsAcceptableProcType(r.Actor)
let linkedHarvs = self.World.ActorsWithTrait<Harvester>().Where(a => a.Trait.LinkedProc == r.Actor).Count() let linkedHarvs = self.World.ActorsWithTrait<Harvester>().Where(a => a.Trait.LinkedProc == r.Actor).Count()
select new { Location = r.Actor.Location + r.Trait.DeliverOffset, Actor = r.Actor, Occupancy = linkedHarvs } select new { Location = r.Actor.Location + r.Trait.DeliverOffset, Actor = r.Actor, Occupancy = linkedHarvs }).ToDictionary(r => r.Location);
).ToDictionary(r => r.Location);
// Start a search from each refinery's delivery location: // Start a search from each refinery's delivery location:
var mi = self.Info.Traits.Get<MobileInfo>(); var mi = self.Info.Traits.Get<MobileInfo>();
@@ -130,13 +129,13 @@ namespace OpenRA.Mods.RA.Traits
if (!refs.ContainsKey(loc)) return 0; if (!refs.ContainsKey(loc)) return 0;
var occupancy = refs[loc].Occupancy; var occupancy = refs[loc].Occupancy;
// 4 harvesters clogs up the refinery's delivery location: // 4 harvesters clogs up the refinery's delivery location:
if (occupancy >= 3) return int.MaxValue; if (occupancy >= 3) return int.MaxValue;
// Prefer refineries with less occupancy (multiplier is to offset distance cost): // Prefer refineries with less occupancy (multiplier is to offset distance cost):
return occupancy * 12; return occupancy * 12;
}) }));
);
// Reverse the found-path to find the refinery location instead of our location: // Reverse the found-path to find the refinery location instead of our location:
path.Reverse(); path.Reverse();
@@ -192,6 +191,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
// I'm blocking someone else from moving to my location: // I'm blocking someone else from moving to my location:
var act = self.GetCurrentActivity(); var act = self.GetCurrentActivity();
// If I'm just waiting around then get out of the way: // If I'm just waiting around then get out of the way:
if (act is Wait) if (act is Wait)
{ {
@@ -319,6 +319,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
// A bot order gives us a CPos.Zero TargetLocation, so find some good resources for him: // A bot order gives us a CPos.Zero TargetLocation, so find some good resources for him:
var loc = FindNextResourceForBot(self); var loc = FindNextResourceForBot(self);
// No more resources? Oh well. // No more resources? Oh well.
if (!loc.HasValue) if (!loc.HasValue)
return; return;
@@ -386,6 +387,7 @@ namespace OpenRA.Mods.RA.Traits
var resType = resLayer.GetResource(loc); var resType = resLayer.GetResource(loc);
if (resType == null) return 1; if (resType == null) return 1;
// Can the harvester collect this kind of resource? // Can the harvester collect this kind of resource?
if (!harvInfo.Resources.Contains(resType.Info.Name)) return 1; if (!harvInfo.Resources.Contains(resType.Info.Name)) return 1;
@@ -398,8 +400,7 @@ namespace OpenRA.Mods.RA.Traits
return 0; return 0;
}) })
.FromPoint(self.Location) .FromPoint(self.Location));
);
if (path.Count == 0) if (path.Count == 0)
return (CPos?)null; return (CPos?)null;
@@ -459,6 +460,7 @@ namespace OpenRA.Mods.RA.Traits
return false; return false;
var location = self.World.Map.CellContaining(target.CenterPosition); var location = self.World.Map.CellContaining(target.CenterPosition);
// Don't leak info about resources under the shroud // Don't leak info about resources under the shroud
if (!self.Owner.Shroud.IsExplored(location)) if (!self.Owner.Shroud.IsExplored(location))
return false; return false;

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Traits
public readonly string FullHuskActor = null; public readonly string FullHuskActor = null;
public readonly int FullnessThreshold = 50; public readonly int FullnessThreshold = 50;
public object Create( ActorInitializer init ) { return new HarvesterHuskModifier(this); } public object Create(ActorInitializer init) { return new HarvesterHuskModifier(this); }
} }
public class HarvesterHuskModifier : IHuskModifier public class HarvesterHuskModifier : IHuskModifier

View File

@@ -8,9 +8,9 @@
*/ */
#endregion #endregion
using System.Linq;
using System.Drawing;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Activities; using OpenRA.Activities;
using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Orders; using OpenRA.Mods.Common.Orders;
@@ -72,9 +72,11 @@ namespace OpenRA.Mods.RA.Traits
if (info.ThumpDamageWeapon != null) if (info.ThumpDamageWeapon != null)
{ {
var weapon = self.World.Map.Rules.Weapons[info.ThumpDamageWeapon.ToLowerInvariant()]; var weapon = self.World.Map.Rules.Weapons[info.ThumpDamageWeapon.ToLowerInvariant()];
// Use .FromPos since this weapon needs to affect more than just the MadTank actor // Use .FromPos since this weapon needs to affect more than just the MadTank actor
weapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>()); weapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>());
} }
screenShaker.AddEffect(info.ThumpShakeTime, self.CenterPosition, info.ThumpShakeIntensity, info.ThumpShakeMultiplier); screenShaker.AddEffect(info.ThumpShakeTime, self.CenterPosition, info.ThumpShakeIntensity, info.ThumpShakeMultiplier);
tick = 0; tick = 0;
} }
@@ -112,9 +114,11 @@ namespace OpenRA.Mods.RA.Traits
if (info.DetonationWeapon != null) if (info.DetonationWeapon != null)
{ {
var weapon = self.World.Map.Rules.Weapons[info.DetonationWeapon.ToLowerInvariant()]; var weapon = self.World.Map.Rules.Weapons[info.DetonationWeapon.ToLowerInvariant()];
// Use .FromPos since this actor is killed. Cannot use Target.FromActor // Use .FromPos since this actor is killed. Cannot use Target.FromActor
weapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>()); weapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>());
} }
self.Kill(self); self.Kill(self);
}); });
} }
@@ -164,7 +168,6 @@ namespace OpenRA.Mods.RA.Traits
self.QueueActivity(new MoveAdjacentTo(self, target)); self.QueueActivity(new MoveAdjacentTo(self, target));
self.QueueActivity(new CallFunc(StartDetonationSequence)); self.QueueActivity(new CallFunc(StartDetonationSequence));
} }
else if (order.OrderString == "Detonate") else if (order.OrderString == "Detonate")
{ {
self.CancelActivity(); self.CancelActivity();

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Traits
this.info = info; this.info = info;
} }
public void WarnCrush(Actor crusher) {} public void WarnCrush(Actor crusher) { }
public void OnCrush(Actor crusher) public void OnCrush(Actor crusher)
{ {

View File

@@ -9,8 +9,8 @@
#endregion #endregion
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Orders; using OpenRA.Mods.Common.Orders;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Traits
TransientActors, TransientActors,
BlockedByMovers, BlockedByMovers,
All = TransientActors | BlockedByMovers All = TransientActors | BlockedByMovers
}; }
[Desc("Unit is able to move.")] [Desc("Unit is able to move.")]
public class MobileInfo : ITraitInfo, IOccupySpaceInfo, IFacingInfo, IMoveInfo, UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit> public class MobileInfo : ITraitInfo, IOccupySpaceInfo, IFacingInfo, IMoveInfo, UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit>
@@ -159,7 +159,7 @@ namespace OpenRA.Mods.RA.Traits
if (otherMobile == null) return false; if (otherMobile == null) return false;
// Sign of dot-product indicates (roughly) if vectors are facing in same or opposite directions: // Sign of dot-product indicates (roughly) if vectors are facing in same or opposite directions:
var dp = CVec.Dot((selfMobile.toCell - self.Location), (otherMobile.toCell - other.Location)); var dp = CVec.Dot(selfMobile.toCell - self.Location, otherMobile.toCell - other.Location);
if (dp <= 0) return false; if (dp <= 0) return false;
return true; return true;
@@ -177,7 +177,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
var canIgnoreMovingAllies = self != null && !check.HasFlag(CellConditions.BlockedByMovers); var canIgnoreMovingAllies = self != null && !check.HasFlag(CellConditions.BlockedByMovers);
var needsCellExclusively = self == null || Crushes == null || !Crushes.Any(); var needsCellExclusively = self == null || Crushes == null || !Crushes.Any();
foreach(var a in world.ActorMap.GetUnitsAt(cell)) foreach (var a in world.ActorMap.GetUnitsAt(cell))
{ {
if (a == ignoreActor) if (a == ignoreActor)
continue; continue;
@@ -239,7 +239,7 @@ namespace OpenRA.Mods.RA.Traits
} }
if (!SharesCell) if (!SharesCell)
return world.ActorMap.AnyUnitsAt(cell, SubCell.FullCell)? SubCell.Invalid : SubCell.FullCell; return world.ActorMap.AnyUnitsAt(cell, SubCell.FullCell) ? SubCell.Invalid : SubCell.FullCell;
return world.ActorMap.FreeSubCell(cell, preferredSubCell); return world.ActorMap.FreeSubCell(cell, preferredSubCell);
} }
@@ -257,8 +257,6 @@ namespace OpenRA.Mods.RA.Traits
CPos __fromCell, __toCell; CPos __fromCell, __toCell;
public SubCell fromSubCell, toSubCell; public SubCell fromSubCell, toSubCell;
//int __altitude;
[Sync] public int Facing [Sync] public int Facing
{ {
get { return __facing; } get { return __facing; }
@@ -333,6 +331,7 @@ namespace OpenRA.Mods.RA.Traits
if (preferred != SubCell.FullCell) if (preferred != SubCell.FullCell)
return SubCell.FullCell; return SubCell.FullCell;
} }
return preferred; return preferred;
} }
@@ -388,6 +387,7 @@ namespace OpenRA.Mods.RA.Traits
return new Order("Move", self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) }; return new Order("Move", self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) };
} }
return null; return null;
} }
@@ -504,7 +504,7 @@ namespace OpenRA.Mods.RA.Traits
public SubCell GetAvailableSubCell(CPos a, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, bool checkTransientActors = true) public SubCell GetAvailableSubCell(CPos a, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, bool checkTransientActors = true)
{ {
return Info.GetAvailableSubCell(self.World, self, a, preferredSubCell, ignoreActor, checkTransientActors? CellConditions.All : CellConditions.None); return Info.GetAvailableSubCell(self.World, self, a, preferredSubCell, ignoreActor, checkTransientActors ? CellConditions.All : CellConditions.None);
} }
public bool CanEnterCell(CPos cell, Actor ignoreActor = null, bool checkTransientActors = true) public bool CanEnterCell(CPos cell, Actor ignoreActor = null, bool checkTransientActors = true)

View File

@@ -8,8 +8,8 @@
*/ */
#endregion #endregion
using System.Drawing;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Graphics; using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Orders; using OpenRA.Mods.Common.Orders;
@@ -130,6 +130,7 @@ namespace OpenRA.Mods.RA.Traits
cursor = "chrono-target"; cursor = "chrono-target";
return true; return true;
} }
return false; return false;
} }
@@ -186,8 +187,7 @@ namespace OpenRA.Mods.RA.Traits
WRange.FromCells(self.Trait<PortableChrono>().Info.MaxDistance), WRange.FromCells(self.Trait<PortableChrono>().Info.MaxDistance),
0, 0,
Color.FromArgb(128, Color.LawnGreen), Color.FromArgb(128, Color.LawnGreen),
Color.FromArgb(96, Color.Black) Color.FromArgb(96, Color.Black));
);
} }
public string GetCursor(World world, CPos xy, MouseInput mi) public string GetCursor(World world, CPos xy, MouseInput mi)

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Traits
public readonly int Duration = 30; public readonly int Duration = 30;
public readonly bool KillCargo = true; public readonly bool KillCargo = true;
public override object Create(ActorInitializer init) { return new ChronoshiftPower(init.self,this); } public override object Create(ActorInitializer init) { return new ChronoshiftPower(init.self, this); }
} }
class ChronoshiftPower : SupportPower class ChronoshiftPower : SupportPower
@@ -255,19 +255,21 @@ namespace OpenRA.Mods.RA.Traits
foreach (var unit in power.UnitsInRange(sourceLocation)) foreach (var unit in power.UnitsInRange(sourceLocation))
{ {
var targetCell = unit.Location + (xy - sourceLocation); var targetCell = unit.Location + (xy - sourceLocation);
if (manager.self.Owner.Shroud.IsExplored(targetCell) && unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell)) if (manager.self.Owner.Shroud.IsExplored(targetCell) && unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit, targetCell))
{ {
canTeleport = true; canTeleport = true;
break; break;
} }
} }
if (!canTeleport) if (!canTeleport)
{ {
// Check the terrain types. This will allow chronoshifts to occur on empty terrain to terrain of // Check the terrain types. This will allow chronoshifts to occur on empty terrain to terrain of
// a similar type. This also keeps the cursor from changing in non-visible property, alerting the // a similar type. This also keeps the cursor from changing in non-visible property, alerting the
// chronoshifter of enemy unit presence // chronoshifter of enemy unit presence
canTeleport = power.SimilarTerrain(sourceLocation,xy); canTeleport = power.SimilarTerrain(sourceLocation, xy);
} }
return canTeleport; return canTeleport;
} }

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Traits
[Desc("Required for GpsPower. Attach this to the player actor.")] [Desc("Required for GpsPower. Attach this to the player actor.")]
class GpsWatcherInfo : ITraitInfo class GpsWatcherInfo : ITraitInfo
{ {
public object Create (ActorInitializer init) { return new GpsWatcher(init.self.Owner); } public object Create(ActorInitializer init) { return new GpsWatcher(init.self.Owner); }
} }
class GpsWatcher : ISync, IFogVisibilityModifier class GpsWatcher : ISync, IFogVisibilityModifier
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA.Traits
void RefreshGranted() void RefreshGranted()
{ {
Granted = (actors.Count > 0 && Launched); Granted = actors.Count > 0 && Launched;
GrantedAllies = owner.World.ActorsWithTrait<GpsWatcher>().Any(p => p.Actor.Owner.IsAlliedWith(owner) && p.Trait.Granted); GrantedAllies = owner.World.ActorsWithTrait<GpsWatcher>().Any(p => p.Actor.Owner.IsAlliedWith(owner) && p.Trait.Granted);
if (Granted || GrantedAllies) if (Granted || GrantedAllies)
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.RA.Traits
public void Killed(Actor self, AttackInfo e) { RemoveGps(self); } public void Killed(Actor self, AttackInfo e) { RemoveGps(self); }
public void Selling(Actor self) {} public void Selling(Actor self) { }
public void Sold(Actor self) { RemoveGps(self); } public void Sold(Actor self) { RemoveGps(self); }
void RemoveGps(Actor self) void RemoveGps(Actor self)

View File

@@ -14,7 +14,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
public class TargetableSubmarineInfo : TargetableUnitInfo, Requires<CloakInfo> public class TargetableSubmarineInfo : TargetableUnitInfo, Requires<CloakInfo>
{ {
public readonly string[] CloakedTargetTypes = {}; public readonly string[] CloakedTargetTypes = { };
public override object Create(ActorInitializer init) { return new TargetableSubmarine(init.self, this); } public override object Create(ActorInitializer init) { return new TargetableSubmarine(init.self, this); }
} }
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Traits
public override string[] TargetTypes public override string[] TargetTypes
{ {
get { return cloak.Cloaked ? info.CloakedTargetTypes get { return cloak.Cloaked ? info.CloakedTargetTypes
: info.TargetTypes;} : info.TargetTypes; }
} }
} }
} }

View File

@@ -13,14 +13,14 @@ using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
using OpenRA.Support; using OpenRA.Support;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits namespace OpenRA.Mods.RA.Traits
{ {
[Desc("Identify untraversable regions of the map for faster pathfinding, especially with AI.", [Desc("Identify untraversable regions of the map for faster pathfinding, especially with AI.",
"This trait is required. Every mod needs it attached to the world actor.")] "This trait is required. Every mod needs it attached to the world actor.")]
class DomainIndexInfo : TraitInfo<DomainIndex> {} class DomainIndexInfo : TraitInfo<DomainIndex> { }
public class DomainIndex : IWorldLoaded public class DomainIndex : IWorldLoaded
{ {

View File

@@ -27,7 +27,8 @@ namespace OpenRA.Mods.RA.Traits
public class PathFinder public class PathFinder
{ {
readonly static List<CPos> emptyPath = new List<CPos>(0); const int MaxPathAge = 50; /* x 40ms ticks */
static readonly List<CPos> emptyPath = new List<CPos>(0);
readonly World world; readonly World world;
public PathFinder(World world) { this.world = world; } public PathFinder(World world) { this.world = world; }
@@ -42,7 +43,6 @@ namespace OpenRA.Mods.RA.Traits
} }
List<CachedPath> CachedPaths = new List<CachedPath>(); List<CachedPath> CachedPaths = new List<CachedPath>();
const int MaxPathAge = 50; /* x 40ms ticks */
public List<CPos> FindUnitPath(CPos from, CPos target, Actor self) public List<CPos> FindUnitPath(CPos from, CPos target, Actor self)
{ {
@@ -75,8 +75,7 @@ namespace OpenRA.Mods.RA.Traits
.Reverse(); .Reverse();
var pb = FindBidiPath( var pb = FindBidiPath(
fromPoint, fromPoint,
fromPointReverse fromPointReverse);
);
CheckSanePath2(pb, from, target); CheckSanePath2(pb, from, target);
@@ -92,7 +91,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
var mi = self.Info.Traits.Get<MobileInfo>(); var mi = self.Info.Traits.Get<MobileInfo>();
var targetCell = self.World.Map.CellContaining(target); var targetCell = self.World.Map.CellContaining(target);
var rangeSquared = range.Range*range.Range; var rangeSquared = range.Range * range.Range;
// Correct for SubCell offset // Correct for SubCell offset
target -= self.World.Map.OffsetOfSubCell(srcSub); target -= self.World.Map.OffsetOfSubCell(srcSub);
@@ -116,8 +115,7 @@ namespace OpenRA.Mods.RA.Traits
var path = FindBidiPath( var path = FindBidiPath(
PathSearch.FromPoints(world, mi, self, tilesInRange, src, true), PathSearch.FromPoints(world, mi, self, tilesInRange, src, true),
PathSearch.FromPoint(world, mi, self, src, targetCell, true).Reverse() PathSearch.FromPoint(world, mi, self, src, targetCell, true).Reverse());
);
return path; return path;
} }
@@ -231,6 +229,7 @@ namespace OpenRA.Mods.RA.Traits
ret.Add(q); ret.Add(q);
q = ca[q].Path; q = ca[q].Path;
} }
ret.Add(q); ret.Add(q);
ret.Reverse(); ret.Reverse();

View File

@@ -339,7 +339,6 @@ namespace OpenRA.Mods.RA.Traits
result.CopyValuesFrom(defaultCellInfoLayer); result.CopyValuesFrom(defaultCellInfoLayer);
} }
return result; return result;
} }

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA
{ {
public class TransformOnPassengerInfo : ITraitInfo public class TransformOnPassengerInfo : ITraitInfo
{ {
[ActorReference] public readonly string[] PassengerTypes = {}; [ActorReference] public readonly string[] PassengerTypes = { };
[ActorReference] public readonly string OnEnter = null; [ActorReference] public readonly string OnEnter = null;
[ActorReference] public readonly string OnExit = null; [ActorReference] public readonly string OnExit = null;
public readonly bool SkipMakeAnims = false; public readonly bool SkipMakeAnims = false;
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA
{ {
if (info.PassengerTypes.Contains(passenger.Info.Name) && transformTo != null) if (info.PassengerTypes.Contains(passenger.Info.Name) && transformTo != null)
{ {
self.World.AddFrameEndTask( w => self.World.AddFrameEndTask(w =>
{ {
var facing = self.TraitOrDefault<IFacing>(); var facing = self.TraitOrDefault<IFacing>();
var transform = new Transform(self, transformTo) { SkipMakeAnims = info.SkipMakeAnims }; var transform = new Transform(self, transformTo) { SkipMakeAnims = info.SkipMakeAnims };

View File

@@ -12,9 +12,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Effects; using OpenRA.Effects;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Traits;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers) public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
{ {
var actors = target.Type == TargetType.Actor ? new [] { target.Actor } : var actors = target.Type == TargetType.Actor ? new[] { target.Actor } :
firedBy.World.FindActorsInCircle(target.CenterPosition, Range); firedBy.World.FindActorsInCircle(target.CenterPosition, Range);
foreach (var a in actors) foreach (var a in actors)

View File

@@ -10,10 +10,10 @@
using System; using System;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Widgets;
using OpenRA.Mods.RA.Widgets; using OpenRA.Mods.RA.Widgets;
using OpenRA.Network; using OpenRA.Network;
using OpenRA.Widgets; using OpenRA.Widgets;
using OpenRA.Mods.Common.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic namespace OpenRA.Mods.RA.Widgets.Logic
{ {

Some files were not shown because too many files have changed in this diff Show More