MCV deploy and FIX.
This commit is contained in:
@@ -13,12 +13,12 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class LimitedAmmoInfo : ITraitInfo
|
||||
public class LimitedAmmoInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Ammo = 0;
|
||||
public readonly int PipCount = 0;
|
||||
|
||||
public object Create(ActorInitializer init) { return new LimitedAmmo(init.self); }
|
||||
public object Create(ActorInitializer init) { return new LimitedAmmo(init.self, this); }
|
||||
}
|
||||
|
||||
public class LimitedAmmo : INotifyAttack, IPips
|
||||
@@ -26,17 +26,20 @@ namespace OpenRA.Mods.RA
|
||||
[Sync]
|
||||
int ammo;
|
||||
Actor self;
|
||||
|
||||
public LimitedAmmo(Actor self)
|
||||
LimitedAmmoInfo Info;
|
||||
|
||||
public LimitedAmmo(Actor self, LimitedAmmoInfo info)
|
||||
{
|
||||
ammo = self.Info.Traits.Get<LimitedAmmoInfo>().Ammo;
|
||||
ammo = info.Ammo;
|
||||
this.self = self;
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public bool FullAmmo() { return ammo == Info.Ammo; }
|
||||
public bool HasAmmo() { return ammo > 0; }
|
||||
public bool GiveAmmo()
|
||||
{
|
||||
if (ammo >= self.Info.Traits.Get<LimitedAmmoInfo>().Ammo) return false;
|
||||
if (ammo >= Info.Ammo) return false;
|
||||
++ammo;
|
||||
return true;
|
||||
}
|
||||
@@ -45,10 +48,9 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public IEnumerable<PipType> GetPips(Actor self)
|
||||
{
|
||||
var info = self.Info.Traits.Get<LimitedAmmoInfo>();
|
||||
var pips = info.PipCount != 0 ? info.PipCount : info.Ammo;
|
||||
var pips = Info.PipCount != 0 ? Info.PipCount : Info.Ammo;
|
||||
return Graphics.Util.MakeArray(pips,
|
||||
i => (ammo * pips) / info.Ammo > i ? PipType.Green : PipType.Transparent);
|
||||
i => (ammo * pips) / Info.Ammo > i ? PipType.Green : PipType.Transparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
@@ -17,7 +18,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RepairableInfo : TraitInfo<Repairable> { public readonly string[] RepairBuildings = { "fix" }; }
|
||||
|
||||
class Repairable : IIssueOrder, IResolveOrder, IOrderCursor
|
||||
class Repairable : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
|
||||
{
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
@@ -26,22 +27,40 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
if (self.Info.Traits.Get<RepairableInfo>().RepairBuildings.Contains(underCursor.Info.Name)
|
||||
&& underCursor.Owner == self.Owner)
|
||||
return new Order("Enter", self, underCursor);
|
||||
return new Order("Repair", self, underCursor);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
bool CanRepair(Actor self)
|
||||
{
|
||||
var li = self.traits.GetOrDefault<LimitedAmmo>();
|
||||
return (self.Health < self.GetMaxHP() || (li != null && !li.FullAmmo()) );
|
||||
}
|
||||
|
||||
public string CursorForOrder(Actor self, Order order)
|
||||
{
|
||||
return (order.OrderString == "Enter") ? "enter" : null;
|
||||
if (order.OrderString != "Repair") return null;
|
||||
return CanRepair(self) ? "enter" : "enter-blocked";
|
||||
}
|
||||
|
||||
public string VoicePhraseForOrder(Actor self, Order order)
|
||||
{
|
||||
return (order.OrderString == "Repair" && CanRepair(self)) ? "Move" : null;
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "Enter")
|
||||
if (order.OrderString == "Repair")
|
||||
{
|
||||
var rp = order.TargetActor.traits.GetOrDefault<RallyPoint>();
|
||||
if (!CanRepair(self))
|
||||
return;
|
||||
|
||||
var rp = order.TargetActor.traits.GetOrDefault<RallyPoint>();
|
||||
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(Util.CellContaining(order.TargetActor.CenterLocation), order.TargetActor));
|
||||
self.QueueActivity(new Rearm());
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
|
||||
public readonly string[] NoTransformSounds = null;
|
||||
}
|
||||
|
||||
class TransformsOnDeploy : IIssueOrder, IResolveOrder, IOrderCursor
|
||||
class TransformsOnDeploy : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
|
||||
{
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
@@ -35,6 +35,11 @@ namespace OpenRA.Mods.RA
|
||||
return null;
|
||||
}
|
||||
|
||||
public string VoicePhraseForOrder(Actor self, Order order)
|
||||
{
|
||||
return (order.OrderString == "DeployTransform") ? "Move" : null;
|
||||
}
|
||||
|
||||
public void ResolveOrder( Actor self, Order order )
|
||||
{
|
||||
if (order.OrderString == "DeployTransform")
|
||||
|
||||
Reference in New Issue
Block a user