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.Linq;
using AI.Fuzzy.Library;
using OpenRA.Mods.RA.Traits;
using OpenRA.GameRules;
using OpenRA.Mods.RA.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.AI
@@ -201,6 +201,7 @@ namespace OpenRA.Mods.RA.AI
if (warhead != null)
sumOfDamage += warhead.Damage;
}
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));
world.IssueOrder(Order.StartProduction(queue.Actor, item.Name, 1));
}
// Production is complete
else if (currentBuilding.Done)
{
// Production is complete
// Choose the placement logic
// HACK: HACK HACK HACK
var type = BuildingType.Building;

View File

@@ -735,6 +735,7 @@ namespace OpenRA.Mods.RA.AI
foreach (var kv in powers)
{
var sp = kv.Value;
// Add power to dictionary if not in delay dictionary yet
if (!waitingPowers.ContainsKey(sp))
waitingPowers.Add(sp, 0);
@@ -743,7 +744,7 @@ namespace OpenRA.Mods.RA.AI
waitingPowers[sp]--;
// 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))
{
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? bestLocation = null;
@@ -815,7 +816,7 @@ namespace OpenRA.Mods.RA.AI
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? bestLocation = null;
@@ -829,11 +830,11 @@ namespace OpenRA.Mods.RA.AI
var checkRadius = powerDecision.CoarseScanRadius;
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;
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 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?")]
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;
[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;
}
///<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)
{
var answer = 0;
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.RA
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)
{
var answer = 0;
@@ -95,10 +95,10 @@ namespace OpenRA.Mods.RA
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
{
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")]
public readonly Stance Against = Stance.Enemy;
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.RA
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)
{
if (stance != Against)
@@ -152,6 +152,7 @@ namespace OpenRA.Mods.RA
return Attractiveness;
}
}
return 0;
}
}

View File

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

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA.Activities
var desiredFacing = Util.GetFacing(d, plane.Facing);
// Don't turn until we've reached the cruise altitude
if (plane.CenterPosition.Z < plane.Info.CruiseAltitude.Range)
if (plane.CenterPosition.Z < plane.Info.CruiseAltitude.Range)
desiredFacing = plane.Facing;
FlyToward(self, plane, desiredFacing, plane.Info.CruiseAltitude);

View File

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

View File

@@ -55,6 +55,7 @@ namespace OpenRA.Mods.RA.Activities
heli.UnReserve();
heli.Reservation = res.Reserve(dest, self, heli);
}
var exit = dest.Info.Traits.WithInterface<ExitInfo>().FirstOrDefault();
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)
{
var ret = InnerTick(self, attack);
attack.IsAttacking = (ret == this);
attack.IsAttacking = ret == this;
return ret;
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,7 +18,6 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities
{
// assumes you have Minelayer on that unit
class LayMines : Activity
{
public override Activity Tick(Actor self)
@@ -30,6 +29,7 @@ namespace OpenRA.Mods.RA.Activities
if (!limitedAmmo.HasAmmo())
{
var info = self.Info.Traits.Get<MinelayerInfo>();
// rearm & repair at fix, then back out here to refill the minefield some more
var buildings = info.RearmBuildings;
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)
{
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);
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.
return new Wait(20); // nothing to do here
}

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA.Activities
mobile.IsMoving = false;
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));
return NextActivity;

View File

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

View File

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

View File

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

View File

@@ -37,9 +37,9 @@ namespace OpenRA.Mods.RA.Traits
public readonly int FireDelay = 0;
[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.")]
public readonly WAngle[] LocalYaw = {};
public readonly WAngle[] LocalYaw = { };
[Desc("Move the turret backwards when firing.")]
public readonly WRange Recoil = WRange.Zero;
[Desc("Recoil recovery per-frame")]

View File

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

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
[Desc("Amount of money awarded for capturing the actor.")]
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

View File

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

View File

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

View File

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

View File

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

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Effects
public readonly string Palette = "effect";
public readonly int BrightZaps = 1;
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
@@ -61,6 +61,7 @@ namespace OpenRA.Mods.RA.Effects
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);
}
yield return zap;
}
}

View File

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

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Traits
var health = self.TraitOrDefault<Health>();
var dudesValue = info.ValuePercent * cost;
if (health != null)
dudesValue = dudesValue*health.HP / health.MaxHP;
dudesValue = dudesValue * health.HP / health.MaxHP;
dudesValue /= 100;
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);
}
public Color GetColor() { return Color.Orange; }
}
}

View File

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

View File

@@ -9,8 +9,8 @@
#endregion
using System.Linq;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA
[Desc("Higher ranked units give higher bounties.")]
public readonly int LevelMod = 125;
[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
@@ -49,6 +49,7 @@ namespace OpenRA.Mods.RA
if (!info.Stances.Contains(e.Attacker.Owner.Stances[self.Owner])) return;
var cost = self.GetSellValue();
// 2 hundreds because of GetMultiplier and info.Percentage.
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 InvulnerabilityUpgrade(InvulnerabilityUpgradeInfo info)
: base (info) { }
: base(info) { }
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
|| map.Bounds.Right == map.MapSize.X || map.Bounds.Bottom == map.MapSize.Y)
emitError("This map does not define a valid cordon.\n"
+"A one cell (or greater) border is required on all four sides "
+"between the playable bounds and the map edges");
+ "A one cell (or greater) border is required on all four sides "
+ "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)
{
var sequences = MiniYaml.MergeLiberal(map.SequenceDefinitions,
Game.modData.Manifest.Sequences.Select(s => MiniYaml.FromFile(s))
.Aggregate(MiniYaml.MergeLiberal));
var sequences = MiniYaml.MergeLiberal(map.SequenceDefinitions, Game.modData.Manifest.Sequences.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
foreach (var actorInfo in map.Rules.Actors)
foreach (var renderInfo in actorInfo.Value.Traits.WithInterface<RenderSimpleInfo>())

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
if (traits.Length == 0)
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));
}

View File

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

View File

@@ -68,11 +68,11 @@ namespace OpenRA.Mods.RA.Orders
public class PowerDownOrderGenerator : GlobalButtonOrderGenerator<CanPowerDown>
{
public PowerDownOrderGenerator() : base( "powerdown", "PowerDown" ) { }
public PowerDownOrderGenerator() : base("powerdown", "PowerDown") { }
}
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;
var cells = new Dictionary<CPos, bool>();
// Linebuild for walls.
// Requires a 1x1 footprint
if (rules.Actors[Building].Traits.Contains<LineBuildInfo>())

View File

@@ -11,8 +11,8 @@
using System;
using System.Collections.Generic;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Traits;
using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.RA.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA
if (!inDropRange || cargo.IsEmpty(self))
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;
if (!self.World.Map.Contains(self.Location))

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
public EnterTransportTargeter(string order, int priority,
Func<Actor, bool> canTarget, Func<Actor, bool> useEnterCursor,
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)
{
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
public EnterTransportsTargeter(string order, int priority,
Func<Actor, bool> canTarget, Func<Actor, bool> useEnterCursor,
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)
{
@@ -77,6 +77,7 @@ namespace OpenRA.Mods.RA
case AlternateTransportsMode.Always:
break;
}
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)
return;
var buildingInfo = unit.Traits.Get<BuildingInfo>();
if (order.OrderString == "LineBuild")

View File

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

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.RA
[Desc("Actor can capture ProximityCapturable actors.")]
public class ProximityCaptorInfo : ITraitInfo
{
public readonly string[] Types = {};
public readonly string[] Types = { };
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
var captor = GetInRange(self);
if (captor != null) // got one
// got one
if (captor != null)
{
ChangeOwnership(self, captor);
return;

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.RA.Traits
public override void Tick(Actor 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;
roof.PlayBackwardsThen(NormalizeSequence(self, "build-top"),

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA.Traits
{
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); }
}

View File

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

View File

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

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.RA.Traits
var turretOrientation = turreted != null ? turreted.LocalOrientation(self) : WRot.Zero;
var quantizedBody = body.QuantizeOrientation(self, self.Orientation);
var quantizedTurret = body.QuantizeOrientation(self, turretOrientation);
var quantizedTurret = body.QuantizeOrientation(self, turretOrientation);
return turretOffset + body.LocalToWorld(localOffset.Rotate(quantizedTurret).Rotate(quantizedBody));
}

View File

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

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Traits
{
var barrel = b;
var turreted = self.TraitsImplementing<Turreted>()
.FirstOrDefault(t => t.Name == arm.Info.Turret);
.FirstOrDefault(t => t.Name == arm.Info.Turret);
// Workaround for broken ternary operators in certain versions of mono (3.10 and
// certain versions of the 3.8 series): https://bugzilla.xamarin.com/show_bug.cgi?id=23319

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA.Traits
if (!info.Recoils)
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 bodyOrientation = body.QuantizeOrientation(self, self.Orientation);
var turretOrientation = body.QuantizeOrientation(self, t.LocalOrientation(self));
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA.Traits
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;
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),
0,
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,
0,
Color.FromArgb(128, Color.Yellow),
Color.FromArgb(96, Color.Black)
);
Color.FromArgb(96, Color.Black));
foreach (var a in w.ActorsWithTrait<RenderRangeCircle>())
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
@@ -76,8 +75,7 @@ namespace OpenRA.Mods.RA.Traits
attack.GetMaximumRange(),
0,
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,
0,
Color.FromArgb(128, Color.Cyan),
Color.FromArgb(96, Color.Black)
);
Color.FromArgb(96, Color.Black));
foreach (var a in w.ActorsWithTrait<RenderShroudCircle>())
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
@@ -54,9 +53,7 @@ namespace OpenRA.Mods.RA.Traits
self.Info.Traits.Get<CreatesShroudInfo>().Range,
0,
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()); }
}
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 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()
{
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)

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Traits
[ActorReference] public readonly string[] Buildings = { "spen", "syrd" };
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
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Traits
readonly Actor self;
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
{
@@ -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 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()
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA.Traits
var target = Target.FromOrder(self.World, order);
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.SetTargetLine(target, Color.Green, false);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -164,8 +164,7 @@ namespace OpenRA.Mods.RA.Traits
Info.BeaconPalettePrefix,
Info.BeaconPoster,
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);
}

View File

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

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Traits
[ActorReference]
[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.")]
public readonly bool AllowImpassableCells = false;
@@ -184,8 +184,7 @@ namespace OpenRA.Mods.RA.Traits
Info.BeaconPalettePrefix,
Info.BeaconPoster,
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);
}

View File

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

View File

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

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Traits
bool isProne { get { return remainingProneTime > 0; } }
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)
: base(init, info)
@@ -46,7 +46,8 @@ namespace OpenRA.Mods.RA.Traits
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)
localOffset = info.ProneOffset;

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Traits
var body = self.Trait<IBodyOrientation>();
// 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);
// Calculate final position

View File

@@ -13,7 +13,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits
{
[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));
}
public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, pos); }
public void AddedToWorld(Actor self)

View File

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

View File

@@ -114,10 +114,11 @@ namespace OpenRA.Mods.RA.Traits
{
if (!preventDock)
{
harv.QueueActivity(new CallFunc( () => dockedHarv = harv, false));
harv.QueueActivity(new CallFunc(() => dockedHarv = harv, false));
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)));
}

View File

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

View File

@@ -12,8 +12,8 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Traits
public bool RepairActive = false;
public RepairableBuilding(Actor self, RepairableBuildingInfo info)
: base (info)
: base(info)
{
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
// the one we're playing in.
return new DisposableAction(
() => { reservedFor = null; reservedForAircraft = null; },
() => 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})"
.F(forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID)); }));
}

View File

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

View File

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

View File

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

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Traits
public readonly string FullHuskActor = null;
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

View File

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

View File

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

View File

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

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Traits
TransientActors,
BlockedByMovers,
All = TransientActors | BlockedByMovers
};
}
[Desc("Unit is able to move.")]
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;
// 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;
return true;
@@ -177,7 +177,7 @@ namespace OpenRA.Mods.RA.Traits
{
var canIgnoreMovingAllies = self != null && !check.HasFlag(CellConditions.BlockedByMovers);
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)
continue;
@@ -239,7 +239,7 @@ namespace OpenRA.Mods.RA.Traits
}
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);
}
@@ -257,8 +257,6 @@ namespace OpenRA.Mods.RA.Traits
CPos __fromCell, __toCell;
public SubCell fromSubCell, toSubCell;
//int __altitude;
[Sync] public int Facing
{
get { return __facing; }
@@ -333,6 +331,7 @@ namespace OpenRA.Mods.RA.Traits
if (preferred != SubCell.FullCell)
return SubCell.FullCell;
}
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 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)
{
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)

View File

@@ -8,8 +8,8 @@
*/
#endregion
using System.Drawing;
using System.Collections.Generic;
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Orders;
@@ -130,6 +130,7 @@ namespace OpenRA.Mods.RA.Traits
cursor = "chrono-target";
return true;
}
return false;
}
@@ -186,8 +187,7 @@ namespace OpenRA.Mods.RA.Traits
WRange.FromCells(self.Trait<PortableChrono>().Info.MaxDistance),
0,
Color.FromArgb(128, Color.LawnGreen),
Color.FromArgb(96, Color.Black)
);
Color.FromArgb(96, Color.Black));
}
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 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
@@ -255,19 +255,21 @@ namespace OpenRA.Mods.RA.Traits
foreach (var unit in power.UnitsInRange(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;
break;
}
}
if (!canTeleport)
{
// 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
// chronoshifter of enemy unit presence
canTeleport = power.SimilarTerrain(sourceLocation,xy);
canTeleport = power.SimilarTerrain(sourceLocation, xy);
}
return canTeleport;
}

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Traits
[Desc("Required for GpsPower. Attach this to the player actor.")]
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
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA.Traits
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);
if (Granted || GrantedAllies)
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.RA.Traits
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); }
void RemoveGps(Actor self)

View File

@@ -14,7 +14,7 @@ namespace OpenRA.Mods.RA.Traits
{
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); }
}
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Traits
public override string[] TargetTypes
{
get { return cloak.Cloaked ? info.CloakedTargetTypes
: info.TargetTypes;}
: info.TargetTypes; }
}
}
}

View File

@@ -13,14 +13,14 @@ using System.Diagnostics;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
using OpenRA.Support;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits
{
[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.")]
class DomainIndexInfo : TraitInfo<DomainIndex> {}
class DomainIndexInfo : TraitInfo<DomainIndex> { }
public class DomainIndex : IWorldLoaded
{

View File

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

View File

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

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