Remove unused parameters.

This commit is contained in:
Matthias Mailänder
2022-03-13 12:02:52 +01:00
committed by abcdefg30
parent ea243b8558
commit 0e7ad43425
205 changed files with 451 additions and 455 deletions

View File

@@ -141,6 +141,9 @@ dotnet_diagnostic.IDE0040.severity = warning
# Make field readonly. # Make field readonly.
dotnet_diagnostic.IDE0044.severity = warning dotnet_diagnostic.IDE0044.severity = warning
# Unused parameter.
dotnet_diagnostic.IDE0060.severity = warning
# Naming rule violation. # Naming rule violation.
dotnet_diagnostic.IDE1006.severity = warning dotnet_diagnostic.IDE1006.severity = warning

View File

@@ -131,7 +131,7 @@ namespace OpenRA
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal)); filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal));
var weapons = MergeOrDefault("Manifest,Weapons", fs, m.Weapons, null, null, var weapons = MergeOrDefault("Manifest,Weapons", fs, m.Weapons, null, null,
k => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value)); k => new WeaponInfo(k.Value));
var voices = MergeOrDefault("Manifest,Voices", fs, m.Voices, null, null, var voices = MergeOrDefault("Manifest,Voices", fs, m.Voices, null, null,
k => new SoundInfo(k.Value)); k => new SoundInfo(k.Value));
@@ -190,7 +190,7 @@ namespace OpenRA
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal)); filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal));
var weapons = MergeOrDefault("Weapons", fileSystem, m.Weapons, mapWeapons, dr.Weapons, var weapons = MergeOrDefault("Weapons", fileSystem, m.Weapons, mapWeapons, dr.Weapons,
k => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value)); k => new WeaponInfo(k.Value));
var voices = MergeOrDefault("Voices", fileSystem, m.Voices, mapVoices, dr.Voices, var voices = MergeOrDefault("Voices", fileSystem, m.Voices, mapVoices, dr.Voices,
k => new SoundInfo(k.Value)); k => new SoundInfo(k.Value));

View File

@@ -127,7 +127,7 @@ namespace OpenRA.GameRules
[FieldLoader.LoadUsing(nameof(LoadWarheads))] [FieldLoader.LoadUsing(nameof(LoadWarheads))]
public readonly List<IWarhead> Warheads = new List<IWarhead>(); public readonly List<IWarhead> Warheads = new List<IWarhead>();
public WeaponInfo(string name, MiniYaml content) public WeaponInfo(MiniYaml content)
{ {
// Resolve any weapon-level yaml inheritance or removals // Resolve any weapon-level yaml inheritance or removals
// HACK: The "Defaults" sequence syntax prevents us from doing this generally during yaml parsing // HACK: The "Defaults" sequence syntax prevents us from doing this generally during yaml parsing

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Graphics
ZOffset = zOffset; ZOffset = zOffset;
} }
public IRenderable[] Render(Actor self, WorldRenderer wr, PaletteReference pal) public IRenderable[] Render(Actor self, PaletteReference pal)
{ {
var center = self.CenterPosition; var center = self.CenterPosition;
var offset = OffsetFunc?.Invoke() ?? WVec.Zero; var offset = OffsetFunc?.Invoke() ?? WVec.Zero;

View File

@@ -84,6 +84,7 @@ namespace OpenRA.Graphics
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
public PlaceholderModelSequenceLoader(ModData modData) { } public PlaceholderModelSequenceLoader(ModData modData) { }
public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelDefinitions) public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelDefinitions)

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Graphics
shader.SetTexture("Palette", palette); shader.SetTexture("Palette", palette);
} }
public void SetViewportParams(Size screen, int2 scroll) public void SetViewportParams()
{ {
var a = 2f / renderer.SheetSize; var a = 2f / renderer.SheetSize;
var view = new[] var view = new[]

View File

@@ -261,7 +261,7 @@ namespace OpenRA.Graphics
return new Vertex(xyz, cr, cg, cb, ca, 0, 0); return new Vertex(xyz, cr, cg, cb, ca, 0, 0);
} }
public void FillEllipse(in float3 tl, in float3 br, Color color, int vertices = 32, BlendMode blendMode = BlendMode.Alpha) public void FillEllipse(in float3 tl, in float3 br, Color color, BlendMode blendMode = BlendMode.Alpha)
{ {
// TODO: Create an ellipse polygon instead // TODO: Create an ellipse polygon instead
var a = (br.X - tl.X) / 2; var a = (br.X - tl.X) / 2;

View File

@@ -56,14 +56,14 @@ namespace OpenRA.Graphics
foreach (var b in waypoints.Skip(1).Select(pos => wr.Viewport.WorldToViewPx(wr.Screen3DPosition(pos)))) foreach (var b in waypoints.Skip(1).Select(pos => wr.Viewport.WorldToViewPx(wr.Screen3DPosition(pos))))
{ {
Game.Renderer.RgbaColorRenderer.DrawLine(a, b, width, color); Game.Renderer.RgbaColorRenderer.DrawLine(a, b, width, color);
DrawTargetMarker(wr, color, b, markerSize); DrawTargetMarker(color, b, markerSize);
a = b; a = b;
} }
DrawTargetMarker(wr, color, first); DrawTargetMarker(color, first);
} }
public static void DrawTargetMarker(WorldRenderer wr, Color color, int2 screenPos, int size = 1) public static void DrawTargetMarker(Color color, int2 screenPos, int size = 1)
{ {
var offset = new int2(size, size); var offset = new int2(size, size);
var tl = screenPos - offset; var tl = screenPos - offset;

View File

@@ -87,7 +87,7 @@ namespace OpenRA
var sequenceFormat = Manifest.Get<SpriteSequenceFormat>(); var sequenceFormat = Manifest.Get<SpriteSequenceFormat>();
var sequenceLoader = ObjectCreator.FindType(sequenceFormat.Type + "Loader"); var sequenceLoader = ObjectCreator.FindType(sequenceFormat.Type + "Loader");
var sequenceCtor = sequenceLoader != null ? sequenceLoader.GetConstructor(new[] { typeof(ModData) }) : null; var sequenceCtor = sequenceLoader?.GetConstructor(new[] { typeof(ModData) });
if (sequenceLoader == null || !sequenceLoader.GetInterfaces().Contains(typeof(ISpriteSequenceLoader)) || sequenceCtor == null) if (sequenceLoader == null || !sequenceLoader.GetInterfaces().Contains(typeof(ISpriteSequenceLoader)) || sequenceCtor == null)
throw new InvalidOperationException($"Unable to find a sequence loader for type '{sequenceFormat.Type}'."); throw new InvalidOperationException($"Unable to find a sequence loader for type '{sequenceFormat.Type}'.");

View File

@@ -44,9 +44,8 @@ namespace OpenRA.Orders
public virtual IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi) public virtual IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
{ {
var target = TargetForInput(world, cell, worldPixel, mi); var target = TargetForInput(world, cell, worldPixel, mi);
var actorsAt = world.ActorMap.GetActorsAt(cell).ToList();
var orders = world.Selection.Actors var orders = world.Selection.Actors
.Select(a => OrderForUnit(a, target, actorsAt, cell, mi)) .Select(a => OrderForUnit(a, target, cell, mi))
.Where(o => o != null) .Where(o => o != null)
.ToList(); .ToList();
@@ -70,7 +69,6 @@ namespace OpenRA.Orders
public virtual string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) public virtual string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{ {
var target = TargetForInput(world, cell, worldPixel, mi); var target = TargetForInput(world, cell, worldPixel, mi);
var actorsAt = world.ActorMap.GetActorsAt(cell).ToList();
bool useSelect; bool useSelect;
if (Game.Settings.Game.UseClassicMouseStyle && !InputOverridesSelection(world, worldPixel, mi)) if (Game.Settings.Game.UseClassicMouseStyle && !InputOverridesSelection(world, worldPixel, mi))
@@ -78,7 +76,7 @@ namespace OpenRA.Orders
else else
{ {
var ordersWithCursor = world.Selection.Actors var ordersWithCursor = world.Selection.Actors
.Select(a => OrderForUnit(a, target, actorsAt, cell, mi)) .Select(a => OrderForUnit(a, target, cell, mi))
.Where(o => o != null && o.Cursor != null); .Where(o => o != null && o.Cursor != null);
var cursorOrder = ordersWithCursor.MaxByOrDefault(o => o.Order.OrderPriority); var cursorOrder = ordersWithCursor.MaxByOrDefault(o => o.Order.OrderPriority);
@@ -120,7 +118,7 @@ namespace OpenRA.Orders
foreach (var a in world.Selection.Actors) foreach (var a in world.Selection.Actors)
{ {
var o = OrderForUnit(a, target, actorsAt, cell, mi); var o = OrderForUnit(a, target, cell, mi);
if (o != null && o.Order.TargetOverridesSelection(a, target, actorsAt, cell, modifiers)) if (o != null && o.Order.TargetOverridesSelection(a, target, actorsAt, cell, modifiers))
return true; return true;
} }
@@ -135,7 +133,7 @@ namespace OpenRA.Orders
/// First priority is given to orders that interact with the given actors. /// First priority is given to orders that interact with the given actors.
/// Second priority is given to actors in the given cell. /// Second priority is given to actors in the given cell.
/// </summary> /// </summary>
static UnitOrderResult OrderForUnit(Actor self, Target target, List<Actor> actorsAt, CPos xy, MouseInput mi) static UnitOrderResult OrderForUnit(Actor self, Target target, CPos xy, MouseInput mi)
{ {
if (mi.Button != Game.Settings.Game.MouseButtonPreference.Action) if (mi.Button != Game.Settings.Game.MouseButtonPreference.Action)
return null; return null;
@@ -174,7 +172,7 @@ namespace OpenRA.Orders
{ {
var localModifiers = modifiers; var localModifiers = modifiers;
string cursor = null; string cursor = null;
if (o.Order.CanTarget(self, target, actorsAt, ref localModifiers, ref cursor)) if (o.Order.CanTarget(self, target, ref localModifiers, ref cursor))
return new UnitOrderResult(self, o.Order, o.Trait, cursor, target); return new UnitOrderResult(self, o.Order, o.Trait, cursor, target);
} }

View File

@@ -254,7 +254,7 @@ namespace OpenRA
if (lastWorldViewport != worldViewport) if (lastWorldViewport != worldViewport)
{ {
WorldSpriteRenderer.SetViewportParams(worldSheet.Size, worldDownscaleFactor, depthMargin, worldViewport.Location); WorldSpriteRenderer.SetViewportParams(worldSheet.Size, worldDownscaleFactor, depthMargin, worldViewport.Location);
WorldModelRenderer.SetViewportParams(worldSheet.Size, worldViewport.Location); WorldModelRenderer.SetViewportParams();
lastWorldViewport = worldViewport; lastWorldViewport = worldViewport;
} }

View File

@@ -252,7 +252,7 @@ namespace OpenRA.Scripting
worldLoaded.Call().Dispose(); worldLoaded.Call().Dispose();
} }
public void Tick(Actor self) public void Tick()
{ {
if (FatalErrorOccurred || disposed) if (FatalErrorOccurred || disposed)
return; return;

View File

@@ -108,7 +108,7 @@ namespace OpenRA.Scripting
throw new LuaException($"The property '{Member.Name}' is write-only"); throw new LuaException($"The property '{Member.Name}' is write-only");
} }
public void Set(LuaRuntime runtime, LuaValue value) public void Set(LuaValue value)
{ {
if (IsSetProperty) if (IsSetProperty)
{ {

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Scripting
if (!members.TryGetValue(name, out var wrapper)) if (!members.TryGetValue(name, out var wrapper))
throw new LuaException(MemberNotFoundError(name)); throw new LuaException(MemberNotFoundError(name));
wrapper.Set(runtime, value); wrapper.Set(value);
} }
} }
} }

View File

@@ -1032,7 +1032,7 @@ namespace OpenRA.Server
} }
} }
public void ReceivePing(Connection conn, int[] pingHistory, byte queueLength) public void ReceivePing(Connection conn, int[] pingHistory)
{ {
// Levels set relative to the default order lag of 3 net ticks (360ms) // Levels set relative to the default order lag of 3 net ticks (360ms)
// TODO: Adjust this once dynamic lag is implemented // TODO: Adjust this once dynamic lag is implemented
@@ -1389,7 +1389,7 @@ namespace OpenRA.Server
void IServerEvent.Invoke(Server server) void IServerEvent.Invoke(Server server)
{ {
server.ReceivePing(connection, pingHistory, queueLength); server.ReceivePing(connection, pingHistory);
} }
} }

View File

@@ -195,7 +195,7 @@ namespace OpenRA.Traits
flashAlpha = null; flashAlpha = null;
} }
public IEnumerable<IRenderable> Render(WorldRenderer wr) public IEnumerable<IRenderable> Render()
{ {
if (Shrouded) if (Shrouded)
return NoRenderables; return NoRenderables;
@@ -323,7 +323,7 @@ namespace OpenRA.Traits
{ {
return world.ScreenMap.RenderableFrozenActorsInBox(owner, wr.Viewport.TopLeft, wr.Viewport.BottomRight) return world.ScreenMap.RenderableFrozenActorsInBox(owner, wr.Viewport.TopLeft, wr.Viewport.BottomRight)
.Where(f => f.Visible) .Where(f => f.Visible)
.SelectMany(ff => ff.Render(wr)); .SelectMany(ff => ff.Render());
} }
public IEnumerable<Rectangle> ScreenBounds(Actor self, WorldRenderer wr) public IEnumerable<Rectangle> ScreenBounds(Actor self, WorldRenderer wr)

View File

@@ -299,7 +299,7 @@ namespace OpenRA.Traits
sources.Remove(key); sources.Remove(key);
} }
public void ExploreProjectedCells(World world, IEnumerable<PPos> cells) public void ExploreProjectedCells(IEnumerable<PPos> cells)
{ {
foreach (var puv in cells) foreach (var puv in cells)
{ {

View File

@@ -138,7 +138,7 @@ namespace OpenRA.Traits
{ {
string OrderID { get; } string OrderID { get; }
int OrderPriority { get; } int OrderPriority { get; }
bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor); bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor);
bool IsQueued { get; } bool IsQueued { get; }
bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers); bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers);
} }

View File

@@ -49,7 +49,7 @@ namespace OpenRA
return self.TraitsImplementing<IVoiced>().Any(x => x.HasVoice(self, voice)); return self.TraitsImplementing<IVoiced>().Any(x => x.HasVoice(self, voice));
} }
public static void PlayVoiceForOrders(this World w, Order[] orders) public static void PlayVoiceForOrders(this Order[] orders)
{ {
// Find the first actor with a phrase to say // Find the first actor with a phrase to say
foreach (var o in orders) foreach (var o in orders)

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Cnc.Activities
int ticks = 0; int ticks = 0;
WPos targetPosition; WPos targetPosition;
public Leap(Actor self, in Target target, Mobile mobile, Mobile targetMobile, int speed, AttackLeap attack, EdibleByLeap edible) public Leap(in Target target, Mobile mobile, Mobile targetMobile, int speed, AttackLeap attack, EdibleByLeap edible)
{ {
this.mobile = mobile; this.mobile = mobile;
this.targetMobile = targetMobile; this.targetMobile = targetMobile;
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Cnc.Activities
// Update movement which results in movementType set to MovementType.None. // Update movement which results in movementType set to MovementType.None.
// This is needed to prevent the move animation from playing. // This is needed to prevent the move animation from playing.
mobile.UpdateMovement(self); mobile.UpdateMovement();
// Revoke the condition before attacking, as it is usually used to pause the attack trait // Revoke the condition before attacking, as it is usually used to pause the attack trait
attack.RevokeLeapCondition(self); attack.RevokeLeapCondition(self);

View File

@@ -138,7 +138,7 @@ namespace OpenRA.Mods.Cnc.Activities
return false; return false;
} }
QueueChild(new Leap(self, target, mobile, targetMobile, info.Speed.Length, attack, edible)); QueueChild(new Leap(target, mobile, targetMobile, info.Speed.Length, attack, edible));
// Re-queue the child activities to kill the target if it didn't die in one go // Re-queue the child activities to kill the target if it didn't die in one go
return false; return false;

View File

@@ -21,6 +21,7 @@ namespace OpenRA.Mods.Cnc.Graphics
{ {
public Action<string> OnMissingModelError { get; set; } public Action<string> OnMissingModelError { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
public VoxelModelSequenceLoader(ModData modData) { } public VoxelModelSequenceLoader(ModData modData) { }
public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelSequences) public IModelCache CacheModels(IReadOnlyFileSystem fileSystem, ModData modData, IReadOnlyDictionary<string, MiniYamlNode> modelSequences)

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Cnc.Traits
public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor) public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{ {
return new AttackTDGunboatTurretedActivity(self, newTarget, allowMove, forceAttack, targetLineColor); return new AttackTDGunboatTurretedActivity(self, newTarget, forceAttack, targetLineColor);
} }
class AttackTDGunboatTurretedActivity : Activity class AttackTDGunboatTurretedActivity : Activity
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
readonly Color? targetLineColor; readonly Color? targetLineColor;
bool hasTicked; bool hasTicked;
public AttackTDGunboatTurretedActivity(Actor self, in Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null) public AttackTDGunboatTurretedActivity(Actor self, in Target target, bool forceAttack, Color? targetLineColor = null)
{ {
attack = self.Trait<AttackTDGunboatTurreted>(); attack = self.Trait<AttackTDGunboatTurreted>();
this.target = target; this.target = target;
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Traits
if (hasTicked && attack.RequestedTarget.Type == TargetType.Invalid) if (hasTicked && attack.RequestedTarget.Type == TargetType.Invalid)
return true; return true;
attack.SetRequestedTarget(self, target); attack.SetRequestedTarget(target);
hasTicked = true; hasTicked = true;
} }

View File

@@ -26,14 +26,14 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Damage is divided by this number when converting damage to drain ticks.")] [Desc("Damage is divided by this number when converting damage to drain ticks.")]
public readonly int DamageDivisor = 600; public readonly int DamageDivisor = 600;
public override object Create(ActorInitializer init) { return new DrainPrerequisitePowerOnDamage(init.Self, this); } public override object Create(ActorInitializer init) { return new DrainPrerequisitePowerOnDamage(this); }
} }
public class DrainPrerequisitePowerOnDamage : ConditionalTrait<DrainPrerequisitePowerOnDamageInfo>, INotifyOwnerChanged, IDamageModifier public class DrainPrerequisitePowerOnDamage : ConditionalTrait<DrainPrerequisitePowerOnDamageInfo>, INotifyOwnerChanged, IDamageModifier
{ {
SupportPowerManager spm; SupportPowerManager spm;
public DrainPrerequisitePowerOnDamage(Actor self, DrainPrerequisitePowerOnDamageInfo info) public DrainPrerequisitePowerOnDamage(DrainPrerequisitePowerOnDamageInfo info)
: base(info) { } : base(info) { }
protected override void Created(Actor self) protected override void Created(Actor self)

View File

@@ -30,14 +30,14 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Sound the perpetrator will hear after successful infiltration.")] [Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null; public readonly string InfiltrationNotification = null;
public override object Create(ActorInitializer init) { return new InfiltrateForExploration(init.Self, this); } public override object Create(ActorInitializer init) { return new InfiltrateForExploration(this); }
} }
class InfiltrateForExploration : INotifyInfiltrated class InfiltrateForExploration : INotifyInfiltrated
{ {
readonly InfiltrateForExplorationInfo info; readonly InfiltrateForExplorationInfo info;
public InfiltrateForExploration(Actor self, InfiltrateForExplorationInfo info) public InfiltrateForExploration(InfiltrateForExplorationInfo info)
{ {
this.info = info; this.info = info;
} }

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Cnc.Traits
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);
} }
bool IsValidOrder(Actor self, Order order) bool IsValidOrder(Order order)
{ {
if (IsTraitDisabled) if (IsTraitDisabled)
return false; return false;
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Cnc.Traits
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)
{ {
return order.OrderString == "Infiltrate" && IsValidOrder(self, order) return order.OrderString == "Infiltrate" && IsValidOrder(order)
? Info.Voice : null; ? Info.Voice : null;
} }
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Cnc.Traits
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString != "Infiltrate" || !IsValidOrder(self, order) || IsTraitDisabled) if (order.OrderString != "Infiltrate" || !IsValidOrder(order) || IsTraitDisabled)
return; return;
if (!CanInfiltrateTarget(self, order.Target)) if (!CanInfiltrateTarget(self, order.Target))

View File

@@ -360,7 +360,7 @@ namespace OpenRA.Mods.Cnc.Traits
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Terrain) if (target.Type != TargetType.Terrain)
return false; return false;

View File

@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Cnc.Traits
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{ {
if (modifiers.HasModifier(TargetModifiers.ForceMove)) if (modifiers.HasModifier(TargetModifiers.ForceMove))
{ {

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
IEnumerable<IRenderable> IRender.Render(Actor self, WorldRenderer wr) IEnumerable<IRenderable> IRender.Render(Actor self, WorldRenderer wr)
{ {
var bodyOrientation = body.QuantizeOrientation(self, self.Orientation); var bodyOrientation = body.QuantizeOrientation(self.Orientation);
var pos = self.CenterPosition; var pos = self.CenterPosition;
var i = 0; var i = 0;

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
.FirstOrDefault(t => t.EnabledByDefault); .FirstOrDefault(t => t.EnabledByDefault);
if (renderSprites != null && infantryBody != null) if (renderSprites != null && infantryBody != null)
{ {
disguiseImage = renderSprites.GetImage(disguiseActor, self.World.Map.Rules.Sequences, disguisePlayer.Faction.InternalName); disguiseImage = renderSprites.GetImage(disguiseActor, disguisePlayer.Faction.InternalName);
disguiseInfantryBody = infantryBody; disguiseInfantryBody = infantryBody;
} }
} }

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
overlay.Play(info.Sequence); overlay.Play(info.Sequence);
WithOffset = new AnimationWithOffset(overlay, WithOffset = new AnimationWithOffset(overlay,
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self.Orientation))),
() => !Visible || IsTraitDisabled); () => !Visible || IsTraitDisabled);
rs.Add(WithOffset, info.Palette, info.IsPlayerPalette); rs.Add(WithOffset, info.Palette, info.IsPlayerPalette);

View File

@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
var idleModel = self.World.ModelCache.GetModelSequence(rv.Image, info.IdleSequence); var idleModel = self.World.ModelCache.GetModelSequence(rv.Image, info.IdleSequence);
modelAnimation = new ModelAnimation(idleModel, () => WVec.Zero, modelAnimation = new ModelAnimation(idleModel, () => WVec.Zero,
() => body.QuantizeOrientation(self, self.Orientation), () => body.QuantizeOrientation(self.Orientation),
() => Docked, () => Docked,
() => 0, info.ShowShadow); () => 0, info.ShowShadow);
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
var unloadModel = self.World.ModelCache.GetModelSequence(rv.Image, info.UnloadSequence); var unloadModel = self.World.ModelCache.GetModelSequence(rv.Image, info.UnloadSequence);
rv.Add(new ModelAnimation(unloadModel, () => WVec.Zero, rv.Add(new ModelAnimation(unloadModel, () => WVec.Zero,
() => body.QuantizeOrientation(self, self.Orientation), () => body.QuantizeOrientation(self.Orientation),
() => !Docked, () => !Docked,
() => 0, info.ShowShadow)); () => 0, info.ShowShadow));
} }

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
var model = self.World.ModelCache.GetModelSequence(rv.Image, info.Sequence); var model = self.World.ModelCache.GetModelSequence(rv.Image, info.Sequence);
frames = model.Frames; frames = model.Frames;
modelAnimation = new ModelAnimation(model, () => WVec.Zero, modelAnimation = new ModelAnimation(model, () => WVec.Zero,
() => body.QuantizeOrientation(self, self.Orientation), () => body.QuantizeOrientation(self.Orientation),
() => IsTraitDisabled, () => frame, info.ShowShadow); () => IsTraitDisabled, () => frame, info.ShowShadow);
rv.Add(modelAnimation); rv.Add(modelAnimation);

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("How often the cash ticks can appear.")] [Desc("How often the cash ticks can appear.")]
public readonly int TickRate = 10; public readonly int TickRate = 10;
public override object Create(ActorInitializer init) { return new ResourcePurifier(init.Self, this); } public override object Create(ActorInitializer init) { return new ResourcePurifier(this); }
} }
public class ResourcePurifier : ConditionalTrait<ResourcePurifierInfo>, INotifyResourceAccepted, ITick, INotifyOwnerChanged public class ResourcePurifier : ConditionalTrait<ResourcePurifierInfo>, INotifyResourceAccepted, ITick, INotifyOwnerChanged
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
int currentDisplayTick; int currentDisplayTick;
int currentDisplayValue; int currentDisplayValue;
public ResourcePurifier(Actor self, ResourcePurifierInfo info) public ResourcePurifier(ResourcePurifierInfo info)
: base(info) : base(info)
{ {
modifier = new int[] { Info.Modifier }; modifier = new int[] { Info.Modifier };

View File

@@ -70,13 +70,13 @@ namespace OpenRA.Mods.Cnc.Traits
return new DischargeableSupportPowerInstance(key, info, manager); return new DischargeableSupportPowerInstance(key, info, manager);
} }
public void Activate(Actor self, SupportPowerInstance instance) public void Activate(Actor self)
{ {
active = true; active = true;
techTree.ActorChanged(self); techTree.ActorChanged(self);
} }
public void Deactivate(Actor self, SupportPowerInstance instance) public void Deactivate(Actor self)
{ {
active = false; active = false;
techTree.ActorChanged(self); techTree.ActorChanged(self);
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Cnc.Traits
available = false; available = false;
foreach (var p in Instances) foreach (var p in Instances)
((GrantPrerequisiteChargeDrainPower)p).Deactivate(p.Self, this); ((GrantPrerequisiteChargeDrainPower)p).Deactivate(p.Self);
} }
public override void Tick() public override void Tick()
@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Cnc.Traits
power.PlayLaunchSounds(); power.PlayLaunchSounds();
foreach (var p in Instances) foreach (var p in Instances)
((GrantPrerequisiteChargeDrainPower)p).Activate(p.Self, this); ((GrantPrerequisiteChargeDrainPower)p).Activate(p.Self);
} }
public override string IconOverlayTextOverride() public override string IconOverlayTextOverride()

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Cnc.Traits
return; return;
var external = toActor.TraitsImplementing<ExternalCondition>() var external = toActor.TraitsImplementing<ExternalCondition>()
.FirstOrDefault(t => t.Info.Condition == info.Condition && t.CanGrantCondition(toActor, this)); .FirstOrDefault(t => t.Info.Condition == info.Condition && t.CanGrantCondition(this));
external?.GrantCondition(toActor, this, duration, remaining); external?.GrantCondition(toActor, this, duration, remaining);
} }

View File

@@ -239,7 +239,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
public override void ReadActors(IniFile file) public override void ReadActors(IniFile file)
{ {
base.ReadActors(file); base.ReadActors(file);
LoadActors(file, "SHIPS", Players, MapSize, Map); LoadActors(file, "SHIPS", Players, Map);
} }
public override void SaveWaypoint(int waypointNumber, ActorReference waypointReference) public override void SaveWaypoint(int waypointNumber, ActorReference waypointReference)

View File

@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Activities
return false; return false;
target = target.Recalculate(self.Owner, out var targetIsHiddenActor); target = target.Recalculate(self.Owner, out var targetIsHiddenActor);
attackAircraft.SetRequestedTarget(self, target, forceAttack); attackAircraft.SetRequestedTarget(target, forceAttack);
hasTicked = true; hasTicked = true;
if (!targetIsHiddenActor && target.Type == TargetType.Actor) if (!targetIsHiddenActor && target.Type == TargetType.Actor)
@@ -171,9 +171,9 @@ namespace OpenRA.Mods.Common.Activities
// The aircraft must keep moving forward even if it is already in an ideal position. // The aircraft must keep moving forward even if it is already in an ideal position.
else if (attackAircraft.Info.AttackType == AirAttackType.Strafe) else if (attackAircraft.Info.AttackType == AirAttackType.Strafe)
QueueChild(new StrafeAttackRun(self, attackAircraft, aircraft, target, strafeDistance != WDist.Zero ? strafeDistance : lastVisibleMaximumRange)); QueueChild(new StrafeAttackRun(attackAircraft, aircraft, target, strafeDistance != WDist.Zero ? strafeDistance : lastVisibleMaximumRange));
else if (attackAircraft.Info.AttackType == AirAttackType.Default && !aircraft.Info.CanHover) else if (attackAircraft.Info.AttackType == AirAttackType.Default && !aircraft.Info.CanHover)
QueueChild(new FlyAttackRun(self, target, lastVisibleMaximumRange, attackAircraft)); QueueChild(new FlyAttackRun(target, lastVisibleMaximumRange, attackAircraft));
// Turn to face the target if required. // Turn to face the target if required.
else if (!attackAircraft.TargetInFiringArc(self, target, attackAircraft.Info.FacingTolerance)) else if (!attackAircraft.TargetInFiringArc(self, target, attackAircraft.Info.FacingTolerance))
@@ -220,7 +220,7 @@ namespace OpenRA.Mods.Common.Activities
Target target; Target target;
bool targetIsVisibleActor; bool targetIsVisibleActor;
public FlyAttackRun(Actor self, in Target t, WDist exitRange, AttackAircraft attack) public FlyAttackRun(in Target t, WDist exitRange, AttackAircraft attack)
{ {
ChildHasPriority = false; ChildHasPriority = false;
@@ -269,7 +269,7 @@ namespace OpenRA.Mods.Common.Activities
Target target; Target target;
public StrafeAttackRun(Actor self, AttackAircraft attackAircraft, Aircraft aircraft, in Target t, WDist exitRange) public StrafeAttackRun(AttackAircraft attackAircraft, Aircraft aircraft, in Target t, WDist exitRange)
{ {
ChildHasPriority = false; ChildHasPriority = false;
@@ -304,7 +304,7 @@ namespace OpenRA.Mods.Common.Activities
// Update the position if we seen the target move; keep the previous one if it dies or disappears // Update the position if we seen the target move; keep the previous one if it dies or disappears
target = target.Recalculate(self.Owner, out var targetIsHiddenActor); target = target.Recalculate(self.Owner, out var targetIsHiddenActor);
if (!targetIsHiddenActor && target.Type == TargetType.Actor) if (!targetIsHiddenActor && target.Type == TargetType.Actor)
attackAircraft.SetRequestedTarget(self, Target.FromTargetPositions(target), true); attackAircraft.SetRequestedTarget(Target.FromTargetPositions(target), true);
return false; return false;
} }

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Activities
protected override void OnFirstRun(Actor self) protected override void OnFirstRun(Actor self)
{ {
if (targetActor != null && targetActor.IsInWorld) if (targetActor != null && targetActor.IsInWorld)
harv.LinkProc(self, targetActor); harv.LinkProc(targetActor);
} }
public override bool Tick(Actor self) public override bool Tick(Actor self)

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Activities
self.Trait<Aircraft>().RemoveInfluence(); self.Trait<Aircraft>().RemoveInfluence();
var localOffset = carryall.CarryableOffset.Rotate(body.QuantizeOrientation(self, self.Orientation)); var localOffset = carryall.CarryableOffset.Rotate(body.QuantizeOrientation(self.Orientation));
var targetPosition = self.CenterPosition + body.LocalToWorld(localOffset); var targetPosition = self.CenterPosition + body.LocalToWorld(localOffset);
var targetLocation = self.World.Map.CellContaining(targetPosition); var targetLocation = self.World.Map.CellContaining(targetPosition);
carryall.Carryable.Trait<IPositionable>().SetPosition(carryall.Carryable, targetLocation, SubCell.FullCell); carryall.Carryable.Trait<IPositionable>().SetPosition(carryall.Carryable, targetLocation, SubCell.FullCell);

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Activities
if (IsCanceling || (deploy.DeployState != DeployState.Deployed && moving)) if (IsCanceling || (deploy.DeployState != DeployState.Deployed && moving))
return true; return true;
QueueChild(new DeployInner(self, deploy)); QueueChild(new DeployInner(deploy));
return true; return true;
} }
} }
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Activities
readonly GrantConditionOnDeploy deployment; readonly GrantConditionOnDeploy deployment;
bool initiated; bool initiated;
public DeployInner(Actor self, GrantConditionOnDeploy deployment) public DeployInner(GrantConditionOnDeploy deployment)
{ {
this.deployment = deployment; this.deployment = deployment;

View File

@@ -159,19 +159,19 @@ namespace OpenRA.Mods.Common.Activities
// Harvesters should respect an explicit harvest order instead of harvesting the current cell. // Harvesters should respect an explicit harvest order instead of harvesting the current cell.
if (orderLocation == null) if (orderLocation == null)
{ {
if (harv.CanHarvestCell(self, self.Location) && claimLayer.CanClaimCell(self, self.Location)) if (harv.CanHarvestCell(self.Location) && claimLayer.CanClaimCell(self, self.Location))
return self.Location; return self.Location;
} }
else else
{ {
if (harv.CanHarvestCell(self, orderLocation.Value) && claimLayer.CanClaimCell(self, orderLocation.Value)) if (harv.CanHarvestCell(orderLocation.Value) && claimLayer.CanClaimCell(self, orderLocation.Value))
return orderLocation; return orderLocation;
orderLocation = null; orderLocation = null;
} }
// Determine where to search from and how far to search: // Determine where to search from and how far to search:
var procLoc = GetSearchFromProcLocation(self); var procLoc = GetSearchFromProcLocation();
var searchFromLoc = lastHarvestedCell ?? procLoc ?? self.Location; var searchFromLoc = lastHarvestedCell ?? procLoc ?? self.Location;
var searchRadius = lastHarvestedCell.HasValue ? harvInfo.SearchFromHarvesterRadius : harvInfo.SearchFromProcRadius; var searchRadius = lastHarvestedCell.HasValue ? harvInfo.SearchFromHarvesterRadius : harvInfo.SearchFromProcRadius;
@@ -186,7 +186,7 @@ namespace OpenRA.Mods.Common.Activities
using (var search = PathSearch.ToTargetCellByPredicate( using (var search = PathSearch.ToTargetCellByPredicate(
self.World, mobile.Locomotor, self, new[] { searchFromLoc, self.Location }, self.World, mobile.Locomotor, self, new[] { searchFromLoc, self.Location },
loc => loc =>
harv.CanHarvestCell(self, loc) && harv.CanHarvestCell(loc) &&
claimLayer.CanClaimCell(self, loc), claimLayer.CanClaimCell(self, loc),
BlockedByActor.Stationary, BlockedByActor.Stationary,
loc => loc =>
@@ -196,7 +196,7 @@ namespace OpenRA.Mods.Common.Activities
// Add a cost modifier to harvestable cells to prefer resources that are closer to the refinery. // Add a cost modifier to harvestable cells to prefer resources that are closer to the refinery.
// This reduces the tendency for harvesters to move in straight lines // This reduces the tendency for harvesters to move in straight lines
if (procPos.HasValue && harvInfo.ResourceRefineryDirectionPenalty > 0 && harv.CanHarvestCell(self, loc)) if (procPos.HasValue && harvInfo.ResourceRefineryDirectionPenalty > 0 && harv.CanHarvestCell(loc))
{ {
var pos = map.CenterOfCell(loc); var pos = map.CenterOfCell(loc);
@@ -244,7 +244,7 @@ namespace OpenRA.Mods.Common.Activities
yield return new TargetLineNode(Target.FromActor(deliverActor), harvInfo.DeliverLineColor); yield return new TargetLineNode(Target.FromActor(deliverActor), harvInfo.DeliverLineColor);
} }
CPos? GetSearchFromProcLocation(Actor self) CPos? GetSearchFromProcLocation()
{ {
if (harv.LastLinkedProc != null && !harv.LastLinkedProc.IsDead && harv.LastLinkedProc.IsInWorld) if (harv.LastLinkedProc != null && !harv.LastLinkedProc.IsDead && harv.LastLinkedProc.IsInWorld)
return harv.LastLinkedProc.Location + harv.LastLinkedProc.Trait<IAcceptResources>().DeliveryOffset; return harv.LastLinkedProc.Location + harv.LastLinkedProc.Trait<IAcceptResources>().DeliveryOffset;

View File

@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Activities
return false; return false;
} }
if (!harv.CanHarvestCell(self, self.Location)) if (!harv.CanHarvestCell(self.Location))
return true; return true;
// Turn to one of the harvestable facings // Turn to one of the harvestable facings

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Activities
case DockingState.Complete: case DockingState.Complete:
Harv.LastLinkedProc = Harv.LinkedProc; Harv.LastLinkedProc = Harv.LinkedProc;
Harv.LinkProc(self, null); Harv.LinkProc(null);
if (IsDragRequired) if (IsDragRequired)
QueueChild(new Drag(self, EndDrag, StartDrag, DragLength)); QueueChild(new Drag(self, EndDrag, StartDrag, DragLength));

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Activities
} }
// Can complete the move in this step // Can complete the move in this step
var speed = mobile.MovementSpeedForCell(self, self.Location); var speed = mobile.MovementSpeedForCell(self.Location);
if (delta.LengthSquared <= speed * speed) if (delta.LengthSquared <= speed * speed)
{ {
mobile.SetCenterPosition(self, targetPos); mobile.SetCenterPosition(self, targetPos);

View File

@@ -415,7 +415,7 @@ namespace OpenRA.Mods.Common.Activities
// Only move by a full speed step if we didn't already move this tick. // Only move by a full speed step if we didn't already move this tick.
// If we did, we limit the move to any carried-over leftover progress. // If we did, we limit the move to any carried-over leftover progress.
if (Move.lastMovePartCompletedTick < self.World.WorldTick) if (Move.lastMovePartCompletedTick < self.World.WorldTick)
progress += mobile.MovementSpeedForCell(self, mobile.ToCell); progress += mobile.MovementSpeedForCell(mobile.ToCell);
if (progress >= Distance) if (progress >= Distance)
{ {
@@ -448,13 +448,13 @@ namespace OpenRA.Mods.Common.Activities
{ {
var currentCellOrientation = self.World.Map.TerrainOrientation(mobile.FromCell); var currentCellOrientation = self.World.Map.TerrainOrientation(mobile.FromCell);
var orientation = WRot.SLerp(FromTerrainOrientation.Value, currentCellOrientation, progress, terrainOrientationMargin); var orientation = WRot.SLerp(FromTerrainOrientation.Value, currentCellOrientation, progress, terrainOrientationMargin);
mobile.SetTerrainRampOrientation(self, orientation); mobile.SetTerrainRampOrientation(orientation);
} }
else if (ToTerrainOrientation.HasValue && Distance - progress < terrainOrientationMargin) else if (ToTerrainOrientation.HasValue && Distance - progress < terrainOrientationMargin)
{ {
var currentCellOrientation = self.World.Map.TerrainOrientation(mobile.FromCell); var currentCellOrientation = self.World.Map.TerrainOrientation(mobile.FromCell);
var orientation = WRot.SLerp(ToTerrainOrientation.Value, currentCellOrientation, Distance - progress, terrainOrientationMargin); var orientation = WRot.SLerp(ToTerrainOrientation.Value, currentCellOrientation, Distance - progress, terrainOrientationMargin);
mobile.SetTerrainRampOrientation(self, orientation); mobile.SetTerrainRampOrientation(orientation);
} }
mobile.Facing = WAngle.Lerp(FromFacing, ToFacing, progress, Distance); mobile.Facing = WAngle.Lerp(FromFacing, ToFacing, progress, Distance);

View File

@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Activities
// Pickup position and facing are now known - swap the fly/wait activity with Land // Pickup position and facing are now known - swap the fly/wait activity with Land
ChildActivity.Cancel(self); ChildActivity.Cancel(self);
var localOffset = carryall.OffsetForCarryable(self, cargo).Rotate(carryableBody.QuantizeOrientation(self, cargo.Orientation)); var localOffset = carryall.OffsetForCarryable(self, cargo).Rotate(carryableBody.QuantizeOrientation(cargo.Orientation));
QueueChild(new Land(self, Target.FromActor(cargo), -carryableBody.LocalToWorld(localOffset), carryableFacing.Facing)); QueueChild(new Land(self, Target.FromActor(cargo), -carryableBody.LocalToWorld(localOffset), carryableFacing.Facing));
// Pause briefly before attachment for visual effect // Pause briefly before attachment for visual effect

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Widgets
if (mi.Modifiers.HasModifier(Modifiers.Shift)) if (mi.Modifiers.HasModifier(Modifiers.Shift))
{ {
FloodFillWithBrush(cell, isMoving); FloodFillWithBrush(cell);
painting = false; painting = false;
} }
else else
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Widgets
editorActionManager.Add(new PaintTileEditorAction(Template, world.Map, cell)); editorActionManager.Add(new PaintTileEditorAction(Template, world.Map, cell));
} }
void FloodFillWithBrush(CPos cell, bool isMoving) void FloodFillWithBrush(CPos cell)
{ {
var map = world.Map; var map = world.Map;
var mapTiles = map.Tiles; var mapTiles = map.Tiles;

View File

@@ -113,10 +113,10 @@ namespace OpenRA.Mods.Common.Effects
if (targetLineNodes.Count == 0) if (targetLineNodes.Count == 0)
return SpriteRenderable.None; return SpriteRenderable.None;
return RenderInner(wr); return RenderInner();
} }
IEnumerable<IRenderable> RenderInner(WorldRenderer wr) IEnumerable<IRenderable> RenderInner()
{ {
var prev = targetLineNodes[0]; var prev = targetLineNodes[0];
foreach (var pos in targetLineNodes.Skip(1)) foreach (var pos in targetLineNodes.Skip(1))

View File

@@ -59,9 +59,9 @@ namespace OpenRA.Mods.Common.FileFormats
3, 4, 5, 6, 7, 8 3, 4, 5, 6, 7, 8
}; };
static readonly Huffman LitCode = new Huffman(LitLen, LitLen.Length, 256); static readonly Huffman LitCode = new Huffman(LitLen, 256);
static readonly Huffman LenCode = new Huffman(LenLen, LenLen.Length, 16); static readonly Huffman LenCode = new Huffman(LenLen, 16);
static readonly Huffman DistCode = new Huffman(DistLen, DistLen.Length, 64); static readonly Huffman DistCode = new Huffman(DistLen, 64);
/// <summary>PKWare Compression Library stream.</summary> /// <summary>PKWare Compression Library stream.</summary>
/// <param name="input">Compressed input stream.</param> /// <param name="input">Compressed input stream.</param>
@@ -247,7 +247,7 @@ namespace OpenRA.Mods.Common.FileFormats
public short[] Count; // number of symbols of each length public short[] Count; // number of symbols of each length
public short[] Symbol; // canonically ordered symbols public short[] Symbol; // canonically ordered symbols
public Huffman(byte[] rep, int n, short symbolCount) public Huffman(byte[] rep, short symbolCount)
{ {
var length = new short[256]; // code lengths var length = new short[256]; // code lengths
var s = 0; // current symbol var s = 0; // current symbol
@@ -262,7 +262,7 @@ namespace OpenRA.Mods.Common.FileFormats
while (--num > 0); while (--num > 0);
} }
n = s; var n = s;
// count number of codes of each length // count number of codes of each length
Count = new short[Blast.MAXBITS + 1]; Count = new short[Blast.MAXBITS + 1];

View File

@@ -41,6 +41,7 @@ namespace OpenRA.Mods.Common.Graphics
public class DefaultSpriteSequenceLoader : ISpriteSequenceLoader public class DefaultSpriteSequenceLoader : ISpriteSequenceLoader
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
public DefaultSpriteSequenceLoader(ModData modData) { } public DefaultSpriteSequenceLoader(ModData modData) { }
public virtual ISpriteSequence CreateSequence(ModData modData, string tileSet, SpriteCache cache, string sequence, string animation, MiniYaml info) public virtual ISpriteSequence CreateSequence(ModData modData, string tileSet, SpriteCache cache, string sequence, string animation, MiniYaml info)

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Graphics
public IRenderable OffsetBy(in WVec vec) { return new SelectionBarsAnnotationRenderable(pos + vec, actor, decorationBounds); } public IRenderable OffsetBy(in WVec vec) { return new SelectionBarsAnnotationRenderable(pos + vec, actor, decorationBounds); }
public IRenderable AsDecoration() { return this; } public IRenderable AsDecoration() { return this; }
void DrawExtraBars(WorldRenderer wr, float2 start, float2 end) void DrawExtraBars(float2 start, float2 end)
{ {
foreach (var extraBar in actor.TraitsImplementing<ISelectionBar>()) foreach (var extraBar in actor.TraitsImplementing<ISelectionBar>())
{ {
@@ -58,12 +58,12 @@ namespace OpenRA.Mods.Common.Graphics
var offset = new float2(0, 4); var offset = new float2(0, 4);
start += offset; start += offset;
end += offset; end += offset;
DrawSelectionBar(wr, start, end, extraBar.GetValue(), extraBar.GetColor()); DrawSelectionBar(start, end, extraBar.GetValue(), extraBar.GetColor());
} }
} }
} }
void DrawSelectionBar(WorldRenderer wr, float2 start, float2 end, float value, Color barColor) void DrawSelectionBar(float2 start, float2 end, float value, Color barColor)
{ {
var c = Color.FromArgb(128, 30, 30, 30); var c = Color.FromArgb(128, 30, 30, 30);
var c2 = Color.FromArgb(128, 10, 10, 10); var c2 = Color.FromArgb(128, 10, 10, 10);
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Graphics
health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen; health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen;
} }
void DrawHealthBar(WorldRenderer wr, IHealth health, float2 start, float2 end) void DrawHealthBar(IHealth health, float2 start, float2 end)
{ {
if (health == null || health.IsDead) if (health == null || health.IsDead)
return; return;
@@ -149,10 +149,10 @@ namespace OpenRA.Mods.Common.Graphics
var end = wr.Viewport.WorldToViewPx(new float2(decorationBounds.Right - 1, decorationBounds.Top)); var end = wr.Viewport.WorldToViewPx(new float2(decorationBounds.Right - 1, decorationBounds.Top));
if (DisplayHealth) if (DisplayHealth)
DrawHealthBar(wr, health, start, end); DrawHealthBar(health, start, end);
if (DisplayExtra) if (DisplayExtra)
DrawExtraBars(wr, start, end); DrawExtraBars(start, end);
} }
public void RenderDebugGeometry(WorldRenderer wr) { } public void RenderDebugGeometry(WorldRenderer wr) { }

View File

@@ -59,12 +59,12 @@ namespace OpenRA.Mods.Common.Lint
foreach (var filename in modData.Manifest.ChromeLayout) foreach (var filename in modData.Manifest.ChromeLayout)
{ {
var yaml = MiniYaml.FromStream(modData.DefaultFileSystem.Open(filename), filename); var yaml = MiniYaml.FromStream(modData.DefaultFileSystem.Open(filename), filename);
CheckInner(modData, namedKeys, checkWidgetFields, customLintMethods, yaml, filename, null, emitError, emitWarning); CheckInner(modData, namedKeys, checkWidgetFields, customLintMethods, yaml, filename, null, emitError);
} }
} }
void CheckInner(ModData modData, string[] namedKeys, (string Widget, string Field)[] checkWidgetFields, Dictionary<string, List<string>> customLintMethods, void CheckInner(ModData modData, string[] namedKeys, (string Widget, string Field)[] checkWidgetFields, Dictionary<string, List<string>> customLintMethods,
List<MiniYamlNode> nodes, string filename, MiniYamlNode parent, Action<string> emitError, Action<string> emitWarning) List<MiniYamlNode> nodes, string filename, MiniYamlNode parent, Action<string> emitError)
{ {
foreach (var node in nodes) foreach (var node in nodes)
{ {
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Lint
if (customLintMethods.TryGetValue(widgetType, out var checkMethods)) if (customLintMethods.TryGetValue(widgetType, out var checkMethods))
{ {
var type = modData.ObjectCreator.FindType(widgetType + "Widget"); var type = modData.ObjectCreator.FindType(widgetType + "Widget");
var keyNames = checkMethods.SelectMany(m => (IEnumerable<string>)type.GetMethod(m).Invoke(null, new object[] { node, emitError, emitWarning })); var keyNames = checkMethods.SelectMany(m => (IEnumerable<string>)type.GetMethod(m).Invoke(null, new object[] { node, emitError }));
foreach (var name in keyNames) foreach (var name in keyNames)
if (!namedKeys.Contains(name) && !Hotkey.TryParse(name, out var unused)) if (!namedKeys.Contains(name) && !Hotkey.TryParse(name, out var unused))
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Common.Lint
} }
if (node.Value.Nodes != null) if (node.Value.Nodes != null)
CheckInner(modData, namedKeys, checkWidgetFields, customLintMethods, node.Value.Nodes, filename, node, emitError, emitWarning); CheckInner(modData, namedKeys, checkWidgetFields, customLintMethods, node.Value.Nodes, filename, node, emitError);
} }
} }
} }

View File

@@ -51,14 +51,14 @@ namespace OpenRA.Mods.Common.Lint
if (string.IsNullOrEmpty(locomotor)) if (string.IsNullOrEmpty(locomotor))
continue; continue;
CheckLocomotors(actorInfo.Value, emitError, rules, locomotorInfos, locomotor); CheckLocomotors(actorInfo.Value, emitError, locomotorInfos, locomotor);
} }
} }
} }
} }
} }
void CheckLocomotors(ActorInfo actorInfo, Action<string> emitError, Ruleset rules, LocomotorInfo[] locomotorInfos, string locomotor) void CheckLocomotors(ActorInfo actorInfo, Action<string> emitError, LocomotorInfo[] locomotorInfos, string locomotor)
{ {
if (!locomotorInfos.Any(l => l.Name == locomotor)) if (!locomotorInfos.Any(l => l.Name == locomotor))
emitError($"Actor {actorInfo.Name} defines Locomotor {locomotor} not found on World actor."); emitError($"Actor {actorInfo.Name} defines Locomotor {locomotor} not found on World actor.");

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Lint
{ {
var palettes = new List<string>(); var palettes = new List<string>();
var playerPalettes = new List<string>(); var playerPalettes = new List<string>();
GetPalettes(emitError, rules, palettes, playerPalettes); GetPalettes(rules, palettes, playerPalettes);
foreach (var actorInfo in rules.Actors) foreach (var actorInfo in rules.Actors)
{ {
@@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Lint
} }
} }
void GetPalettes(Action<string> emitError, Ruleset rules, List<string> palettes, List<string> playerPalettes) void GetPalettes(Ruleset rules, List<string> palettes, List<string> playerPalettes)
{ {
foreach (var actorInfo in rules.Actors) foreach (var actorInfo in rules.Actors)
{ {

View File

@@ -47,12 +47,12 @@ namespace OpenRA.Mods.Common.Lint
var images = new HashSet<string>() var images = new HashSet<string>()
{ {
renderInfo.GetImage(actorInfo.Value, sequences, null).ToLowerInvariant() renderInfo.GetImage(actorInfo.Value, null).ToLowerInvariant()
}; };
// Some actors define faction-specific artwork // Some actors define faction-specific artwork
foreach (var faction in factions) foreach (var faction in factions)
images.Add(renderInfo.GetImage(actorInfo.Value, sequences, faction).ToLowerInvariant()); images.Add(renderInfo.GetImage(actorInfo.Value, faction).ToLowerInvariant());
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>()) foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
{ {

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Orders
public int OrderPriority { get; private set; } public int OrderPriority { get; private set; }
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Actor) if (target.Type != TargetType.Actor)
return false; return false;

View File

@@ -230,7 +230,7 @@ namespace OpenRA.Mods.Common.Orders
{ {
foreach (var a in world.ActorMap.GetActorsAt(cell)) foreach (var a in world.ActorMap.GetActorsAt(cell))
foreach (var p in a.TraitsImplementing<Pluggable>()) foreach (var p in a.TraitsImplementing<Pluggable>())
if (p.AcceptsPlug(a, plug.Type)) if (p.AcceptsPlug(plug.Type))
return true; return true;
return false; return false;

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Orders
public abstract bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor); public abstract bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor);
public abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor); public abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor);
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{ {
var type = target.Type; var type = target.Type;
if (type != TargetType.Actor && type != TargetType.FrozenActor) if (type != TargetType.Actor && type != TargetType.FrozenActor)

View File

@@ -302,7 +302,7 @@ namespace OpenRA.Mods.Common.Projectiles
if ((sbyte)vFacing < 0) if ((sbyte)vFacing < 0)
speed = minSpeed; speed = minSpeed;
else if (!WillClimbWithinDistance(vFacing, loopRadius, predClfDist, diffClfMslHgt) else if (!WillClimbWithinDistance(vFacing, loopRadius, predClfDist, diffClfMslHgt)
&& !WillClimbAroundInclineTop(vFacing, loopRadius, predClfDist, diffClfMslHgt, speed)) && !WillClimbAroundInclineTop(vFacing, loopRadius, predClfDist, diffClfMslHgt))
{ {
// Find highest speed greater than the above minimum that allows the missile // Find highest speed greater than the above minimum that allows the missile
// to surmount the incline // to surmount the incline
@@ -311,7 +311,7 @@ namespace OpenRA.Mods.Common.Projectiles
{ {
var lpRds = LoopRadius(spd, info.VerticalRateOfTurn.Facing); var lpRds = LoopRadius(spd, info.VerticalRateOfTurn.Facing);
return WillClimbWithinDistance(vFac, lpRds, predClfDist, diffClfMslHgt) return WillClimbWithinDistance(vFac, lpRds, predClfDist, diffClfMslHgt)
|| WillClimbAroundInclineTop(vFac, lpRds, predClfDist, diffClfMslHgt, spd); || WillClimbAroundInclineTop(vFac, lpRds, predClfDist, diffClfMslHgt);
}); });
} }
else else
@@ -401,7 +401,7 @@ namespace OpenRA.Mods.Common.Projectiles
// Will missile climb around incline top if bringing vertical facing // Will missile climb around incline top if bringing vertical facing
// down to zero on an arc of radius loopRadius // down to zero on an arc of radius loopRadius
// Calling this function only makes sense when IsNearInclineTop returns true // Calling this function only makes sense when IsNearInclineTop returns true
static bool WillClimbAroundInclineTop(int vFacing, int loopRadius, int predClfDist, int diffClfMslHgt, int speed) static bool WillClimbAroundInclineTop(int vFacing, int loopRadius, int predClfDist, int diffClfMslHgt)
{ {
// Vector from missile's current position pointing to the loop's center // Vector from missile's current position pointing to the loop's center
var radius = new WVec(loopRadius, 0, 0) var radius = new WVec(loopRadius, 0, 0)
@@ -523,7 +523,7 @@ namespace OpenRA.Mods.Common.Projectiles
// Missile will climb around incline top if bringing vertical facing // Missile will climb around incline top if bringing vertical facing
// down to zero on an arc of radius loopRadius // down to zero on an arc of radius loopRadius
else if (IsNearInclineTop(vFacing, loopRadius, predClfDist) else if (IsNearInclineTop(vFacing, loopRadius, predClfDist)
&& WillClimbAroundInclineTop(vFacing, loopRadius, predClfDist, diffClfMslHgt, speed)) && WillClimbAroundInclineTop(vFacing, loopRadius, predClfDist, diffClfMslHgt))
desiredVFacing = 0; desiredVFacing = 0;
// Missile will not climb terrAltDiff w-units within hHeightChange w-units // Missile will not climb terrAltDiff w-units within hHeightChange w-units
@@ -537,7 +537,7 @@ namespace OpenRA.Mods.Common.Projectiles
for (var vFac = System.Math.Min(vFacing + info.VerticalRateOfTurn.Facing - 1, 63); vFac >= vFacing; vFac--) for (var vFac = System.Math.Min(vFacing + info.VerticalRateOfTurn.Facing - 1, 63); vFac >= vFacing; vFac--)
if (!WillClimbWithinDistance(vFac, loopRadius, predClfDist, diffClfMslHgt) if (!WillClimbWithinDistance(vFac, loopRadius, predClfDist, diffClfMslHgt)
&& !(predClfDist <= loopRadius * (1024 - WAngle.FromFacing(vFac).Sin()) / 1024 && !(predClfDist <= loopRadius * (1024 - WAngle.FromFacing(vFac).Sin()) / 1024
&& WillClimbAroundInclineTop(vFac, loopRadius, predClfDist, diffClfMslHgt, speed))) && WillClimbAroundInclineTop(vFac, loopRadius, predClfDist, diffClfMslHgt)))
{ {
desiredVFacing = vFac + 1; desiredVFacing = vFac + 1;
break; break;
@@ -568,7 +568,7 @@ namespace OpenRA.Mods.Common.Projectiles
} }
int HomingInnerTick(int predClfDist, int diffClfMslHgt, int relTarHorDist, int lastHtChg, int lastHt, int HomingInnerTick(int predClfDist, int diffClfMslHgt, int relTarHorDist, int lastHtChg, int lastHt,
int nxtRelTarHorDist, int relTarHgt, int vFacing, bool targetPassedBy) int relTarHgt, int vFacing, bool targetPassedBy)
{ {
int desiredVFacing = vFacing; int desiredVFacing = vFacing;
@@ -772,7 +772,7 @@ namespace OpenRA.Mods.Common.Projectiles
targetPassedBy = false; targetPassedBy = false;
var desiredVFacing = HomingInnerTick(predClfDist, diffClfMslHgt, relTarHorDist, lastHtChg, lastHt, var desiredVFacing = HomingInnerTick(predClfDist, diffClfMslHgt, relTarHorDist, lastHtChg, lastHt,
nxtRelTarHorDist, relTarHgt, vFacing, targetPassedBy); relTarHgt, vFacing, targetPassedBy);
// The target has been passed by // The target has been passed by
if (tarDistVec.HorizontalLength < speed * WAngle.FromFacing(vFacing).Cos() / 1024) if (tarDistVec.HorizontalLength < speed * WAngle.FromFacing(vFacing).Cos() / 1024)

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Scripting
void ITick.Tick(Actor self) void ITick.Tick(Actor self)
{ {
context.Tick(self); context.Tick();
} }
void INotifyActorDisposing.Disposing(Actor self) void INotifyActorDisposing.Disposing(Actor self)

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Scripting
public int GrantCondition(string condition, int duration = 0) public int GrantCondition(string condition, int duration = 0)
{ {
var external = externalConditions var external = externalConditions
.FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(Self, this)); .FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(this));
if (external == null) if (external == null)
throw new LuaException($"Condition `{condition}` has not been listed on an enabled ExternalCondition trait"); throw new LuaException($"Condition `{condition}` has not been listed on an enabled ExternalCondition trait");
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Scripting
public bool AcceptsCondition(string condition) public bool AcceptsCondition(string condition)
{ {
return externalConditions return externalConditions
.Any(t => t.Info.Condition == condition && t.CanGrantCondition(Self, this)); .Any(t => t.Info.Condition == condition && t.CanGrantCondition(this));
} }
} }
} }

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Scripting
public int GrantCondition(string condition, int duration = 0) public int GrantCondition(string condition, int duration = 0)
{ {
var external = externalConditions var external = externalConditions
.FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(Player.PlayerActor, this)); .FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(this));
if (external == null) if (external == null)
throw new LuaException($"Condition `{condition}` has not been listed on an enabled ExternalCondition trait"); throw new LuaException($"Condition `{condition}` has not been listed on an enabled ExternalCondition trait");
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Scripting
public bool AcceptsCondition(string condition) public bool AcceptsCondition(string condition)
{ {
return externalConditions return externalConditions
.Any(t => t.Info.Condition == condition && t.CanGrantCondition(Player.PlayerActor, this)); .Any(t => t.Info.Condition == condition && t.CanGrantCondition(this));
} }
} }
} }

View File

@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Terrain
{ {
public class DefaultTerrainLoader : ITerrainLoader public class DefaultTerrainLoader : ITerrainLoader
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "IDE0060:Remove unused parameter", Justification = "Load game API")]
public DefaultTerrainLoader(ModData modData) { } public DefaultTerrainLoader(ModData modData) { }
public ITerrainInfo ParseTerrain(IReadOnlyFileSystem fileSystem, string path) public ITerrainInfo ParseTerrain(IReadOnlyFileSystem fileSystem, string path)

View File

@@ -23,11 +23,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Player relationships the owner of the delivering actor needs.")] [Desc("Player relationships the owner of the delivering actor needs.")]
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally; public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally;
public override object Create(ActorInitializer init) { return new AcceptsDeliveredExperience(init.Self, this); } public override object Create(ActorInitializer init) { return new AcceptsDeliveredExperience(); }
} }
public class AcceptsDeliveredExperience public class AcceptsDeliveredExperience
{ {
public AcceptsDeliveredExperience(Actor self, AcceptsDeliveredExperienceInfo info) { } public AcceptsDeliveredExperience() { }
} }
} }

View File

@@ -1286,7 +1286,7 @@ namespace OpenRA.Mods.Common.Traits
return modifiers.HasModifier(TargetModifiers.ForceMove); return modifiers.HasModifier(TargetModifiers.ForceMove);
} }
public virtual bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public virtual bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Terrain || (aircraft.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))) if (target.Type != TargetType.Terrain || (aircraft.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false; return false;

View File

@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
OnExitedAttackRange(self); OnExitedAttackRange(self);
} }
public void SetTarget(World w, WPos pos) { target = Target.FromPos(pos); } public void SetTarget(WPos pos) { target = Target.FromPos(pos); }
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self) void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
{ {

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("The condition to grant to self for each ammo point in this pool.")] [Desc("The condition to grant to self for each ammo point in this pool.")]
public readonly string AmmoCondition = null; public readonly string AmmoCondition = null;
public override object Create(ActorInitializer init) { return new AmmoPool(init.Self, this); } public override object Create(ActorInitializer init) { return new AmmoPool(this); }
} }
public class AmmoPool : INotifyCreated, INotifyAttack, ISync public class AmmoPool : INotifyCreated, INotifyAttack, ISync
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits
public bool HasAmmo => CurrentAmmoCount > 0; public bool HasAmmo => CurrentAmmoCount > 0;
public bool HasFullAmmo => CurrentAmmoCount == Info.Ammo; public bool HasFullAmmo => CurrentAmmoCount == Info.Ammo;
public AmmoPool(Actor self, AmmoPoolInfo info) public AmmoPool(AmmoPoolInfo info)
{ {
Info = info; Info = info;
CurrentAmmoCount = Info.InitialAmmo < Info.Ammo && Info.InitialAmmo >= 0 ? Info.InitialAmmo : Info.Ammo; CurrentAmmoCount = Info.InitialAmmo < Info.Ammo && Info.InitialAmmo >= 0 ? Info.InitialAmmo : Info.Ammo;

View File

@@ -380,7 +380,7 @@ namespace OpenRA.Mods.Common.Traits
var localOffset = b.Offset + new WVec(-Recoil, WDist.Zero, WDist.Zero); var localOffset = b.Offset + new WVec(-Recoil, WDist.Zero, WDist.Zero);
// Turret coordinates to body coordinates // Turret coordinates to body coordinates
var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation); var bodyOrientation = coords.QuantizeOrientation(self.Orientation);
if (turret != null) if (turret != null)
localOffset = localOffset.Rotate(turret.WorldOrientation) + turret.Offset.Rotate(bodyOrientation); localOffset = localOffset.Rotate(turret.WorldOrientation) + turret.Offset.Rotate(bodyOrientation);
else else

View File

@@ -19,12 +19,12 @@ namespace OpenRA.Mods.Common.Traits
{ {
public readonly string Type = null; public readonly string Type = null;
public override object Create(ActorInitializer init) { return new Armor(init.Self, this); } public override object Create(ActorInitializer init) { return new Armor(this); }
} }
public class Armor : ConditionalTrait<ArmorInfo> public class Armor : ConditionalTrait<ArmorInfo>
{ {
public Armor(Actor self, ArmorInfo info) public Armor(ArmorInfo info)
: base(info) { } : base(info) { }
} }
} }

View File

@@ -474,7 +474,7 @@ namespace OpenRA.Mods.Common.Traits
return true; return true;
} }
bool CanTargetLocation(Actor self, CPos location, List<Actor> actorsAtLocation, TargetModifiers modifiers, ref string cursor) bool CanTargetLocation(Actor self, CPos location, TargetModifiers modifiers, ref string cursor)
{ {
if (!self.World.Map.Contains(location)) if (!self.World.Map.Contains(location))
return false; return false;
@@ -505,7 +505,7 @@ namespace OpenRA.Mods.Common.Traits
return true; return true;
} }
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{ {
switch (target.Type) switch (target.Type)
{ {
@@ -513,7 +513,7 @@ namespace OpenRA.Mods.Common.Traits
case TargetType.FrozenActor: case TargetType.FrozenActor:
return CanTargetActor(self, target, ref modifiers, ref cursor); return CanTargetActor(self, target, ref modifiers, ref cursor);
case TargetType.Terrain: case TargetType.Terrain:
return CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), othersAtTarget, modifiers, ref cursor); return CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), modifiers, ref cursor);
default: default:
return false; return false;
} }

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
bool opportunityForceAttack; bool opportunityForceAttack;
bool opportunityTargetIsPersistentTarget; bool opportunityTargetIsPersistentTarget;
public void SetRequestedTarget(Actor self, in Target target, bool isForceAttack = false) public void SetRequestedTarget(in Target target, bool isForceAttack = false)
{ {
RequestedTarget = target; RequestedTarget = target;
requestedForceAttack = isForceAttack; requestedForceAttack = isForceAttack;
@@ -274,7 +274,7 @@ namespace OpenRA.Mods.Common.Traits
return false; return false;
target = target.Recalculate(self.Owner, out var targetIsHiddenActor); target = target.Recalculate(self.Owner, out var targetIsHiddenActor);
attack.SetRequestedTarget(self, target, forceAttack); attack.SetRequestedTarget(target, forceAttack);
hasTicked = true; hasTicked = true;
if (!targetIsHiddenActor && target.Type == TargetType.Actor) if (!targetIsHiddenActor && target.Type == TargetType.Actor)

View File

@@ -139,7 +139,7 @@ namespace OpenRA.Mods.Common.Traits
WVec PortOffset(Actor self, FirePort p) WVec PortOffset(Actor self, FirePort p)
{ {
var bodyOrientation = coords.Value.QuantizeOrientation(self, self.Orientation); var bodyOrientation = coords.Value.QuantizeOrientation(self.Orientation);
return coords.Value.LocalToWorld(p.Offset.Rotate(bodyOrientation)); return coords.Value.LocalToWorld(p.Offset.Rotate(bodyOrientation));
} }
@@ -193,7 +193,7 @@ namespace OpenRA.Mods.Common.Traits
// Display muzzle flashes // Display muzzle flashes
foreach (var m in muzzles) foreach (var m in muzzles)
foreach (var r in m.Render(self, wr, pal)) foreach (var r in m.Render(self, pal))
yield return r; yield return r;
} }

View File

@@ -19,15 +19,15 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Required distance away from destination before requesting a pickup. Default is 6 cells.")] [Desc("Required distance away from destination before requesting a pickup. Default is 6 cells.")]
public readonly WDist MinDistance = WDist.FromCells(6); public readonly WDist MinDistance = WDist.FromCells(6);
public override object Create(ActorInitializer init) { return new AutoCarryable(init.Self, this); } public override object Create(ActorInitializer init) { return new AutoCarryable(this); }
} }
public class AutoCarryable : Carryable, ICallForTransport public class AutoCarryable : Carryable, ICallForTransport
{ {
readonly AutoCarryableInfo info; readonly AutoCarryableInfo info;
public AutoCarryable(Actor self, AutoCarryableInfo info) public AutoCarryable(AutoCarryableInfo info)
: base(self, info) : base(info)
{ {
this.info = info; this.info = info;
} }
@@ -35,10 +35,10 @@ namespace OpenRA.Mods.Common.Traits
public WDist MinimumDistance => info.MinDistance; public WDist MinimumDistance => info.MinDistance;
// No longer want to be carried // No longer want to be carried
void ICallForTransport.MovementCancelled(Actor self) { MovementCancelled(self); } void ICallForTransport.MovementCancelled(Actor self) { MovementCancelled(); }
void ICallForTransport.RequestTransport(Actor self, CPos destination) { RequestTransport(self, destination); } void ICallForTransport.RequestTransport(Actor self, CPos destination) { RequestTransport(self, destination); }
void MovementCancelled(Actor self) void MovementCancelled()
{ {
if (state == State.Locked) if (state == State.Locked)
return; return;
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits
if (delta.HorizontalLengthSquared < info.MinDistance.LengthSquared) if (delta.HorizontalLengthSquared < info.MinDistance.LengthSquared)
{ {
// Cancel pickup // Cancel pickup
MovementCancelled(self); MovementCancelled();
return false; return false;
} }
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
if (delta.HorizontalLengthSquared < info.MinDistance.LengthSquared) if (delta.HorizontalLengthSquared < info.MinDistance.LengthSquared)
{ {
// Cancel pickup // Cancel pickup
MovementCancelled(self); MovementCancelled();
return LockResponse.Failed; return LockResponse.Failed;
} }

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
return false; return false;
} }
bool IsBestAutoCarryallForCargo(Actor self, Actor candidateCargo) static bool IsBestAutoCarryallForCargo(Actor self, Actor candidateCargo)
{ {
// Find carriers // Find carriers
var carriers = self.World.ActorsHavingTrait<AutoCarryall>(c => !c.busy) var carriers = self.World.ActorsHavingTrait<AutoCarryall>(c => !c.busy)

View File

@@ -257,7 +257,7 @@ namespace OpenRA.Mods.Common.Traits
Aggressor = attacker; Aggressor = attacker;
Attack(self, Target.FromActor(Aggressor), allowMove); Attack(Target.FromActor(Aggressor), allowMove);
} }
void INotifyIdle.TickIdle(Actor self) void INotifyIdle.TickIdle(Actor self)
@@ -309,10 +309,10 @@ namespace OpenRA.Mods.Common.Traits
{ {
var target = ScanForTarget(self, allowMove, allowTurn); var target = ScanForTarget(self, allowMove, allowTurn);
if (target.Type != TargetType.Invalid) if (target.Type != TargetType.Invalid)
Attack(self, target, allowMove); Attack(target, allowMove);
} }
void Attack(Actor self, in Target target, bool allowMove) void Attack(in Target target, bool allowMove)
{ {
foreach (var ab in ActiveAttackBases) foreach (var ab in ActiveAttackBases)
ab.AttackTarget(target, AttackSource.AutoTarget, false, allowMove); ab.AttackTarget(target, AttackSource.AutoTarget, false, allowMove);

View File

@@ -22,12 +22,12 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Determines what projectiles to block based on their allegiance to the wall owner.")] [Desc("Determines what projectiles to block based on their allegiance to the wall owner.")]
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy; public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
public override object Create(ActorInitializer init) { return new BlocksProjectiles(init.Self, this); } public override object Create(ActorInitializer init) { return new BlocksProjectiles(this); }
} }
public class BlocksProjectiles : ConditionalTrait<BlocksProjectilesInfo>, IBlocksProjectiles public class BlocksProjectiles : ConditionalTrait<BlocksProjectilesInfo>, IBlocksProjectiles
{ {
public BlocksProjectiles(Actor self, BlocksProjectilesInfo info) public BlocksProjectiles(BlocksProjectilesInfo info)
: base(info) { } : base(info) { }
WDist IBlocksProjectiles.BlockingHeight => Info.Height; WDist IBlocksProjectiles.BlockingHeight => Info.Height;

View File

@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits
return info.LocalToWorld(vec); return info.LocalToWorld(vec);
} }
public WRot QuantizeOrientation(Actor self, in WRot orientation) public WRot QuantizeOrientation(in WRot orientation)
{ {
return info.QuantizeOrientation(orientation, quantizedFacings.Value); return info.QuantizeOrientation(orientation, quantizedFacings.Value);
} }

View File

@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
if (plugInfo != null) if (plugInfo != null)
{ {
var possibleBuilding = world.ActorsWithTrait<Pluggable>().FirstOrDefault(a => var possibleBuilding = world.ActorsWithTrait<Pluggable>().FirstOrDefault(a =>
a.Actor.Owner == player && a.Trait.AcceptsPlug(a.Actor, plugInfo.Type)); a.Actor.Owner == player && a.Trait.AcceptsPlug(plugInfo.Type));
if (possibleBuilding.Actor != null) if (possibleBuilding.Actor != null)
{ {

View File

@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits
// IsValid check filters out Frozen Actors that have not initialized their Owner // IsValid check filters out Frozen Actors that have not initialized their Owner
foreach (var scrutinized in checkFrozen) foreach (var scrutinized in checkFrozen)
answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner), firedBy); answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner));
} }
return answer; return answer;
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var consideration in Considerations) foreach (var consideration in Considerations)
foreach (var scrutinized in frozenActors) foreach (var scrutinized in frozenActors)
if (scrutinized.IsValid && scrutinized.Visible) if (scrutinized.IsValid && scrutinized.Visible)
answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner), firedBy); answer += consideration.GetAttractiveness(scrutinized, firedBy.RelationshipWith(scrutinized.Owner));
return answer; return answer;
} }
@@ -174,7 +174,7 @@ namespace OpenRA.Mods.Common.Traits
return 0; return 0;
} }
public int GetAttractiveness(FrozenActor fa, PlayerRelationship stance, Player firedBy) public int GetAttractiveness(FrozenActor fa, PlayerRelationship stance)
{ {
if (stance != Against) if (stance != Against)
return 0; return 0;

View File

@@ -16,12 +16,12 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Manages AI repairing base buildings.")] [Desc("Manages AI repairing base buildings.")]
public class BuildingRepairBotModuleInfo : ConditionalTraitInfo public class BuildingRepairBotModuleInfo : ConditionalTraitInfo
{ {
public override object Create(ActorInitializer init) { return new BuildingRepairBotModule(init.Self, this); } public override object Create(ActorInitializer init) { return new BuildingRepairBotModule(this); }
} }
public class BuildingRepairBotModule : ConditionalTrait<BuildingRepairBotModuleInfo>, IBotRespondToAttack public class BuildingRepairBotModule : ConditionalTrait<BuildingRepairBotModuleInfo>, IBotRespondToAttack
{ {
public BuildingRepairBotModule(Actor self, BuildingRepairBotModuleInfo info) public BuildingRepairBotModule(BuildingRepairBotModuleInfo info)
: base(info) { } : base(info) { }
void IBotRespondToAttack.RespondToAttack(IBot bot, Actor self, AttackInfo e) void IBotRespondToAttack.RespondToAttack(IBot bot, Actor self, AttackInfo e)

View File

@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
Target FindNextResource(Actor actor, HarvesterTraitWrapper harv) Target FindNextResource(Actor actor, HarvesterTraitWrapper harv)
{ {
Func<CPos, bool> isValidResource = cell => Func<CPos, bool> isValidResource = cell =>
harv.Harvester.CanHarvestCell(actor, cell) && harv.Harvester.CanHarvestCell(cell) &&
claimLayer.CanClaimCell(actor, cell); claimLayer.CanClaimCell(actor, cell);
List<CPos> path; List<CPos> path;

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
readonly IActorPreview[] preview; readonly IActorPreview[] preview;
public ActorPreviewPlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, ActorPreviewPlaceBuildingPreviewInfo info, TypeDictionary init) public ActorPreviewPlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, ActorPreviewPlaceBuildingPreviewInfo info, TypeDictionary init)
: base(wr, ai, info, init) : base(wr, ai, info)
{ {
this.info = info; this.info = info;
var previewInit = new ActorPreviewInitializer(ActorInfo, wr, init); var previewInit = new ActorPreviewInitializer(ActorInfo, wr, init);

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
return buildRadiusEnabled && (self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer))); return buildRadiusEnabled && (self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)));
} }
public IEnumerable<IRenderable> RangeCircleRenderables(WorldRenderer wr) public IEnumerable<IRenderable> RangeCircleRenderables()
{ {
if (IsTraitDisabled) if (IsTraitDisabled)
yield break; yield break;
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<IRenderable> IRenderAnnotationsWhenSelected.RenderAnnotations(Actor self, WorldRenderer wr) IEnumerable<IRenderable> IRenderAnnotationsWhenSelected.RenderAnnotations(Actor self, WorldRenderer wr)
{ {
return RangeCircleRenderables(wr); return RangeCircleRenderables();
} }
bool IRenderAnnotationsWhenSelected.SpatiallyPartitionable => false; bool IRenderAnnotationsWhenSelected.SpatiallyPartitionable => false;

View File

@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Traits
return terrainInfo.GetTerrainInfo(new TerrainTile(template, (byte)index)); return terrainInfo.GetTerrainInfo(new TerrainTile(template, (byte)index));
} }
public void LinkNeighbouringBridges(World world, LegacyBridgeLayer bridges) public void LinkNeighbouringBridges(LegacyBridgeLayer bridges)
{ {
for (var d = 0; d <= 1; d++) for (var d = 0; d <= 1; d++)
{ {

View File

@@ -259,7 +259,7 @@ namespace OpenRA.Mods.Common.Traits
if (!RequiresBaseProvider) if (!RequiresBaseProvider)
return SpriteRenderable.None; return SpriteRenderable.None;
return w.ActorsWithTrait<BaseProvider>().SelectMany(a => a.Trait.RangeCircleRenderables(wr)); return w.ActorsWithTrait<BaseProvider>().SelectMany(a => a.Trait.RangeCircleRenderables());
} }
} }

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
protected virtual IPlaceBuildingPreview CreatePreview(WorldRenderer wr, ActorInfo ai, TypeDictionary init) protected virtual IPlaceBuildingPreview CreatePreview(WorldRenderer wr, ActorInfo ai, TypeDictionary init)
{ {
return new FootprintPlaceBuildingPreviewPreview(wr, ai, this, init); return new FootprintPlaceBuildingPreviewPreview(wr, ai, this);
} }
IPlaceBuildingPreview IPlaceBuildingPreviewGeneratorInfo.CreatePreview(WorldRenderer wr, ActorInfo ai, TypeDictionary init) IPlaceBuildingPreview IPlaceBuildingPreviewGeneratorInfo.CreatePreview(WorldRenderer wr, ActorInfo ai, TypeDictionary init)
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
readonly Sprite validTile, blockedTile; readonly Sprite validTile, blockedTile;
readonly float validAlpha, blockedAlpha; readonly float validAlpha, blockedAlpha;
public FootprintPlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, FootprintPlaceBuildingPreviewInfo info, TypeDictionary init) public FootprintPlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, FootprintPlaceBuildingPreviewInfo info)
{ {
ActorInfo = ai; ActorInfo = ai;
this.info = info; this.info = info;

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public bool IsValidTarget(ActorInfo actorInfo, Actor saboteur) { return false; } // TODO: bridges don't support frozen under fog public bool IsValidTarget(ActorInfo actorInfo, Actor saboteur) { return false; } // TODO: bridges don't support frozen under fog
public override object Create(ActorInitializer init) { return new LegacyBridgeHut(init, this); } public override object Create(ActorInitializer init) { return new LegacyBridgeHut(init); }
} }
class LegacyBridgeHut : IDemolishable class LegacyBridgeHut : IDemolishable
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
public bool Repairing => repairDirections > 0; public bool Repairing => repairDirections > 0;
int repairDirections = 0; int repairDirections = 0;
public LegacyBridgeHut(ActorInitializer init, LegacyBridgeHutInfo info) public LegacyBridgeHut(ActorInitializer init)
{ {
var bridge = init.Get<ParentActorInit>().Value; var bridge = init.Get<ParentActorInit>().Value;
init.World.AddFrameEndTask(_ => init.World.AddFrameEndTask(_ =>

View File

@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
public bool ForceSet { get; private set; } public bool ForceSet { get; private set; }
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Terrain) if (target.Type != TargetType.Terrain)
return false; return false;

View File

@@ -138,7 +138,7 @@ namespace OpenRA.Mods.Common.Traits
return count; return count;
} }
void CancelDock(Actor self) void CancelDock()
{ {
preventDock = true; preventDock = true;
} }
@@ -161,7 +161,7 @@ namespace OpenRA.Mods.Common.Traits
void INotifyActorDisposing.Disposing(Actor self) void INotifyActorDisposing.Disposing(Actor self)
{ {
CancelDock(self); CancelDock();
foreach (var harv in GetLinkedHarvesters()) foreach (var harv in GetLinkedHarvesters())
harv.Trait.UnlinkProc(harv.Actor, self); harv.Trait.UnlinkProc(harv.Actor, self);
} }
@@ -193,11 +193,11 @@ namespace OpenRA.Mods.Common.Traits
dockedHarv.ChangeOwner(newOwner); dockedHarv.ChangeOwner(newOwner);
// Relink to this refinery // Relink to this refinery
dockedHarv.Trait<Harvester>().LinkProc(dockedHarv, self); dockedHarv.Trait<Harvester>().LinkProc(self);
} }
} }
void INotifySold.Selling(Actor self) { CancelDock(self); } void INotifySold.Selling(Actor self) { CancelDock(); }
void INotifySold.Sold(Actor self) void INotifySold.Sold(Actor self)
{ {
foreach (var harv in GetLinkedHarvesters()) foreach (var harv in GetLinkedHarvesters())

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
readonly PaletteReference palette; readonly PaletteReference palette;
public SequencePlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, SequencePlaceBuildingPreviewInfo info, TypeDictionary init) public SequencePlaceBuildingPreviewPreview(WorldRenderer wr, ActorInfo ai, SequencePlaceBuildingPreviewInfo info, TypeDictionary init)
: base(wr, ai, info, init) : base(wr, ai, info)
{ {
this.info = info; this.info = info;
var ownerName = init.Get<OwnerInit>().InternalName; var ownerName = init.Get<OwnerInit>().InternalName;
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits
var rsi = ai.TraitInfo<RenderSpritesInfo>(); var rsi = ai.TraitInfo<RenderSpritesInfo>();
palette = wr.Palette(rsi.Palette ?? rsi.PlayerPalette + ownerName); palette = wr.Palette(rsi.Palette ?? rsi.PlayerPalette + ownerName);
preview = new Animation(wr.World, rsi.GetImage(ai, wr.World.Map.Rules.Sequences, faction)); preview = new Animation(wr.World, rsi.GetImage(ai, faction));
preview.PlayRepeating(info.Sequence); preview.PlayRepeating(info.Sequence);
} }

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
AircraftCanEnter, AircraftCanEnter,
target => Reservable.IsAvailableFor(target, self)); target => Reservable.IsAvailableFor(target, self));
yield return new AircraftMoveOrderTargeter(self, this); yield return new AircraftMoveOrderTargeter(this);
} }
} }
} }
@@ -191,7 +191,7 @@ namespace OpenRA.Mods.Common.Traits
return modifiers.HasModifier(TargetModifiers.ForceMove); return modifiers.HasModifier(TargetModifiers.ForceMove);
} }
public AircraftMoveOrderTargeter(Actor self, TransformsIntoAircraft aircraft) public AircraftMoveOrderTargeter(TransformsIntoAircraft aircraft)
{ {
this.aircraft = aircraft; this.aircraft = aircraft;
} }
@@ -200,7 +200,7 @@ namespace OpenRA.Mods.Common.Traits
public int OrderPriority => 4; public int OrderPriority => 4;
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Terrain || (aircraft.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))) if (target.Type != TargetType.Terrain || (aircraft.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false; return false;

View File

@@ -189,7 +189,7 @@ namespace OpenRA.Mods.Common.Traits
public int OrderPriority => 4; public int OrderPriority => 4;
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{ {
if (rejectMove || target.Type != TargetType.Terrain || (mobile.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))) if (rejectMove || target.Type != TargetType.Terrain || (mobile.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false; return false;

View File

@@ -20,12 +20,12 @@ namespace OpenRA.Mods.Common.Traits
[VoiceReference] [VoiceReference]
public readonly string Voice = "Action"; public readonly string Voice = "Action";
public override object Create(ActorInitializer init) { return new TransformsIntoTransforms(init.Self, this); } public override object Create(ActorInitializer init) { return new TransformsIntoTransforms(this); }
} }
public class TransformsIntoTransforms : ConditionalTrait<TransformsIntoTransformsInfo>, IResolveOrder, IOrderVoice, IIssueDeployOrder public class TransformsIntoTransforms : ConditionalTrait<TransformsIntoTransformsInfo>, IResolveOrder, IOrderVoice, IIssueDeployOrder
{ {
public TransformsIntoTransforms(Actor self, TransformsIntoTransformsInfo info) public TransformsIntoTransforms(TransformsIntoTransformsInfo info)
: base(info) { } : base(info) { }
void IResolveOrder.ResolveOrder(Actor self, Order order) void IResolveOrder.ResolveOrder(Actor self, Order order)

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
self.CancelActivity(); self.CancelActivity();
} }
protected override void TraitEnabled(Actor self) { captureManager.RefreshCapturable(self); } protected override void TraitEnabled(Actor self) { captureManager.RefreshCapturable(); }
protected override void TraitDisabled(Actor self) { captureManager.RefreshCapturable(self); } protected override void TraitDisabled(Actor self) { captureManager.RefreshCapturable(); }
} }
} }

View File

@@ -21,14 +21,14 @@ namespace OpenRA.Mods.Common.Traits
{ {
public readonly Color Color = Color.Orange; public readonly Color Color = Color.Orange;
public override object Create(ActorInitializer init) { return new CapturableProgressBar(init.Self, this); } public override object Create(ActorInitializer init) { return new CapturableProgressBar(this); }
} }
class CapturableProgressBar : ConditionalTrait<CapturableProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher class CapturableProgressBar : ConditionalTrait<CapturableProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher
{ {
readonly Dictionary<Actor, (int Current, int Total)> progress = new Dictionary<Actor, (int, int)>(); readonly Dictionary<Actor, (int Current, int Total)> progress = new Dictionary<Actor, (int, int)>();
public CapturableProgressBar(Actor self, CapturableProgressBarInfo info) public CapturableProgressBar(CapturableProgressBarInfo info)
: base(info) { } : base(info) { }
void ICaptureProgressWatcher.Update(Actor self, Actor captor, Actor target, int current, int total) void ICaptureProgressWatcher.Update(Actor self, Actor captor, Actor target, int current, int total)

View File

@@ -99,11 +99,11 @@ namespace OpenRA.Mods.Common.Traits
.ToArray() .ToArray()
.Where(Exts.IsTraitEnabled); .Where(Exts.IsTraitEnabled);
RefreshCaptures(self); RefreshCaptures();
RefreshCapturable(self); RefreshCapturable();
} }
public void RefreshCapturable(Actor self) public void RefreshCapturable()
{ {
allyCapturableTypes = neutralCapturableTypes = enemyCapturableTypes = default(BitSet<CaptureType>); allyCapturableTypes = neutralCapturableTypes = enemyCapturableTypes = default(BitSet<CaptureType>);
foreach (var c in enabledCapturable) foreach (var c in enabledCapturable)
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
} }
} }
public void RefreshCaptures(Actor self) public void RefreshCaptures()
{ {
capturesTypes = enabledCaptures.Aggregate( capturesTypes = enabledCaptures.Aggregate(
default(BitSet<CaptureType>), default(BitSet<CaptureType>),

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public readonly Color Color = Color.Orange; public readonly Color Color = Color.Orange;
public override object Create(ActorInitializer init) { return new CaptureProgressBar(init.Self, this); } public override object Create(ActorInitializer init) { return new CaptureProgressBar(this); }
} }
class CaptureProgressBar : ConditionalTrait<CaptureProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher class CaptureProgressBar : ConditionalTrait<CaptureProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
int current; int current;
int total; int total;
public CaptureProgressBar(Actor self, CaptureProgressBarInfo info) public CaptureProgressBar(CaptureProgressBarInfo info)
: base(info) { } : base(info) { }
void ICaptureProgressWatcher.Update(Actor self, Actor captor, Actor target, int current, int total) void ICaptureProgressWatcher.Update(Actor self, Actor captor, Actor target, int current, int total)

View File

@@ -110,8 +110,8 @@ namespace OpenRA.Mods.Common.Traits
self.ShowTargetLines(); self.ShowTargetLines();
} }
protected override void TraitEnabled(Actor self) { captureManager.RefreshCaptures(self); } protected override void TraitEnabled(Actor self) { captureManager.RefreshCaptures(); }
protected override void TraitDisabled(Actor self) { captureManager.RefreshCaptures(self); } protected override void TraitDisabled(Actor self) { captureManager.RefreshCaptures(); }
class CaptureOrderTargeter : UnitOrderTargeter class CaptureOrderTargeter : UnitOrderTargeter
{ {

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Carryall attachment point relative to body.")] [Desc("Carryall attachment point relative to body.")]
public readonly WVec LocalOffset = WVec.Zero; public readonly WVec LocalOffset = WVec.Zero;
public override object Create(ActorInitializer init) { return new Carryable(init.Self, this); } public override object Create(ActorInitializer init) { return new Carryable(this); }
} }
public enum LockResponse { Success, Pending, Failed } public enum LockResponse { Success, Pending, Failed }
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
protected State state = State.Free; protected State state = State.Free;
protected bool attached; protected bool attached;
public Carryable(Actor self, CarryableInfo info) public Carryable(CarryableInfo info)
: base(info) { } : base(info) { }
protected override void Created(Actor self) protected override void Created(Actor self)

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