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>();
|
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)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsCanceled)
|
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);
|
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.Info.FinishRepairingNotification, self.Owner.Faction.InternalName);
|
||||||
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +115,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
self.InflictDamage(host.Actor, new Damage(-hpToRepair));
|
self.InflictDamage(host.Actor, new Damage(-hpToRepair));
|
||||||
|
|
||||||
foreach (var depot in host.Actor.TraitsImplementing<INotifyRepair>())
|
foreach (var depot in host.Actor.TraitsImplementing<INotifyRepair>())
|
||||||
depot.Repairing(host.Actor, self);
|
depot.RepairTick(host.Actor, self);
|
||||||
|
|
||||||
remainingTicks = repairsUnits.Info.Interval;
|
remainingTicks = repairsUnits.Info.Interval;
|
||||||
}
|
}
|
||||||
@@ -114,5 +124,14 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
return this;
|
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>();
|
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)
|
if (buildComplete && spriteBody != null && !IsTraitDisabled)
|
||||||
spriteBody.PlayCustomAnimation(self, Info.Sequence);
|
spriteBody.PlayCustomAnimation(self, Info.Sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void INotifyRepair.AfterRepair(Actor self, Actor target) { }
|
||||||
|
|
||||||
void INotifyBuildComplete.BuildingComplete(Actor self)
|
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||||
{
|
{
|
||||||
buildComplete = true;
|
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.")]
|
[Desc("Displays an overlay when the building is being repaired by the player.")]
|
||||||
public class WithRepairOverlayInfo : PausableConditionalTraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
|
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";
|
[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")]
|
[Desc("Position relative to body")]
|
||||||
public readonly WVec Offset = WVec.Zero;
|
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));
|
overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyRepair.Repairing(Actor self, Actor host)
|
void INotifyRepair.BeforeRepair(Actor self, Actor host)
|
||||||
|
{
|
||||||
|
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;
|
visible = true;
|
||||||
overlay.PlayThen(overlay.CurrentSequence.Name, () => visible = false);
|
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 INotifyDamage { void Damaged(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); }
|
||||||
|
|
||||||
|
[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 INotifyBuildingPlaced { void BuildingPlaced(Actor self); }
|
||||||
public interface INotifyRepair { void Repairing(Actor self, Actor target); }
|
|
||||||
public interface INotifyNuke { void Launching(Actor self); }
|
public interface INotifyNuke { void Launching(Actor self); }
|
||||||
public interface INotifyBurstComplete { void FiredBurst(Actor self, Target target, Armament a); }
|
public interface INotifyBurstComplete { void FiredBurst(Actor self, Target target, Armament a); }
|
||||||
public interface INotifyChat { bool OnChat(string from, string message); }
|
public interface INotifyChat { bool OnChat(string from, string message); }
|
||||||
|
|||||||
@@ -280,7 +280,9 @@ GADEPT:
|
|||||||
Sequence: circuits
|
Sequence: circuits
|
||||||
WithRepairOverlay@CRANE:
|
WithRepairOverlay@CRANE:
|
||||||
PauseOnCondition: empdisable
|
PauseOnCondition: empdisable
|
||||||
Sequence: crane
|
StartSequence: crane-start
|
||||||
|
Sequence: crane-loop
|
||||||
|
EndSequence: crane-end
|
||||||
WithRepairOverlay@PLATFORM:
|
WithRepairOverlay@PLATFORM:
|
||||||
RequiresCondition: !empdisable
|
RequiresCondition: !empdisable
|
||||||
Sequence: platform
|
Sequence: platform
|
||||||
|
|||||||
@@ -1737,9 +1737,22 @@ gadept.gdi:
|
|||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
Tick: 120
|
Tick: 120
|
||||||
ZRamp: 1
|
ZRamp: 1
|
||||||
crane: gtdept_c
|
crane-start: gtdept_c
|
||||||
Length: 16
|
Length: 6
|
||||||
Offset: 0, -36, 12
|
Offset: 0, -36, 12
|
||||||
|
Tick: 60
|
||||||
|
DepthSprite: isodepth.shp
|
||||||
|
crane-loop: gtdept_c
|
||||||
|
Start: 6
|
||||||
|
Length: 5
|
||||||
|
Offset: 0, -36, 12
|
||||||
|
Tick: 60
|
||||||
|
DepthSprite: isodepth.shp
|
||||||
|
crane-end: gtdept_c
|
||||||
|
Start: 10
|
||||||
|
Length: 6
|
||||||
|
Offset: 0, -36, 12
|
||||||
|
Tick: 60
|
||||||
DepthSprite: isodepth.shp
|
DepthSprite: isodepth.shp
|
||||||
platform: gtdept_d
|
platform: gtdept_d
|
||||||
Length: 7
|
Length: 7
|
||||||
@@ -1821,10 +1834,23 @@ gadept.nod:
|
|||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
Tick: 120
|
Tick: 120
|
||||||
ZRamp: 1
|
ZRamp: 1
|
||||||
crane: gtdept_c
|
crane-start: gtdept_c
|
||||||
Length: 16
|
Length: 6
|
||||||
Offset: 0, -36, 12
|
Offset: 0, -36, 12
|
||||||
DepthSprite: isodepth.shp
|
DepthSprite: isodepth.shp
|
||||||
|
Tick: 60
|
||||||
|
crane-loop: gtdept_c
|
||||||
|
Start: 6
|
||||||
|
Length: 5
|
||||||
|
Offset: 0, -36, 12
|
||||||
|
DepthSprite: isodepth.shp
|
||||||
|
Tick: 60
|
||||||
|
crane-end: gtdept_c
|
||||||
|
Start: 10
|
||||||
|
Length: 6
|
||||||
|
Offset: 0, -36, 12
|
||||||
|
DepthSprite: isodepth.shp
|
||||||
|
Tick: 60
|
||||||
platform: gtdept_d
|
platform: gtdept_d
|
||||||
Length: 7
|
Length: 7
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
|
|||||||
Reference in New Issue
Block a user