Fix IDE0028, IDE0300, IDE0301, IDE0302, IDE0303, IDE0304.
Silence IDE0305.
This commit is contained in:
committed by
Pavel Penev
parent
0740991c12
commit
79454d8fd2
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -19,13 +18,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class AcceptsDeliveredCashInfo : TraitInfo
|
||||
{
|
||||
[Desc("Accepted `DeliversCash` types. Leave empty to accept all types.")]
|
||||
public readonly HashSet<string> ValidTypes = new();
|
||||
public readonly HashSet<string> ValidTypes = [];
|
||||
|
||||
[Desc("Player relationships the owner of the delivering actor needs.")]
|
||||
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally;
|
||||
|
||||
[Desc("Play a randomly selected sound from this list when accepting cash.")]
|
||||
public readonly string[] Sounds = Array.Empty<string>();
|
||||
public readonly string[] Sounds = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AcceptsDeliveredCash(this); }
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class AcceptsDeliveredExperienceInfo : TraitInfo, Requires<GainsExperienceInfo>
|
||||
{
|
||||
[Desc("Accepted `DeliversExperience` types. Leave empty to accept all types.")]
|
||||
public readonly HashSet<string> ValidTypes = new();
|
||||
public readonly HashSet<string> ValidTypes = [];
|
||||
|
||||
[Desc("Player relationships the owner of the delivering actor needs.")]
|
||||
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class ActorSpawnerInfo : ConditionalTraitInfo
|
||||
{
|
||||
[Desc("Type of ActorSpawner with which it connects.")]
|
||||
public readonly HashSet<string> Types = new();
|
||||
public readonly HashSet<string> Types = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ActorSpawner(this); }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
@@ -36,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public abstract class AffectsShroud : ConditionalTrait<AffectsShroudInfo>, ISync, INotifyAddedToWorld,
|
||||
INotifyRemovedFromWorld, INotifyMoving, INotifyCenterPositionChanged, ITick
|
||||
{
|
||||
static readonly PPos[] NoCells = Array.Empty<PPos>();
|
||||
static readonly PPos[] NoCells = [];
|
||||
|
||||
readonly HashSet<PPos> footprint;
|
||||
|
||||
@@ -58,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
: base(info)
|
||||
{
|
||||
if (Info.Type == VisibilityType.Footprint)
|
||||
footprint = new HashSet<PPos>();
|
||||
footprint = [];
|
||||
}
|
||||
|
||||
PPos[] ProjectedCells(Actor self)
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Minimum altitude where this aircraft is considered airborne.")]
|
||||
public readonly int MinAirborneAltitude = 1;
|
||||
|
||||
public readonly HashSet<string> LandableTerrainTypes = new();
|
||||
public readonly HashSet<string> LandableTerrainTypes = [];
|
||||
|
||||
[Desc("Can the actor be ordered to move in to shroud?")]
|
||||
public readonly bool MoveIntoShroud = true;
|
||||
@@ -142,10 +142,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly WDist AltitudeVelocity = new(43);
|
||||
|
||||
[Desc("Sounds to play when the actor is taking off.")]
|
||||
public readonly string[] TakeoffSounds = Array.Empty<string>();
|
||||
public readonly string[] TakeoffSounds = [];
|
||||
|
||||
[Desc("Sounds to play when the actor is landing.")]
|
||||
public readonly string[] LandingSounds = Array.Empty<string>();
|
||||
public readonly string[] LandingSounds = [];
|
||||
|
||||
[Desc("The distance of the resupply base that the aircraft will wait for its turn.")]
|
||||
public readonly WDist WaitDistanceFromResupplyBase = new(3072);
|
||||
@@ -284,7 +284,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool MayYieldReservation { get; private set; }
|
||||
public bool ForceLanding { get; private set; }
|
||||
|
||||
(CPos, SubCell)[] landingCells = Array.Empty<(CPos, SubCell)>();
|
||||
(CPos, SubCell)[] landingCells = [];
|
||||
public bool RequireForceMove;
|
||||
|
||||
readonly int creationActivityDelay;
|
||||
@@ -882,7 +882,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void AddInfluence(CPos landingCell)
|
||||
{
|
||||
AddInfluence(new[] { (landingCell, SubCell.FullCell) });
|
||||
AddInfluence([(landingCell, SubCell.FullCell)]);
|
||||
}
|
||||
|
||||
public void RemoveInfluence()
|
||||
@@ -890,7 +890,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (self.IsInWorld)
|
||||
self.World.ActorMap.RemoveInfluence(self, this);
|
||||
|
||||
landingCells = Array.Empty<(CPos, SubCell)>();
|
||||
landingCells = [];
|
||||
}
|
||||
|
||||
public bool HasInfluence()
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Name = "primary";
|
||||
|
||||
[Desc("Name(s) of armament(s) that use this pool.")]
|
||||
public readonly string[] Armaments = { "primary", "secondary" };
|
||||
public readonly string[] Armaments = ["primary", "secondary"];
|
||||
|
||||
[Desc("How much ammo does this pool contain when fully loaded.")]
|
||||
public readonly int Ammo = 1;
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class AmmoPool : INotifyCreated, INotifyAttack, ISync
|
||||
{
|
||||
public readonly AmmoPoolInfo Info;
|
||||
readonly Stack<int> tokens = new();
|
||||
readonly Stack<int> tokens = [];
|
||||
|
||||
// HACK: Temporarily needed until Rearm activity is gone for good
|
||||
[Sync]
|
||||
|
||||
@@ -42,10 +42,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Desc("Muzzle position relative to turret or body, (forward, right, up) triples.",
|
||||
"If weapon Burst = 1, it cycles through all listed offsets, otherwise the offset corresponding to current burst is used.")]
|
||||
public readonly WVec[] LocalOffset = Array.Empty<WVec>();
|
||||
public readonly WVec[] LocalOffset = [];
|
||||
|
||||
[Desc("Muzzle yaw relative to turret or body.")]
|
||||
public readonly WAngle[] LocalYaw = Array.Empty<WAngle>();
|
||||
public readonly WAngle[] LocalYaw = [];
|
||||
|
||||
[Desc("Move the turret backwards when firing.")]
|
||||
public readonly WDist Recoil = WDist.Zero;
|
||||
@@ -131,7 +131,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
int currentBarrel;
|
||||
readonly int barrelCount;
|
||||
|
||||
readonly List<(int Ticks, int Burst, Action<int> Func)> delayedActions = new();
|
||||
readonly List<(int Ticks, int Burst, Action<int> Func)> delayedActions = [];
|
||||
|
||||
public WDist Recoil;
|
||||
public int FireDelay { get; protected set; }
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public abstract class AttackBaseInfo : PausableConditionalTraitInfo
|
||||
{
|
||||
[Desc("Armament names")]
|
||||
public readonly string[] Armaments = { "primary", "secondary" };
|
||||
public readonly string[] Armaments = ["primary", "secondary"];
|
||||
|
||||
[CursorReference]
|
||||
[Desc("Cursor to display when hovering over a valid target.")]
|
||||
@@ -366,7 +366,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// If force-fire is not used, and the target requires force-firing or the target is
|
||||
// terrain or invalid, no armaments can be used
|
||||
if (!forceAttack && ((t.Type == TargetType.Terrain && !Info.TargetTerrainWithoutForceFire) || t.Type == TargetType.Invalid || t.RequiresForceFire))
|
||||
return Enumerable.Empty<Armament>();
|
||||
return [];
|
||||
|
||||
// Get target's owner; in case of terrain or invalid target there will be no problems
|
||||
// with owner == null since forceFire will have to be true in this part of the method
|
||||
|
||||
@@ -91,11 +91,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
Info = info;
|
||||
coords = Exts.Lazy(self.Trait<BodyOrientation>);
|
||||
armaments = new List<Armament>();
|
||||
muzzles = new List<AnimationWithOffset>();
|
||||
paxFacing = new Dictionary<Actor, IFacing>();
|
||||
paxPos = new Dictionary<Actor, IPositionable>();
|
||||
paxRender = new Dictionary<Actor, RenderSprites>();
|
||||
armaments = [];
|
||||
muzzles = [];
|
||||
paxFacing = [];
|
||||
paxPos = [];
|
||||
paxRender = [];
|
||||
}
|
||||
|
||||
protected override void Created(Actor self)
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class AttackTurretedInfo : AttackFollowInfo, Requires<TurretedInfo>
|
||||
{
|
||||
[Desc("Turret names")]
|
||||
public readonly string[] Turrets = { "primary" };
|
||||
public readonly string[] Turrets = ["primary"];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackTurreted(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string AttackAnythingCondition = null;
|
||||
|
||||
[FieldLoader.Ignore]
|
||||
public readonly Dictionary<UnitStance, string> ConditionByStance = new();
|
||||
public readonly Dictionary<UnitStance, string> ConditionByStance = [];
|
||||
|
||||
[Desc("Allow the player to change the unit stance.")]
|
||||
public readonly bool EnableStances = true;
|
||||
|
||||
@@ -21,37 +21,37 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class BaseBuilderBotModuleInfo : ConditionalTraitInfo
|
||||
{
|
||||
[Desc("Tells the AI what building types are considered construction yards.")]
|
||||
public readonly HashSet<string> ConstructionYardTypes = new();
|
||||
public readonly HashSet<string> ConstructionYardTypes = [];
|
||||
|
||||
[Desc("Tells the AI what building types are considered vehicle production facilities.")]
|
||||
public readonly HashSet<string> VehiclesFactoryTypes = new();
|
||||
public readonly HashSet<string> VehiclesFactoryTypes = [];
|
||||
|
||||
[Desc("Tells the AI what building types are considered refineries.")]
|
||||
public readonly HashSet<string> RefineryTypes = new();
|
||||
public readonly HashSet<string> RefineryTypes = [];
|
||||
|
||||
[Desc("Tells the AI what building types are considered power plants.")]
|
||||
public readonly HashSet<string> PowerTypes = new();
|
||||
public readonly HashSet<string> PowerTypes = [];
|
||||
|
||||
[Desc("Tells the AI what building types are considered infantry production facilities.")]
|
||||
public readonly HashSet<string> BarracksTypes = new();
|
||||
public readonly HashSet<string> BarracksTypes = [];
|
||||
|
||||
[Desc("Tells the AI what building types are considered production facilities.")]
|
||||
public readonly HashSet<string> ProductionTypes = new();
|
||||
public readonly HashSet<string> ProductionTypes = [];
|
||||
|
||||
[Desc("Tells the AI what building types are considered naval production facilities.")]
|
||||
public readonly HashSet<string> NavalProductionTypes = new();
|
||||
public readonly HashSet<string> NavalProductionTypes = [];
|
||||
|
||||
[Desc("Tells the AI what building types are considered silos (resource storage).")]
|
||||
public readonly HashSet<string> SiloTypes = new();
|
||||
public readonly HashSet<string> SiloTypes = [];
|
||||
|
||||
[Desc("Tells the AI what building types are considered defenses.")]
|
||||
public readonly HashSet<string> DefenseTypes = new();
|
||||
public readonly HashSet<string> DefenseTypes = [];
|
||||
|
||||
[Desc("Production queues AI uses for buildings.")]
|
||||
public readonly HashSet<string> BuildingQueues = new() { "Building" };
|
||||
public readonly HashSet<string> BuildingQueues = ["Building"];
|
||||
|
||||
[Desc("Production queues AI uses for defenses.")]
|
||||
public readonly HashSet<string> DefenseQueues = new() { "Defense" };
|
||||
public readonly HashSet<string> DefenseQueues = ["Defense"];
|
||||
|
||||
[Desc("Minimum distance in cells from center of the base when checking for building placement.")]
|
||||
public readonly int MinBaseRadius = 2;
|
||||
@@ -122,7 +122,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int CheckForWaterRadius = 8;
|
||||
|
||||
[Desc("Terrain types which are considered water for base building purposes.")]
|
||||
public readonly HashSet<string> WaterTerrainTypes = new() { "Water" };
|
||||
public readonly HashSet<string> WaterTerrainTypes = ["Water"];
|
||||
|
||||
[Desc("What buildings to the AI should build.", "What integer percentage of the total base must be this type of building.")]
|
||||
public readonly Dictionary<string, int> BuildingFractions = null;
|
||||
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public CPos DefenseCenter { get; private set; }
|
||||
|
||||
// Actor, ActorCount.
|
||||
public Dictionary<string, int> BuildingsBeingProduced = new();
|
||||
public Dictionary<string, int> BuildingsBeingProduced = [];
|
||||
|
||||
readonly World world;
|
||||
readonly Player player;
|
||||
@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
IBotPositionsUpdated[] positionsUpdatedModules;
|
||||
CPos initialBaseCenter;
|
||||
|
||||
readonly Stack<TraitPair<RallyPoint>> rallyPoints = new();
|
||||
readonly Stack<TraitPair<RallyPoint>> rallyPoints = [];
|
||||
int assignRallyPointsTicks;
|
||||
|
||||
readonly BaseBuilderQueueManager[] builders;
|
||||
@@ -406,11 +406,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (IsTraitDisabled)
|
||||
return null;
|
||||
|
||||
return new List<MiniYamlNode>()
|
||||
{
|
||||
return
|
||||
[
|
||||
new("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter)),
|
||||
new("DefenseCenter", FieldSaver.FormatValue(DefenseCenter))
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
void IGameSaveTraitData.ResolveTraitData(Actor self, MiniYaml data)
|
||||
|
||||
@@ -346,7 +346,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Check the number of this structure and its variants
|
||||
var actorInfo = world.Map.Rules.Actors[name];
|
||||
var buildingVariantInfo = actorInfo.TraitInfoOrDefault<PlaceBuildingVariantsInfo>();
|
||||
var variants = buildingVariantInfo?.Actors ?? Array.Empty<string>();
|
||||
var variants = buildingVariantInfo?.Actors ?? [];
|
||||
|
||||
var count = playerBuildings.Count(a =>
|
||||
a.Info.Name == name || variants.Contains(a.Info.Name)) +
|
||||
|
||||
@@ -87,8 +87,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
player = self.Owner;
|
||||
unitCannotBeOrdered = a => a == null || a.IsDead || !a.IsInWorld || a.Owner != player;
|
||||
unitCannotBeOrderedOrIsBusy = a => unitCannotBeOrdered(a) || !a.IsIdle;
|
||||
conflictPositionQueue = new CPos?[MaxPositionCacheLength] { null, null, null, null, null };
|
||||
favoritePositions = new CPos?[MaxPositionCacheLength] { null, null, null, null, null };
|
||||
conflictPositionQueue = new CPos?[MaxPositionCacheLength];
|
||||
favoritePositions = new CPos?[MaxPositionCacheLength];
|
||||
}
|
||||
|
||||
protected override void TraitEnabled(Actor self)
|
||||
@@ -149,7 +149,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var minelayer in minelayers)
|
||||
{
|
||||
var cells = pathFinder.FindPathToTargetCell(
|
||||
minelayer.Actor, new[] { minelayer.Actor.Location }, enemy.Location, BlockedByActor.Immovable, laneBias: false);
|
||||
minelayer.Actor, [minelayer.Actor.Location], enemy.Location, BlockedByActor.Immovable, laneBias: false);
|
||||
if (cells != null && cells.Count != 0)
|
||||
{
|
||||
AIUtils.BotDebug($"{player}: try find a location to lay mine.");
|
||||
@@ -194,7 +194,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var minelayer in minelayers)
|
||||
{
|
||||
var cells = pathFinder.FindPathToTargetCell(
|
||||
minelayer.Actor, new[] { minelayer.Actor.Location }, minelayingPosition, BlockedByActor.Immovable, laneBias: false);
|
||||
minelayer.Actor, [minelayer.Actor.Location], minelayingPosition, BlockedByActor.Immovable, laneBias: false);
|
||||
if (cells != null && cells.Count != 0)
|
||||
{
|
||||
orderedActors.Add(minelayer.Actor);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.LoadUsing(nameof(LoadConsiderations))]
|
||||
[Desc("The decisions associated with this power")]
|
||||
public readonly List<Consideration> Considerations = new();
|
||||
public readonly List<Consideration> Considerations = [];
|
||||
|
||||
[Desc("Minimum ticks to wait until next Decision scan attempt.")]
|
||||
public readonly int MinimumScanTimeInterval = 250;
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Actor types that can capture other actors (via `Captures`).",
|
||||
"Leave this empty to disable capturing.")]
|
||||
public readonly HashSet<string> CapturingActorTypes = new();
|
||||
public readonly HashSet<string> CapturingActorTypes = [];
|
||||
|
||||
[Desc("Actor types that can be targeted for capturing.",
|
||||
"Leave this empty to include all actors.")]
|
||||
public readonly HashSet<string> CapturableActorTypes = new();
|
||||
public readonly HashSet<string> CapturableActorTypes = [];
|
||||
|
||||
[Desc("Minimum delay (in ticks) between trying to capture with CapturingActorTypes.")]
|
||||
public readonly int MinimumCaptureDelay = 375;
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
int minCaptureDelayTicks;
|
||||
|
||||
// Units that the bot already knows about and has given a capture order. Any unit not on this list needs to be given a new order.
|
||||
readonly List<Actor> activeCapturers = new();
|
||||
readonly List<Actor> activeCapturers = [];
|
||||
|
||||
readonly ActorIndex.OwnerAndNamesAndTrait<CapturesInfo> capturingActors;
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Actor types that are considered harvesters. If harvester count drops below RefineryTypes count, a new harvester is built.",
|
||||
"Leave empty to disable harvester replacement. Currently only needed by harvester replacement system.")]
|
||||
public readonly HashSet<string> HarvesterTypes = new();
|
||||
public readonly HashSet<string> HarvesterTypes = [];
|
||||
|
||||
[Desc("Actor types that are counted as refineries. Currently only needed by harvester replacement system.")]
|
||||
public readonly HashSet<string> RefineryTypes = new();
|
||||
public readonly HashSet<string> RefineryTypes = [];
|
||||
|
||||
[Desc("Interval (in ticks) between giving out orders to idle harvesters.")]
|
||||
public readonly int ScanForIdleHarvestersInterval = 50;
|
||||
@@ -68,11 +68,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly World world;
|
||||
readonly Player player;
|
||||
readonly Func<Actor, bool> unitCannotBeOrdered;
|
||||
readonly Dictionary<Actor, HarvesterTraitWrapper> harvesters = new();
|
||||
readonly Stack<HarvesterTraitWrapper> harvestersNeedingOrders = new();
|
||||
readonly Dictionary<Actor, HarvesterTraitWrapper> harvesters = [];
|
||||
readonly Stack<HarvesterTraitWrapper> harvestersNeedingOrders = [];
|
||||
readonly ActorIndex.OwnerAndNamesAndTrait<BuildingInfo> refineries;
|
||||
readonly ActorIndex.OwnerAndNamesAndTrait<HarvesterInfo> harvestersIndex;
|
||||
readonly Dictionary<CPos, string> resourceTypesByCell = new();
|
||||
readonly Dictionary<CPos, string> resourceTypesByCell = [];
|
||||
|
||||
IResourceLayer resourceLayer;
|
||||
ResourceClaimLayer claimLayer;
|
||||
|
||||
@@ -20,13 +20,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class McvManagerBotModuleInfo : ConditionalTraitInfo
|
||||
{
|
||||
[Desc("Actor types that are considered MCVs (deploy into base builders).")]
|
||||
public readonly HashSet<string> McvTypes = new();
|
||||
public readonly HashSet<string> McvTypes = [];
|
||||
|
||||
[Desc("Actor types that are considered construction yards (base builders).")]
|
||||
public readonly HashSet<string> ConstructionYardTypes = new();
|
||||
public readonly HashSet<string> ConstructionYardTypes = [];
|
||||
|
||||
[Desc("Actor types that are able to produce MCVs.")]
|
||||
public readonly HashSet<string> McvFactoryTypes = new();
|
||||
public readonly HashSet<string> McvFactoryTypes = [];
|
||||
|
||||
[Desc("Try to maintain at least this many ConstructionYardTypes, build an MCV if number is below this.")]
|
||||
public readonly int MinimumConstructionYardCount = 1;
|
||||
@@ -211,10 +211,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (IsTraitDisabled)
|
||||
return null;
|
||||
|
||||
return new List<MiniYamlNode>()
|
||||
{
|
||||
return
|
||||
[
|
||||
new("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter))
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
void IGameSaveTraitData.ResolveTraitData(Actor self, MiniYaml data)
|
||||
|
||||
@@ -24,27 +24,27 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[ActorReference]
|
||||
[Desc("Actor types that are valid for naval squads.")]
|
||||
public readonly HashSet<string> NavalUnitsTypes = new();
|
||||
public readonly HashSet<string> NavalUnitsTypes = [];
|
||||
|
||||
[ActorReference]
|
||||
[Desc("Actor types that are excluded from ground attacks.")]
|
||||
public readonly HashSet<string> AirUnitsTypes = new();
|
||||
public readonly HashSet<string> AirUnitsTypes = [];
|
||||
|
||||
[ActorReference]
|
||||
[Desc("Actor types that should generally be excluded from attack squads.")]
|
||||
public readonly HashSet<string> ExcludeFromSquadsTypes = new();
|
||||
public readonly HashSet<string> ExcludeFromSquadsTypes = [];
|
||||
|
||||
[ActorReference]
|
||||
[Desc("Actor types that are considered construction yards (base builders).")]
|
||||
public readonly HashSet<string> ConstructionYardTypes = new();
|
||||
public readonly HashSet<string> ConstructionYardTypes = [];
|
||||
|
||||
[ActorReference]
|
||||
[Desc("Enemy building types around which to scan for targets for naval squads.")]
|
||||
public readonly HashSet<string> NavalProductionTypes = new();
|
||||
public readonly HashSet<string> NavalProductionTypes = [];
|
||||
|
||||
[ActorReference]
|
||||
[Desc("Own actor types that are prioritized when defending.")]
|
||||
public readonly HashSet<string> ProtectionTypes = new();
|
||||
public readonly HashSet<string> ProtectionTypes = [];
|
||||
|
||||
[Desc("Target types are used for identifying aircraft.")]
|
||||
public readonly BitSet<TargetableType> AircraftTargetType = new("Air");
|
||||
@@ -119,13 +119,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly Player Player;
|
||||
|
||||
readonly Predicate<Actor> unitCannotBeOrdered;
|
||||
readonly List<Actor> unitsHangingAroundTheBase = new();
|
||||
readonly List<Actor> unitsHangingAroundTheBase = [];
|
||||
|
||||
// Units that the bot already knows about. Any unit not on this list needs to be given a role.
|
||||
readonly HashSet<Actor> activeUnits = new();
|
||||
readonly HashSet<Actor> activeUnits = [];
|
||||
|
||||
public List<Squad> Squads = new();
|
||||
readonly Stack<Squad> squadsPendingUpdate = new();
|
||||
public List<Squad> Squads = [];
|
||||
readonly Stack<Squad> squadsPendingUpdate = [];
|
||||
readonly ActorIndex.NamesAndTrait<BuildingInfo> constructionYardBuildings;
|
||||
|
||||
IBot bot;
|
||||
@@ -229,8 +229,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var range = ownActorsAndTheirAttackRanges[a].Length;
|
||||
var rangeDiag = Exts.MultiplyBySqrtTwoOverTwo(range);
|
||||
return new[]
|
||||
{
|
||||
return
|
||||
[
|
||||
targetActor.CenterPosition,
|
||||
targetActor.CenterPosition + new WVec(range, 0, 0),
|
||||
targetActor.CenterPosition + new WVec(-range, 0, 0),
|
||||
@@ -240,7 +240,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
targetActor.CenterPosition + new WVec(-rangeDiag, rangeDiag, 0),
|
||||
targetActor.CenterPosition + new WVec(-rangeDiag, -rangeDiag, 0),
|
||||
targetActor.CenterPosition + new WVec(rangeDiag, -rangeDiag, 0),
|
||||
};
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -268,8 +268,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var range = enemiesAndSourceAttackRanges[a].Length;
|
||||
var rangeDiag = Exts.MultiplyBySqrtTwoOverTwo(range);
|
||||
return new[]
|
||||
{
|
||||
return
|
||||
[
|
||||
WVec.Zero,
|
||||
new WVec(range, 0, 0),
|
||||
new WVec(-range, 0, 0),
|
||||
@@ -279,7 +279,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
new WVec(-rangeDiag, rangeDiag, 0),
|
||||
new WVec(-rangeDiag, -rangeDiag, 0),
|
||||
new WVec(rangeDiag, -rangeDiag, 0),
|
||||
};
|
||||
];
|
||||
})
|
||||
.Select(x => (x.Actor, x.ReachableOffsets.MinBy(o => o.LengthSquared)));
|
||||
}
|
||||
@@ -520,8 +520,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (IsTraitDisabled)
|
||||
return null;
|
||||
|
||||
return new List<MiniYamlNode>()
|
||||
{
|
||||
return
|
||||
[
|
||||
new("Squads", "", Squads.ConvertAll(s => new MiniYamlNode("Squad", s.Serialize()))),
|
||||
new("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter)),
|
||||
new("UnitsHangingAroundTheBase", FieldSaver.FormatValue(unitsHangingAroundTheBase
|
||||
@@ -536,7 +536,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
new("AssignRolesTicks", FieldSaver.FormatValue(assignRolesTicks)),
|
||||
new("AttackForceTicks", FieldSaver.FormatValue(attackForceTicks)),
|
||||
new("MinAttackForceDelayTicks", FieldSaver.FormatValue(minAttackForceDelayTicks)),
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
void IGameSaveTraitData.ResolveTraitData(Actor self, MiniYaml data)
|
||||
|
||||
@@ -20,17 +20,17 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
{
|
||||
sealed class AttackOrFleeFuzzy
|
||||
{
|
||||
static readonly string[] DefaultRulesNormalOwnHealth = new[]
|
||||
{
|
||||
static readonly string[] DefaultRulesNormalOwnHealth =
|
||||
[
|
||||
"if ((OwnHealth is Normal) " +
|
||||
"and ((EnemyHealth is NearDead) or (EnemyHealth is Injured) or (EnemyHealth is Normal)) " +
|
||||
"and ((RelativeAttackPower is Weak) or (RelativeAttackPower is Equal) or (RelativeAttackPower is Strong)) " +
|
||||
"and ((RelativeSpeed is Slow) or (RelativeSpeed is Equal) or (RelativeSpeed is Fast))) " +
|
||||
"then AttackOrFlee is Attack"
|
||||
};
|
||||
];
|
||||
|
||||
static readonly string[] DefaultRulesInjuredOwnHealth = new[]
|
||||
{
|
||||
static readonly string[] DefaultRulesInjuredOwnHealth =
|
||||
[
|
||||
"if ((OwnHealth is Injured) " +
|
||||
"and (EnemyHealth is NearDead) " +
|
||||
"and ((RelativeAttackPower is Weak) or (RelativeAttackPower is Equal) or (RelativeAttackPower is Strong)) " +
|
||||
@@ -60,10 +60,10 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
"and ((RelativeAttackPower is Weak) or (RelativeAttackPower is Equal) or (RelativeAttackPower is Strong)) " +
|
||||
"and (RelativeSpeed is Slow)) " +
|
||||
"then AttackOrFlee is Attack"
|
||||
};
|
||||
];
|
||||
|
||||
static readonly string[] DefaultRulesNearDeadOwnHealth = new[]
|
||||
{
|
||||
static readonly string[] DefaultRulesNearDeadOwnHealth =
|
||||
[
|
||||
"if ((OwnHealth is NearDead) " +
|
||||
"and ((EnemyHealth is NearDead) or (EnemyHealth is Injured)) " +
|
||||
"and ((RelativeAttackPower is Equal) or (RelativeAttackPower is Strong)) " +
|
||||
@@ -93,11 +93,11 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
"and (RelativeAttackPower is Equal) " +
|
||||
"and (RelativeSpeed is Fast) " +
|
||||
"then AttackOrFlee is Flee"
|
||||
};
|
||||
];
|
||||
|
||||
public static readonly AttackOrFleeFuzzy Default = new(null, null, null);
|
||||
public static readonly AttackOrFleeFuzzy Rush = new(new[]
|
||||
{
|
||||
public static readonly AttackOrFleeFuzzy Rush = new(
|
||||
[
|
||||
"if ((OwnHealth is Normal) " +
|
||||
"and ((EnemyHealth is NearDead) or (EnemyHealth is Injured) or (EnemyHealth is Normal)) " +
|
||||
"and (RelativeAttackPower is Strong) " +
|
||||
@@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
"and ((RelativeAttackPower is Weak) or (RelativeAttackPower is Equal)) " +
|
||||
"and ((RelativeSpeed is Slow) or (RelativeSpeed is Equal) or (RelativeSpeed is Fast))) " +
|
||||
"then AttackOrFlee is Flee"
|
||||
}, null, null);
|
||||
], null, null);
|
||||
|
||||
readonly MamdaniFuzzySystem fuzzyEngine = new();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
|
||||
public class Squad
|
||||
{
|
||||
public HashSet<Actor> Units = new();
|
||||
public HashSet<Actor> Units = [];
|
||||
public SquadType Type;
|
||||
|
||||
internal IBot Bot;
|
||||
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
// e.g. a ship targeting a land unit, but the land unit moved north.
|
||||
// We need to update our location to move north as well.
|
||||
// If we can reach the actor directly, we'll just target it directly.
|
||||
var target = SquadManager.FindEnemies(new[] { TargetActor }, squadUnit).FirstOrDefault();
|
||||
var target = SquadManager.FindEnemies([TargetActor], squadUnit).FirstOrDefault();
|
||||
SetActorToTarget(target);
|
||||
return target.Actor != null;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Tells the AI how to use its support powers.")]
|
||||
[FieldLoader.LoadUsing(nameof(LoadDecisions))]
|
||||
public readonly List<SupportPowerDecision> Decisions = new();
|
||||
public readonly List<SupportPowerDecision> Decisions = [];
|
||||
|
||||
static object LoadDecisions(MiniYaml yaml)
|
||||
{
|
||||
@@ -41,9 +41,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly World world;
|
||||
readonly Player player;
|
||||
readonly Dictionary<SupportPowerInstance, int> waitingPowers = new();
|
||||
readonly Dictionary<string, SupportPowerDecision> powerDecisions = new();
|
||||
readonly List<SupportPowerInstance> stalePowers = new();
|
||||
readonly Dictionary<SupportPowerInstance, int> waitingPowers = [];
|
||||
readonly Dictionary<string, SupportPowerDecision> powerDecisions = [];
|
||||
readonly List<SupportPowerInstance> stalePowers = [];
|
||||
SupportPowerManager supportPowerManager;
|
||||
|
||||
public SupportPowerBotModule(Actor self, SupportPowerBotModuleInfo info)
|
||||
@@ -153,7 +153,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var wbr = world.Map.CenterOfCell(br.ToCPos(map));
|
||||
var targets = world.ActorMap.ActorsInBox(wtl, wbr);
|
||||
|
||||
var frozenTargets = player.FrozenActorLayer != null ? player.FrozenActorLayer.FrozenActorsInRegion(region) : Enumerable.Empty<FrozenActor>();
|
||||
var frozenTargets = player.FrozenActorLayer != null ? player.FrozenActorLayer.FrozenActorsInRegion(region) : [];
|
||||
var consideredAttractiveness = powerDecision.GetAttractiveness(targets, player) + powerDecision.GetAttractiveness(frozenTargets, player);
|
||||
if (consideredAttractiveness < powerDecision.MinimumAttractiveness)
|
||||
continue;
|
||||
@@ -218,10 +218,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
.Select(kv => new MiniYamlNode(kv.Key.Key, FieldSaver.FormatValue(kv.Value)))
|
||||
.ToList();
|
||||
|
||||
return new List<MiniYamlNode>()
|
||||
{
|
||||
return
|
||||
[
|
||||
new("WaitingPowers", "", waitingPowersNodes)
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
void IGameSaveTraitData.ResolveTraitData(Actor self, MiniYaml data)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int IdleBaseUnitsMaximum = -1;
|
||||
|
||||
[Desc("Production queues AI uses for producing units.")]
|
||||
public readonly string[] UnitQueues = { "Vehicle", "Infantry", "Plane", "Ship", "Aircraft" };
|
||||
public readonly string[] UnitQueues = ["Vehicle", "Infantry", "Plane", "Ship", "Aircraft"];
|
||||
|
||||
[Desc("What units to the AI should build.", "What relative share of the total army must be this type of unit.")]
|
||||
public readonly Dictionary<string, int> UnitsToBuild = null;
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly World world;
|
||||
readonly Player player;
|
||||
|
||||
readonly List<string> queuedBuildRequests = new();
|
||||
readonly List<string> queuedBuildRequests = [];
|
||||
readonly ActorIndex.OwnerAndNames unitsToBuild;
|
||||
|
||||
IBotRequestPauseUnitProduction[] requestPause;
|
||||
@@ -237,11 +237,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (IsTraitDisabled)
|
||||
return null;
|
||||
|
||||
return new List<MiniYamlNode>()
|
||||
{
|
||||
return
|
||||
[
|
||||
new("QueuedBuildRequests", FieldSaver.FormatValue(queuedBuildRequests.ToArray())),
|
||||
new("IdleUnitCount", FieldSaver.FormatValue(idleUnitCount))
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
void IGameSaveTraitData.ResolveTraitData(Actor self, MiniYaml data)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -21,10 +20,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
"This can be prefixed with ! to invert the prerequisite (disabling production if the prerequisite is available)",
|
||||
"and/or ~ to hide the actor from the production palette if the prerequisite is not available.",
|
||||
"Prerequisites are granted by actors with the ProvidesPrerequisite trait.")]
|
||||
public readonly string[] Prerequisites = Array.Empty<string>();
|
||||
public readonly string[] Prerequisites = [];
|
||||
|
||||
[Desc("Production queue(s) that can produce this.")]
|
||||
public readonly HashSet<string> Queue = new();
|
||||
public readonly HashSet<string> Queue = [];
|
||||
|
||||
[Desc("Override the production structure type (from the Production Produces list) that this unit should be built at.")]
|
||||
public readonly string BuildAtProductionType = null;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly ushort DestroyedPlusSouthTemplate = 0;
|
||||
public readonly ushort DestroyedPlusBothTemplate = 0;
|
||||
|
||||
public readonly string[] ShorePieces = { "br1", "br2" };
|
||||
public readonly string[] ShorePieces = ["br1", "br2"];
|
||||
public readonly int[] NorthOffset = null;
|
||||
public readonly int[] SouthOffset = null;
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!initialized)
|
||||
{
|
||||
var palette = wr.Palette(TileSet.TerrainPaletteInternalName);
|
||||
renderables = new Dictionary<ushort, IRenderable[]>();
|
||||
renderables = [];
|
||||
foreach (var t in info.Templates)
|
||||
renderables.Add(t.Template, TemplateRenderables(wr, palette, t.Template));
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class BridgeHutInfo : TraitInfo, IDemolishableInfo
|
||||
{
|
||||
[Desc("Bridge types to act on")]
|
||||
public readonly string[] Types = { "GroundLevelBridge" };
|
||||
public readonly string[] Types = ["GroundLevelBridge"];
|
||||
|
||||
[Desc("Offsets to look for adjacent bridges to act on")]
|
||||
public readonly CVec[] NeighbourOffsets = Array.Empty<CVec>();
|
||||
public readonly CVec[] NeighbourOffsets = [];
|
||||
|
||||
[Desc("Delay between each segment repair step")]
|
||||
public readonly int RepairPropagationDelay = 20;
|
||||
@@ -47,11 +47,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly BridgeLayer bridgeLayer;
|
||||
|
||||
// Fixed at map load
|
||||
readonly List<CPos[]> segmentLocations = new();
|
||||
readonly List<CPos[]> segmentLocations = [];
|
||||
|
||||
// Changes as segments are killed and repaired
|
||||
readonly Dictionary<CPos, IBridgeSegment> segments = new();
|
||||
readonly HashSet<CPos> dirtyLocations = new();
|
||||
readonly Dictionary<CPos, IBridgeSegment> segments = [];
|
||||
readonly HashSet<CPos> dirtyLocations = [];
|
||||
|
||||
// Enabled during a repair action
|
||||
int repairStep;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -26,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Actor type to replace with on repair.")]
|
||||
public readonly string ReplaceWithActor = null;
|
||||
|
||||
public readonly CVec[] NeighbourOffsets = Array.Empty<CVec>();
|
||||
public readonly CVec[] NeighbourOffsets = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new BridgePlaceholder(init.Self, this); }
|
||||
}
|
||||
@@ -63,11 +62,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
self.Dispose();
|
||||
|
||||
w.CreateActor(Info.ReplaceWithActor, new TypeDictionary
|
||||
{
|
||||
w.CreateActor(Info.ReplaceWithActor,
|
||||
[
|
||||
new LocationInit(self.Location),
|
||||
new OwnerInit(self.Owner),
|
||||
});
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class BuildingInfo : TraitInfo, IOccupySpaceInfo, IPlaceBuildingDecorationInfo
|
||||
{
|
||||
[Desc("Where you are allowed to place the building (Water, Clear, ...)")]
|
||||
public readonly HashSet<string> TerrainTypes = new();
|
||||
public readonly HashSet<string> TerrainTypes = [];
|
||||
|
||||
[Desc("x means cell is blocked, capital X means blocked but not counting as targetable, ",
|
||||
"= means part of the footprint but passable, _ means completely empty.")]
|
||||
@@ -56,16 +56,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Clear smudges from underneath the building footprint on transform.")]
|
||||
public readonly bool RemoveSmudgesOnTransform = true;
|
||||
|
||||
public readonly string[] BuildSounds = Array.Empty<string>();
|
||||
public readonly string[] BuildSounds = [];
|
||||
|
||||
public readonly string[] UndeploySounds = Array.Empty<string>();
|
||||
public readonly string[] UndeploySounds = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new Building(init, this); }
|
||||
|
||||
protected static object LoadFootprint(MiniYaml yaml)
|
||||
{
|
||||
var footprintYaml = yaml.NodeWithKeyOrDefault("Footprint");
|
||||
var footprintChars = footprintYaml?.Value.Value.Where(x => !char.IsWhiteSpace(x)).ToArray() ?? new[] { 'x' };
|
||||
var footprintChars = footprintYaml?.Value.Value.Where(x => !char.IsWhiteSpace(x)).ToArray() ?? ['x'];
|
||||
|
||||
var dimensionsYaml = yaml.NodeWithKeyOrDefault("Dimensions");
|
||||
var dim = dimensionsYaml != null ? FieldLoader.GetValue<CVec>("Dimensions", dimensionsYaml.Value.Value) : new CVec(1, 1);
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (r.IsTraitDisabled)
|
||||
continue;
|
||||
|
||||
acceptedReplacements ??= new HashSet<string>();
|
||||
acceptedReplacements ??= [];
|
||||
|
||||
acceptedReplacements.UnionWith(r.Info.Types);
|
||||
}
|
||||
@@ -101,8 +101,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Start at place location, search outwards
|
||||
// TODO: First make it work, then make it nice
|
||||
var vecs = new[] { new CVec(1, 0), new CVec(0, 1), new CVec(-1, 0), new CVec(0, -1) };
|
||||
int[] dirs = { 0, 0, 0, 0 };
|
||||
Actor[] connectors = { null, null, null, null };
|
||||
int[] dirs = [0, 0, 0, 0];
|
||||
Actor[] connectors = [null, null, null, null];
|
||||
|
||||
for (var d = 0; d < 4; d++)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly WAngle? Facing = null;
|
||||
|
||||
[Desc("Type tags on this exit.")]
|
||||
public readonly HashSet<string> ProductionTypes = new();
|
||||
public readonly HashSet<string> ProductionTypes = [];
|
||||
|
||||
[Desc("Number of ticks to wait before moving into the world.")]
|
||||
public readonly int ExitDelay = 0;
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public static IEnumerable<Exit> Exits(this Actor actor, string productionType = null)
|
||||
{
|
||||
if (!actor.IsInWorld || actor.Disposed)
|
||||
return Enumerable.Empty<Exit>();
|
||||
return [];
|
||||
|
||||
var all = actor.TraitsImplementing<Exit>()
|
||||
.Where(t => !t.IsTraitDisabled);
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -72,13 +71,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
w.CreateActor(Info.Actor, new TypeDictionary
|
||||
{
|
||||
w.CreateActor(Info.Actor,
|
||||
[
|
||||
new ParentActorInit(self),
|
||||
new LocationInit(self.Location + Info.SpawnOffset),
|
||||
new OwnerInit(self.Owner),
|
||||
new FacingInit(Info.Facing),
|
||||
});
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -91,19 +90,19 @@ namespace OpenRA.Mods.Common.Traits
|
||||
spawn += new WVec(0, 0, aircraftInfo.CruiseAltitude.Length);
|
||||
|
||||
// Create delivery actor
|
||||
carrier = self.World.CreateActor(false, deliveringActorName, new TypeDictionary
|
||||
{
|
||||
carrier = self.World.CreateActor(false, deliveringActorName,
|
||||
[
|
||||
new LocationInit(location),
|
||||
new CenterPositionInit(spawn),
|
||||
new OwnerInit(self.Owner),
|
||||
new FacingInit(initialFacing)
|
||||
});
|
||||
]);
|
||||
|
||||
// Create delivered actor
|
||||
cargo = self.World.CreateActor(false, actorName, new TypeDictionary
|
||||
{
|
||||
cargo = self.World.CreateActor(false, actorName,
|
||||
[
|
||||
new OwnerInit(self.Owner),
|
||||
});
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||
{
|
||||
blockedPositions = Enumerable.Empty<CPos>();
|
||||
blockedPositions = [];
|
||||
}
|
||||
|
||||
bool CanRemoveBlockage(Actor self, Actor blocking)
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[FieldLoader.Require]
|
||||
[Desc("Types of buildable area this actor gives.")]
|
||||
public readonly HashSet<string> AreaTypes = new();
|
||||
public readonly HashSet<string> AreaTypes = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new GivesBuildableArea(this); }
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public GivesBuildableArea(GivesBuildableAreaInfo info)
|
||||
: base(info) { }
|
||||
|
||||
readonly HashSet<string> noAreaTypes = new();
|
||||
readonly HashSet<string> noAreaTypes = [];
|
||||
|
||||
public HashSet<string> AreaTypes => !IsTraitDisabled ? Info.AreaTypes : noAreaTypes;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Primitives;
|
||||
@@ -24,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public readonly string Type = "GroundLevelBridge";
|
||||
|
||||
public readonly CVec[] NeighbourOffsets = Array.Empty<CVec>();
|
||||
public readonly CVec[] NeighbourOffsets = [];
|
||||
|
||||
[WeaponReference]
|
||||
[Desc("The name of the weapon to use when demolishing the bridge")]
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
@@ -28,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly Actor[] parents = null;
|
||||
|
||||
public LineBuildParentInit(Actor[] value)
|
||||
: base(Array.Empty<string>())
|
||||
: base([])
|
||||
{
|
||||
parents = value;
|
||||
}
|
||||
@@ -56,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int Range = 5;
|
||||
|
||||
[Desc("LineBuildNode 'Types' to attach to.")]
|
||||
public readonly HashSet<string> NodeTypes = new() { "wall" };
|
||||
public readonly HashSet<string> NodeTypes = ["wall"];
|
||||
|
||||
[ActorReference(typeof(LineBuildInfo))]
|
||||
[Desc("Actor type for line-built segments (defaults to same actor).")]
|
||||
@@ -71,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class LineBuild : INotifyKilled, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyLineBuildSegmentsChanged
|
||||
{
|
||||
readonly LineBuildInfo info;
|
||||
readonly Actor[] parentNodes = Array.Empty<Actor>();
|
||||
readonly Actor[] parentNodes = [];
|
||||
HashSet<Actor> segments;
|
||||
|
||||
public LineBuild(ActorInitializer init, LineBuildInfo info)
|
||||
@@ -84,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyLineBuildSegmentsChanged.SegmentAdded(Actor self, Actor segment)
|
||||
{
|
||||
segments ??= new HashSet<Actor>();
|
||||
segments ??= [];
|
||||
|
||||
segments.Add(segment);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class LineBuildNodeInfo : TraitInfo<LineBuildNode>
|
||||
{
|
||||
[Desc("This actor is of LineBuild 'NodeType'...")]
|
||||
public readonly HashSet<string> Types = new() { "wall" };
|
||||
public readonly HashSet<string> Types = ["wall"];
|
||||
|
||||
[Desc("Cells (outside the footprint) that contain cells that can connect to this actor.")]
|
||||
public readonly CVec[] Connections = new[] { new CVec(1, 0), new CVec(0, 1), new CVec(-1, 0), new CVec(0, -1) };
|
||||
public readonly CVec[] Connections = [new CVec(1, 0), new CVec(0, 1), new CVec(-1, 0), new CVec(0, -1)];
|
||||
}
|
||||
|
||||
public class LineBuildNode { }
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Desc("List of production queues for which the primary flag should be set.",
|
||||
"If empty, the list given in the `Produces` property of the `" + nameof(Production) + "` trait will be used.")]
|
||||
public readonly string[] ProductionQueues = Array.Empty<string>();
|
||||
public readonly string[] ProductionQueues = [];
|
||||
|
||||
[CursorReference]
|
||||
[Desc("Cursor to display when setting the primary building.")]
|
||||
|
||||
@@ -104,15 +104,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
}
|
||||
|
||||
var actor = w.CreateActor(info.ActorType, new TypeDictionary
|
||||
{
|
||||
var actor = w.CreateActor(info.ActorType,
|
||||
[
|
||||
new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WDist.Zero, WDist.Zero, aircraftInfo.CruiseAltitude)),
|
||||
new OwnerInit(owner),
|
||||
new FacingInit(spawnFacing)
|
||||
});
|
||||
]);
|
||||
|
||||
var exitCell = self.Location + exit.ExitCell;
|
||||
actor.QueueActivity(new Land(actor, Target.FromActor(self), WDist.Zero, info.LandOffset, info.Facing, clearCells: new CPos[1] { exitCell }));
|
||||
actor.QueueActivity(new Land(actor, Target.FromActor(self), WDist.Zero, info.LandOffset, info.Facing, clearCells: [exitCell]));
|
||||
if (info.WaitTickBeforeProduce > 0)
|
||||
actor.QueueActivity(new Wait(info.WaitTickBeforeProduce));
|
||||
actor.QueueActivity(new CallFunc(() =>
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Effects;
|
||||
@@ -43,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly bool IsPlayerPalette = true;
|
||||
|
||||
[Desc("A list of 0 or more offsets defining the initial rally point path.")]
|
||||
public readonly CVec[] Path = Array.Empty<CVec>();
|
||||
public readonly CVec[] Path = [];
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Speech notification to play when setting a new rallypoint.")]
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly BitSet<DamageType> RepairDamageTypes = default;
|
||||
|
||||
[Desc("The percentage repair bonus applied with increasing numbers of repairers.")]
|
||||
public readonly int[] RepairBonuses = { 100, 150, 175, 200, 220, 240, 260, 280, 300 };
|
||||
public readonly int[] RepairBonuses = [100, 150, 175, 200, 220, 240, 260, 280, 300];
|
||||
|
||||
// TODO: This should be replaced with a pause condition
|
||||
[Desc("Cancel the repair state when the trait is disabled.")]
|
||||
@@ -68,10 +68,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly IHealth health;
|
||||
readonly Predicate<Player> isNotActiveAlly;
|
||||
readonly Stack<int> repairTokens = new();
|
||||
readonly Stack<int> repairTokens = [];
|
||||
int remainingTicks;
|
||||
|
||||
public readonly List<Player> Repairers = new();
|
||||
public readonly List<Player> Repairers = [];
|
||||
public bool RepairActive { get; private set; }
|
||||
|
||||
public RepairableBuilding(Actor self, RepairableBuildingInfo info)
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[FieldLoader.Require]
|
||||
[Desc("Types of buildable are this actor requires.")]
|
||||
public readonly HashSet<string> AreaTypes = new();
|
||||
public readonly HashSet<string> AreaTypes = [];
|
||||
|
||||
[Desc("Maximum range from the actor with 'GivesBuildableArea' this can be placed at.")]
|
||||
public readonly int Adjacent = 2;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[ActorReference]
|
||||
[FieldLoader.Require]
|
||||
public readonly HashSet<string> DockActors = new();
|
||||
public readonly HashSet<string> DockActors = [];
|
||||
|
||||
[VoiceReference]
|
||||
public readonly string Voice = "Action";
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[CursorReference(dictionaryReference: LintDictionaryReference.Values)]
|
||||
[Desc("Cursor overrides to display for specific terrain types.",
|
||||
"A dictionary of [terrain type]: [cursor name].")]
|
||||
public readonly Dictionary<string, string> TerrainCursors = new();
|
||||
public readonly Dictionary<string, string> TerrainCursors = [];
|
||||
|
||||
[CursorReference]
|
||||
[Desc("Cursor to display when a move order cannot be issued at target location.")]
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[ActorReference]
|
||||
[FieldLoader.Require]
|
||||
public readonly HashSet<string> RepairActors = new();
|
||||
public readonly HashSet<string> RepairActors = [];
|
||||
|
||||
[VoiceReference]
|
||||
public readonly string Voice = "Action";
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
sealed class CapturableProgressBar : ConditionalTrait<CapturableProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher
|
||||
{
|
||||
readonly Dictionary<Actor, (int Current, int Total)> progress = new();
|
||||
readonly Dictionary<Actor, (int Current, int Total)> progress = [];
|
||||
|
||||
public CapturableProgressBar(CapturableProgressBarInfo info)
|
||||
: base(info) { }
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
sealed class CapturableProgressBlink : ConditionalTrait<CapturableProgressBlinkInfo>, ITick, ICaptureProgressWatcher
|
||||
{
|
||||
readonly List<Player> captorOwners = new();
|
||||
readonly HashSet<Actor> captors = new();
|
||||
readonly List<Player> captorOwners = [];
|
||||
readonly HashSet<Actor> captors = [];
|
||||
int tick = 0;
|
||||
|
||||
public CapturableProgressBlink(CapturableProgressBlinkInfo info)
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
int beingCapturedToken = Actor.InvalidConditionToken;
|
||||
bool enteringCurrentTarget;
|
||||
|
||||
readonly HashSet<Actor> currentCaptors = new();
|
||||
readonly HashSet<Actor> currentCaptors = [];
|
||||
|
||||
public bool BeingCaptured { get; private set; }
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int MaxWeight = 0;
|
||||
|
||||
[Desc("`Passenger.CargoType`s that can be loaded into this actor.")]
|
||||
public readonly HashSet<string> Types = new();
|
||||
public readonly HashSet<string> Types = [];
|
||||
|
||||
[Desc("A list of actor types that are initially spawned into this actor.")]
|
||||
public readonly string[] InitialUnits = Array.Empty<string>();
|
||||
public readonly string[] InitialUnits = [];
|
||||
|
||||
[Desc("When this actor is sold should all of its passengers be unloaded?")]
|
||||
public readonly bool EjectOnSell = true;
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly bool EjectOnDeath = false;
|
||||
|
||||
[Desc("Terrain types that this actor is allowed to eject actors onto. Leave empty for all terrain types.")]
|
||||
public readonly HashSet<string> UnloadTerrainTypes = new();
|
||||
public readonly HashSet<string> UnloadTerrainTypes = [];
|
||||
|
||||
[VoiceReference]
|
||||
[Desc("Voice to play when ordered to unload the passengers.")]
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[ActorReference(dictionaryReference: LintDictionaryReference.Keys)]
|
||||
[Desc("Conditions to grant when specified actors are loaded inside the transport.",
|
||||
"A dictionary of [actor name]: [condition].")]
|
||||
public readonly Dictionary<string, string> PassengerConditions = new();
|
||||
public readonly Dictionary<string, string> PassengerConditions = [];
|
||||
|
||||
[GrantedConditionReference]
|
||||
public IEnumerable<string> LinterPassengerConditions => PassengerConditions.Values;
|
||||
@@ -92,9 +92,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
INotifyCreated, INotifyKilled, ITransformActorInitModifier
|
||||
{
|
||||
readonly Actor self;
|
||||
readonly List<Actor> cargo = new();
|
||||
readonly HashSet<Actor> reserves = new();
|
||||
readonly Dictionary<string, Stack<int>> passengerTokens = new();
|
||||
readonly List<Actor> cargo = [];
|
||||
readonly HashSet<Actor> reserves = [];
|
||||
readonly Dictionary<string, Stack<int>> passengerTokens = [];
|
||||
readonly Lazy<IFacing> facing;
|
||||
readonly bool checkTerrainType;
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
int reservedWeight = 0;
|
||||
Aircraft aircraft;
|
||||
int loadingToken = Actor.InvalidConditionToken;
|
||||
readonly Stack<int> loadedTokens = new();
|
||||
readonly Stack<int> loadedTokens = [];
|
||||
bool takeOffAfterLoad;
|
||||
bool initialised;
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var u in cargoInit.Value)
|
||||
{
|
||||
var unit = self.World.CreateActor(false, u.ToLowerInvariant(),
|
||||
new TypeDictionary { new OwnerInit(self.Owner) });
|
||||
[new OwnerInit(self.Owner)]);
|
||||
|
||||
cargo.Add(unit);
|
||||
}
|
||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var u in info.InitialUnits)
|
||||
{
|
||||
var unit = self.World.CreateActor(false, u.ToLowerInvariant(),
|
||||
new TypeDictionary { new OwnerInit(self.Owner) });
|
||||
[new OwnerInit(self.Owner)]);
|
||||
|
||||
cargo.Add(unit);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[ActorReference(dictionaryReference: LintDictionaryReference.Keys)]
|
||||
[Desc("Conditions to grant when a specified actor is being carried.",
|
||||
"A dictionary of [actor name]: [condition].")]
|
||||
public readonly Dictionary<string, string> CarryableConditions = new();
|
||||
public readonly Dictionary<string, string> CarryableConditions = [];
|
||||
|
||||
[VoiceReference]
|
||||
public readonly string Voice = "Action";
|
||||
@@ -128,11 +128,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (!string.IsNullOrEmpty(info.InitialActor))
|
||||
{
|
||||
var cargo = self.World.CreateActor(false, info.InitialActor.ToLowerInvariant(), new TypeDictionary
|
||||
{
|
||||
var cargo = self.World.CreateActor(false, info.InitialActor.ToLowerInvariant(),
|
||||
[
|
||||
new ParentActorInit(self),
|
||||
new OwnerInit(self.Owner)
|
||||
});
|
||||
]);
|
||||
|
||||
cargo.Trait<Carryable>().Attached(cargo, self);
|
||||
AttachCarryable(self, cargo);
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
IEnumerable<IRenderable> IRenderAnnotations.RenderAnnotations(Actor self, WorldRenderer wr)
|
||||
{
|
||||
if (debugVis == null || !debugVis.CombatGeometry || self.World.FogObscures(self))
|
||||
return Enumerable.Empty<IRenderable>();
|
||||
return [];
|
||||
|
||||
return RenderAnnotations(self, wr);
|
||||
}
|
||||
|
||||
@@ -55,10 +55,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public readonly ExternalConditionInfo Info;
|
||||
readonly Dictionary<object, HashSet<int>> permanentTokens = new();
|
||||
readonly Dictionary<object, HashSet<int>> permanentTokens = [];
|
||||
|
||||
// Tokens are sorted on insert/remove by ascending expiry time
|
||||
readonly List<TimedToken> timedTokens = new();
|
||||
readonly List<TimedToken> timedTokens = [];
|
||||
IConditionTimerWatcher[] watchers;
|
||||
int duration;
|
||||
int expires;
|
||||
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
else if (permanent == null)
|
||||
permanentTokens.Add(source, new HashSet<int> { token });
|
||||
permanentTokens.Add(source, [token]);
|
||||
else
|
||||
permanent.Add(token);
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Condition = null;
|
||||
|
||||
[Desc("Name of the armaments that grant this condition.")]
|
||||
public readonly HashSet<string> ArmamentNames = new() { "primary" };
|
||||
public readonly HashSet<string> ArmamentNames = ["primary"];
|
||||
|
||||
[Desc("Shots required to apply an instance of the condition. If there are more instances of the condition granted than values listed,",
|
||||
"the last value is used for all following instances beyond the defined range.")]
|
||||
public readonly int[] RequiredShotsPerInstance = { 1 };
|
||||
public readonly int[] RequiredShotsPerInstance = [1];
|
||||
|
||||
[Desc("Maximum instances of the condition to grant.")]
|
||||
public readonly int MaximumInstances = 1;
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class GrantConditionOnAttack : PausableConditionalTrait<GrantConditionOnAttackInfo>, INotifyCreated, ITick, INotifyAttack
|
||||
{
|
||||
readonly Stack<int> tokens = new();
|
||||
readonly Stack<int> tokens = [];
|
||||
|
||||
int cooldown = 0;
|
||||
int shotsFired = 0;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Bot types that trigger the condition.")]
|
||||
public readonly string[] Bots = Array.Empty<string>();
|
||||
public readonly string[] Bots = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new GrantConditionOnBotOwner(this); }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -23,10 +22,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Condition = null;
|
||||
|
||||
[Desc("Play a random sound from this list when enabled.")]
|
||||
public readonly string[] EnabledSounds = Array.Empty<string>();
|
||||
public readonly string[] EnabledSounds = [];
|
||||
|
||||
[Desc("Play a random sound from this list when disabled.")]
|
||||
public readonly string[] DisabledSounds = Array.Empty<string>();
|
||||
public readonly string[] DisabledSounds = [];
|
||||
|
||||
[Desc("Levels of damage at which to grant the condition.")]
|
||||
public readonly DamageState ValidDamageStates = DamageState.Heavy | DamageState.Critical;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string DeployedCondition = null;
|
||||
|
||||
[Desc("The terrain types that this actor can deploy on. Leave empty to allow any.")]
|
||||
public readonly HashSet<string> AllowedTerrainTypes = new();
|
||||
public readonly HashSet<string> AllowedTerrainTypes = [];
|
||||
|
||||
[Desc("Can this actor deploy on slopes?")]
|
||||
public readonly bool CanDeployOnRamps = false;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Condition = null;
|
||||
|
||||
[Desc("Only grant this condition for certain factions.")]
|
||||
public readonly HashSet<string> Factions = new();
|
||||
public readonly HashSet<string> Factions = [];
|
||||
|
||||
[Desc("Should it recheck everything when it is captured?")]
|
||||
public readonly bool ResetOnOwnerChange = false;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -23,10 +22,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Condition = null;
|
||||
|
||||
[Desc("Play a random sound from this list when enabled.")]
|
||||
public readonly string[] EnabledSounds = Array.Empty<string>();
|
||||
public readonly string[] EnabledSounds = [];
|
||||
|
||||
[Desc("Play a random sound from this list when disabled.")]
|
||||
public readonly string[] DisabledSounds = Array.Empty<string>();
|
||||
public readonly string[] DisabledSounds = [];
|
||||
|
||||
[Desc("Minimum level of health at which to grant the condition.")]
|
||||
public readonly int MinHP = 0;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -24,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("List of required prerequisites.")]
|
||||
public readonly string[] Prerequisites = Array.Empty<string>();
|
||||
public readonly string[] Prerequisites = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new GrantConditionOnPrerequisite(this); }
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[ActorReference]
|
||||
[Desc("The actors to grant condition for. If empty condition will be granted for all actors.")]
|
||||
public readonly HashSet<string> Actors = new();
|
||||
public readonly HashSet<string> Actors = [];
|
||||
|
||||
[Desc("How long condition is applies for. Use -1 for infinite.")]
|
||||
public readonly int Duration = -1;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Terrain names to trigger the condition.")]
|
||||
public readonly string[] TerrainTypes = Array.Empty<string>();
|
||||
public readonly string[] TerrainTypes = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new GrantConditionOnTerrain(init, this); }
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Tile set IDs to trigger the condition.")]
|
||||
public readonly string[] TileSets = Array.Empty<string>();
|
||||
public readonly string[] TileSets = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new GrantConditionOnTileSet(this); }
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class LineBuildSegmentExternalCondition : ConditionalTrait<LineBuildSegmentExternalConditionInfo>, INotifyLineBuildSegmentsChanged
|
||||
{
|
||||
readonly HashSet<Actor> segments = new();
|
||||
readonly Dictionary<Actor, int> tokens = new();
|
||||
readonly HashSet<Actor> segments = [];
|
||||
readonly Dictionary<Actor, int> tokens = [];
|
||||
|
||||
public LineBuildSegmentExternalCondition(LineBuildSegmentExternalConditionInfo info)
|
||||
: base(info) { }
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly Actor self;
|
||||
|
||||
readonly Dictionary<Actor, int> tokens = new();
|
||||
readonly Dictionary<Actor, int> tokens = [];
|
||||
|
||||
int proximityTrigger;
|
||||
WPos cachedPosition;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int Duration = 0;
|
||||
|
||||
[Desc("Allowed to land on.")]
|
||||
public readonly HashSet<string> TerrainTypes = new();
|
||||
public readonly HashSet<string> TerrainTypes = [];
|
||||
|
||||
[Desc("Define actors that can collect crates by setting this into the Crushes field from the Mobile trait.")]
|
||||
public readonly string CrushClass = "crate";
|
||||
@@ -187,7 +187,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public CPos TopLeft => Location;
|
||||
public (CPos, SubCell)[] OccupiedCells() { return new[] { (Location, SubCell.FullCell) }; }
|
||||
public (CPos, SubCell)[] OccupiedCells() { return [(Location, SubCell.FullCell)]; }
|
||||
|
||||
public WPos CenterPosition { get; private set; }
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int TimeDelay = 0;
|
||||
|
||||
[Desc("Only allow this crate action when the collector has these prerequisites")]
|
||||
public readonly string[] Prerequisites = Array.Empty<string>();
|
||||
public readonly string[] Prerequisites = [];
|
||||
|
||||
[ActorReference]
|
||||
[Desc("Actor types that this crate action will not occur for.")]
|
||||
public readonly string[] ExcludedActorTypes = Array.Empty<string>();
|
||||
public readonly string[] ExcludedActorTypes = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new CrateAction(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly BitSet<TargetableType> ValidTargets = new("Ground", "Water");
|
||||
|
||||
[Desc("Which factions this crate action can occur for.")]
|
||||
public readonly HashSet<string> ValidFactions = new();
|
||||
public readonly HashSet<string> ValidFactions = [];
|
||||
|
||||
[Desc("Is the new duplicates given to a specific owner, regardless of whom collected it?")]
|
||||
public readonly string Owner = null;
|
||||
@@ -117,11 +117,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
for (var i = 0; i < duplicates; i++)
|
||||
{
|
||||
var actor = w.CreateActor(collector.Info.Name, new TypeDictionary
|
||||
{
|
||||
var actor = w.CreateActor(collector.Info.Name,
|
||||
[
|
||||
new LocationInit(shuffledCandidateCells[i]),
|
||||
new OwnerInit(info.Owner ?? collector.Owner.InternalName)
|
||||
});
|
||||
]);
|
||||
|
||||
// Set the subcell and make sure to crush actors beneath.
|
||||
var positionable = actor.OccupiesSpace as IPositionable;
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -23,10 +21,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[ActorReference]
|
||||
[FieldLoader.Require]
|
||||
[Desc("The list of units to spawn.")]
|
||||
public readonly string[] Units = Array.Empty<string>();
|
||||
public readonly string[] Units = [];
|
||||
|
||||
[Desc("Factions that are allowed to trigger this action.")]
|
||||
public readonly HashSet<string> ValidFactions = new();
|
||||
public readonly HashSet<string> ValidFactions = [];
|
||||
|
||||
[Desc("Override the owner of the newly spawned unit: e.g. Creeps or Neutral")]
|
||||
public readonly string Owner = null;
|
||||
@@ -89,11 +87,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var location = ChooseEmptyCellNear(collector, unit, pathFinder, locomotorsByName);
|
||||
if (location != null)
|
||||
{
|
||||
var actor = w.CreateActor(unit, new TypeDictionary
|
||||
{
|
||||
var actor = w.CreateActor(unit,
|
||||
[
|
||||
new LocationInit(location.Value),
|
||||
new OwnerInit(info.Owner ?? collector.Owner.InternalName)
|
||||
});
|
||||
]);
|
||||
|
||||
// Set the subcell and make sure to crush actors beneath.
|
||||
var positionable = actor.OccupiesSpace as IPositionable;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -38,10 +37,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// We want neither of these properties for crate power proxies.
|
||||
public override void Activate(Actor collector)
|
||||
{
|
||||
collector.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, new TypeDictionary
|
||||
{
|
||||
collector.World.AddFrameEndTask(w => w.CreateActor(info.Proxy,
|
||||
[
|
||||
new OwnerInit(collector.Owner)
|
||||
}));
|
||||
]));
|
||||
|
||||
base.Activate(collector);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Terrain types where the actor will take damage.")]
|
||||
public readonly string[] Terrain = Array.Empty<string>();
|
||||
public readonly string[] Terrain = [];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new DamagedByTerrain(this); }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Mods.Common.Orders;
|
||||
@@ -31,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Type = null;
|
||||
|
||||
[Desc("Sound to play when delivering cash")]
|
||||
public readonly string[] Sounds = Array.Empty<string>();
|
||||
public readonly string[] Sounds = [];
|
||||
|
||||
[CursorReference]
|
||||
[Desc("Cursor to display when hovering over a valid actor to deliver cash to.")]
|
||||
|
||||
@@ -46,8 +46,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
readonly List<DemolishAction> actions = new();
|
||||
readonly List<DemolishAction> removeActions = new();
|
||||
readonly List<DemolishAction> actions = [];
|
||||
readonly List<DemolishAction> removeActions = [];
|
||||
IDamageModifier[] damageModifiers;
|
||||
|
||||
public Demolishable(DemolishableInfo info)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool IsEnabledAndInWorld => !preventDock && !IsTraitDisabled && !self.IsDead && self.IsInWorld;
|
||||
public int ReservationCount => ReservedDockClients.Count;
|
||||
public bool CanBeReserved => ReservationCount < Info.MaxQueueLength;
|
||||
protected readonly List<DockClientManager> ReservedDockClients = new();
|
||||
protected readonly List<DockClientManager> ReservedDockClients = [];
|
||||
|
||||
public WPos DockPosition => self.CenterPosition + Info.DockOffset;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
@@ -22,13 +21,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[WeaponReference]
|
||||
[FieldLoader.Require]
|
||||
[Desc("The weapons used for shrapnel.")]
|
||||
public readonly string[] Weapons = Array.Empty<string>();
|
||||
public readonly string[] Weapons = [];
|
||||
|
||||
[Desc("The amount of pieces of shrapnel to expel. Two values indicate a range.")]
|
||||
public readonly int[] Pieces = { 3, 10 };
|
||||
public readonly int[] Pieces = [3, 10];
|
||||
|
||||
[Desc("The minimum and maximum distances the shrapnel may travel.")]
|
||||
public readonly WDist[] Range = { WDist.FromCells(2), WDist.FromCells(5) };
|
||||
public readonly WDist[] Range = [WDist.FromCells(2), WDist.FromCells(5)];
|
||||
|
||||
public WeaponInfo[] WeaponInfos { get; private set; }
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
@@ -22,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[WeaponReference]
|
||||
[FieldLoader.Require]
|
||||
[Desc("Weapons to fire.")]
|
||||
public readonly string[] Weapons = Array.Empty<string>();
|
||||
public readonly string[] Weapons = [];
|
||||
|
||||
[Desc("How long (in ticks) to wait before the first detonation.")]
|
||||
public readonly int StartCooldown = 0;
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly GainsExperienceInfo info;
|
||||
readonly int initialExperience;
|
||||
|
||||
readonly List<(int RequiredExperience, string Condition)> nextLevel = new();
|
||||
readonly List<(int RequiredExperience, string Condition)> nextLevel = [];
|
||||
|
||||
// Stored as a percentage of our value
|
||||
[Sync]
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
sealed class GivesBounty : ConditionalTrait<GivesBountyInfo>, INotifyKilled, INotifyPassengerEntered, INotifyPassengerExited
|
||||
{
|
||||
readonly Dictionary<Actor, GivesBounty[]> passengerBounties = new();
|
||||
readonly Dictionary<Actor, GivesBounty[]> passengerBounties = [];
|
||||
|
||||
public GivesBounty(GivesBountyInfo info)
|
||||
: base(info) { }
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
e.Attacker.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()
|
||||
?.GiveExperience(Util.ApplyPercentageModifiers(exp, new[] { info.PlayerExperienceModifier }));
|
||||
?.GiveExperience(Util.ApplyPercentageModifiers(exp, [info.PlayerExperienceModifier]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int HarvestFacings = 0;
|
||||
|
||||
[Desc("Which resources it can harvest.")]
|
||||
public readonly string[] Resources = Array.Empty<string>();
|
||||
public readonly string[] Resources = [];
|
||||
|
||||
[Desc("Percentage of maximum speed when fully loaded.")]
|
||||
public readonly int FullyLoadedSpeed = 85;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Turret = null;
|
||||
|
||||
[Desc("Create a targetable position for each offset listed here (relative to CenterPosition).")]
|
||||
public readonly WVec[] TargetableOffsets = { WVec.Zero };
|
||||
public readonly WVec[] TargetableOffsets = [WVec.Zero];
|
||||
|
||||
[Desc("Create a targetable position at the center of each occupied cell. Stacks with TargetableOffsets.")]
|
||||
public readonly bool UseTargetableCellsOffsets = false;
|
||||
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
IEnumerable<WPos> ITargetablePositions.TargetablePositions(Actor self)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return Enumerable.Empty<WPos>();
|
||||
return [];
|
||||
|
||||
// Check for changes in inputs that affect the result of the TargetablePositions method.
|
||||
// If the inputs have not changed we can cache and reuse the result for later calls.
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Spawns remains of a husk actor with the correct facing.")]
|
||||
public class HuskInfo : TraitInfo, IPositionableInfo, IFacingInfo, IActorPreviewInitInfo, IRulesetLoaded
|
||||
{
|
||||
public readonly HashSet<string> AllowedTerrain = new();
|
||||
public readonly HashSet<string> AllowedTerrain = [];
|
||||
|
||||
[Desc("Facing to use for actor previews (map editor, color picker, etc)")]
|
||||
public readonly WAngle PreviewFacing = new(384);
|
||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return true;
|
||||
}
|
||||
|
||||
public (CPos, SubCell)[] OccupiedCells() { return new[] { (TopLeft, SubCell.FullCell) }; }
|
||||
public (CPos, SubCell)[] OccupiedCells() { return [(TopLeft, SubCell.FullCell)]; }
|
||||
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return false; }
|
||||
public SubCell GetValidSubCell(SubCell preferred = SubCell.Any) { return SubCell.FullCell; }
|
||||
public SubCell GetAvailableSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, BlockedByActor check = BlockedByActor.All)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -23,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
return OccupiesSpace ? new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } } :
|
||||
new Dictionary<CPos, SubCell>();
|
||||
[];
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => false;
|
||||
@@ -39,9 +38,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
CenterPosition = init.World.Map.CenterOfCell(TopLeft);
|
||||
|
||||
if (info.OccupiesSpace)
|
||||
occupied = new[] { (TopLeft, SubCell.FullCell) };
|
||||
occupied = [(TopLeft, SubCell.FullCell)];
|
||||
else
|
||||
occupied = Array.Empty<(CPos, SubCell)>();
|
||||
occupied = [];
|
||||
}
|
||||
|
||||
[Sync]
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int AttackPanicChance = 20;
|
||||
|
||||
[Desc("The terrain types that this actor should avoid running on to while panicking.")]
|
||||
public readonly HashSet<string> AvoidTerrainTypes = new();
|
||||
public readonly HashSet<string> AvoidTerrainTypes = [];
|
||||
|
||||
[SequenceReference(prefix: true)]
|
||||
public readonly string PanicSequencePrefix = "panic-";
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly BitSet<DamageType> DamageTriggers = default;
|
||||
|
||||
[Desc("Damage modifiers for each damage type (defined on the warheads) while the unit is prone.")]
|
||||
public readonly Dictionary<string, int> DamageModifiers = new();
|
||||
public readonly Dictionary<string, int> DamageModifiers = [];
|
||||
|
||||
[Desc("Muzzle offset modifier to apply while prone.")]
|
||||
public readonly WVec ProneOffset = new(500, 0, 0);
|
||||
|
||||
@@ -116,10 +116,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
if (height == 0)
|
||||
return new Polygon(new[] { top, left, bottom, right });
|
||||
return new Polygon([top, left, bottom, right]);
|
||||
|
||||
var h = new int2(0, height);
|
||||
return new Polygon(new[] { top - h, left - h, left, bottom, right, right - h });
|
||||
return new Polygon([top - h, left - h, left, bottom, right, right - h]);
|
||||
}
|
||||
|
||||
public Polygon Bounds(Actor self, WorldRenderer wr)
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly bool RemoveInstead = false;
|
||||
|
||||
[Desc("The amount of time (in ticks) before the actor dies. Two values indicate a range between which a random value is chosen.")]
|
||||
public readonly int[] Delay = { 0 };
|
||||
public readonly int[] Delay = [0];
|
||||
|
||||
[Desc("Types of damage that this trait causes. Leave empty for no damage types.")]
|
||||
public readonly BitSet<DamageType> DamageTypes = default;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string TileUnknownName = "build-unknown";
|
||||
|
||||
[Desc("Only allow laying mines on listed terrain types. Leave empty to allow all terrain types.")]
|
||||
public readonly HashSet<string> TerrainTypes = new();
|
||||
public readonly HashSet<string> TerrainTypes = [];
|
||||
|
||||
[CursorReference]
|
||||
[Desc("Cursor to display when able to lay a mine.")]
|
||||
@@ -229,7 +229,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public MinefieldOrderGenerator(Actor a, CPos xy, bool queued)
|
||||
{
|
||||
minelayers = new List<Actor>() { a };
|
||||
minelayers = [a];
|
||||
minefieldStart = xy;
|
||||
this.queued = queued;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[CursorReference(dictionaryReference: LintDictionaryReference.Values)]
|
||||
[Desc("Cursor overrides to display for specific terrain types.",
|
||||
"A dictionary of [terrain type]: [cursor name].")]
|
||||
public readonly Dictionary<string, string> TerrainCursors = new();
|
||||
public readonly Dictionary<string, string> TerrainCursors = [];
|
||||
|
||||
[CursorReference]
|
||||
[Desc("Cursor to display when a move order cannot be issued at target location.")]
|
||||
@@ -255,13 +255,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public (CPos, SubCell)[] OccupiedCells()
|
||||
{
|
||||
if (FromCell == ToCell)
|
||||
return new[] { (FromCell, FromSubCell) };
|
||||
return [(FromCell, FromSubCell)];
|
||||
|
||||
// HACK: Should be fixed properly, see https://github.com/OpenRA/OpenRA/pull/17292 for an explanation
|
||||
if (Info.LocomotorInfo.SharesCell)
|
||||
return new[] { (ToCell, ToSubCell) };
|
||||
return [(ToCell, ToSubCell)];
|
||||
|
||||
return new[] { (FromCell, FromSubCell), (ToCell, ToSubCell) };
|
||||
return [(FromCell, FromSubCell), (ToCell, ToSubCell)];
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -819,7 +819,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return above;
|
||||
|
||||
var path = PathFinder.FindPathToTargetCellByPredicate(
|
||||
self, new[] { self.Location }, loc => loc.Layer == 0 && CanEnterCell(loc), BlockedByActor.All);
|
||||
self, [self.Location], loc => loc.Layer == 0 && CanEnterCell(loc), BlockedByActor.All);
|
||||
|
||||
if (path.Count > 0)
|
||||
return path[0];
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var exploredMap = init.World.LobbyInfo.GlobalSettings.OptionOrDefault("explored", shroudInfo.ExploredMapCheckboxEnabled);
|
||||
startsRevealed = exploredMap && init.Contains<SpawnedByMapInit>() && !init.Contains<HiddenUnderFogInit>();
|
||||
var buildingInfo = init.Self.Info.TraitInfoOrDefault<BuildingInfo>();
|
||||
var footprintCells = buildingInfo?.FrozenUnderFogTiles(init.Self.Location).ToList() ?? new List<CPos>() { init.Self.Location };
|
||||
var footprintCells = buildingInfo?.FrozenUnderFogTiles(init.Self.Location).ToList() ?? [init.Self.Location];
|
||||
footprint = footprintCells.SelectMany(c => map.ProjectedCellsCovering(c.ToMPos(map))).ToArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -22,10 +21,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int Multiplier = 100;
|
||||
|
||||
[Desc("Only apply this cost change if owner has these prerequisites.")]
|
||||
public readonly string[] Prerequisites = Array.Empty<string>();
|
||||
public readonly string[] Prerequisites = [];
|
||||
|
||||
[Desc("Queues that this cost will apply.")]
|
||||
public readonly HashSet<string> Queue = new();
|
||||
public readonly HashSet<string> Queue = [];
|
||||
|
||||
int IProductionCostModifierInfo.GetProductionCostModifier(TechTree techTree, string queue)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -22,10 +21,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int Multiplier = 100;
|
||||
|
||||
[Desc("Only apply this time change if owner has these prerequisites.")]
|
||||
public readonly string[] Prerequisites = Array.Empty<string>();
|
||||
public readonly string[] Prerequisites = [];
|
||||
|
||||
[Desc("Queues that this time will apply.")]
|
||||
public readonly HashSet<string> Queue = new();
|
||||
public readonly HashSet<string> Queue = [];
|
||||
|
||||
int IProductionTimeModifierInfo.GetProductionTimeModifier(TechTree techTree, string queue)
|
||||
{
|
||||
|
||||
@@ -25,12 +25,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly string paletteName = "cloak";
|
||||
|
||||
readonly Color[] colors =
|
||||
{
|
||||
[
|
||||
Color.FromArgb(55, 205, 205, 220),
|
||||
Color.FromArgb(120, 205, 205, 230),
|
||||
Color.FromArgb(192, 180, 180, 255),
|
||||
Color.FromArgb(178, 205, 250, 220),
|
||||
};
|
||||
];
|
||||
|
||||
void IPaletteModifier.AdjustPalette(IReadOnlyDictionary<string, MutablePalette> b)
|
||||
{
|
||||
|
||||
@@ -22,17 +22,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Defines to which palettes this effect should be applied to.",
|
||||
"If none specified, it applies to all palettes not explicitly excluded.")]
|
||||
public readonly HashSet<string> Palettes = new();
|
||||
public readonly HashSet<string> Palettes = [];
|
||||
|
||||
[Desc("Defines for which tileset IDs this effect should be loaded.",
|
||||
"If none specified, it applies to all tileset IDs not explicitly excluded.")]
|
||||
public readonly HashSet<string> Tilesets = new();
|
||||
public readonly HashSet<string> Tilesets = [];
|
||||
|
||||
[Desc("Defines which palettes should be excluded from this effect.")]
|
||||
public readonly HashSet<string> ExcludePalettes = new();
|
||||
public readonly HashSet<string> ExcludePalettes = [];
|
||||
|
||||
[Desc("Don't apply the effect for these tileset IDs.")]
|
||||
public readonly HashSet<string> ExcludeTilesets = new();
|
||||
public readonly HashSet<string> ExcludeTilesets = [];
|
||||
|
||||
[Desc("Palette index of first RotationRange color.")]
|
||||
public readonly int RotationBase = 0x60;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -33,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string BasePalette = null;
|
||||
|
||||
[Desc("Remap these indices to player colors.")]
|
||||
public readonly int[] RemapIndex = Array.Empty<int>();
|
||||
public readonly int[] RemapIndex = [];
|
||||
|
||||
[Desc("Allow palette modifiers to change the palette.")]
|
||||
public readonly bool AllowModifiers = true;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
@@ -30,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Name = "resources";
|
||||
|
||||
[Desc("Remap these indices to pre-defined colors.")]
|
||||
public readonly int[] RemapIndex = Array.Empty<int>();
|
||||
public readonly int[] RemapIndex = [];
|
||||
|
||||
[Desc("The fixed color to remap.")]
|
||||
public readonly Color Color;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using OpenRA.Graphics;
|
||||
@@ -33,11 +32,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Indices from BasePalette to be swapped with ReplaceIndex.")]
|
||||
public readonly int[] Index = Array.Empty<int>();
|
||||
public readonly int[] Index = [];
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Indices from BasePalette to replace from Index.")]
|
||||
public readonly int[] ReplaceIndex = Array.Empty<int>();
|
||||
public readonly int[] ReplaceIndex = [];
|
||||
|
||||
[Desc("Allow palette modifiers to change the palette.")]
|
||||
public readonly bool AllowModifiers = true;
|
||||
@@ -70,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class IndexedColorRemap : IPaletteRemap
|
||||
{
|
||||
readonly Dictionary<int, int> replacements = new();
|
||||
readonly Dictionary<int, int> replacements = [];
|
||||
readonly IPalette basePalette;
|
||||
|
||||
public IndexedColorRemap(IPalette basePalette, int[] ramp, int[] remap)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -31,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string BaseName = "player";
|
||||
|
||||
[Desc("Remap these indices to player colors.")]
|
||||
public readonly int[] RemapIndex = Array.Empty<int>();
|
||||
public readonly int[] RemapIndex = [];
|
||||
|
||||
[Desc("Allow palette modifiers to change the palette.")]
|
||||
public readonly bool AllowModifiers = true;
|
||||
|
||||
@@ -34,10 +34,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Filename = null;
|
||||
|
||||
[Desc("Map listed indices to transparent. Ignores previous color.")]
|
||||
public readonly int[] TransparentIndex = { 0 };
|
||||
public readonly int[] TransparentIndex = [0];
|
||||
|
||||
[Desc("Map listed indices to shadow. Ignores previous color.")]
|
||||
public readonly int[] ShadowIndex = Array.Empty<int>();
|
||||
public readonly int[] ShadowIndex = [];
|
||||
|
||||
public readonly bool AllowModifiers = true;
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Desc("Defines for which tileset IDs this palette should be loaded.",
|
||||
"If none specified, it applies to all tileset IDs not explicitly excluded.")]
|
||||
public readonly HashSet<string> Tilesets = new();
|
||||
public readonly HashSet<string> Tilesets = [];
|
||||
|
||||
[Desc("Don't load palette for these tileset IDs.")]
|
||||
public readonly HashSet<string> ExcludeTilesets = new();
|
||||
public readonly HashSet<string> ExcludeTilesets = [];
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Name of the file to load.")]
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Filename = null;
|
||||
|
||||
[Desc("Map listed indices to shadow. Ignores previous color.")]
|
||||
public readonly int[] ShadowIndex = Array.Empty<int>();
|
||||
public readonly int[] ShadowIndex = [];
|
||||
|
||||
public readonly bool AllowModifiers = true;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user