Merge pull request #12284 from reaperrr/interface-cleanups02
More explicit interface cleanups
This commit is contained in:
@@ -139,7 +139,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return new WDist(Util.ApplyPercentageModifiers(Weapon.Range.Length, rangeModifiers));
|
||||
}
|
||||
|
||||
public virtual void Created(Actor self)
|
||||
protected virtual void Created(Actor self)
|
||||
{
|
||||
turret = self.TraitsImplementing<Turreted>().FirstOrDefault(t => t.Name == Info.Turret);
|
||||
ammoPool = self.TraitsImplementing<AmmoPool>().FirstOrDefault(la => la.Info.Name == Info.AmmoPoolName);
|
||||
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
rangeModifiers = self.TraitsImplementing<IRangeModifier>().ToArray().Select(m => m.GetRangeModifier());
|
||||
}
|
||||
|
||||
public virtual void Tick(Actor self)
|
||||
protected virtual void Tick(Actor self)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return;
|
||||
@@ -168,6 +168,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
delayedActions.RemoveAll(a => a.First <= 0);
|
||||
}
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
// Split into a protected method to allow subclassing
|
||||
Created(self);
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
// Split into a protected method to allow subclassing
|
||||
Tick(self);
|
||||
}
|
||||
|
||||
protected void ScheduleDelayedAction(int t, Action a)
|
||||
{
|
||||
if (t > 0)
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
Do((b, d) => b.UpdateState());
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (!self.IsInWorld)
|
||||
return;
|
||||
|
||||
@@ -105,13 +105,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null)));
|
||||
}
|
||||
|
||||
public void Created(Actor self)
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
if (Info.SearchOnCreation)
|
||||
self.QueueActivity(new FindResources(self));
|
||||
}
|
||||
|
||||
public void BuildingComplete(Actor self)
|
||||
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||
{
|
||||
if (Info.SearchOnCreation)
|
||||
self.QueueActivity(new FindResources(self));
|
||||
@@ -254,7 +254,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public void TickIdle(Actor self)
|
||||
void INotifyIdle.TickIdle(Actor self)
|
||||
{
|
||||
// Should we be intelligent while idle?
|
||||
if (!idleSmart) return;
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
}
|
||||
}
|
||||
|
||||
class WithGateSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, INotifyBuildComplete, IWallConnector, ITick
|
||||
class WithGateSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, IWallConnector, ITick
|
||||
{
|
||||
readonly WithGateSpriteBodyInfo gateInfo;
|
||||
readonly Gate gate;
|
||||
@@ -83,12 +83,12 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
return int2.Lerp(0, DefaultAnimation.CurrentSequence.Length - 1, gate.Position, gate.OpenPosition);
|
||||
}
|
||||
|
||||
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||
protected override void DamageStateChanged(Actor self)
|
||||
{
|
||||
UpdateState(self);
|
||||
}
|
||||
|
||||
public override void BuildingComplete(Actor self)
|
||||
protected override void OnBuildComplete(Actor self)
|
||||
{
|
||||
UpdateState(self);
|
||||
UpdateNeighbours(self);
|
||||
@@ -107,7 +107,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
rb.SetDirty();
|
||||
}
|
||||
|
||||
public void RemovedFromWorld(Actor self)
|
||||
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
|
||||
{
|
||||
UpdateNeighbours(self);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
playerResources = init.Self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
}
|
||||
|
||||
public void BuildingComplete(Actor self)
|
||||
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||
{
|
||||
wsb.DefaultAnimation.PlayFetchIndex(wsb.NormalizeSequence(self, info.Sequence),
|
||||
() => playerResources.ResourceCapacity != 0
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
: 0);
|
||||
}
|
||||
|
||||
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||
{
|
||||
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
||||
|
||||
|
||||
@@ -75,12 +75,17 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
return RenderSprites.NormalizeSequence(DefaultAnimation, self.GetDamageState(), sequence);
|
||||
}
|
||||
|
||||
// TODO: Get rid of INotifyBuildComplete in favor of using the upgrade system
|
||||
public virtual void BuildingComplete(Actor self)
|
||||
protected virtual void OnBuildComplete(Actor self)
|
||||
{
|
||||
DefaultAnimation.PlayRepeating(NormalizeSequence(self, Info.Sequence));
|
||||
}
|
||||
|
||||
// TODO: Get rid of INotifyBuildComplete in favor of using the upgrade system
|
||||
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||
{
|
||||
OnBuildComplete(self);
|
||||
}
|
||||
|
||||
public void PlayCustomAnimation(Actor self, string name, Action after = null)
|
||||
{
|
||||
DefaultAnimation.PlayThen(NormalizeSequence(self, name), () =>
|
||||
@@ -112,10 +117,15 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
DefaultAnimation.PlayRepeating(NormalizeSequence(self, Info.Sequence));
|
||||
}
|
||||
|
||||
public virtual void DamageStateChanged(Actor self, AttackInfo e)
|
||||
protected virtual void DamageStateChanged(Actor self)
|
||||
{
|
||||
if (DefaultAnimation.CurrentSequence != null)
|
||||
DefaultAnimation.ReplaceAnim(NormalizeSequence(self, DefaultAnimation.CurrentSequence.Name));
|
||||
}
|
||||
|
||||
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
DamageStateChanged(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,13 +113,13 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
return RenderSprites.NormalizeSequence(DefaultAnimation, self.GetDamageState(), sequence);
|
||||
}
|
||||
|
||||
public virtual void DamageStateChanged(Actor self, AttackInfo e)
|
||||
protected virtual void DamageStateChanged(Actor self)
|
||||
{
|
||||
if (DefaultAnimation.CurrentSequence != null)
|
||||
DefaultAnimation.ReplaceAnim(NormalizeSequence(self, DefaultAnimation.CurrentSequence.Name));
|
||||
}
|
||||
|
||||
public virtual void Tick(Actor self)
|
||||
protected virtual void Tick(Actor self)
|
||||
{
|
||||
if (Info.AimSequence == null)
|
||||
return;
|
||||
@@ -128,6 +128,17 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
DefaultAnimation.ReplaceAnim(sequence);
|
||||
}
|
||||
|
||||
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
DamageStateChanged(self);
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
// Split into a protected method to allow subclassing
|
||||
Tick(self);
|
||||
}
|
||||
|
||||
void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; }
|
||||
void INotifySold.Selling(Actor self) { buildComplete = false; }
|
||||
void INotifySold.Sold(Actor self) { }
|
||||
|
||||
@@ -54,9 +54,9 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||
}
|
||||
|
||||
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||
protected override void DamageStateChanged(Actor self)
|
||||
{
|
||||
base.DamageStateChanged(self, e);
|
||||
base.DamageStateChanged(self);
|
||||
turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,12 +101,12 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
wallInfo = info;
|
||||
}
|
||||
|
||||
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||
protected override void DamageStateChanged(Actor self)
|
||||
{
|
||||
DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => adjacent);
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
if (!dirty)
|
||||
return;
|
||||
@@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
public override void BuildingComplete(Actor self)
|
||||
protected override void OnBuildComplete(Actor self)
|
||||
{
|
||||
DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => adjacent);
|
||||
UpdateNeighbours(self);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void BuildingComplete(Actor self)
|
||||
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||
{
|
||||
self.PlayVoice(info.Voice);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
var rand = Game.CosmeticRandom;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user