Fix IDE0055
This rule no longer appears to be buggy, so enforce it. Some of the automated fixes are adjusted in order to improve the result. #pragma directives have no option to control indentation, so remove them where possible.
This commit is contained in:
committed by
Pavel Penev
parent
60cbf79c9b
commit
360f24f609
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
|
||||
// Moving to any position (even if quite stale) is still better than immediately giving up
|
||||
if ((target.Type == TargetType.Actor && target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
lastVisibleTarget = Target.FromPos(target.CenterPosition);
|
||||
else if (initialTargetPosition.HasValue)
|
||||
lastVisibleTarget = Target.FromPos(initialTargetPosition.Value);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
|
||||
// Moving to any position (even if quite stale) is still better than immediately giving up
|
||||
if ((target.Type == TargetType.Actor && target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
lastVisibleTarget = Target.FromPos(target.CenterPosition);
|
||||
else if (initialTargetPosition.HasValue)
|
||||
lastVisibleTarget = Target.FromPos(initialTargetPosition.Value);
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
|
||||
// Moving to any position (even if quite stale) is still better than immediately giving up
|
||||
if ((target.Type == TargetType.Actor && target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
{
|
||||
lastVisibleTarget = Target.FromPos(target.CenterPosition);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
|
||||
// Moving to any position (even if quite stale) is still better than immediately giving up
|
||||
if ((target.Type == TargetType.Actor && target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
lastVisibleTarget = Target.FromPos(target.CenterPosition);
|
||||
else if (initialTargetPosition.HasValue)
|
||||
lastVisibleTarget = Target.FromPos(initialTargetPosition.Value);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
|
||||
// Moving to any position (even if quite stale) is still better than immediately giving up
|
||||
if ((target.Type == TargetType.Actor && target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
{
|
||||
lastVisibleTarget = Target.FromPos(target.CenterPosition);
|
||||
SetVisibleTargetLocation(self, target);
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
editorActorPreview = editorLayer.Add(actor);
|
||||
Text = TranslationProvider.GetString(AddedActor,
|
||||
Translation.Arguments("name", editorActorPreview.Info.Name, "id", editorActorPreview.ID));
|
||||
Translation.Arguments("name", editorActorPreview.Info.Name, "id", editorActorPreview.ID));
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
|
||||
@@ -49,11 +49,11 @@ namespace OpenRA.Mods.Common.FileSystem
|
||||
try
|
||||
{
|
||||
// Parse package header
|
||||
/*var signature = */s.ReadUInt32();
|
||||
s.ReadUInt32(); // signature
|
||||
s.Position += 8;
|
||||
/*var FileCount = */s.ReadUInt16();
|
||||
s.ReadUInt16(); // FileCount
|
||||
s.Position += 4;
|
||||
/*var ArchiveSize = */s.ReadUInt32();
|
||||
s.ReadUInt32(); // ArchiveSize
|
||||
s.Position += 19;
|
||||
var tocAddress = s.ReadInt32();
|
||||
s.Position += 4;
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
protected static readonly SpriteSequenceField<int> Tick = new(nameof(Tick), 40);
|
||||
|
||||
[Desc("Value controlling the Z-order. A higher values means rendering on top of other sprites at the same position. " +
|
||||
"Use power of 2 values to avoid glitches.")]
|
||||
"Use power of 2 values to avoid glitches.")]
|
||||
protected static readonly SpriteSequenceField<WDist> ZOffset = new(nameof(ZOffset), WDist.Zero);
|
||||
|
||||
[Desc("Additional sprite depth Z offset to apply as a function of sprite Y (0: vertical, 1: flat on terrain)")]
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
: this(font, pos, zOffset, color,
|
||||
ChromeMetrics.Get<Color>("TextContrastColorDark"),
|
||||
ChromeMetrics.Get<Color>("TextContrastColorLight"),
|
||||
text) { }
|
||||
text)
|
||||
{ }
|
||||
|
||||
public WPos Pos { get; }
|
||||
public int ZOffset { get; }
|
||||
|
||||
@@ -40,7 +40,8 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
: this(font, effectiveWorldPos, screenPos, zOffset, color,
|
||||
ChromeMetrics.Get<Color>("TextContrastColorDark"),
|
||||
ChromeMetrics.Get<Color>("TextContrastColorLight"),
|
||||
text) { }
|
||||
text)
|
||||
{ }
|
||||
|
||||
public WPos Pos { get; }
|
||||
public int ZOffset { get; }
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public Actor[] NamedActors => sma.Actors.Values.ToArray();
|
||||
|
||||
[Desc("Returns the actor that was specified with a given name in " +
|
||||
"the map file (or nil, if the actor is dead or not found).")]
|
||||
"the map file (or nil, if the actor is dead or not found).")]
|
||||
public Actor NamedActor(string actorName)
|
||||
{
|
||||
if (!sma.Actors.TryGetValue(actorName, out var ret))
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public int PowerDrained => pm.PowerDrained;
|
||||
|
||||
[Desc("Returns the player's power state " +
|
||||
"(\"Normal\", \"Low\" or \"Critical\").")]
|
||||
"(\"Normal\", \"Low\" or \"Critical\").")]
|
||||
public string PowerState => pm.PowerState.ToString();
|
||||
|
||||
[Desc("Triggers low power for the chosen amount of ticks.")]
|
||||
|
||||
@@ -1192,7 +1192,7 @@ namespace OpenRA.Mods.Common.Server
|
||||
return true;
|
||||
|
||||
if (!Exts.TryParseInt32Invariant(parts[1], out var spawnPoint)
|
||||
|| spawnPoint < 0 || spawnPoint > server.Map.SpawnPoints.Length)
|
||||
|| spawnPoint < 0 || spawnPoint > server.Map.SpawnPoints.Length)
|
||||
{
|
||||
Log.Write("server", $"Invalid spawn point: {parts[1]}");
|
||||
return true;
|
||||
|
||||
@@ -1262,9 +1262,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var cell in rallyPoint)
|
||||
self.QueueActivity(new AttackMoveActivity(self, () => aircraft.MoveTo(cell, 1, evaluateNearestMovableCell: true, targetLineColor: Color.OrangeRed)));
|
||||
}
|
||||
else
|
||||
if (self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition).Length <= aircraft.LandAltitude.Length)
|
||||
QueueChild(new TakeOff(self));
|
||||
else if (self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition).Length <= aircraft.LandAltitude.Length)
|
||||
QueueChild(new TakeOff(self));
|
||||
|
||||
aircraft.UnReserve();
|
||||
return true;
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
IsAiming = CanAimAtTarget(self, OpportunityTarget, opportunityForceAttack);
|
||||
|
||||
if (!IsAiming && Info.OpportunityFire && autoTarget != null &&
|
||||
!autoTarget.IsTraitDisabled && autoTarget.Stance >= UnitStance.Defend)
|
||||
!autoTarget.IsTraitDisabled && autoTarget.Stance >= UnitStance.Defend)
|
||||
{
|
||||
OpportunityTarget = autoTarget.ScanForTarget(self, false, false);
|
||||
opportunityForceAttack = false;
|
||||
@@ -265,7 +265,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
|
||||
// Moving to any position (even if quite stale) is still better than immediately giving up
|
||||
if ((target.Type == TargetType.Actor && target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
{
|
||||
lastVisibleTarget = Target.FromPos(target.CenterPosition);
|
||||
lastVisibleMaximumRange = attack.GetMaximumRangeVersusTarget(target);
|
||||
|
||||
@@ -204,9 +204,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var explored = self.Owner.Shroud.IsExplored(location);
|
||||
if (!self.World.Map.Contains(location) ||
|
||||
!(self.CurrentActivity is Transform || mobile.transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused))
|
||||
|| (!explored && !mobile.locomotor.Info.MoveIntoShroud)
|
||||
|| (explored && !CanEnterCell(self, location)))
|
||||
!(self.CurrentActivity is Transform || mobile.transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused))
|
||||
|| (!explored && !mobile.locomotor.Info.MoveIntoShroud)
|
||||
|| (explored && !CanEnterCell(self, location)))
|
||||
cursor = mobile.Info.BlockedCursor;
|
||||
else if (!explored || !mobile.Info.TerrainCursors.TryGetValue(self.World.Map.GetTerrainInfo(location).Type, out cursor))
|
||||
cursor = mobile.Info.Cursor;
|
||||
|
||||
@@ -409,7 +409,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
void INotifyKilled.Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
{
|
||||
// IsAtGroundLevel contains Map.Contains(self.Location) check.
|
||||
if (Info.EjectOnDeath && self.IsAtGroundLevel() && (!checkTerrainType || Info.UnloadTerrainTypes.Contains(self.World.Map.GetTerrainInfo(self.Location).Type)))
|
||||
{
|
||||
|
||||
@@ -217,8 +217,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
chargedToken = self.RevokeCondition(chargedToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chargedToken == Actor.InvalidConditionToken)
|
||||
chargedToken = self.GrantCondition(Info.ChargedCondition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// TODO: This won't make sense for MP saves
|
||||
var localPlayer = worldRenderer.World.LocalPlayer;
|
||||
if ((localPlayer != null && localPlayer.PlayerActor != self) ||
|
||||
(localPlayer == null && self.Owner != self.World.Players.FirstOrDefault(p => p.IsBot)))
|
||||
(localPlayer == null && self.Owner != self.World.Players.FirstOrDefault(p => p.IsBot)))
|
||||
return null;
|
||||
|
||||
var nodes = new List<MiniYamlNode>()
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNodeBuilder actorNode)
|
||||
{
|
||||
if (actorNode.ChildrenMatching("Selection").Any(x => !x.IsRemoval())
|
||||
&& !actorNode.ChildrenMatching("ControlGroups").Any())
|
||||
&& !actorNode.ChildrenMatching("ControlGroups").Any())
|
||||
actorNode.AddNode(new MiniYamlNodeBuilder("ControlGroups", ""));
|
||||
|
||||
yield break;
|
||||
|
||||
@@ -27,10 +27,11 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||
{
|
||||
if (locations.Count > 0)
|
||||
yield return "The *Palette fields have been removed from the *PlaceBuildingPreview traits.\n" +
|
||||
"You may wish to inspect the following definitions and define new Alpha or\n" +
|
||||
"LineBuildSegmentAlpha properties as appropriate to recreate transparency effects:\n" +
|
||||
UpdateUtils.FormatMessageList(locations);
|
||||
yield return
|
||||
"The *Palette fields have been removed from the *PlaceBuildingPreview traits.\n" +
|
||||
"You may wish to inspect the following definitions and define new Alpha or\n" +
|
||||
"LineBuildSegmentAlpha properties as appropriate to recreate transparency effects:\n" +
|
||||
UpdateUtils.FormatMessageList(locations);
|
||||
|
||||
locations.Clear();
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||
{
|
||||
if (locations.Count > 0)
|
||||
yield return "You must define new Color fields on the following traits:\n" +
|
||||
UpdateUtils.FormatMessageList(locations);
|
||||
yield return
|
||||
"You must define new Color fields on the following traits:\n" +
|
||||
UpdateUtils.FormatMessageList(locations);
|
||||
|
||||
locations.Clear();
|
||||
}
|
||||
|
||||
@@ -56,9 +56,10 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
|
||||
if (requiredMetadata.Count != 0)
|
||||
{
|
||||
yield return $"The ExplicitSequenceFilenames rule requires {requiredMetadata.JoinWith(", ")}\n" +
|
||||
"to be defined under the SpriteSequenceFormat definition in mod.yaml.\n" +
|
||||
"Add these definitions back and run the update rule again.";
|
||||
yield return
|
||||
$"The ExplicitSequenceFilenames rule requires {requiredMetadata.JoinWith(", ")}\n" +
|
||||
"to be defined under the SpriteSequenceFormat definition in mod.yaml.\n" +
|
||||
"Add these definitions back and run the update rule again.";
|
||||
disabled = true;
|
||||
}
|
||||
}
|
||||
@@ -457,8 +458,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
|
||||
var overrideFilename = filename;
|
||||
if (useTilesetCode)
|
||||
overrideFilename = filename[..1] + tilesetCodes[sequenceTileset] +
|
||||
filename[2..];
|
||||
overrideFilename = filename[..1] + tilesetCodes[sequenceTileset] + filename[2..];
|
||||
|
||||
if (addExtension)
|
||||
overrideFilename += useTilesetExtension ? tilesetExtensions[sequenceTileset] : defaultSpriteExtension;
|
||||
|
||||
@@ -26,9 +26,10 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||
{
|
||||
if (locations.Count > 0)
|
||||
yield return "The PaletteFromEmbeddedSpritePalette trait no longer references a sequence.\n" +
|
||||
"You must manually define Filename (and Frame if needed) on the following actors:\n" +
|
||||
UpdateUtils.FormatMessageList(locations);
|
||||
yield return
|
||||
"The PaletteFromEmbeddedSpritePalette trait no longer references a sequence.\n" +
|
||||
"You must manually define Filename (and Frame if needed) on the following actors:\n" +
|
||||
UpdateUtils.FormatMessageList(locations);
|
||||
|
||||
locations.Clear();
|
||||
}
|
||||
|
||||
@@ -79,9 +79,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
|
||||
var png = new Png(pngData, SpriteFrameType.Indexed8, frameSize.Width, frameSize.Height, palColors);
|
||||
#pragma warning disable SA1003
|
||||
png.Save($"{prefix}-{count++:D4}.png");
|
||||
#pragma warning restore SA1003
|
||||
}
|
||||
|
||||
Console.WriteLine("Saved {0}-[0..{1}].png", prefix, count - 1);
|
||||
|
||||
@@ -73,9 +73,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
for (var s = 0; s < 256; s++)
|
||||
{
|
||||
#pragma warning disable IDE0047
|
||||
(*(c + s * 256 + v)) = Color.FromAhsv(newHue.Value, 1 - s / 255f, v / 255f).ToArgb();
|
||||
#pragma warning restore IDE0047
|
||||
*(c + s * 256 + v) = Color.FromAhsv(newHue.Value, 1 - s / 255f, v / 255f).ToArgb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,9 +39,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var c = (int*)cc;
|
||||
for (var h = 0; h < 256; h++)
|
||||
{
|
||||
#pragma warning disable IDE0047
|
||||
(*(c + 0 * 256 + h)) = Color.FromAhsv(h / 255f, 1, 1).ToArgb();
|
||||
#pragma warning restore IDE0047
|
||||
*(c + 0 * 256 + h) = Color.FromAhsv(h / 255f, 1, 1).ToArgb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,24 +65,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
labelText = viewport.ResourceTooltip;
|
||||
break;
|
||||
case WorldTooltipType.Actor:
|
||||
{
|
||||
o = viewport.ActorTooltip.Owner;
|
||||
showOwner = o != null && !o.NonCombatant && viewport.ActorTooltip.TooltipInfo.IsOwnerRowVisible;
|
||||
{
|
||||
o = viewport.ActorTooltip.Owner;
|
||||
showOwner = o != null && !o.NonCombatant && viewport.ActorTooltip.TooltipInfo.IsOwnerRowVisible;
|
||||
|
||||
var stance = o == null || world.RenderPlayer == null ? PlayerRelationship.None : o.RelationshipWith(world.RenderPlayer);
|
||||
labelText = viewport.ActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
|
||||
break;
|
||||
}
|
||||
var stance = o == null || world.RenderPlayer == null ? PlayerRelationship.None : o.RelationshipWith(world.RenderPlayer);
|
||||
labelText = viewport.ActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
|
||||
break;
|
||||
}
|
||||
|
||||
case WorldTooltipType.FrozenActor:
|
||||
{
|
||||
o = viewport.FrozenActorTooltip.TooltipOwner;
|
||||
showOwner = o != null && !o.NonCombatant && viewport.FrozenActorTooltip.TooltipInfo.IsOwnerRowVisible;
|
||||
{
|
||||
o = viewport.FrozenActorTooltip.TooltipOwner;
|
||||
showOwner = o != null && !o.NonCombatant && viewport.FrozenActorTooltip.TooltipInfo.IsOwnerRowVisible;
|
||||
|
||||
var stance = o == null || world.RenderPlayer == null ? PlayerRelationship.None : o.RelationshipWith(world.RenderPlayer);
|
||||
labelText = viewport.FrozenActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
|
||||
break;
|
||||
}
|
||||
var stance = o == null || world.RenderPlayer == null ? PlayerRelationship.None : o.RelationshipWith(world.RenderPlayer);
|
||||
labelText = viewport.FrozenActorTooltip.TooltipInfo.TooltipForPlayerStance(stance);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (viewport.ActorTooltipExtra != null)
|
||||
|
||||
@@ -749,8 +749,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var players = item.GetOrNull<LabelWithTooltipWidget>("PLAYERS");
|
||||
if (players != null)
|
||||
{
|
||||
var label = $"{game.Players + game.Bots} / {game.MaxPlayers + game.Bots}"
|
||||
+ (game.Spectators > 0 ? $" + {game.Spectators}" : "");
|
||||
var label =
|
||||
$"{game.Players + game.Bots} / {game.MaxPlayers + game.Bots}"
|
||||
+ (game.Spectators > 0 ? $" + {game.Spectators}" : "");
|
||||
|
||||
var color = canJoin ? players.TextColor : incompatibleGameColor;
|
||||
players.GetText = () => label;
|
||||
|
||||
Reference in New Issue
Block a user