fix indents everywhere

This commit is contained in:
Chris Forbes
2011-10-18 15:10:17 +13:00
parent 227bbc109e
commit bc6af1841b
180 changed files with 2707 additions and 2707 deletions

View File

@@ -12,7 +12,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class AcceptsSuppliesInfo : TraitInfo<AcceptsSupplies> {}
class AcceptsSuppliesInfo : TraitInfo<AcceptsSupplies> {}
class AcceptsSupplies {}
class AcceptsSupplies {}
}

View File

@@ -22,10 +22,10 @@ namespace OpenRA.Mods.RA.Activities
int Range;
bool AllowMovement;
int nextPathTime;
int nextPathTime;
const int delayBetweenPathingAttempts = 20;
const int delaySpread = 5;
const int delayBetweenPathingAttempts = 20;
const int delaySpread = 5;
public Attack(Target target, int range, bool allowMovement)
{
@@ -58,16 +58,16 @@ namespace OpenRA.Mods.RA.Activities
if (targetable != null && !targetable.TargetableBy(Target.Actor, self))
return NextActivity;
if (!Combat.IsInRange(self.CenterLocation, Range, Target))
{
if (--nextPathTime > 0)
return this;
if (!Combat.IsInRange(self.CenterLocation, Range, Target))
{
if (--nextPathTime > 0)
return this;
nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
delayBetweenPathingAttempts + delaySpread);
nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
delayBetweenPathingAttempts + delaySpread);
return (AllowMovement) ? Util.SequenceActivities(self.Trait<Mobile>().MoveWithinRange(Target, Range), this) : NextActivity;
}
return (AllowMovement) ? Util.SequenceActivities(self.Trait<Mobile>().MoveWithinRange(Target, Range), this) : NextActivity;
}
var desiredFacing = Util.GetFacing(Target.CenterLocation - self.CenterLocation, 0);
if (facing.Facing != desiredFacing)

View File

@@ -14,30 +14,30 @@ using OpenRA.Mods.RA.Effects;
namespace OpenRA.Mods.RA.Activities
{
class DonateSupplies : Activity
{
Actor target;
int payload;
class DonateSupplies : Activity
{
Actor target;
int payload;
public DonateSupplies(Actor target, int payload)
{
this.target = target;
this.payload = payload;
}
public DonateSupplies(Actor target, int payload)
{
this.target = target;
this.payload = payload;
}
public override Activity Tick(Actor self)
{
if (IsCanceled) return NextActivity;
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
if (!target.OccupiesSpace.OccupiedCells().Any(x => x.First == self.Location))
return NextActivity;
public override Activity Tick(Actor self)
{
if (IsCanceled) return NextActivity;
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
if (!target.OccupiesSpace.OccupiedCells().Any(x => x.First == self.Location))
return NextActivity;
target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
self.Destroy();
target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
self.Destroy();
if (self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
self.World.AddFrameEndTask(w => w.Add(new CashTick(payload, 30, 2, target.CenterLocation, target.Owner.ColorRamp.GetColor(0))));
return this;
}
}
return this;
}
}
}

View File

@@ -17,10 +17,10 @@ namespace OpenRA.Mods.RA.Activities
{
Target Target;
int Range;
int nextPathTime;
int nextPathTime;
const int delayBetweenPathingAttempts = 20;
const int delaySpread = 5;
const int delayBetweenPathingAttempts = 20;
const int delaySpread = 5;
public Follow(Target target, int range)
{
@@ -36,12 +36,12 @@ namespace OpenRA.Mods.RA.Activities
var inRange = ( Util.CellContaining( Target.CenterLocation ) - self.Location ).LengthSquared < Range * Range;
if( inRange ) return this;
if (--nextPathTime > 0) return this;
if (--nextPathTime > 0) return this;
nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
delayBetweenPathingAttempts + delaySpread);
nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
delayBetweenPathingAttempts + delaySpread);
var mobile = self.Trait<Mobile>();
var mobile = self.Trait<Mobile>();
return Util.SequenceActivities( mobile.MoveWithinRange( Target, Range ), this );
}
}

View File

@@ -17,16 +17,16 @@ namespace OpenRA.Mods.RA.Activities
public class Rearm : Activity
{
readonly LimitedAmmo limitedAmmo;
int ticksPerPip = 25 * 2;
int remainingTicks = 25 * 2;
int ticksPerPip = 25 * 2;
int remainingTicks = 25 * 2;
public Rearm(Actor self)
{
public Rearm(Actor self)
{
limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
if (limitedAmmo != null)
ticksPerPip = limitedAmmo.ReloadTimePerAmmo();
remainingTicks = ticksPerPip;
}
ticksPerPip = limitedAmmo.ReloadTimePerAmmo();
remainingTicks = ticksPerPip;
}
public override Activity Tick(Actor self)
{

View File

@@ -31,8 +31,8 @@ namespace OpenRA.Mods.RA.Activities
foreach (var ns in self.TraitsImplementing<INotifySold>())
ns.Sold(self);
if (refund > 0 && self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
self.World.AddFrameEndTask(
if (refund > 0 && self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
self.World.AddFrameEndTask(
w => w.Add(new CashTick(refund, 30, 2,
self.CenterLocation,
self.Owner.ColorRamp.GetColor(0))));

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
var aircraft = self.Trait<IMove>();
if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10
&& self.Owner.WinState != WinState.Lost)
&& self.Owner.WinState != WinState.Lost)
{
self.World.AddFrameEndTask(w => w.Add(
new Parachute(pilot.Owner,

View File

@@ -13,25 +13,25 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Air
{
public class FlyCircle : Activity
{
public override Activity Tick(Actor self)
{
var cruiseAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
public class FlyCircle : Activity
{
public override Activity Tick(Actor self)
{
var cruiseAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
if (IsCanceled) return NextActivity;
if (IsCanceled) return NextActivity;
var aircraft = self.Trait<Aircraft>();
var aircraft = self.Trait<Aircraft>();
var desiredFacing = aircraft.Facing + 64; // we can't possibly turn this fast.
if (aircraft.Altitude == cruiseAltitude)
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
var desiredFacing = aircraft.Facing + 64; // we can't possibly turn this fast.
if (aircraft.Altitude == cruiseAltitude)
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
if (aircraft.Altitude < cruiseAltitude)
++aircraft.Altitude;
if (aircraft.Altitude < cruiseAltitude)
++aircraft.Altitude;
FlyUtil.Fly(self, cruiseAltitude);
return this;
}
}
FlyUtil.Fly(self, cruiseAltitude);
return this;
}
}
}

View File

@@ -34,29 +34,29 @@ namespace OpenRA.Mods.RA.Air
}
else
{
// nowhere to land, pick something friendly and circle over it.
// nowhere to land, pick something friendly and circle over it.
// i'd prefer something we own
var someBuilding = self.World.ActorsWithTrait<Building>()
.Select( a => a.Actor )
.FirstOrDefault(a => a.Owner == self.Owner);
// i'd prefer something we own
var someBuilding = self.World.ActorsWithTrait<Building>()
.Select( a => a.Actor )
.FirstOrDefault(a => a.Owner == self.Owner);
// failing that, something unlikely to shoot at us
if (someBuilding == null)
someBuilding = self.World.ActorsWithTrait<Building>()
.Select( a => a.Actor )
.FirstOrDefault(a => self.Owner.Stances[a.Owner] == Stance.Ally);
// failing that, something unlikely to shoot at us
if (someBuilding == null)
someBuilding = self.World.ActorsWithTrait<Building>()
.Select( a => a.Actor )
.FirstOrDefault(a => self.Owner.Stances[a.Owner] == Stance.Ally);
if (someBuilding == null)
{
// ... going down the garden to eat worms ...
self.QueueActivity(new FlyOffMap());
self.QueueActivity(new RemoveSelf());
return;
}
if (someBuilding == null)
{
// ... going down the garden to eat worms ...
self.QueueActivity(new FlyOffMap());
self.QueueActivity(new RemoveSelf());
return;
}
self.QueueActivity(Fly.ToCell(someBuilding.Location));
self.QueueActivity(new FlyCircle());
self.QueueActivity(Fly.ToCell(someBuilding.Location));
self.QueueActivity(new FlyCircle());
}
}
}

View File

@@ -15,25 +15,25 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Air
{
public class TargetableAircraftInfo : TargetableUnitInfo, Requires<AircraftInfo>
{
public readonly string[] GroundedTargetTypes = { };
public override object Create(ActorInitializer init) { return new TargetableAircraft(init.self, this); }
}
public class TargetableAircraftInfo : TargetableUnitInfo, Requires<AircraftInfo>
{
public readonly string[] GroundedTargetTypes = { };
public override object Create(ActorInitializer init) { return new TargetableAircraft(init.self, this); }
}
public class TargetableAircraft : TargetableUnit<TargetableAircraftInfo>
{
Aircraft Aircraft;
public TargetableAircraft(Actor self, TargetableAircraftInfo info)
: base(self, info)
{
Aircraft = self.Trait<Aircraft>();
}
public class TargetableAircraft : TargetableUnit<TargetableAircraftInfo>
{
Aircraft Aircraft;
public TargetableAircraft(Actor self, TargetableAircraftInfo info)
: base(self, info)
{
Aircraft = self.Trait<Aircraft>();
}
public override string[] TargetTypes
{
get { return (Aircraft.Altitude > 0) ? info.TargetTypes
: info.GroundedTargetTypes; }
}
}
public override string[] TargetTypes
{
get { return (Aircraft.Altitude > 0) ? info.TargetTypes
: info.GroundedTargetTypes; }
}
}
}

View File

@@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA
if (self.TraitsImplementing<IDisable>().Any(d => d.Disabled)) return false;
if (target.IsActor && target.Actor.HasTrait<ITargetable>() &&
!target.Actor.Trait<ITargetable>().TargetableBy(target.Actor,self))
!target.Actor.Trait<ITargetable>().TargetableBy(target.Actor,self))
return false;
return true;

View File

@@ -159,7 +159,7 @@ namespace OpenRA.Mods.RA
{
// If this is a long bridge next to a destroyed shore piece, we need die to give clean edges to the break
if (Info.Long && Health.DamageState != DamageState.Dead &&
((southNeighbour != null && Info.ShorePieces.Contains(southNeighbour.Type) && !IsIntact(southNeighbour)) ||
((southNeighbour != null && Info.ShorePieces.Contains(southNeighbour.Type) && !IsIntact(southNeighbour)) ||
(northNeighbour != null && Info.ShorePieces.Contains(northNeighbour.Type) && !IsIntact(northNeighbour))))
{
self.Kill(self); // this changes the damagestate

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
// todo: UI fluff; doesn't belong here
public readonly int BuildPaletteOrder = 9999;
public readonly string Hotkey = null;
public readonly string Hotkey = null;
}
public class Buildable { }

View File

@@ -34,8 +34,8 @@ namespace OpenRA.Mods.RA.Buildings
public bool IsCloseEnoughToBase(World world, Player p, string buildingName, int2 topLeft)
{
if (p.PlayerActor.Trait<DeveloperMode>().BuildAnywhere)
return true;
if (p.PlayerActor.Trait<DeveloperMode>().BuildAnywhere)
return true;
var buildingMaxBounds = Dimensions;
if( Rules.Info[ buildingName ].Traits.Contains<BibInfo>() )

View File

@@ -61,8 +61,8 @@ namespace OpenRA.Mods.RA.Buildings
return ret;
foreach (var b in player.World.ActorsWithTrait<ITechTreePrerequisite>()
.Where(a => a.Actor.IsInWorld && !a.Actor.IsDead() && a.Actor.Owner == player))
foreach (var b in player.World.ActorsWithTrait<ITechTreePrerequisite>()
.Where(a => a.Actor.IsInWorld && !a.Actor.IsDead() && a.Actor.Owner == player))
foreach (var p in b.Trait.ProvidesPrerequisites)
ret[ p ].Add( b.Actor );

View File

@@ -41,13 +41,13 @@ namespace OpenRA.Mods.RA
}
// Can't be used in synced code, except with ignoreVis.
public virtual bool CanChronoshiftTo(Actor self, int2 targetLocation, bool ignoreVis)
{
// Todo: Allow enemy units to be chronoshifted into bad terrain to kill them
return self.HasTrait<ITeleportable>() &&
self.Trait<ITeleportable>().CanEnterCell(targetLocation) &&
(ignoreVis || self.World.LocalShroud.IsExplored(targetLocation));
}
public virtual bool CanChronoshiftTo(Actor self, int2 targetLocation, bool ignoreVis)
{
// Todo: Allow enemy units to be chronoshifted into bad terrain to kill them
return self.HasTrait<ITeleportable>() &&
self.Trait<ITeleportable>().CanEnterCell(targetLocation) &&
(ignoreVis || self.World.LocalShroud.IsExplored(targetLocation));
}
public virtual bool Teleport(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere)
{

View File

@@ -31,13 +31,13 @@ namespace OpenRA.Mods.RA
if (self.Owner.WinState != WinState.Undefined || self.Owner.NonCombatant) return;
var hasAnything = self.World.ActorsWithTrait<MustBeDestroyed>()
.Any( a => a.Actor.Owner == self.Owner );
.Any( a => a.Actor.Owner == self.Owner );
if (!hasAnything && !self.Owner.NonCombatant)
Lose(self);
var others = self.World.Players.Where( p => !p.NonCombatant
&& p != self.Owner && p.Stances[self.Owner] != Stance.Ally );
&& p != self.Owner && p.Stances[self.Owner] != Stance.Ally );
if (others.Count() == 0) return;
@@ -58,8 +58,8 @@ namespace OpenRA.Mods.RA
Game.Debug("{0} is defeated.".F(self.Owner.PlayerName));
foreach (var a in self.World.Actors.Where(a => a.Owner == self.Owner))
a.Kill(a);
foreach (var a in self.World.Actors.Where(a => a.Owner == self.Owner))
a.Kill(a);
if (self.Owner == self.World.LocalPlayer)
{

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.RA
var startPos = w.ChooseRandomEdgeCell();
var plane = w.CreateActor("badr", new TypeDictionary
{
{
new LocationInit( startPos ),
new OwnerInit( w.WorldActor.Owner),
new FacingInit( Util.GetFacing(p - startPos, 0) ),

View File

@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA
self.World.AddFrameEndTask(
w => crates.Add(w.CreateActor("crate", new TypeDictionary
{
{
new LocationInit( p ),
new OwnerInit( self.World.WorldActor.Owner ),
})));

View File

@@ -30,10 +30,10 @@ namespace OpenRA.Mods.RA.Crates
return 0; // there's some other really good reason why we shouldn't give this.
var hasBase = self.World.ActorsWithTrait<BaseBuilding>()
.Any(a => a.Actor.Owner == collector.Owner);
.Any(a => a.Actor.Owner == collector.Owner);
return hasBase ? info.SelectionShares :
(info as GiveMcvCrateActionInfo).NoBaseSelectionShares;
(info as GiveMcvCrateActionInfo).NoBaseSelectionShares;
}
}
}

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Crates
if (location != null)
collector.World.AddFrameEndTask(
w => w.CreateActor(Info.Unit, new TypeDictionary
{
{
new LocationInit( location.Value ),
new OwnerInit( Info.Owner ?? collector.Owner.InternalName )
}));

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Crates
public override void Activate(Actor collector)
{
collector.World.AddFrameEndTask(w => w.CreateActor(Info.Proxy, new TypeDictionary
{
{
new OwnerInit( collector.Owner )
}));
}

View File

@@ -31,10 +31,10 @@ namespace OpenRA.Mods.RA.Effects
public readonly bool Proximity = false;
public readonly float Angle = 0;
public readonly int TrailInterval = 2;
public readonly int ContrailLength = 0;
public readonly Color ContrailColor = Color.White;
public readonly bool ContrailUsePlayerColor = false;
public readonly int ContrailDelay = 1;
public readonly int ContrailLength = 0;
public readonly Color ContrailColor = Color.White;
public readonly bool ContrailUsePlayerColor = false;
public readonly int ContrailDelay = 1;
public IEffect Create(ProjectileArgs args) { return new Bullet( this, args ); }
}
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Effects
Animation anim;
const int BaseBulletSpeed = 100; /* pixels / 40ms frame */
ContrailHistory Trail;
ContrailHistory Trail;
public Bullet(BulletInfo info, ProjectileArgs args)
{
@@ -67,12 +67,12 @@ namespace OpenRA.Mods.RA.Effects
anim.PlayRepeating("idle");
}
if (Info.ContrailLength > 0)
{
Trail = new ContrailHistory(Info.ContrailLength,
Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor,
Info.ContrailDelay);
}
if (Info.ContrailLength > 0)
{
Trail = new ContrailHistory(Info.ContrailLength,
Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor,
Info.ContrailDelay);
}
}
int TotalTime() { return (Args.dest - Args.src).Length * BaseBulletSpeed / Info.Speed; }
@@ -123,8 +123,8 @@ namespace OpenRA.Mods.RA.Effects
ticksToNextSmoke = Info.TrailInterval;
}
if (Trail != null)
Trail.Tick(highPos);
if (Trail != null)
Trail.Tick(highPos);
}
if (!Info.High) // check for hitting a wall
@@ -144,35 +144,35 @@ namespace OpenRA.Mods.RA.Effects
const float height = .1f;
public IEnumerable<Renderable> Render()
{
if (anim != null)
{
var at = (float)t / TotalTime();
public IEnumerable<Renderable> Render()
{
if (anim != null)
{
var at = (float)t / TotalTime();
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
if (Args.firedBy.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(pos)))
{
if (Info.High || Info.Angle > 0)
{
if (Info.Shadow)
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow", (int)pos.Y);
if (Args.firedBy.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(pos)))
{
if (Info.High || Info.Angle > 0)
{
if (Info.Shadow)
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow", (int)pos.Y);
var highPos = pos - new float2(0, GetAltitude());
var highPos = pos - new float2(0, GetAltitude());
yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, "effect", (int)pos.Y);
}
else
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size,
Args.weapon.Underwater ? "shadow" : "effect", (int)pos.Y);
}
}
yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, "effect", (int)pos.Y);
}
else
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size,
Args.weapon.Underwater ? "shadow" : "effect", (int)pos.Y);
}
}
if (Trail != null)
Trail.Render(Args.firedBy);
}
if (Trail != null)
Trail.Render(Args.firedBy);
}
void Explode( World world )
{

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
public readonly int[] ContrailOffset = {0, 0};
public readonly int TrailLength = 20;
public readonly Color Color = Color.White;
public readonly Color Color = Color.White;
public readonly bool UsePlayerColor = true;
public object Create(ActorInitializer init) { return new Contrail(init.self, this); }
@@ -45,64 +45,64 @@ namespace OpenRA.Mods.RA
public void Tick(Actor self)
{
history.Tick(self.CenterLocation - new int2(0, move.Altitude)
history.Tick(self.CenterLocation - new int2(0, move.Altitude)
- Combat.GetTurretPosition(self, facing, contrailTurret));
}
public void RenderAfterWorld(WorldRenderer wr, Actor self) { history.Render(self); }
public void RenderAfterWorld(WorldRenderer wr, Actor self) { history.Render(self); }
}
class ContrailHistory
{
List<float2> positions = new List<float2>();
readonly int TrailLength;
readonly Color Color;
readonly int StartSkip;
class ContrailHistory
{
List<float2> positions = new List<float2>();
readonly int TrailLength;
readonly Color Color;
readonly int StartSkip;
public static Color ChooseColor(Actor self)
{
var ownerColor = Color.FromArgb(255, self.Owner.ColorRamp.GetColor(0));
return PlayerColorRemap.ColorLerp(0.5f, ownerColor, Color.White);
}
public static Color ChooseColor(Actor self)
{
var ownerColor = Color.FromArgb(255, self.Owner.ColorRamp.GetColor(0));
return PlayerColorRemap.ColorLerp(0.5f, ownerColor, Color.White);
}
public ContrailHistory(int trailLength, Color color)
: this(trailLength, color, 0) { }
public ContrailHistory(int trailLength, Color color)
: this(trailLength, color, 0) { }
public ContrailHistory(int trailLength, Color color, int startSkip)
{
this.TrailLength = trailLength;
this.Color = color;
this.StartSkip = startSkip;
}
public ContrailHistory(int trailLength, Color color, int startSkip)
{
this.TrailLength = trailLength;
this.Color = color;
this.StartSkip = startSkip;
}
public void Tick(float2 currentPos)
{
positions.Add(currentPos);
if (positions.Count >= TrailLength)
positions.RemoveAt(0);
}
public void Tick(float2 currentPos)
{
positions.Add(currentPos);
if (positions.Count >= TrailLength)
positions.RemoveAt(0);
}
public void Render(Actor self)
{
Color trailStart = Color;
Color trailEnd = Color.FromArgb(trailStart.A - 255 / TrailLength, trailStart.R,
trailStart.G, trailStart.B);
public void Render(Actor self)
{
Color trailStart = Color;
Color trailEnd = Color.FromArgb(trailStart.A - 255 / TrailLength, trailStart.R,
trailStart.G, trailStart.B);
for (int i = positions.Count - 1 - StartSkip; i >= 1; --i)
{
var conPos = positions[i];
var nextPos = positions[i - 1];
for (int i = positions.Count - 1 - StartSkip; i >= 1; --i)
{
var conPos = positions[i];
var nextPos = positions[i - 1];
if (self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(conPos)) ||
self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(nextPos)))
{
Game.Renderer.WorldLineRenderer.DrawLine(conPos, nextPos, trailStart, trailEnd);
if (self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(conPos)) ||
self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(nextPos)))
{
Game.Renderer.WorldLineRenderer.DrawLine(conPos, nextPos, trailStart, trailEnd);
trailStart = trailEnd;
trailEnd = Color.FromArgb(trailStart.A - 255 / positions.Count, trailStart.R,
trailStart.G, trailStart.B);
}
}
}
}
trailStart = trailEnd;
trailEnd = Color.FromArgb(trailStart.A - 255 / positions.Count, trailStart.R,
trailStart.G, trailStart.B);
}
}
}
}
}

View File

@@ -33,10 +33,10 @@ namespace OpenRA.Mods.RA.Effects
public readonly int RangeLimit = 0;
public readonly bool TurboBoost = false;
public readonly int TrailInterval = 2;
public readonly int ContrailLength = 0;
public readonly Color ContrailColor = Color.White;
public readonly bool ContrailUsePlayerColor = false;
public readonly int ContrailDelay = 1;
public readonly int ContrailLength = 0;
public readonly Color ContrailColor = Color.White;
public readonly bool ContrailUsePlayerColor = false;
public readonly int ContrailDelay = 1;
public IEffect Create(ProjectileArgs args) { return new Missile( this, args ); }
}
@@ -54,33 +54,33 @@ namespace OpenRA.Mods.RA.Effects
int Facing;
int t;
int Altitude;
ContrailHistory Trail;
ContrailHistory Trail;
public Missile(MissileInfo info, ProjectileArgs args)
{
Info = info;
Args = args;
public Missile(MissileInfo info, ProjectileArgs args)
{
Info = info;
Args = args;
SubPxPosition = 1024 * Args.src;
Altitude = Args.srcAltitude;
Facing = Args.facing;
SubPxPosition = 1024 * Args.src;
Altitude = Args.srcAltitude;
Facing = Args.facing;
if (info.Inaccuracy > 0)
offset = (info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
if (info.Inaccuracy > 0)
offset = (info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
if (Info.Image != null)
{
anim = new Animation(Info.Image, () => Facing);
anim.PlayRepeating("idle");
}
if (Info.Image != null)
{
anim = new Animation(Info.Image, () => Facing);
anim.PlayRepeating("idle");
}
if (Info.ContrailLength > 0)
{
Trail = new ContrailHistory(Info.ContrailLength,
Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor,
Info.ContrailDelay);
}
}
if (Info.ContrailLength > 0)
{
Trail = new ContrailHistory(Info.ContrailLength,
Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor,
Info.ContrailDelay);
}
}
// In pixels
const int MissileCloseEnough = 7;
@@ -140,8 +140,8 @@ namespace OpenRA.Mods.RA.Effects
Explode(world);
}
if (Trail != null)
Trail.Tick(PxPosition - new float2(0,Altitude));
if (Trail != null)
Trail.Tick(PxPosition - new float2(0,Altitude));
}
void Explode(World world)
@@ -154,12 +154,12 @@ namespace OpenRA.Mods.RA.Effects
public IEnumerable<Renderable> Render()
{
if (Args.firedBy.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(PxPosition.ToFloat2())))
yield return new Renderable(anim.Image,PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude),
Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y);
if (Args.firedBy.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(PxPosition.ToFloat2())))
yield return new Renderable(anim.Image,PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude),
Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y);
if (Trail != null)
Trail.Render(Args.firedBy);
if (Trail != null)
Trail.Render(Args.firedBy);
}
}
}

View File

@@ -37,13 +37,13 @@ namespace OpenRA.Mods.RA
public string VoicePhraseForOrder(Actor self, Order order)
{
return (order.OrderString == "EngineerRepair"
&& order.TargetActor.GetDamageState() > DamageState.Undamaged) ? "Attack" : null;
&& order.TargetActor.GetDamageState() > DamageState.Undamaged) ? "Attack" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "EngineerRepair"
&& order.TargetActor.GetDamageState() > DamageState.Undamaged)
&& order.TargetActor.GetDamageState() > DamageState.Undamaged)
{
self.SetTargetLine(Target.FromOrder(order), Color.Yellow);

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA
w =>
{
var a = w.CreateActor(info.Actor, new TypeDictionary
{
{
new LocationInit( self.Location + info.SpawnOffset ),
new OwnerInit( self.Owner ),
new FacingInit( info.Facing ),

View File

@@ -83,7 +83,7 @@ namespace OpenRA.Mods.RA
}
}
public float GetDamageModifier(Actor attacker, WarheadInfo warhead)
public float GetDamageModifier(Actor attacker, WarheadInfo warhead)
{
return Level > 0 ? 1 / Info.ArmorModifier[Level - 1] : 1;
}

View File

@@ -129,22 +129,22 @@ namespace OpenRA.Mods.RA
if (!HasAdequatePower()) /* try to maintain 20% excess power */
{
if (!buildPower) return null;
if (!buildPower) return null;
/* find the best thing we can build which produces power */
return buildableThings.Where(a => GetPowerProvidedBy(a) > 0)
.OrderByDescending(a => GetPowerProvidedBy(a)).FirstOrDefault();
}
var myBuildings = p.World
.ActorsWithTrait<Building>()
.Where( a => a.Actor.Owner == p )
.Select(a => a.Actor.Info.Name).ToArray();
var myBuildings = p.World
.ActorsWithTrait<Building>()
.Where( a => a.Actor.Owner == p )
.Select(a => a.Actor.Info.Name).ToArray();
foreach (var frac in Info.BuildingFractions)
if (buildableThings.Any(b => b.Name == frac.Key))
if (myBuildings.Count(a => a == frac.Key) < frac.Value * myBuildings.Length &&
playerPower.ExcessPower >= Rules.Info[frac.Key].Traits.Get<BuildingInfo>().Power)
playerPower.ExcessPower >= Rules.Info[frac.Key].Traits.Get<BuildingInfo>().Power)
return Rules.Info[frac.Key];
return null;
@@ -206,7 +206,7 @@ namespace OpenRA.Mods.RA
//A bunch of hardcoded lists to keep track of which units are doing what.
List<Actor> unitsHangingAroundTheBase = new List<Actor>();
List<Actor> attackForce = new List<Actor>();
int2? attackTarget;
int2? attackTarget;
//Units that the ai already knows about. Any unit not on this list needs to be given a role.
List<Actor> activeUnits = new List<Actor>();
@@ -335,7 +335,7 @@ namespace OpenRA.Mods.RA
{
var buildings = self.World.ActorsWithTrait<RallyPoint>()
.Where(rp => rp.Actor.Owner == p &&
!IsRallyPointValid(rp.Trait.rallyPoint)).ToArray();
!IsRallyPointValid(rp.Trait.rallyPoint)).ToArray();
if (buildings.Length > 0)
BotDebug("Bot {0} needs to find rallypoints for {1} buildings.",

View File

@@ -70,18 +70,18 @@ namespace OpenRA.Mods.RA
Actor ClosestProc(Actor self, Actor ignore)
{
var refs = self.World.ActorsWithTrait<IAcceptOre>()
.Where(x => x.Actor != ignore && x.Actor.Owner == self.Owner)
.ToList();
var refs = self.World.ActorsWithTrait<IAcceptOre>()
.Where(x => x.Actor != ignore && x.Actor.Owner == self.Owner)
.ToList();
var mi = self.Info.Traits.Get<MobileInfo>();
var path = self.World.WorldActor.Trait<PathFinder>().FindPath(
PathSearch.FromPoints(self.World, mi, self.Owner,
refs.Select(r => r.Actor.Location + r.Trait.DeliverOffset),
refs.Select(r => r.Actor.Location + r.Trait.DeliverOffset),
self.Location, false));
path.Reverse();
if (path.Count != 0)
return refs.Where(x => x.Actor.Location + x.Trait.DeliverOffset == path[0])
.Select(a => a.Actor).FirstOrDefault();
.Select(a => a.Actor).FirstOrDefault();
else
return null;
}

View File

@@ -45,8 +45,8 @@ namespace OpenRA.Mods.RA
{
var to = Util.CenterOfCell(location);
var length = (int)((to - PxPosition).Length * 3 / speed);
self.QueueActivity(new DragHusk(PxPosition, to, length, this));
}
self.QueueActivity(new DragHusk(PxPosition, to, length, this));
}
}
public int2 TopLeft { get { return location; } }

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA
public void OnInfiltrate(Actor self, Actor spy)
{
spy.World.AddFrameEndTask(w => w.CreateActor(Info.Proxy, new TypeDictionary
{
{
new OwnerInit( spy.Owner )
}));
}

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
RemainingTicks--;
}
public float GetDamageModifier(Actor attacker, WarheadInfo warhead)
public float GetDamageModifier(Actor attacker, WarheadInfo warhead)
{
return (RemainingTicks > 0) ? 0.0f : 1.0f;
}

View File

@@ -17,15 +17,15 @@ namespace OpenRA.Mods.RA
{
public readonly int Ammo = 0;
public readonly int PipCount = 0;
public readonly int ReloadTicks = 25 * 2; // This is measured in ticks
public readonly int ReloadTicks = 25 * 2; // This is measured in ticks
public object Create(ActorInitializer init) { return new LimitedAmmo(this); }
}
public class LimitedAmmo : INotifyAttack, IPips, ISync
{
[Sync]
int ammo;
[Sync]
int ammo;
LimitedAmmoInfo Info;
public LimitedAmmo(LimitedAmmoInfo info)
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA
return true;
}
public int ReloadTimePerAmmo() { return Info.ReloadTicks; }
public int ReloadTimePerAmmo() { return Info.ReloadTicks; }
public void Attacking(Actor self, Target target) { --ammo; }

View File

@@ -16,16 +16,16 @@ namespace OpenRA.Mods.RA
class CheckAutotargetWiring : ILintPass
{
public void Run(Action<string> emitError, Action<string> emitWarning)
{
foreach( var i in Rules.Info )
{
foreach( var i in Rules.Info )
{
if (i.Key.StartsWith("^"))
continue;
var attackMove = i.Value.Traits.GetOrDefault<AttackMoveInfo>();
if (attackMove != null && !attackMove.JustMove &&
!i.Value.Traits.Contains<AutoTargetInfo>())
!i.Value.Traits.Contains<AutoTargetInfo>())
emitError( "{0} has AttackMove setup without AutoTarget, and will crash when resolving that order.".F(i.Key) );
}
}
}
}
}

View File

@@ -15,14 +15,14 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class LintBuildablePrerequisites : ILintPass
{
public void Run(Action<string> emitError, Action<string> emitWarning)
{
class LintBuildablePrerequisites : ILintPass
{
public void Run(Action<string> emitError, Action<string> emitWarning)
{
var providedPrereqs = Rules.Info.Keys.Concat(
Rules.Info.SelectMany( a => a.Value.Traits
.WithInterface<ProvidesCustomPrerequisiteInfo>()
.Select( p => p.Prerequisite ))).ToArray();
.WithInterface<ProvidesCustomPrerequisiteInfo>()
.Select( p => p.Prerequisite ))).ToArray();
foreach( var i in Rules.Info )
{
@@ -32,6 +32,6 @@ namespace OpenRA.Mods.RA
if ( !providedPrereqs.Contains(prereq) )
emitError( "Buildable actor {0} has prereq {1} not provided by anything.".F( i.Key, prereq ) );
}
}
}
}
}
}

View File

@@ -18,53 +18,53 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Move
{
public class MobileInfo : ITraitInfo, IFacingInfo
{
[FieldLoader.LoadUsing("LoadSpeeds")]
public readonly Dictionary<string, TerrainInfo> TerrainSpeeds;
public readonly string[] Crushes;
public readonly int WaitAverage = 60;
public readonly int WaitSpread = 20;
public readonly int InitialFacing = 128;
public readonly int ROT = 255;
public readonly int Speed = 1;
public readonly bool OnRails = false;
public class MobileInfo : ITraitInfo, IFacingInfo
{
[FieldLoader.LoadUsing("LoadSpeeds")]
public readonly Dictionary<string, TerrainInfo> TerrainSpeeds;
public readonly string[] Crushes;
public readonly int WaitAverage = 60;
public readonly int WaitSpread = 20;
public readonly int InitialFacing = 128;
public readonly int ROT = 255;
public readonly int Speed = 1;
public readonly bool OnRails = false;
public readonly bool SharesCell = false;
public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }
public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }
static object LoadSpeeds(MiniYaml y)
{
Dictionary<string, TerrainInfo> ret = new Dictionary<string, TerrainInfo>();
foreach (var t in y.NodesDict["TerrainSpeeds"].Nodes)
{
var speed = FieldLoader.GetValue<decimal>("speed", t.Value.Value);
var cost = t.Value.NodesDict.ContainsKey("PathingCost")
static object LoadSpeeds(MiniYaml y)
{
Dictionary<string, TerrainInfo> ret = new Dictionary<string, TerrainInfo>();
foreach (var t in y.NodesDict["TerrainSpeeds"].Nodes)
{
var speed = FieldLoader.GetValue<decimal>("speed", t.Value.Value);
var cost = t.Value.NodesDict.ContainsKey("PathingCost")
? FieldLoader.GetValue<int>("cost", t.Value.NodesDict["PathingCost"].Value)
: (int)(10000 / speed);
ret.Add(t.Key, new TerrainInfo { Speed = speed, Cost = cost });
}
ret.Add(t.Key, new TerrainInfo { Speed = speed, Cost = cost });
}
return ret;
}
return ret;
}
public class TerrainInfo
{
public int Cost = int.MaxValue;
public decimal Speed = 0;
}
public class TerrainInfo
{
public int Cost = int.MaxValue;
public decimal Speed = 0;
}
public int MovementCostForCell(World world, int2 cell)
{
if (!world.Map.IsInMap(cell.X, cell.Y))
return int.MaxValue;
public int MovementCostForCell(World world, int2 cell)
{
if (!world.Map.IsInMap(cell.X, cell.Y))
return int.MaxValue;
var type = world.GetTerrainType(cell);
if (!TerrainSpeeds.ContainsKey(type))
return int.MaxValue;
var type = world.GetTerrainType(cell);
if (!TerrainSpeeds.ContainsKey(type))
return int.MaxValue;
return TerrainSpeeds[type].Cost;
}
return TerrainSpeeds[type].Cost;
}
public readonly Dictionary<SubCell, int2> SubCellOffsets = new Dictionary<SubCell, int2>()
{
@@ -76,88 +76,88 @@ namespace OpenRA.Mods.RA.Move
{SubCell.FullCell, new int2(0,0)},
};
public bool CanEnterCell(World world, Player owner, int2 cell, Actor ignoreActor, bool checkTransientActors)
{
if (MovementCostForCell(world, cell) == int.MaxValue)
return false;
public bool CanEnterCell(World world, Player owner, int2 cell, Actor ignoreActor, bool checkTransientActors)
{
if (MovementCostForCell(world, cell) == int.MaxValue)
return false;
if (SharesCell && world.ActorMap.HasFreeSubCell(cell))
return true;
var blockingActors = world.ActorMap.GetUnitsAt(cell).Where(x => x != ignoreActor).ToList();
if (checkTransientActors && blockingActors.Count > 0)
{
// Non-sharable unit can enter a cell with shareable units only if it can crush all of them
if (Crushes == null)
return false;
var blockingActors = world.ActorMap.GetUnitsAt(cell).Where(x => x != ignoreActor).ToList();
if (checkTransientActors && blockingActors.Count > 0)
{
// Non-sharable unit can enter a cell with shareable units only if it can crush all of them
if (Crushes == null)
return false;
if (blockingActors.Any(a => !(a.HasTrait<ICrushable>() &&
a.TraitsImplementing<ICrushable>().Any(b => b.CrushableBy(Crushes, owner)))))
return false;
}
if (blockingActors.Any(a => !(a.HasTrait<ICrushable>() &&
a.TraitsImplementing<ICrushable>().Any(b => b.CrushableBy(Crushes, owner)))))
return false;
}
return true;
}
}
return true;
}
}
public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IOccupySpace, IMove, IFacing, INudge, ISync
{
public readonly Actor self;
public readonly MobileInfo Info;
public bool IsMoving { get; internal set; }
{
public readonly Actor self;
public readonly MobileInfo Info;
public bool IsMoving { get; internal set; }
int __facing;
int2 __fromCell, __toCell;
int __facing;
int2 __fromCell, __toCell;
public SubCell fromSubCell, toSubCell;
int __altitude;
int __altitude;
[Sync]
public int Facing
{
get { return __facing; }
set { __facing = value; }
}
[Sync]
public int Facing
{
get { return __facing; }
set { __facing = value; }
}
[Sync]
public int Altitude
{
get { return __altitude; }
set { __altitude = value; }
}
[Sync]
public int Altitude
{
get { return __altitude; }
set { __altitude = value; }
}
public int ROT { get { return Info.ROT; } }
public int InitialFacing { get { return Info.InitialFacing; } }
public int ROT { get { return Info.ROT; } }
public int InitialFacing { get { return Info.InitialFacing; } }
[Sync]
public int2 PxPosition { get; set; }
[Sync]
public int2 fromCell { get { return __fromCell; } }
[Sync]
public int2 toCell { get { return __toCell; } }
[Sync]
public int2 PxPosition { get; set; }
[Sync]
public int2 fromCell { get { return __fromCell; } }
[Sync]
public int2 toCell { get { return __toCell; } }
[Sync]
public int PathHash; // written by Move.EvalPath, to temporarily debug this crap.
[Sync]
public int PathHash; // written by Move.EvalPath, to temporarily debug this crap.
public void SetLocation(int2 from, SubCell fromSub, int2 to, SubCell toSub)
{
if (fromCell == from && toCell == to) return;
RemoveInfluence();
__fromCell = from;
__toCell = to;
public void SetLocation(int2 from, SubCell fromSub, int2 to, SubCell toSub)
{
if (fromCell == from && toCell == to) return;
RemoveInfluence();
__fromCell = from;
__toCell = to;
fromSubCell = fromSub;
toSubCell = toSub;
AddInfluence();
}
AddInfluence();
}
const int avgTicksBeforePathing = 5;
const int spreadTicksBeforePathing = 5;
internal int ticksBeforePathing = 0;
const int avgTicksBeforePathing = 5;
const int spreadTicksBeforePathing = 5;
internal int ticksBeforePathing = 0;
public Mobile(ActorInitializer init, MobileInfo info)
{
this.self = init.self;
this.Info = info;
public Mobile(ActorInitializer init, MobileInfo info)
{
this.self = init.self;
this.Info = info;
toSubCell = fromSubCell = info.SharesCell ? SubCell.Center : SubCell.FullCell;
if (init.Contains<SubCellInit>())
@@ -165,111 +165,111 @@ namespace OpenRA.Mods.RA.Move
this.fromSubCell = this.toSubCell = init.Get<SubCellInit, SubCell>();
}
if (init.Contains<LocationInit>())
{
this.__fromCell = this.__toCell = init.Get<LocationInit, int2>();
this.PxPosition = Util.CenterOfCell(fromCell) + info.SubCellOffsets[fromSubCell];
}
if (init.Contains<LocationInit>())
{
this.__fromCell = this.__toCell = init.Get<LocationInit, int2>();
this.PxPosition = Util.CenterOfCell(fromCell) + info.SubCellOffsets[fromSubCell];
}
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit, int>() : 0;
}
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit, int>() : 0;
}
public void SetPosition(Actor self, int2 cell)
{
SetLocation(cell,fromSubCell, cell,fromSubCell);
PxPosition = Util.CenterOfCell(fromCell) + Info.SubCellOffsets[fromSubCell];
FinishedMoving(self);
}
public void SetPosition(Actor self, int2 cell)
{
SetLocation(cell,fromSubCell, cell,fromSubCell);
PxPosition = Util.CenterOfCell(fromCell) + Info.SubCellOffsets[fromSubCell];
FinishedMoving(self);
}
public void SetPxPosition(Actor self, int2 px)
{
var cell = Util.CellContaining(px);
SetLocation(cell,fromSubCell, cell,fromSubCell);
PxPosition = px;
FinishedMoving(self);
}
public void SetPxPosition(Actor self, int2 px)
{
var cell = Util.CellContaining(px);
SetLocation(cell,fromSubCell, cell,fromSubCell);
PxPosition = px;
FinishedMoving(self);
}
public void AdjustPxPosition(Actor self, int2 px) /* visual hack only */
{
PxPosition = px;
}
public IEnumerable<IOrderTargeter> Orders { get { yield return new MoveOrderTargeter(Info); } }
public IEnumerable<IOrderTargeter> Orders { get { yield return new MoveOrderTargeter(Info); } }
// Note: Returns a valid order even if the unit can't move to the target
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
{
if (order is MoveOrderTargeter)
{
if (Info.OnRails) return null;
return new Order("Move", self, queued) { TargetLocation = Util.CellContaining(target.CenterLocation) };
}
return null;
}
// Note: Returns a valid order even if the unit can't move to the target
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
{
if (order is MoveOrderTargeter)
{
if (Info.OnRails) return null;
return new Order("Move", self, queued) { TargetLocation = Util.CellContaining(target.CenterLocation) };
}
return null;
}
public int2 NearestMoveableCell(int2 target)
{
if (CanEnterCell(target))
return target;
public int2 NearestMoveableCell(int2 target)
{
if (CanEnterCell(target))
return target;
var searched = new List<int2>() { };
// Limit search to a radius of 10 tiles
for (int r = 1; r < 10; r++)
foreach (var tile in self.World.FindTilesInCircle(target, r).Except(searched))
{
if (CanEnterCell(tile))
return tile;
var searched = new List<int2>() { };
// Limit search to a radius of 10 tiles
for (int r = 1; r < 10; r++)
foreach (var tile in self.World.FindTilesInCircle(target, r).Except(searched))
{
if (CanEnterCell(tile))
return tile;
searched.Add(tile);
}
searched.Add(tile);
}
// Couldn't find a cell
return target;
}
// Couldn't find a cell
return target;
}
void PerformMoveInner(Actor self, int2 targetLocation, bool queued)
{
int2 currentLocation = NearestMoveableCell(targetLocation);
if (!CanEnterCell(currentLocation))
{
if (queued) self.CancelActivity();
return;
}
if (!CanEnterCell(currentLocation))
{
if (queued) self.CancelActivity();
return;
}
if (!queued) self.CancelActivity();
if (!queued) self.CancelActivity();
ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing);
ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing);
self.QueueActivity(new Move(currentLocation, 8));
self.QueueActivity(new Move(currentLocation, 8));
self.SetTargetLine(Target.FromCell(currentLocation), Color.Green);
self.SetTargetLine(Target.FromCell(currentLocation), Color.Green);
}
protected void PerformMove(Actor self, int2 targetLocation, bool queued)
{
if (queued)
protected void PerformMove(Actor self, int2 targetLocation, bool queued)
{
if (queued)
self.QueueActivity(new CallFunc(() => PerformMoveInner(self, targetLocation, queued)));
else
PerformMoveInner(self, targetLocation, queued);
}
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Move")
PerformMove(self, self.World.ClampToWorld(order.TargetLocation),
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Move")
PerformMove(self, self.World.ClampToWorld(order.TargetLocation),
order.Queued && !self.IsIdle);
if (order.OrderString == "Stop")
self.CancelActivity();
if (order.OrderString == "Stop")
self.CancelActivity();
if (order.OrderString == "Scatter")
OnNudge(self, self, true);
}
OnNudge(self, self, true);
}
public string VoicePhraseForOrder(Actor self, Order order)
{
public string VoicePhraseForOrder(Actor self, Order order)
{
switch( order.OrderString )
{
case "Move":
@@ -279,13 +279,13 @@ namespace OpenRA.Mods.RA.Move
default:
return null;
}
}
}
public int2 TopLeft { get { return toCell; } }
public int2 TopLeft { get { return toCell; } }
public IEnumerable<Pair<int2, SubCell>> OccupiedCells()
{
if (fromCell == toCell)
public IEnumerable<Pair<int2, SubCell>> OccupiedCells()
{
if (fromCell == toCell)
yield return Pair.New(fromCell, fromSubCell);
else if (CanEnterCell(toCell))
yield return Pair.New(toCell, toSubCell);
@@ -294,7 +294,7 @@ namespace OpenRA.Mods.RA.Move
yield return Pair.New(fromCell, fromSubCell);
yield return Pair.New(toCell, toSubCell);
}
}
}
public SubCell GetDesiredSubcell(int2 a, Actor ignoreActor)
{
@@ -307,152 +307,152 @@ namespace OpenRA.Mods.RA.Move
{
var blockingActors = self.World.ActorMap.GetUnitsAt(a,b).Where(c => c != ignoreActor);
if (blockingActors.Count() > 0)
{
// Non-sharable unit can enter a cell with shareable units only if it can crush all of them
if (Info.Crushes == null)
return false;
{
// Non-sharable unit can enter a cell with shareable units only if it can crush all of them
if (Info.Crushes == null)
return false;
if (blockingActors.Any(c => !(c.HasTrait<ICrushable>() &&
c.TraitsImplementing<ICrushable>().Any(d => d.CrushableBy(Info.Crushes, self.Owner)))))
return false;
}
c.TraitsImplementing<ICrushable>().Any(d => d.CrushableBy(Info.Crushes, self.Owner)))))
return false;
}
return true;
});
}
public bool CanEnterCell(int2 p)
{
return CanEnterCell(p, null, true);
}
public bool CanEnterCell(int2 p)
{
return CanEnterCell(p, null, true);
}
public bool CanEnterCell(int2 cell, Actor ignoreActor, bool checkTransientActors)
{
return Info.CanEnterCell(self.World, self.Owner, cell, ignoreActor, checkTransientActors);
}
public bool CanEnterCell(int2 cell, Actor ignoreActor, bool checkTransientActors)
{
return Info.CanEnterCell(self.World, self.Owner, cell, ignoreActor, checkTransientActors);
}
public void EnteringCell(Actor self)
{
var crushable = self.World.ActorMap.GetUnitsAt(toCell).Where(a => a != self && a.HasTrait<ICrushable>());
foreach (var a in crushable)
{
foreach (var a in crushable)
{
var crushActions = a.TraitsImplementing<ICrushable>().Where(b => b.CrushableBy(Info.Crushes, self.Owner));
foreach (var b in crushActions)
foreach (var b in crushActions)
b.WarnCrush(self);
}
}
public void FinishedMoving(Actor self)
{
var crushable = self.World.ActorMap.GetUnitsAt(toCell).Where(a => a != self && a.HasTrait<ICrushable>());
foreach (var a in crushable)
{
var crushActions = a.TraitsImplementing<ICrushable>().Where(b => b.CrushableBy(Info.Crushes, self.Owner));
foreach (var b in crushActions)
b.OnCrush(self);
}
}
public void FinishedMoving(Actor self)
{
var crushable = self.World.ActorMap.GetUnitsAt(toCell).Where(a => a != self && a.HasTrait<ICrushable>());
foreach (var a in crushable)
{
var crushActions = a.TraitsImplementing<ICrushable>().Where(b => b.CrushableBy(Info.Crushes, self.Owner));
foreach (var b in crushActions)
b.OnCrush(self);
}
}
public int MovementSpeedForCell(Actor self, int2 cell)
{
var type = self.World.GetTerrainType(cell);
public int MovementSpeedForCell(Actor self, int2 cell)
{
var type = self.World.GetTerrainType(cell);
if (!Info.TerrainSpeeds.ContainsKey(type))
return 0;
if (!Info.TerrainSpeeds.ContainsKey(type))
return 0;
decimal speed = Info.Speed * Info.TerrainSpeeds[type].Speed;
foreach (var t in self.TraitsImplementing<ISpeedModifier>())
speed *= t.GetSpeedModifier();
return (int)(speed / 100);
}
decimal speed = Info.Speed * Info.TerrainSpeeds[type].Speed;
foreach (var t in self.TraitsImplementing<ISpeedModifier>())
speed *= t.GetSpeedModifier();
return (int)(speed / 100);
}
public void AddInfluence()
{
if (self.IsInWorld)
self.World.ActorMap.Add(self, this);
}
public void AddInfluence()
{
if (self.IsInWorld)
self.World.ActorMap.Add(self, this);
}
public void RemoveInfluence()
{
if (self.IsInWorld)
self.World.ActorMap.Remove(self, this);
}
public void RemoveInfluence()
{
if (self.IsInWorld)
self.World.ActorMap.Remove(self, this);
}
public void OnNudge(Actor self, Actor nudger, bool force)
{
/* initial fairly braindead implementation. */
if (!force && self.Owner.Stances[nudger.Owner] != Stance.Ally)
return; /* don't allow ourselves to be pushed around
public void OnNudge(Actor self, Actor nudger, bool force)
{
/* initial fairly braindead implementation. */
if (!force && self.Owner.Stances[nudger.Owner] != Stance.Ally)
return; /* don't allow ourselves to be pushed around
* by the enemy! */
if (!force && !self.IsIdle)
return; /* don't nudge if we're busy doing something! */
if (!force && !self.IsIdle)
return; /* don't nudge if we're busy doing something! */
// pick an adjacent available cell.
var availCells = new List<int2>();
var notStupidCells = new List<int2>();
// pick an adjacent available cell.
var availCells = new List<int2>();
var notStupidCells = new List<int2>();
for (var i = -1; i < 2; i++)
for (var j = -1; j < 2; j++)
{
var p = toCell + new int2(i, j);
if (CanEnterCell(p))
availCells.Add(p);
else
if (p != nudger.Location && p != toCell)
notStupidCells.Add(p);
}
for (var i = -1; i < 2; i++)
for (var j = -1; j < 2; j++)
{
var p = toCell + new int2(i, j);
if (CanEnterCell(p))
availCells.Add(p);
else
if (p != nudger.Location && p != toCell)
notStupidCells.Add(p);
}
var moveTo = availCells.Any() ? availCells.Random(self.World.SharedRandom) :
notStupidCells.Any() ? notStupidCells.Random(self.World.SharedRandom) : (int2?)null;
var moveTo = availCells.Any() ? availCells.Random(self.World.SharedRandom) :
notStupidCells.Any() ? notStupidCells.Random(self.World.SharedRandom) : (int2?)null;
if (moveTo.HasValue)
{
self.CancelActivity();
self.SetTargetLine(Target.FromCell(moveTo.Value), Color.Green, false);
self.QueueActivity(new Move(moveTo.Value, 0));
if (moveTo.HasValue)
{
self.CancelActivity();
self.SetTargetLine(Target.FromCell(moveTo.Value), Color.Green, false);
self.QueueActivity(new Move(moveTo.Value, 0));
Log.Write("debug", "OnNudge #{0} from {1} to {2}",
self.ActorID, self.Location, moveTo.Value);
}
else
Log.Write("debug", "OnNudge #{0} refuses at {1}",
self.ActorID, self.Location);
}
Log.Write("debug", "OnNudge #{0} from {1} to {2}",
self.ActorID, self.Location, moveTo.Value);
}
else
Log.Write("debug", "OnNudge #{0} refuses at {1}",
self.ActorID, self.Location);
}
class MoveOrderTargeter : IOrderTargeter
{
readonly MobileInfo unitType;
class MoveOrderTargeter : IOrderTargeter
{
readonly MobileInfo unitType;
public MoveOrderTargeter(MobileInfo unitType)
{
this.unitType = unitType;
}
public MoveOrderTargeter(MobileInfo unitType)
{
this.unitType = unitType;
}
public string OrderID { get { return "Move"; } }
public int OrderPriority { get { return 4; } }
public bool IsQueued { get; protected set; }
public string OrderID { get { return "Move"; } }
public int OrderPriority { get { return 4; } }
public bool IsQueued { get; protected set; }
public bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor)
{
return false;
}
public bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor)
{
return false;
}
public bool CanTargetLocation(Actor self, int2 location, List<Actor> actorsAtLocation, bool forceAttack, bool forceQueued, ref string cursor)
{
IsQueued = forceQueued;
cursor = "move";
if (!self.World.Map.IsInMap(location) || (self.World.LocalPlayer.Shroud.IsExplored(location) &&
unitType.MovementCostForCell(self.World, location) == int.MaxValue))
cursor = "move-blocked";
public bool CanTargetLocation(Actor self, int2 location, List<Actor> actorsAtLocation, bool forceAttack, bool forceQueued, ref string cursor)
{
IsQueued = forceQueued;
cursor = "move";
if (!self.World.Map.IsInMap(location) || (self.World.LocalPlayer.Shroud.IsExplored(location) &&
unitType.MovementCostForCell(self.World, location) == int.MaxValue))
cursor = "move-blocked";
return true;
}
}
return true;
}
}
public Activity ScriptedMove(int2 cell) { return new Move(cell); }
public Activity MoveTo(int2 cell, int nearEnough) { return new Move(cell, nearEnough); }
public Activity MoveTo(int2 cell, Actor ignoredActor) { return new Move(cell, ignoredActor); }
public Activity MoveWithinRange(Target target, int range) { return new Move(target, range); }
public Activity MoveTo(Func<List<int2>> pathFunc) { return new Move(pathFunc); }
}
public Activity ScriptedMove(int2 cell) { return new Move(cell); }
public Activity MoveTo(int2 cell, int nearEnough) { return new Move(cell, nearEnough); }
public Activity MoveTo(int2 cell, Actor ignoredActor) { return new Move(cell, ignoredActor); }
public Activity MoveWithinRange(Target target, int range) { return new Move(target, range); }
public Activity MoveTo(Func<List<int2>> pathFunc) { return new Move(pathFunc); }
}
}

View File

@@ -74,12 +74,12 @@ namespace OpenRA.Mods.RA.Move
var tilesInRange = world.FindTilesInCircle(target, range)
.Where( t => mi.CanEnterCell(self.World, self.Owner, t, null, true));
var path = FindBidiPath(
PathSearch.FromPoints(world, mi, self.Owner, tilesInRange, src, true),
PathSearch.FromPoint(world, mi, self.Owner, src, target, true)
.InReverse());
var path = FindBidiPath(
PathSearch.FromPoints(world, mi, self.Owner, tilesInRange, src, true),
PathSearch.FromPoint(world, mi, self.Owner, src, target, true)
.InReverse());
return path;
return path;
}
}

View File

@@ -216,7 +216,7 @@ namespace OpenRA.Mods.RA.Move
if (cellInfo.GetUpperBound(0) != world.Map.MapSize.X - 1 ||
cellInfo.GetUpperBound(1) != world.Map.MapSize.Y - 1)
{
Log.Write("debug", "Discarding old pooled CellInfo of wrong size.");
Log.Write("debug", "Discarding old pooled CellInfo of wrong size.");
continue;
}

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Orders
{
public class DeployOrderTargeter : IOrderTargeter
public class DeployOrderTargeter : IOrderTargeter
{
readonly Func<bool> useDeployCursor;

View File

@@ -92,8 +92,8 @@ namespace OpenRA.Mods.RA.Orders
{
foreach (var r in Preview)
r.Sprite.DrawAt(Game.CellSize*topLeft + r.Pos,
wr.GetPaletteIndex(r.Palette),
r.Scale*r.Sprite.size);
wr.GetPaletteIndex(r.Palette),
r.Scale*r.Sprite.size);
var res = world.WorldActor.Trait<ResourceLayer>();
var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft);

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Orders
{
var underCursor = world.FindUnitsAtMouse(mi.Location)
.Where(a => a.Owner == world.LocalPlayer
&& a.HasTrait<Sellable>()).FirstOrDefault();
&& a.HasTrait<Sellable>()).FirstOrDefault();
if (underCursor != null)
yield return new Order("Sell", underCursor, false);

View File

@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Orders
{
public class UnitOrderTargeter : IOrderTargeter
public class UnitOrderTargeter : IOrderTargeter
{
readonly string cursor;
readonly bool targetEnemyUnits, targetAllyUnits;
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Orders
public virtual bool IsQueued { get; protected set; }
}
public class UnitTraitOrderTargeter<T> : UnitOrderTargeter
public class UnitTraitOrderTargeter<T> : UnitOrderTargeter
{
public UnitTraitOrderTargeter( string order, int priority, string cursor, bool targetEnemyUnits, bool targetAllyUnits )
: base( order, priority, cursor, targetEnemyUnits, targetAllyUnits )

View File

@@ -63,11 +63,11 @@ namespace OpenRA.Mods.RA
currentDisplayTick = Info.TickRate;
}
public IEnumerable<TraitPair<Harvester>> GetLinkedHarvesters()
{
return self.World.ActorsWithTrait<Harvester>()
.Where(a => a.Trait.LinkedProc == self);
}
public IEnumerable<TraitPair<Harvester>> GetLinkedHarvesters()
{
return self.World.ActorsWithTrait<Harvester>()
.Where(a => a.Trait.LinkedProc == self);
}
public bool CanGiveOre(int amount)
{
@@ -135,9 +135,9 @@ namespace OpenRA.Mods.RA
dockedHarv.ChangeOwner(newOwner);
// Unlink any non-docked harvs
foreach (var harv in GetLinkedHarvesters())
if (harv.Actor.Owner == oldOwner)
harv.Trait.UnlinkProc(harv.Actor, self);
foreach (var harv in GetLinkedHarvesters())
if (harv.Actor.Owner == oldOwner)
harv.Trait.UnlinkProc(harv.Actor, self);
PlayerResources = newOwner.PlayerActor.Trait<PlayerResources>();
}
@@ -145,8 +145,8 @@ namespace OpenRA.Mods.RA
public void Selling(Actor self) { CancelDock(self); }
public void Sold(Actor self)
{
foreach (var harv in GetLinkedHarvesters())
harv.Trait.UnlinkProc(harv.Actor, self);
foreach (var harv in GetLinkedHarvesters())
harv.Trait.UnlinkProc(harv.Actor, self);
}
public bool ShouldExplode(Actor self) { return Ore > 0; }

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
public object Create( ActorInitializer init ) { return new Passenger( this ); }
}
public class Passenger : IIssueOrder, IResolveOrder, IOrderVoice
public class Passenger : IIssueOrder, IResolveOrder, IOrderVoice
{
readonly PassengerInfo info;
public Passenger( PassengerInfo info ) { this.info = info; }

View File

@@ -30,8 +30,8 @@ namespace OpenRA.Mods.RA
public override void Tick( Actor self )
{
isActive = self.World.ActorsWithTrait<Production>()
.Any(x => x.Actor.Owner == self.Owner
&& x.Trait.Info.Produces.Contains(Info.Type));
.Any(x => x.Actor.Owner == self.Owner
&& x.Trait.Info.Produces.Contains(Info.Type));
base.Tick(self);
}
@@ -51,8 +51,8 @@ namespace OpenRA.Mods.RA
{
// Find a production structure to build this actor
var producers = self.World.ActorsWithTrait<Production>()
.Where(x => x.Actor.Owner == self.Owner
&& x.Trait.Info.Produces.Contains(Info.Type))
.Where(x => x.Actor.Owner == self.Owner
&& x.Trait.Info.Produces.Contains(Info.Type))
.OrderByDescending(x => x.Actor.IsPrimaryBuilding() ? 1 : 0 ); // prioritize the primary.
if (producers.Count() == 0)

View File

@@ -31,9 +31,9 @@ namespace OpenRA.Mods.RA
// Find the queue with the target actor
var queue = w.ActorsWithTrait<ProductionQueue>()
.Where(p => p.Actor.Owner == self.Owner &&
p.Trait.CurrentItem() != null &&
p.Trait.CurrentItem().Item == order.TargetString &&
p.Trait.CurrentItem().RemainingTime == 0)
p.Trait.CurrentItem() != null &&
p.Trait.CurrentItem().Item == order.TargetString &&
p.Trait.CurrentItem().RemainingTime == 0)
.Select(p => p.Trait)
.FirstOrDefault();
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.RA
var producers = self.World.ActorsWithTrait<Production>()
.Where( x => x.Actor.Owner == self.Owner
&& x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( bi.Queue ) )
&& x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( bi.Queue ) )
.ToList();
var producer = producers.Where( x => x.Actor.IsPrimaryBuilding() ).Concat( producers )
.FirstOrDefault();

View File

@@ -54,12 +54,12 @@ namespace OpenRA.Mods.RA
return;
}
// THIS IS SHIT
// THIS IS SHIT
// Cancel existing primaries
foreach (var p in self.Info.Traits.Get<ProductionInfo>().Produces)
foreach (var b in self.World
.ActorsWithTrait<PrimaryBuilding>()
.Where(a => a.Actor.Owner == self.Owner)
.Where(a => a.Actor.Owner == self.Owner)
.Where(x => x.Trait.IsPrimary
&& (x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains(p))))
b.Trait.SetPrimaryProducer(b.Actor, false);

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA
{
var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary
{
new OwnerInit( self.Owner ),
new OwnerInit( self.Owner ),
});
var exit = self.Location + exitinfo.ExitCell;
@@ -56,75 +56,75 @@ namespace OpenRA.Mods.RA
// Set the physical position of the unit as the exit cell
teleportable.SetPosition(newUnit,exit);
var to = Util.CenterOfCell(exit);
teleportable.AdjustPxPosition(newUnit, spawn);
teleportable.AdjustPxPosition(newUnit, spawn);
if (facing != null)
facing.Facing = exitinfo.Facing < 0 ? Util.GetFacing(to - spawn, facing.Facing) : exitinfo.Facing;
self.World.Add(newUnit);
var mobile = newUnit.TraitOrDefault<Mobile>();
if (mobile != null)
{
// Animate the spawn -> exit transition
var speed = mobile.MovementSpeedForCell(newUnit, exit);
var length = speed > 0 ? (int)((to - spawn).Length * 3 / speed) : 0;
newUnit.QueueActivity(new Drag(spawn, to, length));
}
var mobile = newUnit.TraitOrDefault<Mobile>();
if (mobile != null)
{
// Animate the spawn -> exit transition
var speed = mobile.MovementSpeedForCell(newUnit, exit);
var length = speed > 0 ? (int)((to - spawn).Length * 3 / speed) : 0;
newUnit.QueueActivity(new Drag(spawn, to, length));
}
var target = MoveToRallyPoint(self, newUnit, exit);
var target = MoveToRallyPoint(self, newUnit, exit);
newUnit.SetTargetLine(Target.FromCell(target), Color.Green, false);
foreach (var t in self.TraitsImplementing<INotifyProduction>())
t.UnitProduced(self, newUnit, exit);
}
static int2 MoveToRallyPoint(Actor self, Actor newUnit, int2 exitLocation)
{
var rp = self.TraitOrDefault<RallyPoint>();
if (rp == null)
return exitLocation;
static int2 MoveToRallyPoint(Actor self, Actor newUnit, int2 exitLocation)
{
var rp = self.TraitOrDefault<RallyPoint>();
if (rp == null)
return exitLocation;
var mobile = newUnit.TraitOrDefault<Mobile>();
if (mobile != null)
{
newUnit.QueueActivity(mobile.MoveTo(rp.rallyPoint, 1));
return rp.rallyPoint;
}
var mobile = newUnit.TraitOrDefault<Mobile>();
if (mobile != null)
{
newUnit.QueueActivity(mobile.MoveTo(rp.rallyPoint, 1));
return rp.rallyPoint;
}
// todo: don't talk about HeliFly here.
var helicopter = newUnit.TraitOrDefault<Helicopter>();
if (helicopter != null)
{
newUnit.QueueActivity(new HeliFly(Util.CenterOfCell(rp.rallyPoint)));
return rp.rallyPoint;
}
// todo: don't talk about HeliFly here.
var helicopter = newUnit.TraitOrDefault<Helicopter>();
if (helicopter != null)
{
newUnit.QueueActivity(new HeliFly(Util.CenterOfCell(rp.rallyPoint)));
return rp.rallyPoint;
}
return exitLocation;
}
return exitLocation;
}
public virtual bool Produce(Actor self, ActorInfo producee)
{
if (Reservable.IsReserved(self))
return false;
public virtual bool Produce(Actor self, ActorInfo producee)
{
if (Reservable.IsReserved(self))
return false;
// pick a spawn/exit point pair
var exit = self.Info.Traits.WithInterface<ExitInfo>().Shuffle(self.World.SharedRandom)
.FirstOrDefault(e => CanUseExit(self, producee, e));
// pick a spawn/exit point pair
var exit = self.Info.Traits.WithInterface<ExitInfo>().Shuffle(self.World.SharedRandom)
.FirstOrDefault(e => CanUseExit(self, producee, e));
if (exit != null)
{
DoProduction(self, producee, exit);
return true;
}
if (exit != null)
{
DoProduction(self, producee, exit);
return true;
}
return false;
}
return false;
}
static bool CanUseExit(Actor self, ActorInfo producee, ExitInfo s)
{
var mobileInfo = producee.Traits.GetOrDefault<MobileInfo>();
static bool CanUseExit(Actor self, ActorInfo producee, ExitInfo s)
{
var mobileInfo = producee.Traits.GetOrDefault<MobileInfo>();
return mobileInfo == null ||
mobileInfo.CanEnterCell(self.World, self.Owner, self.Location + s.ExitCell, self, true);
}
return mobileInfo == null ||
mobileInfo.CanEnterCell(self.World, self.Owner, self.Location + s.ExitCell, self, true);
}
}
}

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA
{
public readonly ProximityCaptorInfo Info;
public ProximityCaptor(ProximityCaptorInfo info) { Info = info; }
public ProximityCaptor(ProximityCaptorInfo info) { Info = info; }
public bool HasAny(string[] typesList)
{

View File

@@ -136,9 +136,9 @@ namespace OpenRA.Mods.RA
return UnitsInRange()
.Where(a => a.Owner != OriginalOwner)
.Where(a => CanBeCapturedBy(a));
}
}
// TODO exclude other NeutralActor that arent permanent
// TODO exclude other NeutralActor that arent permanent
Actor GetInRange(Actor self)
{
return CaptorsInRange(self).ClosestTo( self.CenterLocation );

View File

@@ -27,8 +27,8 @@ namespace OpenRA.Mods.RA.Render
public override IEnumerable<Renderable> RenderPreview(ActorInfo building, Player owner)
{
return base.RenderPreview(building, owner)
.Select(a => a.WithPos(a.Pos + building.Traits.Get<RenderBuildingInfo>().Origin));
return base.RenderPreview(building, owner)
.Select(a => a.WithPos(a.Pos + building.Traits.Get<RenderBuildingInfo>().Origin));
}
}

View File

@@ -19,11 +19,11 @@ namespace OpenRA.Mods.RA.Render
{
public override object Create(ActorInitializer init) { return new RenderBuildingWarFactory( init, this ); }
/* get around unverifiability */
IEnumerable<Renderable> BaseBuildingPreview(ActorInfo building, Player owner)
{
return base.RenderPreview(building, owner);
}
/* get around unverifiability */
IEnumerable<Renderable> BaseBuildingPreview(ActorInfo building, Player owner)
{
return base.RenderPreview(building, owner);
}
public override IEnumerable<Renderable> RenderPreview(ActorInfo building, Player owner)
{
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.RA.Render
{
base.Tick(self);
if (isOpen && !self.World.ActorMap.GetUnitsAt(openExit)
.Any( a => a != self ))
.Any( a => a != self ))
{
isOpen = false;
roof.PlayBackwardsThen(NormalizeSequence(self, "build-top"),

View File

@@ -32,9 +32,9 @@ namespace OpenRA.Mods.RA
ai.Traits.Get<AttackBaseInfo>().GetMaximumRange());
foreach (var a in w.ActorsWithTrait<RenderRangeCircle>())
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
if (a.Actor.Info.Traits.Get<RenderRangeCircleInfo>().RangeCircleType == RangeCircleType)
a.Trait.RenderBeforeWorld(wr, a.Actor);
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
if (a.Actor.Info.Traits.Get<RenderRangeCircleInfo>().RangeCircleType == RangeCircleType)
a.Trait.RenderBeforeWorld(wr, a.Actor);
}
}

View File

@@ -67,7 +67,7 @@ namespace OpenRA.Mods.RA
public void Selling (Actor self) { Sold(self); }
public void Sold (Actor self)
{
if (herp != null)
if (herp != null)
herp.UnReserve();
}
}

View File

@@ -36,10 +36,10 @@ namespace OpenRA.Scripting
var cs = target.Trait<Chronoshiftable>();
if (cs.CanChronoshiftTo(target, targetCell, true))
target.Trait<Chronoshiftable>().Teleport(target,
targetCell,
duration,
killCargo,
chronosphere);
targetCell,
duration,
killCargo,
chronosphere);
}

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Mods.RA.Server
server.lobbyInfo.Clients.Count,
string.Join(",", Game.CurrentMods.Select(f => "{0}@{1}".F(f.Key, f.Value.Version)).ToArray()),
server.lobbyInfo.GlobalSettings.Map,
server.Map.PlayerCount));
server.Map.PlayerCount));
if (isInitialPing)
{

View File

@@ -17,65 +17,65 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class SupplyTruckInfo : ITraitInfo
{
public readonly int Payload = 500;
public object Create(ActorInitializer init) { return new SupplyTruck(this); }
}
class SupplyTruckInfo : ITraitInfo
{
public readonly int Payload = 500;
public object Create(ActorInitializer init) { return new SupplyTruck(this); }
}
class SupplyTruck : IIssueOrder, IResolveOrder, IOrderVoice
{
SupplyTruckInfo Info;
public SupplyTruck(SupplyTruckInfo info)
{
Info = info;
}
class SupplyTruck : IIssueOrder, IResolveOrder, IOrderVoice
{
SupplyTruckInfo Info;
public SupplyTruck(SupplyTruckInfo info)
{
Info = info;
}
public IEnumerable<IOrderTargeter> Orders
{
get { yield return new SupplyTruckOrderTargeter(); }
}
public IEnumerable<IOrderTargeter> Orders
{
get { yield return new SupplyTruckOrderTargeter(); }
}
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
{
if (order.OrderID == "SupplyTruck")
return new Order(order.OrderID, self, queued) { TargetActor = target.Actor };
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
{
if (order.OrderID == "SupplyTruck")
return new Order(order.OrderID, self, queued) { TargetActor = target.Actor };
return null;
}
return null;
}
public string VoicePhraseForOrder(Actor self, Order order)
{
return "Move";
}
public string VoicePhraseForOrder(Actor self, Order order)
{
return "Move";
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "SupplyTruck")
{
self.SetTargetLine(Target.FromOrder(order), Color.Yellow);
self.CancelActivity();
self.QueueActivity(new Enter(order.TargetActor));
self.QueueActivity(new DonateSupplies(order.TargetActor, Info.Payload));
}
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "SupplyTruck")
{
self.SetTargetLine(Target.FromOrder(order), Color.Yellow);
self.CancelActivity();
self.QueueActivity(new Enter(order.TargetActor));
self.QueueActivity(new DonateSupplies(order.TargetActor, Info.Payload));
}
}
class SupplyTruckOrderTargeter : UnitTraitOrderTargeter<Building>
{
public SupplyTruckOrderTargeter()
: base("SupplyTruck", 5, "enter", false, true)
{
}
class SupplyTruckOrderTargeter : UnitTraitOrderTargeter<Building>
{
public SupplyTruckOrderTargeter()
: base("SupplyTruck", 5, "enter", false, true)
{
}
public override bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor)
{
if (!base.CanTargetActor(self, target, forceAttack, forceQueued, ref cursor)) return false;
if (target.AppearsHostileTo(self)) return false;
if (!target.HasTrait<AcceptsSupplies>()) return false;
public override bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor)
{
if (!base.CanTargetActor(self, target, forceAttack, forceQueued, ref cursor)) return false;
if (target.AppearsHostileTo(self)) return false;
if (!target.HasTrait<AcceptsSupplies>()) return false;
IsQueued = forceQueued;
return true;
}
}
}
IsQueued = forceQueued;
return true;
}
}
}
}

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA
{
var info = (Info as AirstrikePowerInfo);
var flare = info.FlareType != null ? w.CreateActor(info.FlareType, new TypeDictionary
{
{
new LocationInit( order.TargetLocation ),
new OwnerInit( self.Owner ),
}) : null;
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA
}
var a = w.CreateActor(info.UnitType, new TypeDictionary
{
{
new LocationInit( startPos ),
new OwnerInit( self.Owner ),
new FacingInit( Util.GetFacing(order.TargetLocation - startPos, 0) ),

View File

@@ -51,11 +51,11 @@ namespace OpenRA.Mods.RA
{
var cs = target.Trait<Chronoshiftable>();
var targetCell = target.Location + order.TargetLocation - order.ExtraLocation;
var cpi = Info as ChronoshiftPowerInfo;
var cpi = Info as ChronoshiftPowerInfo;
if (cs.CanChronoshiftTo(target, targetCell, true))
cs.Teleport(target, targetCell,
cpi.Duration * 25, cpi.KillCargo, self);
cs.Teleport(target, targetCell,
cpi.Duration * 25, cpi.KillCargo, self);
}
}
@@ -87,14 +87,14 @@ namespace OpenRA.Mods.RA
tile = SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0);
}
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
{
world.CancelInputMode();
if (mi.Button == MouseButton.Left)
world.OrderGenerator = new SelectDestination(order, manager, power, xy);
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
{
world.CancelInputMode();
if (mi.Button == MouseButton.Left)
world.OrderGenerator = new SelectDestination(order, manager, power, xy);
yield break;
}
yield break;
}
public void Tick(World world)
{
@@ -206,7 +206,7 @@ namespace OpenRA.Mods.RA
foreach (var r in unit.Render())
r.Sprite.DrawAt(r.Pos - Traits.Util.CenterOfCell(unit.Location) + Traits.Util.CenterOfCell(targetCell),
wr.GetPaletteIndex(r.Palette),
r.Scale*r.Sprite.size);
r.Scale*r.Sprite.size);
}
// Unit tiles

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA
plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w =>
{
var camera = w.CreateActor("camera", new TypeDictionary
{
{
new LocationInit( order.TargetLocation ),
new OwnerInit( self.Owner ),
});

View File

@@ -22,12 +22,12 @@ namespace OpenRA.Mods.RA
public class TargetableSubmarine : TargetableUnit<TargetableSubmarineInfo>
{
public TargetableSubmarine(Actor self, TargetableSubmarineInfo info)
: base(self, info) {}
: base(self, info) {}
public override string[] TargetTypes
{
get { return (Cloak.Cloaked) ? info.CloakedTargetTypes
: info.TargetTypes;}
: info.TargetTypes;}
}
}
}

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.RA.Widgets
.ToDictionary(
u => u.Name,
u => Game.modData.SpriteLoader.LoadAllSprites(
u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);
u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);
}
public override Rectangle EventBounds
@@ -464,7 +464,7 @@ namespace OpenRA.Mods.RA.Widgets
Game.Renderer.Fonts["Bold"].DrawText(
tooltip.Name + ((buildable.Hotkey != null)? " ({0})".F(buildable.Hotkey.ToUpper()) : ""),
p.ToInt2() + new int2(5, 5), Color.White);
p.ToInt2() + new int2(5, 5), Color.White);
var resources = pl.PlayerActor.Trait<PlayerResources>();
var power = pl.PlayerActor.Trait<PowerManager>();
@@ -480,7 +480,7 @@ namespace OpenRA.Mods.RA.Widgets
var bi = info.Traits.GetOrDefault<BuildingInfo>();
if (bi != null)
DrawRightAligned("{1}{0}".F(bi.Power, bi.Power > 0 ? "+" : ""), pos + new int2(-5, 20),
((power.PowerProvided - power.PowerDrained) >= -bi.Power || bi.Power > 0)? Color.White: Color.Red);
((power.PowerProvided - power.PowerDrained) >= -bi.Power || bi.Power > 0)? Color.White: Color.Red);
p += new int2(5, 35);
if (!canBuildThis)
@@ -500,31 +500,31 @@ namespace OpenRA.Mods.RA.Widgets
p.ToInt2(), Color.White);
}
bool DoBuildingHotkey(string key, World world)
{
bool DoBuildingHotkey(string key, World world)
{
if (!paletteOpen) return false;
if (CurrentQueue == null) return false;
var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get<BuildableInfo>().Hotkey == key);
var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get<BuildableInfo>().Hotkey == key);
if ( toBuild != null )
if ( toBuild != null )
{
Sound.Play(TabClick);
HandleBuildPalette(world, toBuild.Name, true);
HandleBuildPalette(world, toBuild.Name, true);
return true;
}
return false;
}
}
void TabChange(bool shift)
{
{
var queues = VisibleQueues.Concat(VisibleQueues);
if (shift) queues.Reverse();
var nextQueue = queues.SkipWhile( q => q != CurrentQueue )
.ElementAtOrDefault(1);
if (nextQueue != null)
SetCurrentTab( nextQueue );
}
}
}
}

View File

@@ -32,14 +32,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
"Connecting to {0}:{1}...".F(host, port);
}
}
}
public class ConnectionFailedLogic
{
[ObjectCreator.UseCtor]
public ConnectionFailedLogic(
[ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] OrderManager orderManager)
[ObjectCreator.Param] OrderManager orderManager)
{
widget.GetWidget<ButtonWidget>("CONNECTION_BUTTON_CANCEL").OnClick = () => {
widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false;

View File

@@ -126,8 +126,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Func<Stance, ScrollItemWidget, ScrollItemWidget> setupItem = (s, template) =>
{
var item = ScrollItemWidget.Setup(template,
() => s == world.LocalPlayer.Stances[ p ],
() => SetStance(dropdown, p, s));
() => s == world.LocalPlayer.Stances[ p ],
() => SetStance(dropdown, p, s));
item.GetWidget<LabelWidget>("LABEL").GetText = () => s.ToString();
return item;

View File

@@ -22,23 +22,23 @@ namespace OpenRA.Mods.RA.Widgets.Logic
dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text = Game.Settings.Player.LastServer;
dc.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () =>
{
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
var addressParts = address.Split(':').ToArray();
if (addressParts.Length < 1 || addressParts.Length > 2)
return;
dc.GetWidget<ButtonWidget>("JOIN_BUTTON").OnClick = () =>
{
var address = dc.GetWidget<TextFieldWidget>("SERVER_ADDRESS").Text;
var addressParts = address.Split(':').ToArray();
if (addressParts.Length < 1 || addressParts.Length > 2)
return;
int port;
if (addressParts.Length != 2 || !int.TryParse(addressParts[1], out port))
port = 1234;
int port;
if (addressParts.Length != 2 || !int.TryParse(addressParts[1], out port))
port = 1234;
Game.Settings.Player.LastServer = address;
Game.Settings.Save();
Game.Settings.Player.LastServer = address;
Game.Settings.Save();
Widget.CloseWindow();
Game.JoinServer(addressParts[0], port);
};
Widget.CloseWindow();
Game.JoinServer(addressParts[0], port);
};
dc.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
{

View File

@@ -30,14 +30,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
string MapUid;
Map Map;
public static ColorRamp CurrentColorPreview;
public static ColorRamp CurrentColorPreview;
readonly OrderManager orderManager;
readonly WorldRenderer worldRenderer;
[ObjectCreator.UseCtor]
internal LobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby,
[ObjectCreator.Param] OrderManager orderManager,
[ObjectCreator.Param] WorldRenderer worldRenderer)
[ObjectCreator.Param] OrderManager orderManager,
[ObjectCreator.Param] WorldRenderer worldRenderer)
{
this.orderManager = orderManager;
this.worldRenderer = worldRenderer;
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
var map = mapPreview.Map();
if (map == null || mi.Button != MouseButton.Left
|| orderManager.LocalClient.State == Session.ClientState.Ready)
|| orderManager.LocalClient.State == Session.ClientState.Ready)
return;
var p = map.SpawnPoints
@@ -208,7 +208,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
void UpdateColorPreview(float hf, float sf, float lf, float r)
{
CurrentColorPreview = new ColorRamp((byte)(hf * 255), (byte)(sf * 255), (byte)(lf * 255), (byte)(r * 255));
CurrentColorPreview = new ColorRamp((byte)(hf * 255), (byte)(sf * 255), (byte)(lf * 255), (byte)(r * 255));
}
void UpdateCurrentMap()

View File

@@ -29,8 +29,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
[ObjectCreator.UseCtor]
public RADownloadPackagesLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Dictionary<string,string> installData,
[ObjectCreator.Param] Action continueLoading)
[ObjectCreator.Param] Dictionary<string,string> installData,
[ObjectCreator.Param] Action continueLoading)
{
this.installData = installData;
this.continueLoading = continueLoading;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
[ObjectCreator.UseCtor]
public RAInstallFromCDLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Action continueLoading)
[ObjectCreator.Param] Action continueLoading)
{
this.continueLoading = continueLoading;
panel = widget.GetWidget("INSTALL_FROMCD_PANEL");
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
return;
if (!InstallUtils.ExtractFromPackage(source, extractPackage, extractFiles, dest, onProgress, onError))
return;
return;
Game.RunAfterTick(() =>
{

View File

@@ -18,12 +18,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
[ObjectCreator.UseCtor]
public RAInstallLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Dictionary<string,string> installData,
[ObjectCreator.Param] Action continueLoading)
[ObjectCreator.Param] Dictionary<string,string> installData,
[ObjectCreator.Param] Action continueLoading)
{
var panel = widget.GetWidget("INSTALL_PANEL");
var args = new WidgetArgs()
{
{
{ "continueLoading", () => { Widget.CloseWindow(); continueLoading(); } },
{ "installData", installData }
};

View File

@@ -85,8 +85,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
void AddReplay(ScrollPanelWidget list, string filename, ScrollItemWidget template)
{
var item = ScrollItemWidget.Setup(template,
() => CurrentReplay == filename,
() => CurrentReplay = filename);
() => CurrentReplay == filename,
() => CurrentReplay = filename);
var f = Path.GetFileName(filename);
item.GetWidget<LabelWidget>("TITLE").GetText = () => f;
list.AddChild(item);

View File

@@ -88,8 +88,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
return string.Join("\n", s.UsefulMods
.Select(m =>
Mod.AllMods.ContainsKey(m.Key) ? string.Format("{0} ({1})", Mod.AllMods[m.Key].Title, m.Value)
: string.Format("Unknown Mod: {0}",m.Key)).ToArray());
Mod.AllMods.ContainsKey(m.Key) ? string.Format("{0} ({1})", Mod.AllMods[m.Key].Title, m.Value)
: string.Format("Unknown Mod: {0}",m.Key)).ToArray());
}
void RefreshServerList(IEnumerable<GameServer> games)
@@ -97,8 +97,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var r = Widget.RootWidget;
var bg = r.GetWidget("JOINSERVER_BG");
if (bg == null) // We got a MasterServer reply AFTER the browser is gone, just return to prevent crash - Gecko
return;
if (bg == null) // We got a MasterServer reply AFTER the browser is gone, just return to prevent crash - Gecko
return;
var sl = bg.GetWidget<ScrollPanelWidget>("SERVER_LIST");
@@ -112,9 +112,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
return;
}
var gamesWaiting = games.Where(g => g.CanJoin());
var gamesWaiting = games.Where(g => g.CanJoin());
if (gamesWaiting.Count() == 0)
if (gamesWaiting.Count() == 0)
{
r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true;
r.GetWidget<LabelWidget>("JOINSERVER_PROGRESS_TITLE").Text = "No games found.";

View File

@@ -46,15 +46,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
else
Game.Settings.Player.Name = name.Text;
};
name.OnEnterKey = () => { name.LoseFocus(); return true; };
name.OnEnterKey = () => { name.LoseFocus(); return true; };
var edgescrollCheckbox = general.GetWidget<CheckboxWidget>("EDGE_SCROLL");
edgescrollCheckbox.IsChecked = () => Game.Settings.Game.ViewportEdgeScroll;
edgescrollCheckbox.OnClick = () => Game.Settings.Game.ViewportEdgeScroll ^= true;
var edgeScrollSlider = general.GetWidget<SliderWidget>("EDGE_SCROLL_AMOUNT");
var edgeScrollSlider = general.GetWidget<SliderWidget>("EDGE_SCROLL_AMOUNT");
edgeScrollSlider.Value = Game.Settings.Game.ViewportEdgeScrollStep;
edgeScrollSlider.OnChange += x => Game.Settings.Game.ViewportEdgeScrollStep = x;
edgeScrollSlider.OnChange += x => Game.Settings.Game.ViewportEdgeScrollStep = x;
var inversescroll = general.GetWidget<CheckboxWidget>("INVERSE_SCROLL");
inversescroll.IsChecked = () => Game.Settings.Game.MouseScroll == MouseScrollType.Inverted;

View File

@@ -166,9 +166,9 @@ namespace OpenRA.Mods.RA.Widgets
int updateTicks = 0;
public override void Tick()
{
var hasRadarNew = world
.ActorsWithTrait<ProvidesRadar>()
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
var hasRadarNew = world
.ActorsWithTrait<ProvidesRadar>()
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
if (hasRadarNew != hasRadar)
radarAnimating = true;

View File

@@ -53,12 +53,12 @@ namespace OpenRA.Mods.RA.Widgets
if (e.Modifiers == Modifiers.None && e.Event == KeyInputEvent.Down)
{
if (e.KeyName == BaseCycleKey)
return CycleBases();
return CycleBases();
if (!World.Selection.Actors.Any())
return false;
if (e.KeyName == AttackMoveKey)
if (e.KeyName == AttackMoveKey)
return PerformAttackMove();
if (e.KeyName == StopKey)
@@ -142,24 +142,24 @@ namespace OpenRA.Mods.RA.Widgets
return true;
}
bool CycleBases()
{
var bases = World.ActorsWithTrait<BaseBuilding>()
.Where( a => a.Actor.Owner == World.LocalPlayer ).ToArray();
if (!bases.Any()) return true;
bool CycleBases()
{
var bases = World.ActorsWithTrait<BaseBuilding>()
.Where( a => a.Actor.Owner == World.LocalPlayer ).ToArray();
if (!bases.Any()) return true;
var next = bases
.Select(b => b.Actor)
.SkipWhile(b => !World.Selection.Actors.Contains(b))
.Skip(1)
.FirstOrDefault();
var next = bases
.Select(b => b.Actor)
.SkipWhile(b => !World.Selection.Actors.Contains(b))
.Skip(1)
.FirstOrDefault();
if (next == null)
next = bases.Select(b => b.Actor).First();
if (next == null)
next = bases.Select(b => b.Actor).First();
World.Selection.Combine(World, new Actor[] { next }, false, true);
Game.viewport.Center(World.Selection.Actors);
return true;
}
World.Selection.Combine(World, new Actor[] { next }, false, true);
Game.viewport.Center(World.Selection.Actors);
return true;
}
}
}

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Widgets
var nameText = itt.Name();
var ownerText = !owner.NonCombatant ? owner.PlayerName : "";
var stanceText = (world.LocalPlayer != null && owner != actor.World.LocalPlayer
&& !owner.NonCombatant) ? " ({0})".F(itt.Stance()) : "";
&& !owner.NonCombatant) ? " ({0})".F(itt.Stance()) : "";
var nameSize = Game.Renderer.Fonts["Bold"].Measure(nameText);
var ownerSize = Game.Renderer.Fonts["Regular"].Measure(ownerText);

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA
var onComplete = Info.Loop ? (Action)PlayMusic : () => {};
if (Game.Settings.Sound.ShellmapMusic &&
Rules.Music.ContainsKey(Info.Music))
Rules.Music.ContainsKey(Info.Music))
Sound.PlayMusicThen(Rules.Music[Info.Music], onComplete);
}
}

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA
// Add map smudges
foreach (var s in w.Map.Smudges.Value.Where( s => Info.Types.Contains(s.Type )))
tiles.Add(s.Location,new TileReference<byte,byte>((byte)Array.IndexOf(Info.Types,s.Type),
(byte)s.Depth));
(byte)s.Depth));
}
public void AddSmudge(int2 loc)