fixes WEAP roof when selling.

This commit is contained in:
Bob
2010-01-18 17:24:05 +13:00
parent 18e46bb886
commit b54aedc287
5 changed files with 33 additions and 9 deletions

View File

@@ -46,6 +46,7 @@ namespace OpenRa.Graphics
public void PlayThen( string sequenceName, Action after )
{
after = after ?? ( () => { } );
backwards = false;
tickAlways = false;
CurrentSequence = SequenceProvider.GetSequence( name, sequenceName );
@@ -112,5 +113,10 @@ namespace OpenRa.Graphics
ReplaceAnim(CurrentSequence.Name);
}
}
public Sequence GetSequence( string sequenceName )
{
return SequenceProvider.GetSequence( name, sequenceName );
}
}
}

View File

@@ -11,6 +11,8 @@ namespace OpenRa.Traits.Activities
bool started;
int framesRemaining;
void DoSell(Actor self)
{
var cost = self.Info.Traits.Get<BuildableInfo>().Cost;
@@ -21,23 +23,26 @@ namespace OpenRa.Traits.Activities
self.Health = 0;
foreach (var ns in self.traits.WithInterface<INotifySold>())
ns.Sold(self);
Game.world.Remove(self);
Game.world.AddFrameEndTask( _ => Game.world.Remove( self ) );
// todo: give dudes
}
public IActivity Tick(Actor self)
{
if (!started)
if( !started )
{
var rb = self.traits.Get<RenderBuilding>();
//var rb = self.traits.Get<RenderBuilding>();
rb.PlayCustomAnimBackwards(self, "make",
() => Game.world.AddFrameEndTask(w => DoSell(self)));
framesRemaining = self.traits.Get<RenderSimple>().anim.GetSequence( "make" ).Length;
foreach( var ns in self.traits.WithInterface<INotifySold>() )
ns.Selling( self );
Sound.Play("cashturn.aud");
started = true;
}
else if( framesRemaining <= 0 )
DoSell( self );
else
--framesRemaining;
return this;
}

View File

@@ -92,6 +92,12 @@ namespace OpenRa.Traits
}
}
public void Selling( Actor self )
{
anim.PlayBackwardsThen( "make", null );
Sound.Play("cashturn.aud");
}
public void Sold(Actor self) { DoBib(self, true); }
}
}

View File

@@ -9,7 +9,7 @@ namespace OpenRa.Traits
public object Create(Actor self) { return new RenderWarFactory(self); }
}
class RenderWarFactory : INotifyBuildComplete, INotifyDamage, ITick, INotifyProduction
class RenderWarFactory : INotifyBuildComplete, INotifyDamage, ITick, INotifyProduction, INotifySold
{
public Animation roof;
[Sync]
@@ -59,5 +59,12 @@ namespace OpenRa.Traits
{
roof.PlayThen(GetPrefix(self) + "build-top", () => isOpen = true);
}
public void Selling( Actor self )
{
self.traits.Get<RenderSimple>().anims.Remove( "roof" );
}
public void Sold( Actor self ) { }
}
}

View File

@@ -17,7 +17,7 @@ namespace OpenRa.Traits
public interface IIssueOrder { Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor ); }
public interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
public interface INotifySold { 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 INotifyBuildComplete { void BuildingComplete(Actor self); }
public interface INotifyProduction { void UnitProduced(Actor self, Actor other); }