Add repairing and unit repaired sounds to fix

This commit is contained in:
abcdefg30
2015-01-06 16:19:37 +01:00
parent e4ce46514c
commit 15c07d94ac
5 changed files with 33 additions and 5 deletions

View File

@@ -17,11 +17,17 @@ namespace OpenRA.Mods.Common.Activities
{
public class Repair : Activity
{
readonly RepairsUnitsInfo repairsUnits;
readonly Actor host;
int remainingTicks;
Actor host;
Health health;
bool played = false;
public Repair(Actor host) { this.host = host; }
public Repair(Actor host)
{
this.host = host;
repairsUnits = host.Info.Traits.Get<RepairsUnitsInfo>();
}
public override Activity Tick(Actor self)
{
@@ -32,15 +38,23 @@ namespace OpenRA.Mods.Common.Activities
if (health == null) return NextActivity;
if (health.DamageState == DamageState.Undamaged)
{
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.FinishRepairingNotification, self.Owner.Country.Race);
return NextActivity;
}
if (remainingTicks == 0)
{
var repairsUnits = host.Info.Traits.Get<RepairsUnitsInfo>();
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
var hpToRepair = repairsUnits.HpPerStep;
var cost = Math.Max(1, (hpToRepair * unitCost * repairsUnits.ValuePercentage) / (health.MaxHP * 100));
if (!played)
{
played = true;
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.StartRepairingNotification, self.Owner.Country.Race);
}
if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
{
remainingTicks = 1;