Merge pull request #10910 from RoosterDragon/turret-active-tracking
Turrets actively track targets
This commit is contained in:
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
return false;
|
||||
}
|
||||
|
||||
return turret.FaceTarget(self, target);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void TickIdle(Actor self)
|
||||
|
||||
@@ -186,6 +186,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (ammoPool != null && !ammoPool.HasAmmo())
|
||||
return null;
|
||||
|
||||
if (turret != null && !turret.HasAchievedDesiredFacing)
|
||||
return null;
|
||||
|
||||
if (!target.IsInRange(self.CenterPosition, MaxRange()))
|
||||
return null;
|
||||
|
||||
|
||||
@@ -32,14 +32,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
protected override bool CanAttack(Actor self, Target target)
|
||||
{
|
||||
if (!base.CanAttack(self, target))
|
||||
if (target.Type == TargetType.Invalid)
|
||||
return false;
|
||||
|
||||
// Don't break early from this loop - we want to bring all turrets to bear!
|
||||
var turretReady = false;
|
||||
foreach (var t in turrets)
|
||||
if (t.FaceTarget(self, target))
|
||||
return true;
|
||||
turretReady = true;
|
||||
|
||||
return false;
|
||||
return turretReady && base.CanAttack(self, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var delta = target.CenterPosition - self.CenterPosition;
|
||||
DesiredFacing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : TurretFacing;
|
||||
MoveTurret();
|
||||
return TurretFacing == DesiredFacing.Value;
|
||||
return HasAchievedDesiredFacing;
|
||||
}
|
||||
|
||||
public bool HasAchievedDesiredFacing
|
||||
{
|
||||
get { return DesiredFacing != null && TurretFacing == DesiredFacing.Value; }
|
||||
}
|
||||
|
||||
// Turret offset in world-space
|
||||
|
||||
Reference in New Issue
Block a user