Sound and Animation support for DonateCash
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Mods.Common.Traits.Sound;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -23,11 +24,27 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Stance the delivering actor needs to enter.")]
|
||||
public readonly Stance ValidStances = Stance.Ally;
|
||||
|
||||
[Desc("Play a randomly selected sound from this list when accepting cash.")]
|
||||
public readonly string[] Sounds = { };
|
||||
|
||||
public object Create(ActorInitializer init) { return new AcceptsDeliveredCash(init.Self, this); }
|
||||
}
|
||||
|
||||
public class AcceptsDeliveredCash
|
||||
public class AcceptsDeliveredCash : INotifyCashTransfer
|
||||
{
|
||||
public AcceptsDeliveredCash(Actor self, AcceptsDeliveredCashInfo info) { }
|
||||
AcceptsDeliveredCashInfo info;
|
||||
|
||||
public AcceptsDeliveredCash(Actor self, AcceptsDeliveredCashInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
void INotifyCashTransfer.OnAcceptingCash(Actor self, Actor donor)
|
||||
{
|
||||
if (info.Sounds.Length > 0)
|
||||
Game.Sound.Play(SoundType.World, info.Sounds.Random(self.World.SharedRandom), self.CenterPosition);
|
||||
}
|
||||
|
||||
void INotifyCashTransfer.OnDeliveringCash(Actor self, Actor acceptor) { }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user