fix trailing whitespace everywhere

This commit is contained in:
Chris Forbes
2011-09-25 14:37:12 +13:00
parent 0eb98ef3b5
commit 55036cd58c
596 changed files with 3194 additions and 3194 deletions

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Activities
Target = target;
if (target.IsActor)
targetable = target.Actor.TraitOrDefault<ITargetable>();
Range = range;
AllowMovement = allowMovement;
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Activities
this.a = a;
this.interruptable = interruptable;
}
Action a;
bool interruptable;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Activities
if (IsCanceled) return NextActivity;
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
if (target.Owner == self.Owner) return NextActivity;
if( !target.OccupiesSpace.OccupiedCells().Any( x => x.First == self.Location ) )
return NextActivity;
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Activities
w.Remove(target);
target.Owner = self.Owner;
w.Add(target);
foreach (var t in target.TraitsImplementing<INotifyCapture>())
t.OnCapture(target, self, oldOwner, self.Owner);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Activities
var proc = harv.LinkedProc;
var iao = proc.Trait<IAcceptOre>();
self.SetTargetLine(Target.FromActor(proc), Color.Green, false);
if( self.Location != proc.Location + iao.DeliverOffset )
return Util.SequenceActivities( mobile.MoveTo(proc.Location + iao.DeliverOffset, 0), this );
@@ -48,10 +48,10 @@ namespace OpenRA.Mods.RA.Activities
isDocking = true;
iao.OnDock(self, this);
}
return Util.SequenceActivities( new Wait(10), this );
}
// Cannot be cancelled
public override void Cancel(Actor self) { }
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Activities
{
Actor target;
int delay;
public Demolish( Actor target, int delay )
{
this.target = target;
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Activities
{
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;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -20,8 +20,8 @@ namespace OpenRA.Mods.RA.Activities
Actor target;
int payload;
public DonateSupplies(Actor target, int payload)
{
public DonateSupplies(Actor target, int payload)
{
this.target = target;
this.payload = payload;
}
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Activities
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();
if (self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -30,13 +30,13 @@ namespace OpenRA.Mods.RA.Activities
var cargo = transport.Trait<Cargo>();
if (!cargo.HasSpace(1))
return NextActivity;
// Todo: Queue a move order to the transport? need to be
// careful about units that can't path to the transport
if ((transport.Location - self.Location).LengthSquared > 2)
return NextActivity;
cargo.Load(transport, self);
self.World.AddFrameEndTask(w => w.Remove(self));

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Activities
{
if (Target.IsActor && Target.Actor.GetDamageState() == DamageState.Undamaged)
return NextActivity;
return base.InnerTick(self, attack);
}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -22,14 +22,14 @@ namespace OpenRA.Mods.RA.Activities
readonly bool Reversed;
readonly Action OnComplete;
RenderBuilding rb;
public MakeAnimation(Actor self, Action onComplete) : this(self, false, onComplete) {}
public MakeAnimation(Actor self, bool reversed, Action onComplete)
{
Reversed = reversed;
OnComplete = onComplete;
}
bool complete = false;
bool started = false;
public override Activity Tick( Actor self )
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Activities
return this;
}
// Cannot be cancelled
public override void Cancel( Actor self ) { }
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
Undock,
Complete
};
readonly Actor proc;
readonly Harvester harv;
readonly RenderUnit ru;
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA
harv = self.Trait<Harvester>();
ru = self.Trait<RenderUnit>();
}
public override Activity Tick(Actor self)
{
switch (state)

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -13,7 +13,7 @@ using OpenRA.Traits;
using OpenRA.Mods.RA.Effects;
using OpenRA.Traits.Activities;
using OpenRA.Mods.RA.Buildings;
namespace OpenRA.Mods.RA.Activities
{
class Sell : Activity
@@ -23,21 +23,21 @@ namespace OpenRA.Mods.RA.Activities
var h = self.TraitOrDefault<Health>();
var si = self.Info.Traits.Get<SellableInfo>();
var pr = self.Owner.PlayerActor.Trait<PlayerResources>();
var cost = self.GetSellValue();
var refund = (cost * si.RefundPercent * (h == null ? 1 : h.HP)) / (100 * (h == null ? 1 : h.MaxHP));
var refund = (cost * si.RefundPercent * (h == null ? 1 : h.HP)) / (100 * (h == null ? 1 : h.MaxHP));
pr.GiveCash(refund);
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(
w => w.Add(new CashTick(refund, 30, 2,
self.CenterLocation,
w => w.Add(new CashTick(refund, 30, 2,
self.CenterLocation,
self.Owner.ColorRamp.GetColor(0))));
self.Destroy();
return this;
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Activities
public int Facing = 96;
public string[] Sounds = {};
public int ForceHealthPercentage = 0;
public Transform(Actor self, string toActor)
{
this.ToActor = toActor;
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Activities
public override Activity Tick( Actor self )
{
if (IsCanceled) return NextActivity;
self.World.AddFrameEndTask(w =>
{
var selected = w.Selection.Contains(self);
@@ -57,11 +57,11 @@ namespace OpenRA.Mods.RA.Activities
init.Add( new HealthInit( (float)health.HP / health.MaxHP ));
}
var a = w.CreateActor( ToActor, init );
if (selected)
w.Selection.Add(w, a);
});
return this;
}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -24,12 +24,12 @@ namespace OpenRA.Mods.RA.Activities
// is anyone still hogging this tile?
if (self.World.ActorMap.GetUnitsAt(self.Location).Count() > 1)
return null;
var mobile = cargo.Trait<Mobile>();
for (var i = -1; i < 2; i++)
for (var j = -1; j < 2; j++)
if ((i != 0 || j != 0) &&
if ((i != 0 || j != 0) &&
mobile.CanEnterCell(self.Location + new int2(i, j)))
return self.Location + new int2(i, j);
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA.Activities
ru.PlayCustomAnimation(self, "unload", null);
var exitTile = ChooseExitTile(self, cargo.Peek(self));
if (exitTile == null)
if (exitTile == null)
return this;
var actor = cargo.Unload(self);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Activities
remainingTicks = period;
this.interruptable = interruptable;
}
public override Activity Tick(Actor self)
{
return (remainingTicks-- == 0) ? NextActivity: this;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -20,25 +20,25 @@ namespace OpenRA.Mods.RA
var spy = a.TraitOrDefault<Spy>();
return spy != null && spy.Disguised;
}
public static bool AppearsFriendlyTo(this Actor self, Actor toActor)
public static bool AppearsFriendlyTo(this Actor self, Actor toActor)
{
var stance = toActor.Owner.Stances[ self.Owner ];
if (stance == Stance.Ally)
return true;
if (self.IsDisguisedSpy() && !toActor.HasTrait<IgnoresDisguise>())
return toActor.Owner.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Ally;
return stance == Stance.Ally;
}
public static bool AppearsHostileTo(this Actor self, Actor toActor)
{
public static bool AppearsHostileTo(this Actor self, Actor toActor)
{
var stance = toActor.Owner.Stances[ self.Owner ];
if (stance == Stance.Ally)
return false; /* otherwise, we'll hate friendly disguised spies */
if (self.IsDisguisedSpy() && !toActor.HasTrait<IgnoresDisguise>())
return toActor.Owner.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Enemy;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
{
Info = info;
}
public void Killed(Actor self, AttackInfo e)
{
var player = (Info.NotifyAll) ? self.World.LocalPlayer : self.Owner;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Air
public DebugAircraftFacing(Actor self){ a = self.Trait<Aircraft>(); }
[Sync] public int foo { get { return a.Facing; } }
}
public class DebugAircraftSubPxXInfo : ITraitInfo, Requires<AircraftInfo>
{
public object Create(ActorInitializer init) { return new DebugAircraftSubPxX(init.self); }
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Air
public DebugAircraftSubPxX(Actor self){ a = self.Trait<Aircraft>(); }
[Sync] public int foo { get { return a.SubPxPosition.Y; } }
}
public class DebugAircraftSubPxYInfo : ITraitInfo, Requires<AircraftInfo>
{
public object Create(ActorInitializer init) { return new DebugAircraftSubPxY(init.self); }
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Air
public DebugAircraftSubPxY(Actor self){ a = self.Trait<Aircraft>(); }
[Sync] public int foo { get { return a.SubPxPosition.Y; } }
}
public class DebugAircraftAltitudeInfo : ITraitInfo, Requires<AircraftInfo>
{
public object Create(ActorInitializer init) { return new DebugAircraftAltitude(init.self); }
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.RA.Air
public DebugAircraftAltitude(Actor self){ a = self.Trait<Aircraft>(); }
[Sync] public int foo { get { return a.Altitude; } }
}
public class AircraftInfo : ITraitInfo, IFacingInfo
{
public readonly int CruiseAltitude = 30;
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA.Air
public class Aircraft : IMove, IFacing, IOccupySpace, ISync, INotifyKilled, IIssueOrder, IOrderVoice
{
public IDisposable reservation;
public void UnReserve()
{
if (reservation != null)
@@ -94,13 +94,13 @@ namespace OpenRA.Mods.RA.Air
reservation = null;
}
}
public void Killed(Actor self, AttackInfo e)
{
UnReserve();
}
protected readonly Actor self;
[Sync]
public int Facing { get; set; }
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.RA.Air
this.self = init.self;
if( init.Contains<LocationInit>() )
this.SubPxPosition = 1024 * Util.CenterOfCell( init.Get<LocationInit, int2>() );
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;
Info = info;
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.RA.Air
}
public int ROT { get { return Info.ROT; } }
public int InitialFacing { get { return Info.InitialFacing; } }
public void SetPosition(Actor self, int2 cell)
@@ -176,7 +176,7 @@ namespace OpenRA.Mods.RA.Air
return (int)ret;
}
}
Pair<int2, SubCell>[] noCells = new Pair<int2, SubCell>[] { };
public IEnumerable<Pair<int2, SubCell>> OccupiedCells() { return noCells; }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Air
protected override bool CanAttack(Actor self, Target target)
{
// dont fire while landed
return base.CanAttack(self, target)
return base.CanAttack(self, target)
&& self.Trait<Aircraft>().Altitude > 0;
}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
public void Killed(Actor self, AttackInfo e)
{
var info = self.Info.Traits.Get<EjectOnDeathInfo>();
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(),
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(),
new TypeDictionary { new OwnerInit(self.Owner) });
var r = self.World.SharedRandom.Next(1, 100);
var aircraft = self.Trait<IMove>();

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Air
public readonly int2 Pos;
Fly( int2 px ) { Pos = px; }
public static Fly ToPx( int2 px ) { return new Fly( px ); }
public static Fly ToCell( int2 pos ) { return new Fly( Util.CenterOfCell( pos ) ); }

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Air
var reloads = self.TraitOrDefault<Reloads>();
if (limitedAmmo != null && !limitedAmmo.HasAmmo() && reloads == null)
return Util.SequenceActivities( new HeliReturn(), NextActivity );
var aircraft = self.Trait<Aircraft>();
var info = self.Info.Traits.Get<HelicopterInfo>();
if (aircraft.Altitude != info.CruiseAltitude)

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Air
aircraft.Altitude += Math.Sign(info.CruiseAltitude - aircraft.Altitude);
return this;
}
var dist = Dest - aircraft.PxPosition;
if (float2.WithinEpsilon(float2.Zero, dist, 2))
{

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Air
if (requireSpace && !aircraft.CanLand(self.Location))
return this;
--aircraft.Altitude;
return this;
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Air
if (dest == null)
return Util.SequenceActivities(
new Turn(initialFacing),
new Turn(initialFacing),
new HeliLand(true),
NextActivity);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -28,11 +28,11 @@ namespace OpenRA.Mods.RA.Air
HelicopterInfo Info;
bool firstTick = true;
public Helicopter( ActorInitializer init, HelicopterInfo info) : base( init, info )
public Helicopter( ActorInitializer init, HelicopterInfo info) : base( init, info )
{
Info = info;
}
public void ResolveOrder(Actor self, Order order)
{
if (reservation != null)
@@ -44,11 +44,11 @@ namespace OpenRA.Mods.RA.Air
if (order.OrderString == "Move")
{
var target = self.World.ClampToWorld(order.TargetLocation);
self.SetTargetLine(Target.FromCell(target), Color.Green);
self.CancelActivity();
self.QueueActivity(new HeliFly(Util.CenterOfCell(target)));
if (Info.LandWhenIdle)
{
self.QueueActivity(new Turn(Info.InitialFacing));
@@ -65,9 +65,9 @@ namespace OpenRA.Mods.RA.Air
var exit = order.TargetActor.Info.Traits.WithInterface<ExitInfo>().FirstOrDefault();
var offset = exit != null ? exit.SpawnOffset : int2.Zero;
self.SetTargetLine(Target.FromActor(order.TargetActor), Color.Green);
self.CancelActivity();
self.QueueActivity(new HeliFly(order.TargetActor.Trait<IHasLocation>().PxPosition + offset));
self.QueueActivity(new Turn(Info.InitialFacing));
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA.Air
}
}
}
public void Tick(Actor self)
{
if (firstTick)
@@ -117,7 +117,7 @@ namespace OpenRA.Mods.RA.Air
var aircraft = self.Trait<Aircraft>();
if (aircraft.Altitude <= 0)
return;
var otherHelis = self.World.FindUnitsInCircle(self.CenterLocation, Info.IdealSeparation)
.Where(a => a.HasTrait<Helicopter>());
@@ -138,7 +138,7 @@ namespace OpenRA.Mods.RA.Air
if( h.Trait<Helicopter>().Altitude < Altitude )
return int2.Zero;
var d = self.CenterLocation - h.CenterLocation;
if (d.Length > Info.IdealSeparation)
return int2.Zero;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -20,12 +20,12 @@ namespace OpenRA.Mods.RA.Air
Target Target;
public Land(Target t) { Target = t; }
public override Activity Tick(Actor self)
{
if (!Target.IsValid)
Cancel(self);
if (IsCanceled) return NextActivity;
var d = Target.CenterLocation - self.CenterLocation;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Air
{
[Sync]
public int2 RTBPathHash;
public Plane( ActorInitializer init, PlaneInfo info ) : base( init, info ) { }
bool firstTick = true;
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Air
if (order.OrderString == "Move")
{
UnReserve();
var target = self.World.ClampToWorld(order.TargetLocation);
self.SetTargetLine(Target.FromCell(target), Color.Green);
self.CancelActivity();

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Air
if (someBuilding == null)
{
// ... going down the garden to eat worms ...
// ... going down the garden to eat worms ...
self.QueueActivity(new FlyOffMap());
self.QueueActivity(new RemoveSelf());
return;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Air
{
dest = ChooseAirfield(self);
}
var plane = self.Trait<Plane>();
var res = dest.TraitOrDefault<Reservable>();
if (res != null)
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA.Air
var aircraft = self.Trait<Aircraft>();
var speed = .2f * aircraft.MovementSpeed;
var approachStart = landPos - new float2(aircraft.Altitude * speed, 0);
var turnRadius = (128f / self.Info.Traits.Get<AircraftInfo>().ROT) * speed / (float)Math.PI;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Air
public override string[] TargetTypes
{
get { return (Aircraft.Altitude > 0) ? info.TargetTypes
get { return (Aircraft.Altitude > 0) ? info.TargetTypes
: info.GroundedTargetTypes; }
}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -13,12 +13,12 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class AnnounceOnBuildInfo : ITraitInfo
{
{
public object Create(ActorInitializer init) { return new AnnounceOnBuild(init.self); }
}
public class AnnounceOnBuild
{
{
public AnnounceOnBuild(Actor self)
{
Sound.PlayVoice("Build", self, self.Owner.Country.Race);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -15,7 +15,7 @@ namespace OpenRA.Mods.RA
public class AnnounceOnKillInfo : TraitInfo<AnnounceOnKill> {}
public class AnnounceOnKill : INotifyAppliedDamage
{
{
public void AppliedDamage(Actor self, Actor damaged, AttackInfo e)
{
if (e.DamageState == DamageState.Dead)

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -35,13 +35,13 @@ namespace OpenRA.Mods.RA
else
return self.OccupiesSpace.OccupiedCells().Select(c => c.First);
}
public Color RadarSignatureColor(Actor self)
{
var mod = self.TraitsImplementing<IRadarColorModifier>().FirstOrDefault();
if (mod != null)
return mod.RadarColorOverride(self);
return self.Owner.ColorRamp.GetColor(0);
}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -70,11 +70,11 @@ namespace OpenRA.Mods.RA
Turrets.Add(new Turret(info.SecondaryOffset, info.SecondaryRecoilRecovery));
if (info.PrimaryWeapon != null)
Weapons.Add(new Weapon(info.PrimaryWeapon,
Weapons.Add(new Weapon(info.PrimaryWeapon,
Turrets[0], info.PrimaryLocalOffset, info.PrimaryRecoil));
if (info.SecondaryWeapon != null)
Weapons.Add(new Weapon(info.SecondaryWeapon,
Weapons.Add(new Weapon(info.SecondaryWeapon,
info.SecondaryOffset != null ? Turrets[1] : Turrets[0], info.SecondaryLocalOffset, info.SecondaryRecoil));
}
@@ -83,11 +83,11 @@ namespace OpenRA.Mods.RA
if (!target.IsValid) return false;
if (Weapons.All(w => w.IsReloading)) return false;
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))
return false;
return true;
}
@@ -169,7 +169,7 @@ namespace OpenRA.Mods.RA
self.Trait<Turreted>().desiredFacing = null;
}
}
public string VoicePhraseForOrder(Actor self, Order order)
{
return (order.OrderString == "Attack" || order.OrderString == "AttackHold") ? "Attack" : null;
@@ -224,7 +224,7 @@ namespace OpenRA.Mods.RA
{
if (!self.World.Map.IsInMap(location))
return false;
IsQueued = forceQueued;
cursor = isHeal ? "heal" : "attack";

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA
class AttackWanderInfo : ITraitInfo
{
public readonly int MoveRadius = 4;
public object Create(ActorInitializer init) { return new AttackWander(init.self, this); }
}
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
{
Info = info;
}
public void TickIdle(Actor self)
{
var target = Util.SubPxVector[self.World.SharedRandom.Next(255)]* Info.MoveRadius / 1024 + self.Location;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -19,45 +19,45 @@ namespace OpenRA.Mods.RA
class AttackMoveInfo : ITraitInfo
{
public readonly bool JustMove = false;
public object Create(ActorInitializer init) { return new AttackMove(init.self, this); }
}
class AttackMove : IResolveOrder, IOrderVoice, INotifyIdle, ISync
{
[Sync] public int2 _targetLocation { get { return TargetLocation.HasValue ? TargetLocation.Value : int2.Zero; } }
public int2? TargetLocation = null;
public int2? TargetLocation = null;
readonly Mobile mobile;
readonly AttackMoveInfo Info;
public AttackMove(Actor self, AttackMoveInfo info)
{
Info = info;
mobile = self.Trait<Mobile>();
}
public string VoicePhraseForOrder(Actor self, Order order)
{
if (order.OrderString == "AttackMove")
return "AttackMove";
return null;
}
void Activate(Actor self)
{
self.CancelActivity();
self.QueueActivity(new AttackMoveActivity(mobile.MoveTo(TargetLocation.Value, 1)));
self.SetTargetLine(Target.FromCell(TargetLocation.Value), Color.Red);
}
public void TickIdle(Actor self)
{
if (TargetLocation.HasValue)
Activate(self);
}
public void ResolveOrder(Actor self, Order order)
{
TargetLocation = null;
@@ -77,9 +77,9 @@ namespace OpenRA.Mods.RA
{
Activity inner;
int scanTicks;
const int ScanInterval = 7;
public AttackMoveActivity( Activity inner ) { this.inner = inner; }
public override Activity Tick( Actor self )
@@ -92,9 +92,9 @@ namespace OpenRA.Mods.RA
if( inner == null )
return NextActivity;
inner = Util.RunActivity( self, inner );
return this;
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
.Where(a => a.GetDamageState() > DamageState.Undamaged)
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
.ClosestTo( self.CenterLocation );
if( target != null )
self.QueueActivity(attack.GetAttackActivity(self, Target.FromActor( target ), false ));
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA
{
public readonly bool AllowMovement = true;
public readonly int ScanRadius = -1;
public object Create(ActorInitializer init) { return new AutoTarget(init.self, this); }
}
@@ -27,16 +27,16 @@ namespace OpenRA.Mods.RA
{
readonly AutoTargetInfo Info;
readonly AttackBase attack;
[Sync]
int nextScanTime = 0;
public AutoTarget(Actor self, AutoTargetInfo info)
{
Info = info;
attack = self.Trait<AttackBase>();
}
public void Damaged(Actor self, AttackInfo e)
{
if (!self.IsIdle) return;
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.RA
Info.AllowMovement));
}
}
public void Tick(Actor self)
{
--nextScanTime;
@@ -74,14 +74,14 @@ namespace OpenRA.Mods.RA
public Actor ScanForTarget(Actor self, Actor currentTarget)
{
var range = Info.ScanRadius > 0 ? Info.ScanRadius : attack.GetMaximumRange();
if (self.IsIdle || currentTarget == null || !Combat.IsInRange(self.CenterLocation, range, currentTarget))
if(nextScanTime <= 0)
return ChooseTarget(self, range);
return currentTarget;
}
public void ScanAndAttack(Actor self, bool allowMovement, bool holdStill)
{
var targetActor = ScanForTarget(self, null);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -20,17 +20,17 @@ namespace OpenRA.Mods.RA
class BridgeInfo : ITraitInfo, Requires<HealthInfo>
{
public readonly bool Long = false;
public readonly ushort Template = 0;
public readonly ushort DamagedTemplate = 0;
public readonly ushort DestroyedTemplate = 0;
// For long bridges
public readonly ushort DestroyedPlusNorthTemplate = 0;
public readonly ushort DestroyedPlusSouthTemplate = 0;
public readonly ushort DestroyedPlusBothTemplate = 0;
public readonly string[] ShorePieces = {"br1", "br2"};
public readonly int[] NorthOffset = null;
public readonly int[] SouthOffset = null;
@@ -70,13 +70,13 @@ namespace OpenRA.Mods.RA
Dictionary<ushort, Dictionary<int2, Sprite>> TileSprites = new Dictionary<ushort, Dictionary<int2, Sprite>>();
Dictionary<ushort, TileTemplate> Templates = new Dictionary<ushort, TileTemplate>();
ushort currentTemplate;
Actor self;
BridgeInfo Info;
public string Type;
Bridge northNeighbour, southNeighbour;
Health Health;
public Bridge(Actor self, BridgeInfo info)
{
this.self = self;
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA
public void Create(ushort template, Dictionary<int2, byte> subtiles)
{
currentTemplate = template;
// Create a new cache to store the tile data
if (cachedTileset != self.World.Map.Tileset)
{
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.RA
x => Game.modData.SheetBuilder.Add(self.World.TileSet.GetBytes(x),
new Size(Game.CellSize, Game.CellSize)));
}
// Cache templates and tiles for the different states
foreach (var t in Info.Templates)
{
@@ -112,14 +112,14 @@ namespace OpenRA.Mods.RA
foreach (var c in TileSprites[currentTemplate].Keys)
self.World.Map.CustomTerrain[c.X, c.Y] = GetTerrainType(c);
}
public string GetTerrainType(int2 cell)
{
var dx = cell - self.Location;
var index = dx.X + Templates[currentTemplate].Size.X*dx.Y;
return self.World.TileSet.GetTerrainType(new TileReference<ushort, byte>(currentTemplate,(byte)index));
}
public void LinkNeighbouringBridges(World world, BridgeLayer bridges)
{
// go looking for our neighbors if this is a long bridge.
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.RA
if (Info.SouthOffset != null)
southNeighbour = GetNeighbor(Info.SouthOffset, bridges);
}
public Bridge GetNeighbor(int[] offset, BridgeLayer bridges)
{
if (offset == null) return null;
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.RA
foreach (var t in TileSprites[currentTemplate])
yield return new Renderable(t.Value, Game.CellSize * t.Key, "terrain", Game.CellSize * t.Key.Y);
}
bool IsIntact(Bridge b)
{
return b != null && !b.self.IsDead();
@@ -153,10 +153,10 @@ namespace OpenRA.Mods.RA
if (a.HasTrait<IMove>() && !a.Trait<IMove>().CanEnterCell(c))
a.Kill(self);
}
bool dead = false;
void UpdateState()
{
{
// 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)) ||

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
readonly World world;
Dictionary<ushort, Pair<string, float>> BridgeTypes = new Dictionary<ushort, Pair<string,float>>();
Bridge[,] Bridges;
public BridgeLayer(Actor self, BridgeLayerInfo Info)
{
this.Info = Info;
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA
public void WorldLoaded(World w)
{
Bridges = new Bridge[w.Map.MapSize.X, w.Map.MapSize.Y];
// Build a list of templates that should be overlayed with bridges
foreach(var bridge in Info.Bridges)
{
@@ -47,31 +47,31 @@ namespace OpenRA.Mods.RA
foreach (var template in bi.Templates)
BridgeTypes.Add(template.First, Pair.New(bridge, template.Second));
}
// Loop through the map looking for templates to overlay
for (int i = w.Map.Bounds.Left; i < w.Map.Bounds.Right; i++)
for (int j = w.Map.Bounds.Top; j < w.Map.Bounds.Bottom; j++)
if (BridgeTypes.Keys.Contains(w.Map.MapTiles.Value[i, j].type))
ConvertBridgeToActor(w, i, j);
// Link adjacent (long)-bridges so that artwork is updated correctly
foreach (var b in w.Actors.SelectMany(a => a.TraitsImplementing<Bridge>()))
b.LinkNeighbouringBridges(w,this);
}
void ConvertBridgeToActor(World w, int i, int j)
{
{
// This cell already has a bridge overlaying it from a previous iteration
if (Bridges[i,j] != null)
return;
// Correlate the tile "image" aka subtile with its position to find the template origin
var tile = w.Map.MapTiles.Value[i, j].type;
var index = w.Map.MapTiles.Value[i, j].index;
var template = w.TileSet.Templates[tile];
var ni = i - index % template.Size.X;
var nj = j - index / template.Size.X;
// Create a new actor for this bridge and keep track of which subtiles this bridge includes
var bridge = w.CreateActor(BridgeTypes[tile].First, new TypeDictionary
{
@@ -79,36 +79,36 @@ namespace OpenRA.Mods.RA
new OwnerInit( w.WorldActor.Owner ),
new HealthInit( BridgeTypes[tile].Second ),
}).Trait<Bridge>();
Dictionary<int2, byte> subTiles = new Dictionary<int2, byte>();
// For each subtile in the template
for (byte ind = 0; ind < template.Size.X*template.Size.Y; ind++)
{
// Is this tile actually included in the bridge template?
if (!template.Tiles.Keys.Contains(ind))
continue;
// Where do we expect to find the subtile
// Where do we expect to find the subtile
var x = ni + ind % template.Size.X;
var y = nj + ind / template.Size.X;
// This isn't the bridge you're looking for
if (!w.Map.IsInMap(x, y) || w.Map.MapTiles.Value[x, y].index != ind)
continue;
subTiles.Add(new int2(x,y),ind);
Bridges[x,y] = bridge;
}
bridge.Create(tile, subTiles);
}
// Used to check for neighbouring bridges
public Bridge GetBridge(int2 cell)
{
if (!world.Map.IsInMap(cell.X, cell.Y))
return null;
return Bridges[ cell.X, cell.Y ];
}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -17,9 +17,9 @@ namespace OpenRA.Mods.RA
public readonly string[] Prerequisites = { };
[ActorReference]
public readonly string[] BuiltAt = { };
public readonly string[] Owner = { };
public readonly string Queue;
public readonly bool Hidden = false;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -27,15 +27,15 @@ namespace OpenRA.Mods.RA
{
Info = info;
}
public void OnCapture (Actor self, Actor captor, Player oldOwner, Player newOwner)
{
if (captor.World.LocalPlayer != captor.Owner)
return;
if (Info.Race != null && Info.Race != oldOwner.Country.Race)
return;
Sound.PlayToPlayer(captor.World.LocalPlayer, Info.Notification);
}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -26,42 +26,42 @@ namespace OpenRA.Mods.RA.Buildings
}
class BibLayer: IRenderOverlay, IWorldLoaded
{
{
World world;
BibLayerInfo info;
Dictionary<int2, TileReference<byte, byte>> tiles;
Sprite[][] bibSprites;
public BibLayer(Actor self, BibLayerInfo info)
{
this.info = info;
bibSprites = info.BibTypes.Select(x => Game.modData.SpriteLoader.LoadAllSprites(x)).ToArray();
self.World.ActorAdded +=
a => { if (a.HasTrait<Bib>()) DoBib(a,true); };
self.World.ActorRemoved +=
a => { if (a.HasTrait<Bib>()) DoBib(a,false); };
}
public void WorldLoaded(World w)
{
world = w;
tiles = new Dictionary<int2, TileReference<byte, byte>>();
}
public void DoBib(Actor b, bool isAdd)
{
var buildingInfo = b.Info.Traits.Get<BuildingInfo>();
var buildingInfo = b.Info.Traits.Get<BuildingInfo>();
var size = buildingInfo.Dimensions.X;
var bibOffset = buildingInfo.Dimensions.Y - 1;
int bib = Array.IndexOf(info.BibWidths,size);
if (bib < 0)
{
Log.Write("debug", "Cannot bib {0}-wide building {1}", size, b.Info.Name);
return;
}
for (int i = 0; i < 2 * size; i++)
{
var p = b.Location + new int2(i % size, i / size + bibOffset);
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA.Buildings
}
}
}
public class BibInfo : TraitInfo<Bib> { }
public class Bib { }
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Buildings
public readonly int Adjacent = 2;
public readonly string Footprint = "x";
public readonly int2 Dimensions = new int2(1, 1);
public readonly string[] BuildSounds = {"placbldg.aud", "build5.aud"};
public readonly string[] SellSounds = {"cashturn.aud"};
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Buildings
var nearnessCandidates = new List<int2>();
var bi = world.WorldActor.Trait<BuildingInfluence>();
for( int y = scanStart.Y ; y < scanEnd.Y ; y++ )
for( int x = scanStart.X ; x < scanEnd.X ; x++ )
{
@@ -76,26 +76,26 @@ namespace OpenRA.Mods.RA.Buildings
public int2 TopLeft { get { return topLeft; } }
public int2 PxPosition { get { return pxPosition; } }
public IEnumerable<string> ProvidesPrerequisites { get { yield return self.Info.Name; } }
public Building(ActorInitializer init, BuildingInfo info)
{
this.self = init.self;
this.topLeft = init.Get<LocationInit,int2>();
this.Info = info;
this.PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>();
occupiedCells = FootprintUtils.UnpathableTiles( self.Info.Name, Info, TopLeft )
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
pxPosition = ( 2 * topLeft + Info.Dimensions ) * Game.CellSize / 2;
}
public int GetPowerUsage()
{
if (Info.Power <= 0)
return Info.Power;
var health = self.TraitOrDefault<Health>();
return health != null ? (Info.Power * health.HP / health.MaxHP) : Info.Power;
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -24,14 +24,14 @@ namespace OpenRA.Mods.RA.Buildings
bool disabled = false;
int normalPower = 0;
PowerManager PowerManager;
public CanPowerDown(ActorInitializer init)
{
PowerManager = init.self.Owner.PlayerActor.Trait<PowerManager>();
normalPower = init.self.Info.Traits.Get<BuildingInfo>().Power;
}
public bool Disabled { get { return disabled; } }
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "PowerDown")
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Buildings
disabled = !disabled;
var eva = self.World.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
Sound.PlayToPlayer(self.Owner, disabled ? eva.EnablePower : eva.DisablePower);
PowerManager.UpdateActor(self, disabled ? 0 : normalPower);
if (disabled)
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Buildings
w => w.Add(new PowerdownIndicator(self)));
}
}
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
{
PowerManager = newOwner.PlayerActor.Trait<PowerManager>();

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -26,12 +26,12 @@ namespace OpenRA.Mods.RA.Buildings
{
public static int GetSellValue( this Actor a )
{
var csv = a.Info.Traits.GetOrDefault<CustomSellValueInfo>();
var csv = a.Info.Traits.GetOrDefault<CustomSellValueInfo>();
if (csv != null) return csv.Value;
var valued = a.Info.Traits.GetOrDefault<ValuedInfo>();
if (valued != null) return valued.Cost;
return 0;
}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Buildings
var dim = buildingInfo.Dimensions;
var footprint = buildingInfo.Footprint.Where(x => !char.IsWhiteSpace(x));
if (Rules.Info[ name ].Traits.Contains<BibInfo>())
{
dim.Y += 1;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Buildings
PowerManagerInfo Info;
Player Player;
DeveloperMode devMode;
Dictionary<Actor, int> PowerDrain = new Dictionary<Actor, int>();
[Sync] int totalProvided;
public int PowerProvided { get { return totalProvided; } }
@@ -38,14 +38,14 @@ namespace OpenRA.Mods.RA.Buildings
{
Info = info;
Player = init.self.Owner;
init.world.ActorAdded += ActorAdded;
init.world.ActorRemoved += ActorRemoved;
devMode = init.self.Trait<DeveloperMode>();
wasHackEnabled = devMode.UnlimitedPower;
}
void ActorAdded(Actor a)
{
if (a.Owner != Player || !a.HasTrait<Building>())
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA.Buildings
PowerDrain.Add(a, a.Trait<Building>().GetPowerUsage());
UpdateTotals();
}
void ActorRemoved(Actor a)
{
if (a.Owner != Player || !a.HasTrait<Building>())
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA.Buildings
PowerDrain.Remove(a);
UpdateTotals();
}
void UpdateTotals()
{
totalProvided = 0;
@@ -78,16 +78,16 @@ namespace OpenRA.Mods.RA.Buildings
if (devMode.UnlimitedPower)
totalProvided = 1000000;
}
public void UpdateActor(Actor a, int newPower)
{
if (a.Owner != Player || !a.HasTrait<Building>())
return;
PowerDrain[a] = newPower;
UpdateTotals();
}
int nextPowerAdviceTime = 0;
bool wasLowPower = false;
bool wasHackEnabled;
@@ -104,16 +104,16 @@ namespace OpenRA.Mods.RA.Buildings
if (lowPower && !wasLowPower)
nextPowerAdviceTime = 0;
wasLowPower = lowPower;
if (--nextPowerAdviceTime <= 0)
{
if (lowPower)
Player.GiveAdvice(Rules.Info["world"].Traits.Get<EvaAlertsInfo>().LowPower);
nextPowerAdviceTime = Info.AdviceInterval;
}
}
public PowerState PowerState
{
get {

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Buildings
{
get { return power.PowerProvided < power.PowerDrained; }
}
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
{
power = newOwner.PlayerActor.Trait<PowerManager>();

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Buildings
{
this.Info = info;
}
public void Killed(Actor self, AttackInfo e)
{
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(Info.Intensity, self.CenterLocation, 1);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Render
{
public readonly string DamagedSound;
public readonly string DestroyedSound;
public object Create(ActorInitializer init) { return new SoundOnDamageTransition(this);}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -30,20 +30,20 @@ namespace OpenRA.Mods.RA.Buildings
init.world.ActorAdded += ActorChanged;
init.world.ActorRemoved += ActorChanged;
}
public void ActorChanged(Actor a)
{
if (a.Owner == player && a.HasTrait<ITechTreePrerequisite>())
Update();
}
public void Update()
{
var buildings = GatherBuildings(player);
foreach(var w in watchers)
w.Update(buildings);
}
public void Add(string key, List<string> prerequisites, ITechTreeElement tte)
{
watchers.Add(new Watcher( key, prerequisites, tte ));
@@ -53,22 +53,22 @@ namespace OpenRA.Mods.RA.Buildings
{
watchers.RemoveAll(x => x.key == key);
}
static Cache<string, List<Actor>> GatherBuildings( Player player )
{
var ret = new Cache<string, List<Actor>>( x => new List<Actor>() );
if (player == null)
return ret;
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 );
return ret;
}
class Watcher
{
public readonly string key;
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.RA.Buildings
public readonly List<string> prerequisites;
public readonly ITechTreeElement watcher;
bool hasPrerequisites;
public Watcher(string key, List<string> prerequisites, ITechTreeElement watcher)
{
this.key = key;
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.RA.Buildings
}
public void Update(Cache<string, List<Actor>> buildings)
{
{
var nowHasPrerequisites = true;
foreach (var p in prerequisites)
if (!buildings.Keys.Contains(p))
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA.Buildings
nowHasPrerequisites = false;
break;
}
if( nowHasPrerequisites && !hasPrerequisites )
watcher.PrerequisitesAvailable(key);
@@ -111,12 +111,12 @@ namespace OpenRA.Mods.RA.Buildings
void PrerequisitesAvailable(string key);
void PrerequisitesUnavailable(string key);
}
public interface ITechTreePrerequisite
{
IEnumerable<string> ProvidesPrerequisites {get;}
}
public class ProvidesCustomPrerequisiteInfo : ITraitInfo
{
public string Prerequisite;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -20,12 +20,12 @@ namespace OpenRA.Mods.RA.Buildings
{
return world.IsCellBuildable(a, bi, null);
}
public static bool IsCellBuildable(this World world, int2 a, BuildingInfo bi, Actor toIgnore)
{
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(a) != null) return false;
if (world.ActorMap.GetUnitsAt(a).Any(b => b != toIgnore)) return false;
return world.Map.IsInMap(a) && bi.TerrainTypes.Contains(world.GetTerrainType(a));
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Buildings
{
readonly Actor self;
readonly WallInfo info;
public Wall(Actor self, WallInfo info)
{
this.self = self;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
[Sync]
int ticks;
BurnsInfo Info;
public Burns(Actor self, BurnsInfo info)
{
Info = info;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -28,12 +28,12 @@ namespace OpenRA.Mods.RA
class C4Demolition : IIssueOrder, IResolveOrder, IOrderVoice
{
readonly C4DemolitionInfo Info;
public C4Demolition(C4DemolitionInfo info)
{
Info = info;
}
public IEnumerable<IOrderTargeter> Orders
{
get { yield return new UnitTraitOrderTargeter<Building>( "C4", 6, "c4", true, false ); }
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA
if (order.OrderString == "C4")
{
self.SetTargetLine(Target.FromOrder(order), Color.Red);
var mobile = self.Trait<Mobile>();
self.CancelActivity();
self.QueueActivity(new Enter(order.TargetActor));
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA
self.QueueActivity(mobile.MoveTo(self.Location, 0));
}
}
public string VoicePhraseForOrder(Actor self, Order order)
{
return (order.OrderString == "C4") ? "Attack" : null;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA
public string[] CaptureTypes = {"building"};
public object Create(ActorInitializer init) { return new Captures(this); }
}
class Captures : IIssueOrder, IResolveOrder, IOrderVoice
{
public readonly CapturesInfo Info;
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA
{
Info = info;
}
public IEnumerable<IOrderTargeter> Orders
{
get
@@ -50,22 +50,22 @@ namespace OpenRA.Mods.RA
public string VoicePhraseForOrder(Actor self, Order order)
{
return (order.OrderString == "CaptureActor") ? "Attack" : null;
return (order.OrderString == "CaptureActor") ? "Attack" : null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "CaptureActor")
{
self.SetTargetLine(Target.FromOrder(order), Color.Red);
self.CancelActivity();
self.QueueActivity(new Enter(order.TargetActor));
self.QueueActivity(new CaptureActor(order.TargetActor));
}
}
}
class CaptureOrderTargeter : UnitTraitOrderTargeter<Capturable>
{
readonly string[] captureTypes;
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.RA
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;
var ci = target.Info.Traits.Get<CapturableInfo>();
var playerRelationship = self.Owner.Stances[ target.Owner ];
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA
cursor = "enter";
return true;
}
return false;
}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -55,26 +55,26 @@ namespace OpenRA.Mods.RA
{
if (!CanUnload(self))
return;
self.CancelActivity();
self.QueueActivity(new UnloadCargo());
}
}
bool CanUnload(Actor self)
{
if (IsEmpty(self))
return false;
// Cannot unload mid-air
var move = self.TraitOrDefault<IMove>();
if (move != null && move.Altitude > 0)
return false;
// Todo: Check if there is a free tile to unload to
return true;
}
public string CursorForOrder(Actor self, Order order)
{
if (order.OrderString != "Unload") return null;
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.RA
public string VoicePhraseForOrder(Actor self, Order order)
{
if (order.OrderString != "Unload" || IsEmpty(self)) return null;
if (order.OrderString != "Unload" || IsEmpty(self)) return null;
return "Move";
}
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.RA
public bool IsEmpty(Actor self) { return cargo.Count == 0; }
public Actor Peek(Actor self) { return cargo[0]; }
static int GetWeight(Actor a) { return a.Info.Traits.Get<PassengerInfo>().Weight; }
public Actor Unload(Actor self)

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA
public readonly bool ShowTicks = true;
public readonly int TickLifetime = 30;
public readonly int TickVelocity = 1;
public object Create (ActorInitializer init) { return new CashTrickler(this); }
}
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
{
Info = info;
}
public void Tick(Actor self)
{
if (--ticks < 0)

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA
{
self.World.CancelInputMode();
}
self.CancelActivity();
self.QueueActivity(new Teleport(order.TargetLocation));
Sound.Play("chrotnk1.aud", self.CenterLocation);
@@ -72,7 +72,7 @@ namespace OpenRA.Mods.RA
{
return (order.OrderString == "ChronoshiftDeploy" && chargeTick <= 0) ? "Move" : null;
}
// Display 5 pips indicating the current charge status
public IEnumerable<PipType> GetPips(Actor self)
{

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -37,14 +37,14 @@ namespace OpenRA.Mods.RA
{
if (remainingFrames == 0)
return;
var frac = (float)remainingFrames / chronoEffectLength;
var excludePalettes = new List<string>(){"cursor", "chrome", "colorpicker", "shroud", "fog"};
foreach (var pal in palettes)
{
if (excludePalettes.Contains(pal.Key))
continue;
for (var x = 0; x < 256; x++)
{
var orig = pal.Value.GetColor(x);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA
self.QueueActivity(new Teleport(chronoshiftOrigin));
}
}
// Can't be used in synced code, except with ignoreVis.
public virtual bool CanChronoshiftTo(Actor self, int2 targetLocation, bool ignoreVis)
{
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA
/// Set up return-to-sender info
chronoshiftOrigin = self.Location;
chronoshiftReturnTicks = duration;
// Kill cargo
if (killCargo && self.HasTrait<Cargo>())
{
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.RA
// Set up the teleport
self.CancelActivity();
self.QueueActivity(new Teleport(targetLocation));
return true;
}
}

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA
public bool Cloaked { get { return remainingTime <= 0; } }
public void DamageStateChanged(Actor self, AttackInfo e)
{
{
canCloak = (e.DamageState < DamageState.Critical);
if (!canCloak) Uncloak();
}
@@ -84,8 +84,8 @@ namespace OpenRA.Mods.RA
public bool IsVisible(Actor self)
{
if (!Cloaked || self.Owner == self.World.LocalPlayer ||
self.World.LocalPlayer == null ||
if (!Cloaked || self.Owner == self.World.LocalPlayer ||
self.World.LocalPlayer == null ||
self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
return true;
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA
a.Actor.Owner.Stances[self.Owner] != Stance.Ally &&
(self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<DetectCloakedInfo>().Range);
}
public Color RadarColorOverride(Actor self)
{
var c = self.Owner.ColorRamp.GetColor(0);

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -22,14 +22,14 @@ namespace OpenRA.Mods.RA
public string PlayerPalette = "player";
public object Create( ActorInitializer init ) { return new ColorPickerPaletteModifier( this ); }
}
class ColorPickerPaletteModifier : IPalette, IPaletteModifier
{
{
ColorPickerPaletteModifierInfo Info;
PaletteFormat format;
public ColorPickerPaletteModifier(ColorPickerPaletteModifierInfo info) { Info = info; }
public void InitPalette( WorldRenderer wr )
{
var info = Rules.Info["player"].Traits.WithInterface<PlayerColorPaletteInfo>()

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA
w => w.Add(new Explosion(w, args.dest, explosionType, isWater, args.destAltitude)));
Sound.Play(GetImpactSound(warhead, isWater), args.dest);
if (warhead.SmudgeType != null)
{
var smudgeLayer = world.WorldActor.TraitsImplementing<SmudgeLayer>()
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA
else
smudgeLayer.AddSmudge(targetTile);
}
if (warhead.Ore)
world.WorldActor.Trait<ResourceLayer>().Destroy(targetTile);
@@ -132,9 +132,9 @@ namespace OpenRA.Mods.RA
DoImpacts(args);
}
static readonly float[] falloff =
static readonly float[] falloff =
{
1f, 0.3678795f, 0.1353353f, 0.04978707f,
1f, 0.3678795f, 0.1353353f, 0.04978707f,
0.01831564f, 0.006737947f, 0.002478752f, 0.000911882f
};
@@ -167,7 +167,7 @@ namespace OpenRA.Mods.RA
var targetable = target.TraitOrDefault<ITargetable>();
if (targetable == null || !weapon.ValidTargets.Intersect(targetable.TargetTypes).Any())
return false;
if (weapon.Warheads.All( w => w.EffectivenessAgainst(target) <= 0))
return false;
@@ -210,7 +210,7 @@ namespace OpenRA.Mods.RA
public static float2 GetBarrelPosition(Actor self, IFacing facing, Turret turret, Barrel barrel)
{
var turreted = self.TraitOrDefault<Turreted>();
if (turreted == null && facing == null)
return float2.Zero;

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
@@ -25,22 +25,22 @@ namespace OpenRA.Mods.RA
{
ConquestVictoryConditionsInfo Info;
public ConquestVictoryConditions(ConquestVictoryConditionsInfo info) { Info = info; }
public void Tick(Actor self)
{
if (self.Owner.WinState != WinState.Undefined || self.Owner.NonCombatant) return;
var hasAnything = self.World.ActorsWithTrait<MustBeDestroyed>()
.Any( a => a.Actor.Owner == self.Owner );
if (!hasAnything && !self.Owner.NonCombatant)
Lose(self);
var others = self.World.Players.Where( p => !p.NonCombatant
var others = self.World.Players.Where( p => !p.NonCombatant
&& p != self.Owner && p.Stances[self.Owner] != Stance.Ally );
if (others.Count() == 0) return;
if (others.Count() == 0) return;
if(others.All(p => p.WinState == WinState.Lost))
Win(self);
}
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA
{
if (self.Owner.WinState == WinState.Lost) return;
self.Owner.WinState = WinState.Lost;
Game.Debug("{0} is defeated.".F(self.Owner.PlayerName));
foreach (var a in self.World.Actors.Where(a => a.Owner == self.Owner))
@@ -71,12 +71,12 @@ namespace OpenRA.Mods.RA
});
}
}
public void Win(Actor self)
public void Win(Actor self)
{
if (self.Owner.WinState == WinState.Won) return;
self.Owner.WinState = WinState.Won;
Game.Debug("{0} is victorious.".F(self.Owner.PlayerName));
if (self.Owner == self.World.LocalPlayer)
{

View File

@@ -1,7 +1,7 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.

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