planes rearm
This commit is contained in:
@@ -142,6 +142,7 @@
|
||||
<Compile Include="Graphics\WorldRenderer.cs" />
|
||||
<Compile Include="Traits\Activities\Idle.cs" />
|
||||
<Compile Include="Traits\Activities\Land.cs" />
|
||||
<Compile Include="Traits\Activities\Rearm.cs" />
|
||||
<Compile Include="Traits\Activities\ReturnToBase.cs" />
|
||||
<Compile Include="Traits\Activities\Teleport.cs" />
|
||||
<Compile Include="BuildingInfluenceMap.cs" />
|
||||
|
||||
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; }
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace OpenRa.Game.Traits
|
||||
target = order.TargetActor;
|
||||
self.QueueActivity(new FlyAttack(order.TargetActor));
|
||||
self.QueueActivity(new ReturnToBase(self, null));
|
||||
self.QueueActivity(new Rearm());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,12 @@ namespace OpenRa.Game.Traits
|
||||
}
|
||||
|
||||
public bool HasAmmo() { return ammo > 0; }
|
||||
public bool GiveAmmo()
|
||||
{
|
||||
if (ammo >= self.Info.Ammo) return false;
|
||||
++ammo;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Attacking(Actor self) { --ammo; }
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace OpenRa.Game.Traits
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
|
||||
self.QueueActivity(new ReturnToBase(self, null));
|
||||
self.QueueActivity(new Rearm());
|
||||
}
|
||||
|
||||
if (order.OrderString == "Enter")
|
||||
@@ -57,6 +58,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new ReturnToBase(self, order.TargetActor));
|
||||
self.QueueActivity(new Rearm()); /* todo: something else when it's FIX rather than AFLD */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user