Stance modification for engineer repair
This commit is contained in:
@@ -18,11 +18,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
readonly Actor target;
|
||||
readonly Health health;
|
||||
readonly Stance validStances;
|
||||
|
||||
public RepairBuilding(Actor self, Actor target, EnterBehaviour enterBehaviour)
|
||||
public RepairBuilding(Actor self, Actor target, EnterBehaviour enterBehaviour, Stance validStances)
|
||||
: base(self, target, enterBehaviour)
|
||||
{
|
||||
this.target = target;
|
||||
this.validStances = validStances;
|
||||
health = target.Trait<Health>();
|
||||
}
|
||||
|
||||
@@ -33,6 +35,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
protected override void OnInside(Actor self)
|
||||
{
|
||||
var stance = self.Owner.Stances[target.Owner];
|
||||
if (!stance.HasStance(validStances))
|
||||
return;
|
||||
|
||||
if (health.DamageState == DamageState.Undamaged)
|
||||
return;
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
"Possible values are Exit, Suicide, Dispose.")]
|
||||
public readonly EnterBehaviour EnterBehaviour = EnterBehaviour.Dispose;
|
||||
|
||||
[Desc("What diplomatic stances allow target to be repaired by this actor.")]
|
||||
public readonly Stance ValidStances = Stance.Ally;
|
||||
|
||||
public object Create(ActorInitializer init) { return new EngineerRepair(init, this); }
|
||||
}
|
||||
|
||||
@@ -96,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.CancelActivity();
|
||||
|
||||
self.SetTargetLine(target, Color.Yellow);
|
||||
self.QueueActivity(new RepairBuilding(self, target.Actor, info.EnterBehaviour));
|
||||
self.QueueActivity(new RepairBuilding(self, target.Actor, info.EnterBehaviour, info.ValidStances));
|
||||
}
|
||||
|
||||
class EngineerRepairOrderTargeter : UnitOrderTargeter
|
||||
|
||||
Reference in New Issue
Block a user