Formatted all files.
Automatically formatted all files via VS. This generally corrects indentation, removes trailing whitespace and corrects misplaced tabs or spaces. Manually tweaked a few files where required.
This commit is contained in:
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (dest == null)
|
||||
{
|
||||
var nearestAfld = ChooseAirfield(self, false);
|
||||
|
||||
|
||||
self.CancelActivity();
|
||||
if (nearestAfld != null)
|
||||
return Util.SequenceActivities(new Fly(self, Target.FromActor(nearestAfld)), new FlyCircle());
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var type = Target.Type;
|
||||
if (!Target.IsValidFor(self) || type == TargetType.FrozenActor)
|
||||
return NextActivity;
|
||||
|
||||
|
||||
if (attack.Info.AttackRequiresEnteringCell && !positionable.CanEnterCell(Target.Actor.Location, null, false))
|
||||
return NextActivity;
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
ReserveStatus TryReserveElseTryAlternateReserve(Actor self)
|
||||
{
|
||||
for (var tries = 0;;)
|
||||
for (var tries = 0;;)
|
||||
switch (Reserve(self))
|
||||
{
|
||||
case ReserveStatus.None:
|
||||
@@ -255,7 +255,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// Check target validity if not exiting or done
|
||||
if (nextState != State.Done && (target.Type != TargetType.Actor || !target.IsValidFor(self)))
|
||||
AbortOrExit(self);
|
||||
AbortOrExit(self);
|
||||
|
||||
// If no current activity, tick next activity
|
||||
if (inner == null && FindAndTransitionToNextState(self) == State.Done)
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
protected override void OnInside(Actor self)
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (self.IsDead || transport.IsDead || !cargo.CanLoad(transport, self))
|
||||
return;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
if (IsCanceled)
|
||||
return NextActivity;
|
||||
|
||||
|
||||
var target = targets.ClosestTo(self);
|
||||
if (target == null)
|
||||
return this;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Commands
|
||||
World world;
|
||||
ChatCommands console;
|
||||
|
||||
public HelpCommand()
|
||||
public HelpCommand()
|
||||
{
|
||||
helpDescriptions = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,9 @@ namespace OpenRA.Mods.Common.Commands
|
||||
{
|
||||
case "pause":
|
||||
world.IssueOrder(new Order("PauseGame", null, false)
|
||||
{ TargetString = world.Paused ? "UnPause" : "Pause" });
|
||||
{
|
||||
TargetString = world.Paused ? "UnPause" : "Pause"
|
||||
});
|
||||
break;
|
||||
case "surrender":
|
||||
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
var palette = r.Palette(palettePrefix + owner.InternalName);
|
||||
foreach (var a in circles.Render(position, palette))
|
||||
yield return a;
|
||||
|
||||
|
||||
foreach (var a in arrow.Render(position + new WVec(0, 0, arrowHeight), palette))
|
||||
yield return a;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
[Desc("Explodes when leaving the following terrain type, e.g., Water for torpedoes.")]
|
||||
public readonly string BoundToTerrainType = "";
|
||||
[Desc("Explodes when inside this proximity radius to target.",
|
||||
"Note: If this value is lower than the missile speed, this check might",
|
||||
"Note: If this value is lower than the missile speed, this check might",
|
||||
"not trigger fast enough, causing the missile to fly past the target.")]
|
||||
public readonly WRange CloseEnough = new WRange(298);
|
||||
|
||||
|
||||
@@ -32,9 +32,10 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
// Generated at render-time
|
||||
VoxelRenderProxy renderProxy;
|
||||
|
||||
public VoxelRenderable(IEnumerable<VoxelAnimation> voxels, WPos pos, int zOffset, WRot camera, float scale,
|
||||
WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
||||
PaletteReference color, PaletteReference normals, PaletteReference shadow)
|
||||
public VoxelRenderable(
|
||||
IEnumerable<VoxelAnimation> voxels, WPos pos, int zOffset, WRot camera, float scale,
|
||||
WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
||||
PaletteReference color, PaletteReference normals, PaletteReference shadow)
|
||||
{
|
||||
this.voxels = voxels;
|
||||
this.pos = pos;
|
||||
@@ -58,30 +59,34 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
public IRenderable WithScale(float newScale)
|
||||
{
|
||||
return new VoxelRenderable(voxels, pos, zOffset, camera, newScale,
|
||||
lightSource, lightAmbientColor, lightDiffuseColor,
|
||||
palette, normalsPalette, shadowPalette);
|
||||
return new VoxelRenderable(
|
||||
voxels, pos, zOffset, camera, newScale,
|
||||
lightSource, lightAmbientColor, lightDiffuseColor,
|
||||
palette, normalsPalette, shadowPalette);
|
||||
}
|
||||
|
||||
public IRenderable WithPalette(PaletteReference newPalette)
|
||||
{
|
||||
return new VoxelRenderable(voxels, pos, zOffset, camera, scale,
|
||||
lightSource, lightAmbientColor, lightDiffuseColor,
|
||||
newPalette, normalsPalette, shadowPalette);
|
||||
return new VoxelRenderable(
|
||||
voxels, pos, zOffset, camera, scale,
|
||||
lightSource, lightAmbientColor, lightDiffuseColor,
|
||||
newPalette, normalsPalette, shadowPalette);
|
||||
}
|
||||
|
||||
public IRenderable WithZOffset(int newOffset)
|
||||
{
|
||||
return new VoxelRenderable(voxels, pos, newOffset, camera, scale,
|
||||
lightSource, lightAmbientColor, lightDiffuseColor,
|
||||
palette, normalsPalette, shadowPalette);
|
||||
return new VoxelRenderable(
|
||||
voxels, pos, newOffset, camera, scale,
|
||||
lightSource, lightAmbientColor, lightDiffuseColor,
|
||||
palette, normalsPalette, shadowPalette);
|
||||
}
|
||||
|
||||
public IRenderable OffsetBy(WVec vec)
|
||||
{
|
||||
return new VoxelRenderable(voxels, pos + vec, zOffset, camera, scale,
|
||||
lightSource, lightAmbientColor, lightDiffuseColor,
|
||||
palette, normalsPalette, shadowPalette);
|
||||
return new VoxelRenderable(
|
||||
voxels, pos + vec, zOffset, camera, scale,
|
||||
lightSource, lightAmbientColor, lightDiffuseColor,
|
||||
palette, normalsPalette, shadowPalette);
|
||||
}
|
||||
|
||||
public IRenderable AsDecoration() { return this; }
|
||||
|
||||
@@ -20,7 +20,8 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public class MapGlobal : ScriptGlobal
|
||||
{
|
||||
SpawnMapActors sma;
|
||||
public MapGlobal(ScriptContext context) : base(context)
|
||||
public MapGlobal(ScriptContext context)
|
||||
: base(context)
|
||||
{
|
||||
sma = context.World.WorldActor.Trait<SpawnMapActors>();
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public class MediaGlobal : ScriptGlobal
|
||||
{
|
||||
World world;
|
||||
public MediaGlobal(ScriptContext context) : base(context)
|
||||
public MediaGlobal(ScriptContext context)
|
||||
: base(context)
|
||||
{
|
||||
world = context.World;
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
GetScriptTriggers(a).ClearAll();
|
||||
}
|
||||
|
||||
[Desc("Removes the specified trigger from this actor." +
|
||||
[Desc("Removes the specified trigger from this actor." +
|
||||
"Note that the removal will only take effect at the end of a tick, " +
|
||||
"so you must not add new triggers at the same time that you are calling this function.")]
|
||||
public void Clear(Actor a, string triggerName)
|
||||
|
||||
@@ -18,8 +18,11 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
public enum Trigger { OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnPlayerWon, OnPlayerLost,
|
||||
OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated, OnAddedToWorld, OnRemovedFromWorld }
|
||||
public enum Trigger
|
||||
{
|
||||
OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnPlayerWon, OnPlayerLost,
|
||||
OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated, OnAddedToWorld, OnRemovedFromWorld
|
||||
}
|
||||
|
||||
[Desc("Allows map scripts to attach triggers to this actor via the Triggers global.")]
|
||||
public class ScriptTriggersInfo : ITraitInfo
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace OpenRA.Mods.Common.Server
|
||||
{
|
||||
public class MasterServerPinger : ServerTrait, ITick, INotifySyncLobbyInfo, IStartGame, IEndGame
|
||||
{
|
||||
const int MasterPingInterval = 60 * 3; // 3 minutes. server has a 5 minute TTL for games, so give ourselves a bit
|
||||
// of leeway.
|
||||
// 3 minutes. Server has a 5 minute TTL for games, so give ourselves a bit of leeway.
|
||||
const int MasterPingInterval = 60 * 3;
|
||||
public int TickTimeout { get { return MasterPingInterval * 10000; } }
|
||||
|
||||
public void Tick(S server)
|
||||
|
||||
@@ -168,26 +168,26 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
||||
{
|
||||
case Format.Format20:
|
||||
case Format.Format40:
|
||||
{
|
||||
if (h.RefImage.Data == null)
|
||||
{
|
||||
++recurseDepth;
|
||||
Decompress(h.RefImage);
|
||||
--recurseDepth;
|
||||
if (h.RefImage.Data == null)
|
||||
{
|
||||
++recurseDepth;
|
||||
Decompress(h.RefImage);
|
||||
--recurseDepth;
|
||||
}
|
||||
|
||||
h.Data = CopyImageData(h.RefImage.Data);
|
||||
Format40.DecodeInto(shpBytes, h.Data, (int)(h.FileOffset - shpBytesFileOffset));
|
||||
break;
|
||||
}
|
||||
|
||||
h.Data = CopyImageData(h.RefImage.Data);
|
||||
Format40.DecodeInto(shpBytes, h.Data, (int)(h.FileOffset - shpBytesFileOffset));
|
||||
break;
|
||||
}
|
||||
|
||||
case Format.Format80:
|
||||
{
|
||||
var imageBytes = new byte[Size.Width * Size.Height];
|
||||
Format80.DecodeInto(shpBytes, imageBytes, (int)(h.FileOffset - shpBytesFileOffset));
|
||||
h.Data = imageBytes;
|
||||
break;
|
||||
}
|
||||
{
|
||||
var imageBytes = new byte[Size.Width * Size.Height];
|
||||
Format80.DecodeInto(shpBytes, imageBytes, (int)(h.FileOffset - shpBytesFileOffset));
|
||||
h.Data = imageBytes;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new InvalidDataException();
|
||||
|
||||
@@ -288,12 +288,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
switch (order.OrderString)
|
||||
{
|
||||
case "Move":
|
||||
case "Enter":
|
||||
case "ReturnToBase":
|
||||
case "Stop":
|
||||
return "Move";
|
||||
default: return null;
|
||||
case "Move":
|
||||
case "Enter":
|
||||
case "ReturnToBase":
|
||||
case "Stop":
|
||||
return "Move";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) { return new Fly(self, Target.FromCell(self.World, cell)); }
|
||||
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new Fly(self, Target.FromPos(toPos))); }
|
||||
public Activity MoveToTarget(Actor self, Target target) { return new Fly(self, target, WRange.FromCells(3), WRange.FromCells(5)); }
|
||||
public Activity MoveToTarget(Actor self, Target target) { return new Fly(self, target, WRange.FromCells(3), WRange.FromCells(5)); }
|
||||
public Activity MoveIntoTarget(Actor self, Target target) { return new Land(target); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public override string[] TargetTypes
|
||||
{
|
||||
get { return (self.CenterPosition.Z > 0) ? info.TargetTypes
|
||||
: info.GroundedTargetTypes; }
|
||||
get
|
||||
{
|
||||
return (self.CenterPosition.Z > 0) ? info.TargetTypes
|
||||
: info.GroundedTargetTypes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Has to be defined here and in weapons.yaml.")]
|
||||
public readonly string Weapon = null;
|
||||
public readonly string Turret = "primary";
|
||||
[Desc("Time (in frames) until the weapon can fire again.")]
|
||||
[Desc("Time (in frames) until the weapon can fire again.")]
|
||||
public readonly int FireDelay = 0;
|
||||
|
||||
[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
|
||||
|
||||
@@ -113,12 +113,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
switch (target.Type)
|
||||
{
|
||||
case TargetType.Actor:
|
||||
return new Order("Attack", self, queued) { TargetActor = target.Actor };
|
||||
case TargetType.FrozenActor:
|
||||
return new Order("Attack", self, queued) { ExtraData = target.FrozenActor.ID };
|
||||
case TargetType.Terrain:
|
||||
return new Order("Attack", self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) };
|
||||
case TargetType.Actor:
|
||||
return new Order("Attack", self, queued) { TargetActor = target.Actor };
|
||||
case TargetType.FrozenActor:
|
||||
return new Order("Attack", self, queued) { ExtraData = target.FrozenActor.ID };
|
||||
case TargetType.Terrain:
|
||||
return new Order("Attack", self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,13 +255,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
switch (target.Type)
|
||||
{
|
||||
case TargetType.Actor:
|
||||
case TargetType.FrozenActor:
|
||||
return CanTargetActor(self, target, modifiers, ref cursor);
|
||||
case TargetType.Terrain:
|
||||
return CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), othersAtTarget, modifiers, ref cursor);
|
||||
default:
|
||||
return false;
|
||||
case TargetType.Actor:
|
||||
case TargetType.FrozenActor:
|
||||
return CanTargetActor(self, target, modifiers, ref cursor);
|
||||
case TargetType.Terrain:
|
||||
return CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), othersAtTarget, modifiers, ref cursor);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,10 +84,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly AttackCharge attack;
|
||||
readonly Target target;
|
||||
|
||||
public ChargeAttack(AttackCharge attack, Target target)
|
||||
{
|
||||
public ChargeAttack(AttackCharge attack, Target target)
|
||||
{
|
||||
this.attack = attack;
|
||||
this.target = target;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
@@ -109,10 +109,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly AttackCharge attack;
|
||||
readonly Target target;
|
||||
|
||||
public ChargeFire(AttackCharge attack, Target target)
|
||||
{
|
||||
public ChargeFire(AttackCharge attack, Target target)
|
||||
{
|
||||
this.attack = attack;
|
||||
this.target = target;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Disable production when there are more than this many of this actor on the battlefield. Set to 0 to disable.")]
|
||||
public readonly int BuildLimit = 0;
|
||||
|
||||
[Desc("What the unit should start doing. Warning: If this is not a harvester", "it will break if you use FindResources.")]
|
||||
[Desc("What the unit should start doing. Warning: If this is not a harvester", "it will break if you use FindResources.")]
|
||||
public readonly string InitialActivity = null;
|
||||
|
||||
// TODO: UI fluff; doesn't belong here
|
||||
|
||||
@@ -35,12 +35,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
if (!rs.DefaultAnimation.HasSequence("dead")) return;
|
||||
|
||||
|
||||
if (rs.DefaultAnimation.GetSequence("dead").Length > 1)
|
||||
rs.DefaultAnimation.Play("dead");
|
||||
else
|
||||
rs.DefaultAnimation.PlayRepeating("dead");
|
||||
|
||||
|
||||
self.World.AddFrameEndTask(
|
||||
w => w.Add(
|
||||
new DelayedAction(info.LingerTime,
|
||||
|
||||
@@ -40,10 +40,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// the one we're playing in.
|
||||
return new DisposableAction(
|
||||
() => { reservedFor = null; reservedForAircraft = null; },
|
||||
() => Game.RunAfterTick(
|
||||
() => { if (Game.IsCurrentWorld(self.World)) throw new InvalidOperationException(
|
||||
"Attempted to finalize an undisposed DisposableAction. {0} ({1}) reserved {2} ({3})"
|
||||
.F(forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID)); }));
|
||||
() => Game.RunAfterTick(() =>
|
||||
{
|
||||
if (Game.IsCurrentWorld(self.World))
|
||||
throw new InvalidOperationException(
|
||||
"Attempted to finalize an undisposed DisposableAction. {0} ({1}) reserved {2} ({3})".F(
|
||||
forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID));
|
||||
}));
|
||||
}
|
||||
|
||||
public static bool IsReserved(Actor a)
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
lastPos = self.Location;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsVisible(Actor self, Player viewer)
|
||||
{
|
||||
if (!Cloaked || self.Owner.IsAlliedWith(viewer))
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var info = self.Info.Traits.Get<GivesBountyInfo>();
|
||||
|
||||
if (e.Attacker == null || e.Attacker.Destroyed) return;
|
||||
if (e.Attacker == null || e.Attacker.Destroyed) return;
|
||||
|
||||
if (!info.Stances.Contains(e.Attacker.Owner.Stances[self.Owner])) return;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (available == wasAvailable)
|
||||
return;
|
||||
|
||||
|
||||
if (available)
|
||||
foreach (var u in info.Upgrades)
|
||||
manager.GrantUpgrade(self, u, this);
|
||||
|
||||
@@ -12,7 +12,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("This actor can be targeted by the Hunt activity.")]
|
||||
public class HuntableInfo : TraitInfo<Huntable> { }
|
||||
public class Huntable { }
|
||||
[Desc("This actor can be targeted by the Hunt activity.")]
|
||||
public class HuntableInfo : TraitInfo<Huntable> { }
|
||||
public class Huntable { }
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Allows automatic targeting of disguised actors.")]
|
||||
class IgnoresDisguiseInfo : TraitInfo<IgnoresDisguise> { }
|
||||
[Desc("Allows automatic targeting of disguised actors.")]
|
||||
class IgnoresDisguiseInfo : TraitInfo<IgnoresDisguise> { }
|
||||
|
||||
class IgnoresDisguise { }
|
||||
class IgnoresDisguise { }
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Neutral/enemy units are blockers. Allied units that are moving are not blockers.
|
||||
if (canIgnoreMovingAllies && self.Owner.Stances[a.Owner] == Stance.Ally && IsMovingInMyDirection(self, a)) continue;
|
||||
|
||||
|
||||
// Non-sharable unit can enter a cell with shareable units only if it can crush all of them.
|
||||
if (needsCellExclusively)
|
||||
return false;
|
||||
@@ -218,7 +218,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Neutral/enemy units are blockers. Allied units that are moving are not blockers.
|
||||
if (canIgnoreMovingAllies && self.Owner.Stances[a.Owner] == Stance.Ally && IsMovingInMyDirection(self, a))
|
||||
return false;
|
||||
|
||||
|
||||
// Non-sharable unit can enter a cell with shareable units only if it can crush all of them.
|
||||
if (needsCellExclusively)
|
||||
return true;
|
||||
@@ -252,7 +252,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
const int AverageTicksBeforePathing = 5;
|
||||
const int SpreadTicksBeforePathing = 5;
|
||||
internal int TicksBeforePathing = 0;
|
||||
|
||||
|
||||
readonly Actor self;
|
||||
public readonly MobileInfo Info;
|
||||
public bool IsMoving { get; set; }
|
||||
|
||||
@@ -36,13 +36,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class MissionObjectivesInfo : ITraitInfo
|
||||
{
|
||||
[Desc("Set this to true if multiple cooperative players have a distinct set of " +
|
||||
"objectives that each of them has to complete to win the game. This is mainly " +
|
||||
"useful for multiplayer coop missions. Do not use this for skirmish team games.")]
|
||||
"objectives that each of them has to complete to win the game. This is mainly " +
|
||||
"useful for multiplayer coop missions. Do not use this for skirmish team games.")]
|
||||
public readonly bool Cooperative = false;
|
||||
|
||||
[Desc("If set to true, this setting causes the game to end immediately once the first " +
|
||||
"player (or team of cooperative players) fails or completes his objectives. If " +
|
||||
"set to false, players that fail their objectives will stick around and become observers.")]
|
||||
"player (or team of cooperative players) fails or completes his objectives. If " +
|
||||
"set to false, players that fail their objectives will stick around and become observers.")]
|
||||
public readonly bool EarlyGameOver = false;
|
||||
|
||||
[Desc("Delay between the game over condition being met, and the game actually ending, in milliseconds.")]
|
||||
@@ -245,8 +245,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
[Desc("Provides game mode progress information for players.",
|
||||
"Goes on WorldActor - observers don't have a player it can live on.",
|
||||
"Current options for PanelName are 'SKIRMISH_STATS' and 'MISSION_OBJECTIVES'.")]
|
||||
"Goes on WorldActor - observers don't have a player it can live on.",
|
||||
"Current options for PanelName are 'SKIRMISH_STATS' and 'MISSION_OBJECTIVES'.")]
|
||||
public class ObjectivesPanelInfo : ITraitInfo
|
||||
{
|
||||
public string PanelName = null;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public double MapControl;
|
||||
public int OrderCount;
|
||||
|
||||
public int EarnedThisMinute
|
||||
public int EarnedThisMinute
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
this.info = info;
|
||||
|
||||
var race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Country.Race;
|
||||
var race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Country.Race;
|
||||
|
||||
Update(init.Self.Owner, race);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
PlayerPower = self.Owner.PlayerActor.Trait<PowerManager>();
|
||||
powerModifiers = Exts.Lazy(() => self.TraitsImplementing<IPowerModifier>().ToArray());
|
||||
}
|
||||
|
||||
|
||||
protected override void UpgradeEnabled(Actor self) { PlayerPower.UpdateActor(self); }
|
||||
protected override void UpgradeDisabled(Actor self) { PlayerPower.UpdateActor(self); }
|
||||
public void AddedToWorld(Actor self) { PlayerPower.UpdateActor(self); }
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var t = init.Actor.Traits.WithInterface<TurretedInfo>()
|
||||
.FirstOrDefault();
|
||||
|
||||
|
||||
// Show the correct turret facing
|
||||
var anim = new Animation(init.World, image, () => t.InitialFacing);
|
||||
anim.PlayRepeating("idle");
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Desc("Custom palette name")]
|
||||
public readonly string Palette = "effect";
|
||||
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithBuildingExplosion(this); }
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.info = info;
|
||||
renderSimple = self.Trait<RenderSimple>();
|
||||
}
|
||||
|
||||
|
||||
public void BuildingPlaced(Actor self)
|
||||
{
|
||||
renderSimple.PlayCustomAnim(self, info.Sequence);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var building = self.Trait<Building>();
|
||||
if (!building.SkipMakeAnimation)
|
||||
{
|
||||
renderBuilding.PlayCustomAnimThen(self, info.Sequence, () =>
|
||||
renderBuilding.PlayCustomAnimThen(self, info.Sequence, () =>
|
||||
{
|
||||
building.NotifyBuildingComplete(self);
|
||||
});
|
||||
|
||||
@@ -38,9 +38,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
anim = new Animation(self.World, rs.GetImage(self));
|
||||
anim.PlayFetchIndex(info.Sequence,
|
||||
() => playerResources.ResourceCapacity != 0
|
||||
? ((10 * anim.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity)
|
||||
: 0);
|
||||
() =>
|
||||
playerResources.ResourceCapacity != 0 ?
|
||||
((10 * anim.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity) :
|
||||
0);
|
||||
|
||||
rs.Add("resources_{0}".F(info.Sequence), new AnimationWithOffset(
|
||||
anim, null, () => !buildComplete, 1024));
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (health.HP >= Info.HealIfBelow * health.MaxHP)
|
||||
return;
|
||||
|
||||
|
||||
if (damageTicks > 0)
|
||||
{
|
||||
--damageTicks;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void AppliedDamage(Actor self, Actor damaged, AttackInfo e)
|
||||
{
|
||||
// Don't notify suicides
|
||||
if (e.DamageState == DamageState.Dead && damaged != e.Attacker)
|
||||
if (e.DamageState == DamageState.Dead && damaged != e.Attacker)
|
||||
{
|
||||
if (self.World.WorldTick - lastAnnounce > info.Interval * 25)
|
||||
Sound.PlayVoice("Kill", self, self.Owner.Country.Race);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Death notification voice.")]
|
||||
public readonly string DeathSound = "Die";
|
||||
|
||||
|
||||
[Desc("Multiply volume with this factor.")]
|
||||
public readonly float VolumeMultiplier = 1f;
|
||||
|
||||
|
||||
@@ -99,8 +99,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Select only the tiles that are within range from the requested SubCell
|
||||
// This assumes that the SubCell does not change during the path traversal
|
||||
var tilesInRange = world.Map.FindTilesInCircle(targetCell, range.Range / 1024 + 1)
|
||||
.Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= rangeSquared
|
||||
&& mi.CanEnterCell(self.World, self, t));
|
||||
.Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= rangeSquared &&
|
||||
mi.CanEnterCell(self.World, self, t));
|
||||
|
||||
// See if there is any cell within range that does not involve a cross-domain request
|
||||
// Really, we only need to check the circle perimeter, but it's not clear that would be a performance win
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string FogPalette = "fog";
|
||||
|
||||
[Desc("Bitfield of shroud directions for each frame. Lower four bits are",
|
||||
"corners clockwise from TL; upper four are edges clockwise from top")]
|
||||
"corners clockwise from TL; upper four are edges clockwise from top")]
|
||||
public readonly int[] Index = new[] { 12, 9, 8, 3, 1, 6, 4, 2, 13, 11, 7, 14 };
|
||||
|
||||
[Desc("Use the upper four bits when calculating frame")]
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* 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.
|
||||
*/
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -284,7 +284,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
if (o != 255 && overlayResourceMapping.ContainsKey(redAlertOverlayNames[o]))
|
||||
res = overlayResourceMapping[redAlertOverlayNames[o]];
|
||||
|
||||
|
||||
var cell = new CPos(i, j);
|
||||
map.MapResources.Value[cell] = new ResourceTile(res.First, res.Second);
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
var powerFields = new List<MiniYamlNode> { new MiniYamlNode("Amount", power.Value) };
|
||||
actorTraits.Add(new MiniYamlNode("Power", new MiniYaml("", powerFields)));
|
||||
|
||||
|
||||
if (FieldLoader.GetValue<int>("Power", power.Value.Value) > 0)
|
||||
actorTraits.Add(new MiniYamlNode("ScaleWithHealth", ""));
|
||||
}
|
||||
@@ -528,7 +528,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (engineVersion < 20140913)
|
||||
{
|
||||
var spawnsCorpseRemoval = node.Value.Nodes.FirstOrDefault(n => n.Key == "SpawnsCorpse");
|
||||
|
||||
|
||||
if (depth == 0 && node.Value.Nodes.Any(n => n.Key.StartsWith("RenderInfantry")) && spawnsCorpseRemoval == null)
|
||||
node.Value.Nodes.Add(new MiniYamlNode("WithDeathAnimation", new MiniYaml("")));
|
||||
|
||||
@@ -732,13 +732,13 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
ConvertAngle(ref node.Value.Value);
|
||||
break;
|
||||
case "Speed":
|
||||
{
|
||||
if (parent.Value.Value == "Missile")
|
||||
ConvertPxToRange(ref node.Value.Value, 1, 5);
|
||||
if (parent.Value.Value == "Bullet")
|
||||
ConvertPxToRange(ref node.Value.Value, 2, 5);
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (parent.Value.Value == "Missile")
|
||||
ConvertPxToRange(ref node.Value.Value, 1, 5);
|
||||
if (parent.Value.Value == "Bullet")
|
||||
ConvertPxToRange(ref node.Value.Value, 2, 5);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -171,25 +171,25 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
switch (mi.Event)
|
||||
{
|
||||
case MouseInputEvent.Up:
|
||||
isMoving = false;
|
||||
YieldMouseFocus(mi);
|
||||
break;
|
||||
case MouseInputEvent.Up:
|
||||
isMoving = false;
|
||||
YieldMouseFocus(mi);
|
||||
break;
|
||||
|
||||
case MouseInputEvent.Down:
|
||||
isMoving = true;
|
||||
SetValueFromPx(mi.Location - RenderOrigin);
|
||||
OnChange();
|
||||
break;
|
||||
|
||||
case MouseInputEvent.Move:
|
||||
if (isMoving)
|
||||
{
|
||||
case MouseInputEvent.Down:
|
||||
isMoving = true;
|
||||
SetValueFromPx(mi.Location - RenderOrigin);
|
||||
OnChange();
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
case MouseInputEvent.Move:
|
||||
if (isMoving)
|
||||
{
|
||||
SetValueFromPx(mi.Location - RenderOrigin);
|
||||
OnChange();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
var playerWidget = panel.GetOrNull<VqaPlayerWidget>("PLAYER");
|
||||
if (playerWidget != null)
|
||||
if (playerWidget != null)
|
||||
playerWidget.IsVisible = () => isVideoLoaded;
|
||||
|
||||
var paletteDropDown = panel.GetOrNull<DropDownButtonWidget>("PALETTE_SELECTOR");
|
||||
@@ -118,22 +118,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
frameSlider = panel.Get<SliderWidget>("FRAME_SLIDER");
|
||||
if (frameSlider != null)
|
||||
{
|
||||
frameSlider.OnChange += x =>
|
||||
frameSlider.OnChange += x =>
|
||||
{
|
||||
if (!isVideoLoaded)
|
||||
currentFrame = (int)Math.Round(x);
|
||||
if (!isVideoLoaded)
|
||||
currentFrame = (int)Math.Round(x);
|
||||
};
|
||||
|
||||
frameSlider.GetValue = () => isVideoLoaded ? player.Video.CurrentFrame : currentFrame;
|
||||
frameSlider.IsDisabled = () => isVideoLoaded;
|
||||
frameSlider.IsDisabled = () => isVideoLoaded;
|
||||
}
|
||||
|
||||
var frameText = panel.GetOrNull<LabelWidget>("FRAME_COUNT");
|
||||
if (frameText != null)
|
||||
{
|
||||
frameText.GetText = () =>
|
||||
isVideoLoaded ?
|
||||
"{0} / {1}".F(player.Video.CurrentFrame + 1, player.Video.Frames) :
|
||||
frameText.GetText = () =>
|
||||
isVideoLoaded ?
|
||||
"{0} / {1}".F(player.Video.CurrentFrame + 1, player.Video.Frames) :
|
||||
"{0} / {1}".F(currentFrame + 1, currentSprites.Length);
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
nextButton.OnClick = () =>
|
||||
{
|
||||
if (!isVideoLoaded)
|
||||
if (!isVideoLoaded)
|
||||
nextButton.OnClick = SelectNextFrame;
|
||||
};
|
||||
|
||||
@@ -211,12 +211,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var closeButton = panel.GetOrNull<ButtonWidget>("CLOSE_BUTTON");
|
||||
if (closeButton != null)
|
||||
closeButton.OnClick = () =>
|
||||
closeButton.OnClick = () =>
|
||||
{
|
||||
if (isVideoLoaded)
|
||||
player.Stop();
|
||||
Ui.CloseWindow();
|
||||
onExit();
|
||||
onExit();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
player = null;
|
||||
isVideoLoaded = false;
|
||||
}
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
return false;
|
||||
|
||||
@@ -325,8 +325,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Func<IFolder, ScrollItemWidget, ScrollItemWidget> setupItem = (source, itemTemplate) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => assetSource == source,
|
||||
() => { assetSource = source; PopulateAssetList(); });
|
||||
() => assetSource == source,
|
||||
() => { assetSource = source; PopulateAssetList(); });
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => source != null ? Platform.UnresolvePath(source.Name) : "All Packages";
|
||||
return item;
|
||||
};
|
||||
@@ -359,7 +359,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ShowPaletteDropdown(DropDownButtonWidget dropdown, World world)
|
||||
{
|
||||
Func<PaletteFromFile, ScrollItemWidget, ScrollItemWidget> setupItem = (palette, itemTemplate) =>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public DisconnectWatcherLogic(Widget widget, OrderManager orderManager)
|
||||
{
|
||||
var disconnected = false;
|
||||
widget.Get<LogicTickerWidget>("DISCONNECT_WATCHER").OnTick = () =>
|
||||
widget.Get<LogicTickerWidget>("DISCONNECT_WATCHER").OnTick = () =>
|
||||
{
|
||||
if (disconnected || orderManager.Connection.ConnectionState != ConnectionState.NotConnected)
|
||||
return;
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var textBox = key.Get<HotkeyEntryWidget>("HOTKEY");
|
||||
textBox.Key = (Hotkey)field.GetValue(ks);
|
||||
textBox.OnLoseFocus = () => field.SetValue(ks, textBox.Key);
|
||||
textBox.OnLoseFocus = () => field.SetValue(ks, textBox.Key);
|
||||
parent.AddChild(key);
|
||||
}
|
||||
|
||||
@@ -536,8 +536,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (o, itemTemplate) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||
() => s.MouseScroll == options[o],
|
||||
() => s.MouseScroll = options[o]);
|
||||
() => s.MouseScroll == options[o],
|
||||
() => s.MouseScroll = options[o]);
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => o;
|
||||
return item;
|
||||
};
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var stride = radarSheet.Size.Width;
|
||||
var dx = actorSprite.Bounds.Left - world.Map.Bounds.Left;
|
||||
var dy = actorSprite.Bounds.Top - world.Map.Bounds.Top;
|
||||
|
||||
|
||||
Array.Clear(radarData, 4 * (actorSprite.Bounds.Top * stride + actorSprite.Bounds.Left), 4 * actorSprite.Bounds.Height * stride);
|
||||
|
||||
unsafe
|
||||
|
||||
@@ -96,8 +96,9 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
}
|
||||
}
|
||||
else
|
||||
Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, (int)float2.Lerp(b.Bottom, b.Top, providedFrac),
|
||||
b.Width, (int)(providedFrac * b.Height)), color);
|
||||
Game.Renderer.LineRenderer.FillRect(new Rectangle(
|
||||
b.X, (int)float2.Lerp(b.Bottom, b.Top, providedFrac),
|
||||
b.Width, (int)(providedFrac * b.Height)), color);
|
||||
|
||||
var x = (b.Left + b.Right - indicator.Size.X) / 2;
|
||||
var y = float2.Lerp(b.Bottom, b.Top, usedFrac) - indicator.Size.Y / 2;
|
||||
|
||||
Reference in New Issue
Block a user