Remove unused parameters and variables.

This commit is contained in:
Matthias Mailänder
2021-12-05 13:27:29 +01:00
committed by abcdefg30
parent 07815143f1
commit 9d905d8291
31 changed files with 54 additions and 59 deletions

View File

@@ -205,7 +205,7 @@ namespace OpenRA
customDataLoaded = true;
}
static string[] YamlList(Dictionary<string, MiniYaml> yaml, string key, bool parsePaths = false)
static string[] YamlList(Dictionary<string, MiniYaml> yaml, string key)
{
if (!yaml.ContainsKey(key))
return Array.Empty<string>();

View File

@@ -326,13 +326,13 @@ namespace OpenRA
var inherited = new Dictionary<string, MiniYamlNode.SourceLocation>();
inherited.Add(kv.Key, default(MiniYamlNode.SourceLocation));
var children = ResolveInherits(kv.Key, kv.Value, tree, inherited);
var children = ResolveInherits(kv.Value, tree, inherited);
resolved.Add(kv.Key, new MiniYaml(kv.Value.Value, children));
}
// Resolve any top-level removals (e.g. removing whole actor blocks)
var nodes = new MiniYaml("", resolved.Select(kv => new MiniYamlNode(kv.Key, kv.Value)).ToList());
return ResolveInherits("", nodes, tree, new Dictionary<string, MiniYamlNode.SourceLocation>());
return ResolveInherits(nodes, tree, new Dictionary<string, MiniYamlNode.SourceLocation>());
}
static void MergeIntoResolved(MiniYamlNode overrideNode, List<MiniYamlNode> existingNodes,
@@ -342,13 +342,13 @@ namespace OpenRA
if (existingNode != null)
{
existingNode.Value = MergePartial(existingNode.Value, overrideNode.Value);
existingNode.Value.Nodes = ResolveInherits(existingNode.Key, existingNode.Value, tree, inherited);
existingNode.Value.Nodes = ResolveInherits(existingNode.Value, tree, inherited);
}
else
existingNodes.Add(overrideNode.Clone());
}
static List<MiniYamlNode> ResolveInherits(string key, MiniYaml node, Dictionary<string, MiniYaml> tree, Dictionary<string, MiniYamlNode.SourceLocation> inherited)
static List<MiniYamlNode> ResolveInherits(MiniYaml node, Dictionary<string, MiniYaml> tree, Dictionary<string, MiniYamlNode.SourceLocation> inherited)
{
var resolved = new List<MiniYamlNode>(node.Nodes.Count);
@@ -367,7 +367,7 @@ namespace OpenRA
throw new YamlException($"{n.Location}: Parent type `{n.Value.Value}` was already inherited by this yaml tree at {inherited[n.Value.Value]} (note: may be from a derived tree)");
inherited.Add(n.Value.Value, n.Location);
foreach (var r in ResolveInherits(n.Key, parent, tree, inherited))
foreach (var r in ResolveInherits(parent, tree, inherited))
MergeIntoResolved(r, resolved, tree, inherited);
}
else if (n.Key.StartsWith("-", StringComparison.Ordinal))

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Cnc.Activities
var cargo = self.TraitOrDefault<Cargo>();
if (cargo != null && teleporter != null)
{
while (!cargo.IsEmpty(self))
while (!cargo.IsEmpty())
{
var a = cargo.Unload(self);

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Cnc.Traits
if (!info.Types.Overlaps(types))
return;
var transform = new Transform(self, info.IntoActor)
var transform = new Transform(info.IntoActor)
{
ForceHealthPercentage = info.ForceHealthPercentage,
Faction = faction,

View File

@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Cnc.Traits
void Transform(Actor self)
{
var transform = new Transform(self, info.IntoActor);
var transform = new Transform(info.IntoActor);
var facing = self.TraitOrDefault<IFacing>();
if (facing != null)

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Activities
if (enterLegacyHut != null)
enterLegacyHut.Repair(self);
else if (enterHut != null)
enterHut.Repair(enterActor, self);
enterHut.Repair(self);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", notification, self.Owner.Faction.InternalName);

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Activities
if (targetActor != enterActor)
return;
if (!enterCargo.CanLoad(enterActor, self))
if (!enterCargo.CanLoad(self))
return;
enterCargo.Load(enterActor, self);

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Activities
public bool SkipMakeAnims = false;
public string Faction = null;
public Transform(Actor self, string toActor)
public Transform(string toActor)
{
ToActor = toActor;
}

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Activities
public override bool Tick(Actor self)
{
if (IsCanceling || cargo.IsEmpty(self))
if (IsCanceling || cargo.IsEmpty())
return true;
if (cargo.CanUnload())
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Activities
foreach (var inu in notifiers)
inu.Unloading(self);
var actor = cargo.Peek(self);
var actor = cargo.Peek();
var spawn = self.CenterPosition;
var exitSubCell = ChooseExitSubCell(actor);

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
protected abstract void AddCellsToPlayerShroud(Actor self, Player player, PPos[] uv);
protected abstract void RemoveCellsFromPlayerShroud(Actor self, Player player);
public AffectsShroud(Actor self, AffectsShroudInfo info)
public AffectsShroud(AffectsShroudInfo info)
: base(info)
{
if (Info.Type == VisibilityType.Footprint)

View File

@@ -224,8 +224,6 @@ namespace OpenRA.Mods.Common.Traits
INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyActorDisposing, INotifyBecomingIdle, ICreationActivity,
IActorPreviewInitModifier, IDeathActorInitModifier, IIssueDeployOrder, IIssueOrder, IResolveOrder, IOrderVoice
{
static readonly (CPos, SubCell)[] NoCells = { };
readonly Actor self;
Repairable repairable;

View File

@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
public void Repair(Actor self, Actor repairer)
public void Repair(Actor repairer)
{
if (Info.RepairPropagationDelay > 0)
{

View File

@@ -144,7 +144,7 @@ namespace OpenRA.Mods.Common.Traits
return;
// Manually manage the inner activity queue
var activity = currentTransform ?? transform.GetTransformActivity(self);
var activity = currentTransform ?? transform.GetTransformActivity();
if (!order.Queued)
activity.NextActivity?.Cancel(self);

View File

@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits
return;
// Manually manage the inner activity queue
var activity = currentTransform ?? transform.GetTransformActivity(self);
var activity = currentTransform ?? transform.GetTransformActivity();
if (!order.Queued)
activity.NextActivity?.Cancel(self);

View File

@@ -120,7 +120,7 @@ namespace OpenRA.Mods.Common.Traits
return;
// Manually manage the inner activity queue
var activity = currentTransform ?? transform.GetTransformActivity(self);
var activity = currentTransform ?? transform.GetTransformActivity();
if (!order.Queued)
activity.NextActivity?.Cancel(self);

View File

@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits
return;
// Manually manage the inner activity queue
var activity = currentTransform ?? transform.GetTransformActivity(self);
var activity = currentTransform ?? transform.GetTransformActivity();
if (!order.Queued)
activity.NextActivity?.Cancel(self);

View File

@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Traits
return;
// Manually manage the inner activity queue
var activity = currentTransform ?? transform.GetTransformActivity(self);
var activity = currentTransform ?? transform.GetTransformActivity();
if (!order.Queued)
activity.NextActivity?.Cancel(self);

View File

@@ -243,11 +243,11 @@ namespace OpenRA.Mods.Common.Traits
return false;
}
return !IsEmpty(self) && (aircraft == null || aircraft.CanLand(self.Location, blockedByMobile: false))
return !IsEmpty() && (aircraft == null || aircraft.CanLand(self.Location, blockedByMobile: false))
&& CurrentAdjacentCells != null && CurrentAdjacentCells.Any(c => Passengers.Any(p => !p.IsDead && p.Trait<IPositionable>().CanEnterCell(c, null, check)));
}
public bool CanLoad(Actor self, Actor a)
public bool CanLoad(Actor a)
{
return reserves.Contains(a) || HasSpace(GetWeight(a));
}
@@ -320,16 +320,16 @@ namespace OpenRA.Mods.Common.Traits
public string VoicePhraseForOrder(Actor self, Order order)
{
if (order.OrderString != "Unload" || IsEmpty(self) || !self.HasVoice(Info.UnloadVoice))
if (order.OrderString != "Unload" || IsEmpty() || !self.HasVoice(Info.UnloadVoice))
return null;
return Info.UnloadVoice;
}
public bool HasSpace(int weight) { return totalWeight + reservedWeight + weight <= Info.MaxWeight; }
public bool IsEmpty(Actor self) { return cargo.Count == 0; }
public bool IsEmpty() { return cargo.Count == 0; }
public Actor Peek(Actor self) { return cargo.Last(); }
public Actor Peek() { return cargo.Last(); }
public Actor Unload(Actor self, Actor passenger = null)
{
@@ -406,7 +406,7 @@ namespace OpenRA.Mods.Common.Traits
void INotifyKilled.Killed(Actor self, AttackInfo e)
{
if (Info.EjectOnDeath)
while (!IsEmpty(self) && CanUnload(BlockedByActor.All))
while (!IsEmpty() && CanUnload(BlockedByActor.All))
{
var passenger = Unload(self);
var cp = self.CenterPosition;
@@ -445,7 +445,7 @@ namespace OpenRA.Mods.Common.Traits
if (!Info.EjectOnSell || cargo == null)
return;
while (!IsEmpty(self))
while (!IsEmpty())
SpawnPassenger(Unload(self));
}

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Bot types that trigger the condition.")]
public readonly string[] Bots = Array.Empty<string>();
public override object Create(ActorInitializer init) { return new GrantConditionOnBotOwner(init, this); }
public override object Create(ActorInitializer init) { return new GrantConditionOnBotOwner(this); }
}
public class GrantConditionOnBotOwner : INotifyCreated, INotifyOwnerChanged
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
int conditionToken = Actor.InvalidConditionToken;
public GrantConditionOnBotOwner(ActorInitializer init, GrantConditionOnBotOwnerInfo info)
public GrantConditionOnBotOwner(GrantConditionOnBotOwnerInfo info)
{
this.info = info;
}

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("List of required prerequisites.")]
public readonly string[] Prerequisites = Array.Empty<string>();
public override object Create(ActorInitializer init) { return new GrantConditionOnPrerequisite(init.Self, this); }
public override object Create(ActorInitializer init) { return new GrantConditionOnPrerequisite(this); }
}
public class GrantConditionOnPrerequisite : INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOwnerChanged
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
GrantConditionOnPrerequisiteManager globalManager;
int conditionToken = Actor.InvalidConditionToken;
public GrantConditionOnPrerequisite(Actor self, GrantConditionOnPrerequisiteInfo info)
public GrantConditionOnPrerequisite(GrantConditionOnPrerequisiteInfo info)
{
this.info = info;
}

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Relationship the watching player needs to see the generated shroud.")]
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Neutral | PlayerRelationship.Enemy;
public override object Create(ActorInitializer init) { return new CreatesShroud(init.Self, this); }
public override object Create(ActorInitializer init) { return new CreatesShroud(this); }
}
public class CreatesShroud : AffectsShroud
@@ -28,8 +28,8 @@ namespace OpenRA.Mods.Common.Traits
readonly CreatesShroudInfo info;
IEnumerable<int> rangeModifiers;
public CreatesShroud(Actor self, CreatesShroudInfo info)
: base(self, info)
public CreatesShroud(CreatesShroudInfo info)
: base(info)
{
this.info = info;
}

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Allow palette modifiers to change the palette.")]
public readonly bool AllowModifiers = true;
public override object Create(ActorInitializer init) { return new ColorPickerPalette(init.World, this); }
public override object Create(ActorInitializer init) { return new ColorPickerPalette(this); }
}
class ColorPickerPalette : ILoadsPalettes, IProvidesAssetBrowserColorPickerPalettes, ITickRender
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
readonly ColorPickerManagerInfo colorManager;
Color color;
public ColorPickerPalette(World world, ColorPickerPaletteInfo info)
public ColorPickerPalette(ColorPickerPaletteInfo info)
{
// All users need to use the same TraitInfo instance, chosen as the default mod rules
colorManager = Game.ModData.DefaultRules.Actors[SystemActors.World].TraitInfo<ColorPickerManagerInfo>();

View File

@@ -81,10 +81,10 @@ namespace OpenRA.Mods.Common.Traits
OnExitedDropRange(self);
// Are we able to drop the next trooper?
if (!inDropRange || cargo.IsEmpty(self) || !self.World.Map.Contains(self.Location))
if (!inDropRange || cargo.IsEmpty() || !self.World.Map.Contains(self.Location))
return;
var dropActor = cargo.Peek(self);
var dropActor = cargo.Peek();
var dropPositionable = dropActor.Trait<IPositionable>();
var dropCell = self.Location;
var dropSubCell = dropPositionable.GetAvailableSubCell(dropCell);

View File

@@ -27,14 +27,14 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Should the level-up animation be suppressed when actor is created?")]
public readonly bool SuppressLevelupAnimation = true;
public override object Create(ActorInitializer init) { return new ProducibleWithLevel(init, this); }
public override object Create(ActorInitializer init) { return new ProducibleWithLevel(this); }
}
public class ProducibleWithLevel : INotifyCreated
{
readonly ProducibleWithLevelInfo info;
public ProducibleWithLevel(ActorInitializer init, ProducibleWithLevelInfo info)
public ProducibleWithLevel(ProducibleWithLevelInfo info)
{
this.info = info;
}

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Can this actor reveal shroud generated by the `" + nameof(CreatesShroud) + "` trait?")]
public readonly bool RevealGeneratedShroud = true;
public override object Create(ActorInitializer init) { return new RevealsShroud(init.Self, this); }
public override object Create(ActorInitializer init) { return new RevealsShroud(this); }
}
public class RevealsShroud : AffectsShroud
@@ -32,8 +32,8 @@ namespace OpenRA.Mods.Common.Traits
readonly Shroud.SourceType type;
IEnumerable<int> rangeModifiers;
public RevealsShroud(Actor self, RevealsShroudInfo info)
: base(self, info)
public RevealsShroud(RevealsShroudInfo info)
: base(info)
{
this.info = info;
type = info.RevealGeneratedShroud ? Shroud.SourceType.Visibility

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
[Desc("Should the sound be delayed relative to preparation or actual attack?")]
public readonly AttackDelayType DelayRelativeTo = AttackDelayType.Preparation;
public override object Create(ActorInitializer init) { return new AttackSounds(init, this); }
public override object Create(ActorInitializer init) { return new AttackSounds(this); }
}
public class AttackSounds : ConditionalTrait<AttackSoundsInfo>, INotifyAttack, ITick
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
readonly AttackSoundsInfo info;
int tick;
public AttackSounds(ActorInitializer init, AttackSoundsInfo info)
public AttackSounds(AttackSoundsInfo info)
: base(info)
{
this.info = info;

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
return;
var facing = crusher.TraitOrDefault<IFacing>();
var transform = new Transform(crusher, info.IntoActor) { Faction = faction };
var transform = new Transform(info.IntoActor) { Faction = faction };
if (facing != null)
transform.Facing = facing.Facing;

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
return;
var facing = self.TraitOrDefault<IFacing>();
var transform = new Transform(self, info.IntoActor) { ForceHealthPercentage = info.ForceHealthPercentage, Faction = faction };
var transform = new Transform(info.IntoActor) { ForceHealthPercentage = info.ForceHealthPercentage, Faction = faction };
if (facing != null) transform.Facing = facing.Facing;
transform.SkipMakeAnims = info.SkipMakeAnims;
self.QueueActivity(false, transform);

View File

@@ -89,9 +89,9 @@ namespace OpenRA.Mods.Common.Traits
return buildingInfo == null || self.World.CanPlaceBuilding(self.Location + Info.Offset, actorInfo, buildingInfo, self);
}
public Activity GetTransformActivity(Actor self)
public Activity GetTransformActivity()
{
return new Transform(self, Info.IntoActor)
return new Transform(Info.IntoActor)
{
Offset = Info.Offset,
Facing = Info.Facing,
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits
return;
}
self.QueueActivity(queued, GetTransformActivity(self));
self.QueueActivity(queued, GetTransformActivity());
}
public void ResolveOrder(Actor self, Order order)

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
throw new YamlException($"{nameof(ActorSpawnManager)}.{nameof(SpawnInterval)}'s value(s) must not be less than 0");
}
public override object Create(ActorInitializer init) { return new ActorSpawnManager(init.Self, this); }
public override object Create(ActorInitializer init) { return new ActorSpawnManager(this); }
}
public class ActorSpawnManager : ConditionalTrait<ActorSpawnManagerInfo>, ITick
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
int spawnCountdown;
int actorsPresent;
public ActorSpawnManager(Actor self, ActorSpawnManagerInfo info)
public ActorSpawnManager(ActorSpawnManagerInfo info)
: base(info)
{
this.info = info;

View File

@@ -276,10 +276,7 @@ namespace OpenRA.Mods.Common.Widgets
if (world.OrderGenerator is ForceModifiersOrderGenerator fmog && fmog.Modifiers.HasFlag(modifiers))
return true;
if (world.OrderGenerator is UnitOrderGenerator uog && Game.GetModifierKeys().HasFlag(modifiers))
return true;
return false;
return world.OrderGenerator is UnitOrderGenerator && Game.GetModifierKeys().HasFlag(modifiers);
}
void UpdateStateIfNecessary()