Fix warfactory roof glitch
This commit is contained in:
@@ -13,17 +13,20 @@ using OpenRA.Mods.RA.Buildings;
|
|||||||
using OpenRA.Mods.RA.Render;
|
using OpenRA.Mods.RA.Render;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Traits.Activities;
|
using OpenRA.Traits.Activities;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Activities
|
namespace OpenRA.Mods.RA.Activities
|
||||||
{
|
{
|
||||||
class MakeAnimation : Activity
|
class MakeAnimation : Activity
|
||||||
{
|
{
|
||||||
readonly bool Reversed;
|
readonly bool Reversed;
|
||||||
|
readonly Action OnComplete;
|
||||||
|
|
||||||
public MakeAnimation(Actor self) : this(self, false) {}
|
public MakeAnimation(Actor self, Action onComplete) : this(self, false, onComplete) {}
|
||||||
public MakeAnimation(Actor self, bool reversed)
|
public MakeAnimation(Actor self, bool reversed, Action onComplete)
|
||||||
{
|
{
|
||||||
Reversed = reversed;
|
Reversed = reversed;
|
||||||
|
OnComplete = onComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool complete = false;
|
bool complete = false;
|
||||||
@@ -41,11 +44,10 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
foreach (var s in bi.SellSounds)
|
foreach (var s in bi.SellSounds)
|
||||||
Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);
|
Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);
|
||||||
|
|
||||||
// PlayCustomAnim is required to stop a frame of the normal state after the anim completes
|
rb.PlayCustomAnimBackwards(self, "make", () => { OnComplete(); complete = true;});
|
||||||
rb.PlayCustomAnimBackwards(self, "make", () => {rb.PlayCustomAnim(self, "make"); complete = true;});
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rb.PlayCustomAnimThen(self, "make", () => complete = true);
|
rb.PlayCustomAnimThen(self, "make", () => { OnComplete(); complete = true;});
|
||||||
}
|
}
|
||||||
return complete ? NextActivity : this;
|
return complete ? NextActivity : this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,11 +47,11 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
// Work around a bogus crash
|
// Work around a bogus crash
|
||||||
anim.PlayRepeating( NormalizeSequence(self, "idle") );
|
anim.PlayRepeating( NormalizeSequence(self, "idle") );
|
||||||
|
|
||||||
|
// Can't call Complete() directly from ctor because other traits haven't been inited yet
|
||||||
if (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation && !init.Contains<SkipMakeAnimsInit>())
|
if (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation && !init.Contains<SkipMakeAnimsInit>())
|
||||||
self.QueueActivity(new MakeAnimation(self));
|
self.QueueActivity(new MakeAnimation(self, () => Complete(self)));
|
||||||
|
else
|
||||||
// Can't call Complete() from ctor because other traits haven't been inited yet
|
self.QueueActivity(new CallFunc(() => Complete(self)));
|
||||||
self.QueueActivity(new CallFunc(() => Complete(self)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
|
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
|
||||||
|
|||||||
@@ -44,18 +44,22 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
bool isOpen;
|
bool isOpen;
|
||||||
[Sync]
|
[Sync]
|
||||||
int2 openExit;
|
int2 openExit;
|
||||||
|
|
||||||
|
bool buildComplete;
|
||||||
public RenderBuildingWarFactory(ActorInitializer init, RenderBuildingInfo info)
|
public RenderBuildingWarFactory(ActorInitializer init, RenderBuildingInfo info)
|
||||||
: base(init, info)
|
: base(init, info)
|
||||||
{
|
{
|
||||||
roof = new Animation(GetImage(init.self));
|
roof = new Animation(GetImage(init.self));
|
||||||
|
var offset = new RenderSimple.AnimationWithOffset( roof ) { ZOffset = 24 };
|
||||||
|
offset.DisableFunc = () => !buildComplete;
|
||||||
|
anims.Add("roof", offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BuildingComplete( Actor self )
|
public void BuildingComplete( Actor self )
|
||||||
{
|
{
|
||||||
roof.Play(NormalizeSequence(self,
|
roof.Play(NormalizeSequence(self,
|
||||||
self.GetDamageState() > DamageState.Heavy ? "damaged-idle-top" : "idle-top"));
|
self.GetDamageState() > DamageState.Heavy ? "damaged-idle-top" : "idle-top"));
|
||||||
self.Trait<RenderSimple>().anims.Add( "roof", new RenderSimple.AnimationWithOffset( roof ) { ZOffset = 24 } );
|
buildComplete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Tick(Actor self)
|
public override void Tick(Actor self)
|
||||||
@@ -89,7 +93,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
public void Selling(Actor self)
|
public void Selling(Actor self)
|
||||||
{
|
{
|
||||||
self.Trait<RenderSimple>().anims.Remove("roof");
|
anims.Remove("roof");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sold(Actor self) { }
|
public void Sold(Actor self) { }
|
||||||
|
|||||||
@@ -30,13 +30,15 @@ namespace OpenRA.Mods.RA
|
|||||||
if (order.OrderString == "Sell" && !selling)
|
if (order.OrderString == "Sell" && !selling)
|
||||||
{
|
{
|
||||||
selling = true;
|
selling = true;
|
||||||
self.CancelActivity();
|
|
||||||
if (self.HasTrait<RenderBuilding>() && self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation)
|
|
||||||
self.QueueActivity(new MakeAnimation(self, true));
|
|
||||||
|
|
||||||
foreach( var ns in self.TraitsImplementing<INotifySold>() )
|
foreach( var ns in self.TraitsImplementing<INotifySold>() )
|
||||||
ns.Selling( self );
|
ns.Selling( self );
|
||||||
|
|
||||||
|
self.CancelActivity();
|
||||||
|
|
||||||
|
var rb = self.TraitOrDefault<RenderBuilding>();
|
||||||
|
if (rb != null && self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation)
|
||||||
|
self.QueueActivity(new MakeAnimation(self, true, () => rb.PlayCustomAnim(self, "make")));
|
||||||
self.QueueActivity(new Sell());
|
self.QueueActivity(new Sell());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,8 +80,9 @@ namespace OpenRA.Mods.RA
|
|||||||
if (self.HasTrait<IFacing>())
|
if (self.HasTrait<IFacing>())
|
||||||
self.QueueActivity(new Turn(Info.Facing));
|
self.QueueActivity(new Turn(Info.Facing));
|
||||||
|
|
||||||
if (self.HasTrait<RenderBuilding>() && self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation)
|
var rb = self.TraitOrDefault<RenderBuilding>();
|
||||||
self.QueueActivity(new MakeAnimation(self, true));
|
if (rb != null && self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation)
|
||||||
|
self.QueueActivity(new MakeAnimation(self, true, () => rb.PlayCustomAnim(self, "make")));
|
||||||
|
|
||||||
self.QueueActivity(new Transform(self, Info.IntoActor) {Offset = Info.Offset, Facing = Info.Facing, Sounds = Info.TransformSounds});
|
self.QueueActivity(new Transform(self, Info.IntoActor) {Offset = Info.Offset, Facing = Info.Facing, Sounds = Info.TransformSounds});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user