Give the mechanic a wrench icon instead of red-cross
closes #3133 don't try to guess hard-coded cursors from weapon damage
This commit is contained in:
@@ -20,6 +20,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public abstract class AttackBaseInfo : ITraitInfo
|
public abstract class AttackBaseInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly bool CanAttackGround = true;
|
public readonly bool CanAttackGround = true;
|
||||||
|
public readonly string Cursor = "attack";
|
||||||
|
|
||||||
public abstract object Create(ActorInitializer init);
|
public abstract object Create(ActorInitializer init);
|
||||||
}
|
}
|
||||||
@@ -41,10 +42,17 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
protected virtual bool CanAttack(Actor self, Target target)
|
protected virtual bool CanAttack(Actor self, Target target)
|
||||||
{
|
{
|
||||||
if (!self.IsInWorld) return false;
|
if (!self.IsInWorld)
|
||||||
if (!target.IsValid) return false;
|
return false;
|
||||||
if (Armaments.All(a => a.IsReloading)) return false;
|
|
||||||
if (self.IsDisabled()) return false;
|
if (!target.IsValid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (Armaments.All(a => a.IsReloading))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (self.IsDisabled())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (target.IsActor && target.Actor.HasTrait<ITargetable>() &&
|
if (target.IsActor && target.Actor.HasTrait<ITargetable>() &&
|
||||||
!target.Actor.Trait<ITargetable>().TargetableBy(target.Actor,self))
|
!target.Actor.Trait<ITargetable>().TargetableBy(target.Actor,self))
|
||||||
@@ -96,8 +104,9 @@ namespace OpenRA.Mods.RA
|
|||||||
if (Armaments.Count() == 0)
|
if (Armaments.Count() == 0)
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
bool isHeal = Armaments.First().Weapon.Warheads[0].Damage < 0;
|
var negativeDamage = (Armaments.First().Weapon.Warheads[0].Damage < 0);
|
||||||
yield return new AttackOrderTargeter("Attack", 6, isHeal);
|
|
||||||
|
yield return new AttackOrderTargeter("Attack", 6, negativeDamage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,20 +146,24 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void AttackTarget(Target target, bool queued, bool allowMove)
|
public void AttackTarget(Target target, bool queued, bool allowMove)
|
||||||
{
|
{
|
||||||
if( !target.IsValid ) return;
|
if (!target.IsValid)
|
||||||
if (!queued) self.CancelActivity();
|
return;
|
||||||
|
|
||||||
|
if (!queued)
|
||||||
|
self.CancelActivity();
|
||||||
|
|
||||||
self.QueueActivity(GetAttackActivity(self, target, allowMove));
|
self.QueueActivity(GetAttackActivity(self, target, allowMove));
|
||||||
}
|
}
|
||||||
|
|
||||||
class AttackOrderTargeter : IOrderTargeter
|
class AttackOrderTargeter : IOrderTargeter
|
||||||
{
|
{
|
||||||
readonly bool isHeal;
|
readonly bool negativeDamage;
|
||||||
|
|
||||||
public AttackOrderTargeter( string order, int priority, bool isHeal )
|
public AttackOrderTargeter(string order, int priority, bool negativeDamage)
|
||||||
{
|
{
|
||||||
this.OrderID = order;
|
this.OrderID = order;
|
||||||
this.OrderPriority = priority;
|
this.OrderPriority = priority;
|
||||||
this.isHeal = isHeal;
|
this.negativeDamage = negativeDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string OrderID { get; private set; }
|
public string OrderID { get; private set; }
|
||||||
@@ -160,12 +173,18 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
IsQueued = forceQueued;
|
IsQueued = forceQueued;
|
||||||
|
|
||||||
cursor = isHeal ? "heal" : "attack";
|
cursor = self.Info.Traits.Get<AttackBaseInfo>().Cursor;
|
||||||
if( self == target ) return false;
|
|
||||||
if( !self.Trait<AttackBase>().HasAnyValidWeapons( Target.FromActor( target ) ) ) return false;
|
|
||||||
if (forceAttack) return true;
|
|
||||||
|
|
||||||
var targetableRelationship = isHeal ? Stance.Ally : Stance.Enemy;
|
if (self == target)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!self.Trait<AttackBase>().HasAnyValidWeapons(Target.FromActor(target)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (forceAttack)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
var targetableRelationship = negativeDamage ? Stance.Ally : Stance.Enemy;
|
||||||
|
|
||||||
return self.Owner.Stances[target.Owner] == targetableRelationship;
|
return self.Owner.Stances[target.Owner] == targetableRelationship;
|
||||||
}
|
}
|
||||||
@@ -177,9 +196,13 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
IsQueued = forceQueued;
|
IsQueued = forceQueued;
|
||||||
|
|
||||||
cursor = isHeal ? "heal" : "attack";
|
cursor = self.Info.Traits.Get<AttackBaseInfo>().Cursor;
|
||||||
if( isHeal ) return false;
|
|
||||||
if( !self.Trait<AttackBase>().HasAnyValidWeapons( Target.FromCell( location ) ) ) return false;
|
if (negativeDamage)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!self.Trait<AttackBase>().HasAnyValidWeapons(Target.FromCell(location)))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (forceAttack)
|
if (forceAttack)
|
||||||
if (self.Info.Traits.Get<AttackBaseInfo>().CanAttackGround)
|
if (self.Info.Traits.Get<AttackBaseInfo>().CanAttackGround)
|
||||||
|
|||||||
@@ -189,16 +189,6 @@ Cursors:
|
|||||||
length: 8
|
length: 8
|
||||||
x: 12
|
x: 12
|
||||||
y: 12
|
y: 12
|
||||||
heal:
|
|
||||||
start:72
|
|
||||||
length: 8
|
|
||||||
x: 12
|
|
||||||
y: 12
|
|
||||||
heal-minimap:
|
|
||||||
start:72
|
|
||||||
length: 8
|
|
||||||
x: 12
|
|
||||||
y: 12
|
|
||||||
|
|
||||||
# Cursors that need minimap variants
|
# Cursors that need minimap variants
|
||||||
deploy:
|
deploy:
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ MEDIC:
|
|||||||
Armament:
|
Armament:
|
||||||
Weapon: Heal
|
Weapon: Heal
|
||||||
AttackMedic:
|
AttackMedic:
|
||||||
|
Cursor: ability
|
||||||
Passenger:
|
Passenger:
|
||||||
PipType: Blue
|
PipType: Blue
|
||||||
-AutoTarget:
|
-AutoTarget:
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ MEDI:
|
|||||||
Armament:
|
Armament:
|
||||||
Weapon: Heal
|
Weapon: Heal
|
||||||
AttackMedic:
|
AttackMedic:
|
||||||
|
Cursor: heal
|
||||||
TakeCover:
|
TakeCover:
|
||||||
-AutoTarget:
|
-AutoTarget:
|
||||||
-DebugRetiliateAgainstAggressor:
|
-DebugRetiliateAgainstAggressor:
|
||||||
@@ -365,6 +366,7 @@ MECH:
|
|||||||
Armament:
|
Armament:
|
||||||
Weapon: Repair
|
Weapon: Repair
|
||||||
AttackMedic:
|
AttackMedic:
|
||||||
|
Cursor: repair
|
||||||
TakeCover:
|
TakeCover:
|
||||||
-AutoTarget:
|
-AutoTarget:
|
||||||
-DebugRetiliateAgainstAggressor:
|
-DebugRetiliateAgainstAggressor:
|
||||||
|
|||||||
Reference in New Issue
Block a user