Made all traitInfo fields readonly
This came up while working on the new documentation generation and comparing the results to ORAIDE's own code parser.
This commit is contained in:
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly string SpreadCondition = "spreading";
|
public readonly string SpreadCondition = "spreading";
|
||||||
|
|
||||||
[Desc("Time in ticks to wait between spreading further.")]
|
[Desc("Time in ticks to wait between spreading further.")]
|
||||||
public int Delay = 5;
|
public readonly int Delay = 5;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new SpreadsCondition(this); }
|
public override object Create(ActorInitializer init) { return new SpreadsCondition(this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
[ActorReference]
|
[ActorReference]
|
||||||
[Desc("Actor types that this crate action will not occur for.")]
|
[Desc("Actor types that this crate action will not occur for.")]
|
||||||
public string[] ExcludedActorTypes = Array.Empty<string>();
|
public readonly string[] ExcludedActorTypes = Array.Empty<string>();
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new CrateAction(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new CrateAction(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[WeaponReference]
|
[WeaponReference]
|
||||||
[FieldLoader.Require]
|
[FieldLoader.Require]
|
||||||
[Desc("The weapon to fire upon collection.")]
|
[Desc("The weapon to fire upon collection.")]
|
||||||
public string Weapon = null;
|
public readonly string Weapon = null;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new ExplodeCrateAction(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new ExplodeCrateAction(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
class GiveCashCrateActionInfo : CrateActionInfo
|
class GiveCashCrateActionInfo : CrateActionInfo
|
||||||
{
|
{
|
||||||
[Desc("Amount of cash to give.")]
|
[Desc("Amount of cash to give.")]
|
||||||
public int Amount = 2000;
|
public readonly int Amount = 2000;
|
||||||
|
|
||||||
[Desc("Should the collected amount be displayed as a cash tick?")]
|
[Desc("Should the collected amount be displayed as a cash tick?")]
|
||||||
public bool UseCashTick = false;
|
public readonly bool UseCashTick = false;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new GiveCashCrateAction(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new GiveCashCrateAction(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
class GiveMcvCrateActionInfo : GiveUnitCrateActionInfo
|
class GiveMcvCrateActionInfo : GiveUnitCrateActionInfo
|
||||||
{
|
{
|
||||||
[Desc("The selection shares to use if the collector has no base.")]
|
[Desc("The selection shares to use if the collector has no base.")]
|
||||||
public int NoBaseSelectionShares = 1000;
|
public readonly int NoBaseSelectionShares = 1000;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new GiveMcvCrateAction(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new GiveMcvCrateAction(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public class MustBeDestroyedInfo : TraitInfo
|
public class MustBeDestroyedInfo : TraitInfo
|
||||||
{
|
{
|
||||||
[Desc("In a short game only actors that have this value set to true need to be destroyed.")]
|
[Desc("In a short game only actors that have this value set to true need to be destroyed.")]
|
||||||
public bool RequiredForShortGame = false;
|
public readonly bool RequiredForShortGame = false;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new MustBeDestroyed(this); }
|
public override object Create(ActorInitializer init) { return new MustBeDestroyed(this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
[NotificationReference("Speech")]
|
[NotificationReference("Speech")]
|
||||||
[Desc("The audio notification type to play.")]
|
[Desc("The audio notification type to play.")]
|
||||||
public string Notification = "BaseAttack";
|
public readonly string Notification = "BaseAttack";
|
||||||
|
|
||||||
[NotificationReference("Speech")]
|
[NotificationReference("Speech")]
|
||||||
[Desc("The audio notification to play to allies when under attack.",
|
[Desc("The audio notification to play to allies when under attack.",
|
||||||
"Won't play a notification to allies if this is null.")]
|
"Won't play a notification to allies if this is null.")]
|
||||||
public string AllyNotification = null;
|
public readonly string AllyNotification = null;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new BaseAttackNotifier(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new BaseAttackNotifier(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
[NotificationReference("Speech")]
|
[NotificationReference("Speech")]
|
||||||
[Desc("The audio notification type to play.")]
|
[Desc("The audio notification type to play.")]
|
||||||
public string Notification = "HarvesterAttack";
|
public readonly string Notification = "HarvesterAttack";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new HarvesterAttackNotifier(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new HarvesterAttackNotifier(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,10 +265,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
"Current options for PanelName are 'SKIRMISH_STATS' and 'MISSION_OBJECTIVES'.")]
|
"Current options for PanelName are 'SKIRMISH_STATS' and 'MISSION_OBJECTIVES'.")]
|
||||||
public class ObjectivesPanelInfo : TraitInfo
|
public class ObjectivesPanelInfo : TraitInfo
|
||||||
{
|
{
|
||||||
public string PanelName = null;
|
public readonly string PanelName = null;
|
||||||
|
|
||||||
[Desc("in ms")]
|
[Desc("in ms")]
|
||||||
public int ExitDelay = 1400;
|
public readonly int ExitDelay = 1400;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new ObjectivesPanel(this); }
|
public override object Create(ActorInitializer init) { return new ObjectivesPanel(this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly string CannotPlaceNotification = null;
|
public readonly string CannotPlaceNotification = null;
|
||||||
|
|
||||||
[Desc("Hotkey to toggle between PlaceBuildingVariants when placing a structure.")]
|
[Desc("Hotkey to toggle between PlaceBuildingVariants when placing a structure.")]
|
||||||
public HotkeyReference ToggleVariantKey = new HotkeyReference();
|
public readonly HotkeyReference ToggleVariantKey = new HotkeyReference();
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new PlaceBuilding(this); }
|
public override object Create(ActorInitializer init) { return new PlaceBuilding(this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,14 +176,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public class UpdatesPlayerStatisticsInfo : TraitInfo
|
public class UpdatesPlayerStatisticsInfo : TraitInfo
|
||||||
{
|
{
|
||||||
[Desc("Add to army value in statistics")]
|
[Desc("Add to army value in statistics")]
|
||||||
public bool AddToArmyValue = false;
|
public readonly bool AddToArmyValue = false;
|
||||||
|
|
||||||
[Desc("Add to assets value in statistics")]
|
[Desc("Add to assets value in statistics")]
|
||||||
public bool AddToAssetsValue = true;
|
public readonly bool AddToAssetsValue = true;
|
||||||
|
|
||||||
[ActorReference]
|
[ActorReference]
|
||||||
[Desc("Count this actor as a different type in the spectator army display.")]
|
[Desc("Count this actor as a different type in the spectator army display.")]
|
||||||
public string OverrideActor = null;
|
public readonly string OverrideActor = null;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new UpdatesPlayerStatistics(this, init.Self); }
|
public override object Create(ActorInitializer init) { return new UpdatesPlayerStatistics(this, init.Self); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[TraitLocation(SystemActors.World)]
|
[TraitLocation(SystemActors.World)]
|
||||||
class ProductionQueueFromSelectionInfo : TraitInfo
|
class ProductionQueueFromSelectionInfo : TraitInfo
|
||||||
{
|
{
|
||||||
public string ProductionTabsWidget = null;
|
public readonly string ProductionTabsWidget = null;
|
||||||
public string ProductionPaletteWidget = null;
|
public readonly string ProductionPaletteWidget = null;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new ProductionQueueFromSelection(init.World, this); }
|
public override object Create(ActorInitializer init) { return new ProductionQueueFromSelection(init.World, this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
[NotificationReference("Speech")]
|
[NotificationReference("Speech")]
|
||||||
[Desc("The audio notification type to play.")]
|
[Desc("The audio notification type to play.")]
|
||||||
public string Notification = null;
|
public readonly string Notification = null;
|
||||||
|
|
||||||
[Desc("Whether to show the cash tick indicators rising from the actor.")]
|
[Desc("Whether to show the cash tick indicators rising from the actor.")]
|
||||||
public readonly bool ShowTicks = true;
|
public readonly bool ShowTicks = true;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly BitSet<TargetableType> TargetTypes;
|
public readonly BitSet<TargetableType> TargetTypes;
|
||||||
public BitSet<TargetableType> GetTargetTypes() { return TargetTypes; }
|
public BitSet<TargetableType> GetTargetTypes() { return TargetTypes; }
|
||||||
|
|
||||||
public bool RequiresForceFire = false;
|
public readonly bool RequiresForceFire = false;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new Targetable(this); }
|
public override object Create(ActorInitializer init) { return new Targetable(this); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
public readonly WDist Spread = new WDist(3072);
|
public readonly WDist Spread = new WDist(3072);
|
||||||
|
|
||||||
[Desc("Ranges at which each Falloff step is defined. Overrides Spread.")]
|
[Desc("Ranges at which each Falloff step is defined. Overrides Spread.")]
|
||||||
public WDist[] Range = null;
|
public readonly WDist[] Range = null;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new AttractsWorms(init, this); }
|
public override object Create(ActorInitializer init) { return new AttractsWorms(init, this); }
|
||||||
}
|
}
|
||||||
@@ -34,22 +34,22 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
public class AttractsWorms : ConditionalTrait<AttractsWormsInfo>
|
public class AttractsWorms : ConditionalTrait<AttractsWormsInfo>
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
readonly WDist[] effectiveRange;
|
||||||
|
|
||||||
public AttractsWorms(ActorInitializer init, AttractsWormsInfo info)
|
public AttractsWorms(ActorInitializer init, AttractsWormsInfo info)
|
||||||
: base(info)
|
: base(info)
|
||||||
{
|
{
|
||||||
self = init.Self;
|
self = init.Self;
|
||||||
|
|
||||||
if (info.Range == null)
|
effectiveRange = info.Range ?? Exts.MakeArray(info.Falloff.Length, i => i * info.Spread);
|
||||||
info.Range = Exts.MakeArray(info.Falloff.Length, i => i * info.Spread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetNoisePercentageAtDistance(int distance)
|
int GetNoisePercentageAtDistance(int distance)
|
||||||
{
|
{
|
||||||
var inner = Info.Range[0].Length;
|
var inner = effectiveRange[0].Length;
|
||||||
for (var i = 1; i < Info.Range.Length; i++)
|
for (var i = 1; i < effectiveRange.Length; i++)
|
||||||
{
|
{
|
||||||
var outer = Info.Range[i].Length;
|
var outer = effectiveRange[i].Length;
|
||||||
if (outer > distance)
|
if (outer > distance)
|
||||||
return int2.Lerp(Info.Falloff[i - 1], Info.Falloff[i], distance - inner, outer - inner);
|
return int2.Lerp(Info.Falloff[i - 1], Info.Falloff[i], distance - inner, outer - inner);
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
var length = distance.Length;
|
var length = distance.Length;
|
||||||
|
|
||||||
// Actor is too far to hear anything.
|
// Actor is too far to hear anything.
|
||||||
if (length > Info.Range[Info.Range.Length - 1].Length)
|
if (length > effectiveRange[effectiveRange.Length - 1].Length)
|
||||||
return WVec.Zero;
|
return WVec.Zero;
|
||||||
|
|
||||||
var direction = 1024 * distance / length;
|
var direction = 1024 * distance / length;
|
||||||
|
|||||||
Reference in New Issue
Block a user