planes rearm
This commit is contained in:
28
OpenRa.Game/Traits/Activities/Rearm.cs
Normal file
28
OpenRa.Game/Traits/Activities/Rearm.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace OpenRa.Game.Traits.Activities
|
||||
{
|
||||
class Rearm : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
bool isCanceled;
|
||||
int remainingTicks = ticksPerPip;
|
||||
|
||||
const int ticksPerPip = 25 * 2;
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (isCanceled) return NextActivity;
|
||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
||||
if (limitedAmmo == null) return NextActivity;
|
||||
|
||||
if (--remainingTicks == 0)
|
||||
{
|
||||
if (!limitedAmmo.GiveAmmo()) return NextActivity;
|
||||
remainingTicks = ticksPerPip;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ namespace OpenRa.Game.Traits.Activities
|
||||
Actor ChooseAirfield(Actor self)
|
||||
{
|
||||
var airfield = Game.world.Actors
|
||||
.Where(a => a.Info == Rules.UnitInfo["AFLD"]
|
||||
.Where(a => a.Info == Rules.UnitInfo["AFLD"] /* todo: generalize this */
|
||||
&& a.Owner == self.Owner
|
||||
&& !IsReserved(a))
|
||||
.FirstOrDefault();
|
||||
@@ -92,7 +92,8 @@ namespace OpenRa.Game.Traits.Activities
|
||||
new Fly(w1),
|
||||
new Fly(w2),
|
||||
new Fly(w3),
|
||||
new Land(landPoint));
|
||||
new Land(landPoint),
|
||||
NextActivity);
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
|
||||
|
||||
Reference in New Issue
Block a user