Fix EngineerRepairable stance checks.
This commit is contained in:
committed by
reaperrr
parent
8752e76d1e
commit
2194584b25
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -16,17 +17,15 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
class RepairBuilding : Enter
|
||||
{
|
||||
readonly EnterBehaviour enterBehaviour;
|
||||
readonly Stance validStances;
|
||||
readonly EngineerRepairInfo info;
|
||||
|
||||
Actor enterActor;
|
||||
IHealth enterHealth;
|
||||
|
||||
public RepairBuilding(Actor self, Target target, EnterBehaviour enterBehaviour, Stance validStances)
|
||||
public RepairBuilding(Actor self, Target target, EngineerRepairInfo info)
|
||||
: base(self, target, Color.Yellow)
|
||||
{
|
||||
this.enterBehaviour = enterBehaviour;
|
||||
this.validStances = validStances;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
protected override bool TryStartEnter(Actor self, Actor targetActor)
|
||||
@@ -37,7 +36,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Make sure we can still repair the target before entering
|
||||
// (but not before, because this may stop the actor in the middle of nowhere)
|
||||
var stance = self.Owner.Stances[enterActor.Owner];
|
||||
if (enterHealth == null || enterHealth.DamageState == DamageState.Undamaged || !stance.HasStance(validStances))
|
||||
if (enterHealth == null || enterHealth.DamageState == DamageState.Undamaged || !info.ValidStances.HasStance(stance))
|
||||
{
|
||||
Cancel(self, true);
|
||||
return false;
|
||||
@@ -57,7 +56,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return;
|
||||
|
||||
var stance = self.Owner.Stances[enterActor.Owner];
|
||||
if (!stance.HasStance(validStances))
|
||||
if (!info.ValidStances.HasStance(stance))
|
||||
return;
|
||||
|
||||
if (enterHealth.DamageState == DamageState.Undamaged)
|
||||
@@ -65,9 +64,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
enterActor.InflictDamage(self, new Damage(-enterHealth.MaxHP));
|
||||
|
||||
if (enterBehaviour == EnterBehaviour.Dispose)
|
||||
if (info.EnterBehaviour == EnterBehaviour.Dispose)
|
||||
self.Dispose();
|
||||
else if (enterBehaviour == EnterBehaviour.Suicide)
|
||||
else if (info.EnterBehaviour == EnterBehaviour.Suicide)
|
||||
self.Kill(self);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,20 +80,25 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.CancelActivity();
|
||||
|
||||
self.SetTargetLine(order.Target, Color.Yellow);
|
||||
self.QueueActivity(new RepairBuilding(self, order.Target, info.EnterBehaviour, info.ValidStances));
|
||||
self.QueueActivity(new RepairBuilding(self, order.Target, info));
|
||||
}
|
||||
|
||||
class EngineerRepairOrderTargeter : UnitOrderTargeter
|
||||
{
|
||||
public EngineerRepairOrderTargeter()
|
||||
: base("EngineerRepair", 6, "goldwrench", false, true) { }
|
||||
EngineerRepairInfo info;
|
||||
|
||||
public EngineerRepairOrderTargeter(EngineerRepairInfo info)
|
||||
: base("EngineerRepair", 6, "goldwrench", true, true)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (!target.Info.HasTraitInfo<EngineerRepairableInfo>())
|
||||
return false;
|
||||
|
||||
if (self.Owner.Stances[target.Owner] != Stance.Ally)
|
||||
if (!info.ValidStances.HasStance(self.Owner.Stances[target.Owner]))
|
||||
return false;
|
||||
|
||||
if (target.GetDamageState() == DamageState.Undamaged)
|
||||
@@ -107,7 +112,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!target.Info.HasTraitInfo<EngineerRepairableInfo>())
|
||||
return false;
|
||||
|
||||
if (self.Owner.Stances[target.Owner] != Stance.Ally)
|
||||
if (!info.ValidStances.HasStance(self.Owner.Stances[target.Owner]))
|
||||
return false;
|
||||
|
||||
if (target.DamageState == DamageState.Undamaged)
|
||||
|
||||
Reference in New Issue
Block a user