Create INotifyDamageStateChanged for nearly everything else that used INotifyDamage.
This commit is contained in:
@@ -90,7 +90,6 @@ namespace OpenRA.Traits
|
|||||||
Damage = damage,
|
Damage = damage,
|
||||||
DamageState = this.DamageState,
|
DamageState = this.DamageState,
|
||||||
PreviousDamageState = oldState,
|
PreviousDamageState = oldState,
|
||||||
DamageStateChanged = this.DamageState != oldState,
|
|
||||||
Warhead = warhead,
|
Warhead = warhead,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -98,6 +97,11 @@ namespace OpenRA.Traits
|
|||||||
.Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyDamage>()))
|
.Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyDamage>()))
|
||||||
nd.Damaged(self, ai);
|
nd.Damaged(self, ai);
|
||||||
|
|
||||||
|
|
||||||
|
if (DamageState != oldState)
|
||||||
|
foreach (var nd in self.TraitsImplementing<INotifyDamageStateChanged>())
|
||||||
|
nd.DamageStateChanged(self, ai);
|
||||||
|
|
||||||
if (attacker != null && attacker.IsInWorld && !attacker.IsDead())
|
if (attacker != null && attacker.IsInWorld && !attacker.IsDead())
|
||||||
foreach (var nd in attacker.TraitsImplementing<INotifyAppliedDamage>()
|
foreach (var nd in attacker.TraitsImplementing<INotifyAppliedDamage>()
|
||||||
.Concat(attacker.Owner.PlayerActor.TraitsImplementing<INotifyAppliedDamage>()))
|
.Concat(attacker.Owner.PlayerActor.TraitsImplementing<INotifyAppliedDamage>()))
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ namespace OpenRA.Traits
|
|||||||
public int Damage;
|
public int Damage;
|
||||||
public DamageState DamageState;
|
public DamageState DamageState;
|
||||||
public DamageState PreviousDamageState;
|
public DamageState PreviousDamageState;
|
||||||
public bool DamageStateChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ITick { void Tick(Actor self); }
|
public interface ITick { void Tick(Actor self); }
|
||||||
@@ -57,6 +56,7 @@ namespace OpenRA.Traits
|
|||||||
public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); }
|
public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); }
|
||||||
public interface INotifySold { void Selling(Actor self); void Sold(Actor self); }
|
public interface INotifySold { void Selling(Actor self); void Sold(Actor self); }
|
||||||
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
|
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
|
||||||
|
public interface INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); }
|
||||||
public interface INotifyKilled { void Killed(Actor self, AttackInfo e); }
|
public interface INotifyKilled { void Killed(Actor self, AttackInfo e); }
|
||||||
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }
|
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }
|
||||||
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
||||||
|
|||||||
@@ -19,9 +19,11 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
public override object Create(ActorInitializer init) { return new RenderGunboat(init.self); }
|
public override object Create(ActorInitializer init) { return new RenderGunboat(init.self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class RenderGunboat : RenderSimple, INotifyDamage
|
class RenderGunboat : RenderSimple, INotifyDamage, INotifyDamageStateChanged
|
||||||
{
|
{
|
||||||
IFacing facing;
|
IFacing facing;
|
||||||
|
bool isSmoking = false;
|
||||||
|
|
||||||
public RenderGunboat(Actor self)
|
public RenderGunboat(Actor self)
|
||||||
: base(self, () => self.HasTrait<Turreted>() ? self.Trait<Turreted>().turretFacing : 0)
|
: base(self, () => self.HasTrait<Turreted>() ? self.Trait<Turreted>().turretFacing : 0)
|
||||||
{
|
{
|
||||||
@@ -49,11 +51,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSmoking;
|
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
|
||||||
{
|
|
||||||
// Damagestate
|
|
||||||
if (e.DamageStateChanged)
|
|
||||||
{
|
{
|
||||||
if (e.DamageState >= DamageState.Critical)
|
if (e.DamageState >= DamageState.Critical)
|
||||||
lastDamage = "-critical";
|
lastDamage = "-critical";
|
||||||
@@ -64,6 +62,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
anim.ReplaceAnim(lastDir+lastDamage);
|
anim.ReplaceAnim(lastDir+lastDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
|
{
|
||||||
// Smoking
|
// Smoking
|
||||||
if (e.DamageState < DamageState.Heavy) return;
|
if (e.DamageState < DamageState.Heavy) return;
|
||||||
if (isSmoking) return;
|
if (isSmoking) return;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bridge: IRenderAsTerrain, INotifyDamage
|
class Bridge: IRenderAsTerrain, INotifyDamageStateChanged
|
||||||
{
|
{
|
||||||
static string cachedTileset;
|
static string cachedTileset;
|
||||||
static Cache<TileReference<ushort,byte>, Sprite> sprites;
|
static Cache<TileReference<ushort,byte>, Sprite> sprites;
|
||||||
@@ -192,14 +192,11 @@ namespace OpenRA.Mods.RA
|
|||||||
self.World.Map.CustomTerrain[c.X, c.Y] = GetTerrainType(c);
|
self.World.Map.CustomTerrain[c.X, c.Y] = GetTerrainType(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
|
||||||
if (e.DamageStateChanged)
|
|
||||||
{
|
{
|
||||||
UpdateState();
|
UpdateState();
|
||||||
if (northNeighbour != null) northNeighbour.UpdateState();
|
if (northNeighbour != null) northNeighbour.UpdateState();
|
||||||
if (southNeighbour != null) southNeighbour.UpdateState();
|
if (southNeighbour != null) southNeighbour.UpdateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
public object Create(ActorInitializer init) { return new SoundOnDamageTransition(this);}
|
public object Create(ActorInitializer init) { return new SoundOnDamageTransition(this);}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SoundOnDamageTransition : INotifyDamage
|
public class SoundOnDamageTransition : INotifyDamageStateChanged
|
||||||
{
|
{
|
||||||
readonly SoundOnDamageTransitionInfo Info;
|
readonly SoundOnDamageTransitionInfo Info;
|
||||||
public SoundOnDamageTransition( SoundOnDamageTransitionInfo info )
|
public SoundOnDamageTransition( SoundOnDamageTransitionInfo info )
|
||||||
@@ -34,11 +34,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
Info = info;
|
Info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Damaged(Actor self, AttackInfo e)
|
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (!e.DamageStateChanged)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (e.DamageState == DamageState.Dead)
|
if (e.DamageState == DamageState.Dead)
|
||||||
Sound.Play(Info.DestroyedSound, self.CenterLocation);
|
Sound.Play(Info.DestroyedSound, self.CenterLocation);
|
||||||
else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
|
else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new Cloak(init.self, this); }
|
public object Create(ActorInitializer init) { return new Cloak(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Cloak : IRenderModifier, INotifyDamage, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, ISync
|
public class Cloak : IRenderModifier, INotifyDamageStateChanged, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, ISync
|
||||||
{
|
{
|
||||||
[Sync]
|
[Sync]
|
||||||
int remainingTime;
|
int remainingTime;
|
||||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Attacking(Actor self, Target target) { DoUncloak(); }
|
public void Attacking(Actor self, Target target) { DoUncloak(); }
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
canCloak = (e.DamageState < DamageState.Critical);
|
canCloak = (e.DamageState < DamageState.Critical);
|
||||||
if (Cloaked && !canCloak)
|
if (Cloaked && !canCloak)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RenderBuilding : RenderSimple, INotifyDamage, IRenderModifier
|
public class RenderBuilding : RenderSimple, INotifyDamageStateChanged, IRenderModifier
|
||||||
{
|
{
|
||||||
readonly RenderBuildingInfo Info;
|
readonly RenderBuildingInfo Info;
|
||||||
|
|
||||||
@@ -96,11 +96,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
anim.PlayRepeating( NormalizeSequence(self, "idle") );
|
anim.PlayRepeating( NormalizeSequence(self, "idle") );
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Damaged(Actor self, AttackInfo e)
|
public virtual void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (!e.DamageStateChanged)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (e.DamageState == DamageState.Dead)
|
if (e.DamageState == DamageState.Dead)
|
||||||
foreach (var t in FootprintUtils.UnpathableTiles( self.Info.Name, self.Info.Traits.Get<BuildingInfo>(), self.Location ))
|
foreach (var t in FootprintUtils.UnpathableTiles( self.Info.Name, self.Info.Traits.Get<BuildingInfo>(), self.Location ))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,10 +28,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
anim.Play( "idle" );
|
anim.Play( "idle" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Damaged(Actor self, AttackInfo e)
|
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (!e.DamageStateChanged) return;
|
|
||||||
|
|
||||||
if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
|
if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
|
||||||
anim.ReplaceAnim("damaged-idle");
|
anim.ReplaceAnim("damaged-idle");
|
||||||
else if (e.DamageState < DamageState.Heavy)
|
else if (e.DamageState < DamageState.Heavy)
|
||||||
|
|||||||
@@ -35,10 +35,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
anim.PlayFetchIndex(seqName, () => adjacentWalls);
|
anim.PlayFetchIndex(seqName, () => adjacentWalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Damaged(Actor self, AttackInfo e)
|
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (!e.DamageStateChanged) return;
|
|
||||||
|
|
||||||
if (e.DamageState == DamageState.Medium && anim.HasSequence("scratched-idle"))
|
if (e.DamageState == DamageState.Medium && anim.HasSequence("scratched-idle"))
|
||||||
seqName = "scratched-idle";
|
seqName = "scratched-idle";
|
||||||
else if (e.DamageState <= DamageState.Medium)
|
else if (e.DamageState <= DamageState.Medium)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RenderWarFactory : RenderBuilding, INotifyBuildComplete, INotifyDamage, ITick, INotifyProduction, INotifySold, ISync
|
class RenderWarFactory : RenderBuilding, INotifyBuildComplete, ITick, INotifyProduction, INotifySold, ISync
|
||||||
{
|
{
|
||||||
public Animation roof;
|
public Animation roof;
|
||||||
[Sync]
|
[Sync]
|
||||||
@@ -69,10 +69,8 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Damaged(Actor self, AttackInfo e)
|
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (!e.DamageStateChanged) return;
|
|
||||||
|
|
||||||
if (roof.CurrentSequence != null)
|
if (roof.CurrentSequence != null)
|
||||||
{
|
{
|
||||||
if (e.DamageState >= DamageState.Heavy)
|
if (e.DamageState >= DamageState.Heavy)
|
||||||
|
|||||||
Reference in New Issue
Block a user