setup the minelayer rearm sound

This commit is contained in:
Matthias Mailänder
2014-09-28 16:05:08 +02:00
parent 45e3d41093
commit c9346d1da8
3 changed files with 16 additions and 7 deletions

View File

@@ -26,8 +26,9 @@ namespace OpenRA.Mods.RA.Activities
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
if (!limitedAmmo.HasAmmo())
{
var info = self.Info.Traits.Get<MinelayerInfo>();
// rearm & repair at fix, then back out here to refill the minefield some more
var buildings = self.Info.Traits.Get<MinelayerInfo>().RearmBuildings;
var buildings = info.RearmBuildings;
var rearmTarget = self.World.Actors.Where(a => self.Owner.Stances[a.Owner] == Stance.Ally
&& buildings.Contains(a.Info.Name))
.ClosestTo(self);
@@ -38,26 +39,27 @@ namespace OpenRA.Mods.RA.Activities
return Util.SequenceActivities(
new MoveAdjacentTo(self, Target.FromActor(rearmTarget)),
movement.MoveTo(self.World.Map.CellContaining(rearmTarget.CenterPosition), rearmTarget),
new Rearm(self),
new Rearm(self, info.RearmSound),
new Repair(rearmTarget),
this);
}
var ml = self.Trait<Minelayer>();
if (ml.Minefield.Contains(self.Location) &&
ShouldLayMine(self, self.Location))
if (ml.Minefield.Contains(self.Location) && ShouldLayMine(self, self.Location))
{
LayMine(self);
return Util.SequenceActivities(new Wait(20), this); // a little wait after placing each mine, for show
}
if (ml.Minefield.Length > 0)
{
for (var n = 0; n < 20; n++) // dont get stuck forever here
{
var p = ml.Minefield.Random(self.World.SharedRandom);
if (ShouldLayMine(self, p))
return Util.SequenceActivities( movement.MoveTo(p, 0), this );
}
}
// TODO: return somewhere likely to be safe (near fix) so we're not sitting out in the minefield.

View File

@@ -19,18 +19,21 @@ namespace OpenRA.Mods.RA.Activities
readonly LimitedAmmo limitedAmmo;
int ticksPerPip = 25 * 2;
int remainingTicks = 25 * 2;
string sound = null;
public Rearm(Actor self)
public Rearm(Actor self, string sound = null)
{
limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
if (limitedAmmo != null)
ticksPerPip = limitedAmmo.ReloadTimePerAmmo();
remainingTicks = ticksPerPip;
this.sound = sound;
}
public override Activity Tick(Actor self)
{
if (IsCanceled || limitedAmmo == null) return NextActivity;
if (IsCanceled || limitedAmmo == null)
return NextActivity;
if (--remainingTicks == 0)
{
@@ -44,6 +47,8 @@ namespace OpenRA.Mods.RA.Activities
return NextActivity;
hostBuilding.Trait<RenderBuilding>().PlayCustomAnim(hostBuilding, "active");
if (sound != null)
Sound.Play(sound, self.CenterPosition);
remainingTicks = limitedAmmo.ReloadTimePerAmmo();
}

View File

@@ -23,6 +23,8 @@ namespace OpenRA.Mods.RA
[ActorReference] public readonly string Mine = "minv";
[ActorReference] public readonly string[] RearmBuildings = { "fix" };
public readonly string RearmSound = "minelay1.aud";
public readonly float MinefieldDepth = 1.5f;
public object Create(ActorInitializer init) { return new Minelayer(init.self); }
@@ -30,7 +32,7 @@ namespace OpenRA.Mods.RA
class Minelayer : IIssueOrder, IResolveOrder, IPostRenderSelection, ISync
{
/* [Sync] when sync can cope with arrays! */
/* TODO: [Sync] when sync can cope with arrays! */
public CPos[] Minefield = null;
[Sync] CPos minefieldStart;
Actor self;