Merge pull request #8868 from pchote/readonly-traits
Make trait fields readonly
This commit is contained in:
@@ -36,9 +36,11 @@ namespace OpenRA.Mods.Common.Effects
|
||||
|
||||
class Contrail : ITick, IRender
|
||||
{
|
||||
ContrailInfo info;
|
||||
readonly ContrailInfo info;
|
||||
readonly IBodyOrientation body;
|
||||
|
||||
// This is a mutable struct, so it can't be readonly.
|
||||
ContrailRenderable trail;
|
||||
IBodyOrientation body;
|
||||
|
||||
public Contrail(Actor self, ContrailInfo info)
|
||||
{
|
||||
|
||||
@@ -21,20 +21,20 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class ExternalCapturableBar : ISelectionBar
|
||||
{
|
||||
ExternalCapturable cap;
|
||||
readonly ExternalCapturable capturable;
|
||||
|
||||
public ExternalCapturableBar(Actor self)
|
||||
{
|
||||
this.cap = self.Trait<ExternalCapturable>();
|
||||
capturable = self.Trait<ExternalCapturable>();
|
||||
}
|
||||
|
||||
public float GetValue()
|
||||
{
|
||||
// only show when building is being captured
|
||||
if (!cap.CaptureInProgress)
|
||||
if (!capturable.CaptureInProgress)
|
||||
return 0f;
|
||||
|
||||
return (float)cap.CaptureProgressTime / (cap.Info.CaptureCompleteTime * 25);
|
||||
return (float)capturable.CaptureProgressTime / (capturable.Info.CaptureCompleteTime * 25);
|
||||
}
|
||||
|
||||
public Color GetColor() { return Color.Orange; }
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class RenderBuildingTurreted : RenderBuilding
|
||||
{
|
||||
Turreted t;
|
||||
readonly Turreted turreted;
|
||||
|
||||
static Func<int> MakeTurretFacingFunc(Actor self)
|
||||
{
|
||||
@@ -48,14 +48,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public RenderBuildingTurreted(ActorInitializer init, RenderBuildingInfo info)
|
||||
: base(init, info, MakeTurretFacingFunc(init.Self))
|
||||
{
|
||||
t = init.Self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||
t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||
turreted = init.Self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||
turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||
}
|
||||
|
||||
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
base.DamageStateChanged(self, e);
|
||||
t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||
turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class RenderDetectionCircle : IPostRenderSelection
|
||||
{
|
||||
Actor self;
|
||||
readonly Actor self;
|
||||
|
||||
public RenderDetectionCircle(Actor self) { this.self = self; }
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class RenderRangeCircle : IPostRenderSelection
|
||||
{
|
||||
Actor self;
|
||||
AttackBase attack;
|
||||
readonly Actor self;
|
||||
readonly AttackBase attack;
|
||||
|
||||
public RenderRangeCircle(Actor self)
|
||||
{
|
||||
|
||||
@@ -73,11 +73,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class RenderVoxels : IRender, INotifyOwnerChanged
|
||||
{
|
||||
readonly List<VoxelAnimation> components = new List<VoxelAnimation>();
|
||||
Actor self;
|
||||
RenderVoxelsInfo info;
|
||||
IBodyOrientation body;
|
||||
WRot camera;
|
||||
WRot lightSource;
|
||||
readonly Actor self;
|
||||
readonly RenderVoxelsInfo info;
|
||||
readonly IBodyOrientation body;
|
||||
readonly WRot camera;
|
||||
readonly WRot lightSource;
|
||||
|
||||
public RenderVoxels(Actor self, RenderVoxelsInfo info)
|
||||
{
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class WithBuildingExplosion : INotifyKilled
|
||||
{
|
||||
WithBuildingExplosionInfo info;
|
||||
BuildingInfo buildingInfo;
|
||||
readonly WithBuildingExplosionInfo info;
|
||||
readonly BuildingInfo buildingInfo;
|
||||
|
||||
public WithBuildingExplosion(Actor self, WithBuildingExplosionInfo info)
|
||||
{
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithBuildingPlacedAnimation : INotifyBuildingPlaced, INotifyBuildComplete
|
||||
{
|
||||
WithBuildingPlacedAnimationInfo info;
|
||||
RenderSimple renderSimple;
|
||||
readonly WithBuildingPlacedAnimationInfo info;
|
||||
readonly RenderSimple renderSimple;
|
||||
bool buildComplete;
|
||||
|
||||
public WithBuildingPlacedAnimation(Actor self, WithBuildingPlacedAnimationInfo info)
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithBuildingPlacedOverlay : INotifyBuildComplete, INotifySold, INotifyDamageStateChanged, INotifyBuildingPlaced, INotifyTransform
|
||||
{
|
||||
Animation overlay;
|
||||
readonly Animation overlay;
|
||||
bool buildComplete;
|
||||
|
||||
public WithBuildingPlacedOverlay(Actor self, WithBuildingPlacedOverlayInfo info)
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class WithHarvestOverlay : INotifyHarvesterAction
|
||||
{
|
||||
WithHarvestOverlayInfo info;
|
||||
Animation anim;
|
||||
readonly WithHarvestOverlayInfo info;
|
||||
readonly Animation anim;
|
||||
bool visible;
|
||||
|
||||
public WithHarvestOverlay(Actor self, WithHarvestOverlayInfo info)
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithIdleOverlay : UpgradableTrait<WithIdleOverlayInfo>, INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyTransform
|
||||
{
|
||||
Animation overlay;
|
||||
readonly Animation overlay;
|
||||
bool buildComplete;
|
||||
|
||||
public WithIdleOverlay(Actor self, WithIdleOverlayInfo info)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithProductionOverlay : INotifyDamageStateChanged, ITick, INotifyBuildComplete, INotifySold
|
||||
{
|
||||
Animation overlay;
|
||||
readonly Animation overlay;
|
||||
ProductionQueue queue;
|
||||
bool buildComplete;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithRepairAnimation : INotifyRepair
|
||||
{
|
||||
WithRepairAnimationInfo info;
|
||||
readonly WithRepairAnimationInfo info;
|
||||
|
||||
public WithRepairAnimation(Actor self, WithRepairAnimationInfo info)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithRepairOverlay : INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyRepair
|
||||
{
|
||||
Animation overlay;
|
||||
readonly Animation overlay;
|
||||
bool buildComplete;
|
||||
|
||||
public WithRepairOverlay(Actor self, WithRepairOverlayInfo info)
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithRotor : ITick
|
||||
{
|
||||
WithRotorInfo info;
|
||||
Animation rotorAnim;
|
||||
IMove movement;
|
||||
readonly WithRotorInfo info;
|
||||
readonly Animation rotorAnim;
|
||||
readonly IMove movement;
|
||||
|
||||
public WithRotor(Actor self, WithRotorInfo info)
|
||||
{
|
||||
|
||||
@@ -58,11 +58,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithTurret : UpgradableTrait<WithTurretInfo>, ITick, INotifyDamageStateChanged
|
||||
{
|
||||
RenderSprites rs;
|
||||
IBodyOrientation body;
|
||||
AttackBase ab;
|
||||
Turreted t;
|
||||
Armament[] arms;
|
||||
readonly RenderSprites rs;
|
||||
readonly IBodyOrientation body;
|
||||
readonly AttackBase ab;
|
||||
readonly Turreted t;
|
||||
readonly Armament[] arms;
|
||||
public readonly Animation DefaultAnimation;
|
||||
|
||||
public WithTurret(Actor self, WithTurretInfo info)
|
||||
|
||||
@@ -48,11 +48,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithVoxelBarrel
|
||||
{
|
||||
WithVoxelBarrelInfo info;
|
||||
Actor self;
|
||||
Armament armament;
|
||||
Turreted turreted;
|
||||
IBodyOrientation body;
|
||||
readonly WithVoxelBarrelInfo info;
|
||||
readonly Actor self;
|
||||
readonly Armament armament;
|
||||
readonly Turreted turreted;
|
||||
readonly IBodyOrientation body;
|
||||
|
||||
public WithVoxelBarrel(Actor self, WithVoxelBarrelInfo info)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithVoxelBody : IAutoSelectionSize
|
||||
{
|
||||
int2 size;
|
||||
readonly int2 size;
|
||||
|
||||
public WithVoxelBody(Actor self, WithVoxelBodyInfo info)
|
||||
{
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class SmokeTrailWhenDamaged : ITick
|
||||
{
|
||||
IBodyOrientation body;
|
||||
SmokeTrailWhenDamagedInfo info;
|
||||
readonly SmokeTrailWhenDamagedInfo info;
|
||||
readonly IBodyOrientation body;
|
||||
int ticks;
|
||||
|
||||
public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info)
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
class NukePower : SupportPower
|
||||
{
|
||||
readonly NukePowerInfo info;
|
||||
IBodyOrientation body;
|
||||
readonly IBodyOrientation body;
|
||||
|
||||
public NukePower(Actor self, NukePowerInfo info)
|
||||
: base(self, info)
|
||||
|
||||
Reference in New Issue
Block a user