Add start and stop repair overlay animation support.
This commit is contained in:
committed by
Paul Chote
parent
7160c8a1a9
commit
0018bf3063
@@ -35,6 +35,15 @@ namespace OpenRA.Mods.Common.Activities
|
||||
health = self.TraitOrDefault<Health>();
|
||||
}
|
||||
|
||||
protected override void OnFirstRun(Actor self)
|
||||
{
|
||||
if (host.Actor.IsDead)
|
||||
return;
|
||||
|
||||
foreach (var depot in host.Actor.TraitsImplementing<INotifyRepair>())
|
||||
depot.BeforeRepair(host.Actor, self);
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled)
|
||||
@@ -81,6 +90,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.Info.FinishRepairingNotification, self.Owner.Faction.InternalName);
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
@@ -105,7 +115,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
self.InflictDamage(host.Actor, new Damage(-hpToRepair));
|
||||
|
||||
foreach (var depot in host.Actor.TraitsImplementing<INotifyRepair>())
|
||||
depot.Repairing(host.Actor, self);
|
||||
depot.RepairTick(host.Actor, self);
|
||||
|
||||
remainingTicks = repairsUnits.Info.Interval;
|
||||
}
|
||||
@@ -114,5 +124,14 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
protected override void OnLastRun(Actor self)
|
||||
{
|
||||
if (host.Actor.IsDead)
|
||||
return;
|
||||
|
||||
foreach (var depot in host.Actor.TraitsImplementing<INotifyRepair>())
|
||||
depot.AfterRepair(host.Actor, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +33,16 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
spriteBody = self.TraitOrDefault<WithSpriteBody>();
|
||||
}
|
||||
|
||||
void INotifyRepair.Repairing(Actor self, Actor target)
|
||||
void INotifyRepair.BeforeRepair(Actor self, Actor target) { }
|
||||
|
||||
void INotifyRepair.RepairTick(Actor self, Actor target)
|
||||
{
|
||||
if (buildComplete && spriteBody != null && !IsTraitDisabled)
|
||||
spriteBody.PlayCustomAnimation(self, Info.Sequence);
|
||||
}
|
||||
|
||||
void INotifyRepair.AfterRepair(Actor self, Actor target) { }
|
||||
|
||||
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||
{
|
||||
buildComplete = true;
|
||||
|
||||
@@ -18,9 +18,15 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
[Desc("Displays an overlay when the building is being repaired by the player.")]
|
||||
public class WithRepairOverlayInfo : PausableConditionalTraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
[Desc("Sequence to use upon repair beginning.")]
|
||||
[SequenceReference("Image")] public readonly string StartSequence = null;
|
||||
|
||||
[Desc("Sequence name to play once during repair intervals or repeatedly if a start sequence is set.")]
|
||||
[SequenceReference] public readonly string Sequence = "active";
|
||||
|
||||
[Desc("Sequence to use after repairing has finished.")]
|
||||
[SequenceReference("Image")] public readonly string EndSequence = null;
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
@@ -73,10 +79,32 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name));
|
||||
}
|
||||
|
||||
void INotifyRepair.Repairing(Actor self, Actor host)
|
||||
void INotifyRepair.BeforeRepair(Actor self, Actor host)
|
||||
{
|
||||
visible = true;
|
||||
overlay.PlayThen(overlay.CurrentSequence.Name, () => visible = false);
|
||||
if (Info.StartSequence != null)
|
||||
{
|
||||
visible = true;
|
||||
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), Info.StartSequence),
|
||||
() => overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), Info.Sequence)));
|
||||
}
|
||||
}
|
||||
|
||||
void INotifyRepair.RepairTick(Actor self, Actor host)
|
||||
{
|
||||
if (Info.StartSequence == null)
|
||||
{
|
||||
visible = true;
|
||||
overlay.PlayThen(overlay.CurrentSequence.Name, () => visible = false);
|
||||
}
|
||||
}
|
||||
|
||||
void INotifyRepair.AfterRepair(Actor self, Actor target)
|
||||
{
|
||||
if (Info.EndSequence != null)
|
||||
{
|
||||
visible = true;
|
||||
overlay.PlayThen(Info.EndSequence, () => visible = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,8 +86,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
|
||||
public interface INotifyKilled { void Killed(Actor self, AttackInfo e); }
|
||||
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }
|
||||
|
||||
[RequireExplicitImplementation]
|
||||
public interface INotifyRepair
|
||||
{
|
||||
void BeforeRepair(Actor self, Actor target);
|
||||
void RepairTick(Actor self, Actor target);
|
||||
void AfterRepair(Actor self, Actor target);
|
||||
}
|
||||
|
||||
public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); }
|
||||
public interface INotifyRepair { void Repairing(Actor self, Actor target); }
|
||||
public interface INotifyNuke { void Launching(Actor self); }
|
||||
public interface INotifyBurstComplete { void FiredBurst(Actor self, Target target, Armament a); }
|
||||
public interface INotifyChat { bool OnChat(string from, string message); }
|
||||
|
||||
Reference in New Issue
Block a user