Sound and Animation support for DonateCash

This commit is contained in:
Forcecore
2017-07-24 10:38:37 -05:00
committed by reaperrr
parent d170262e09
commit 18c6fe09db
6 changed files with 110 additions and 3 deletions

View File

@@ -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) { }
}
}