Merge pull request #4721 from Smilex/A10_vision

closes #4696
closes #4687
This commit is contained in:
Matthias Mailänder
2014-02-24 22:11:17 +01:00
3 changed files with 39 additions and 3 deletions

View File

@@ -23,19 +23,22 @@ namespace OpenRA.Mods.RA
[Desc("Armament name")]
public readonly string Guns = "secondary";
public readonly int FacingTolerance = 2;
public readonly WRange VisionRange = WRange.FromCells(10);
public override object Create(ActorInitializer init) { return new AttackBomber(init.self, this); }
}
class AttackBomber : AttackBase, ISync
class AttackBomber : AttackBase, ISync, INotifyKilled
{
AttackBomberInfo info;
Actor camera;
[Sync] Target target;
public AttackBomber(Actor self, AttackBomberInfo info)
: base(self)
{
this.info = info;
this.camera = null;
}
public override void Tick(Actor self)
@@ -46,6 +49,23 @@ namespace OpenRA.Mods.RA
var cp = self.CenterPosition;
var bombTarget = Target.FromPos(cp - new WVec(0, 0, cp.Z));
// Provide vision
if (this.camera == null &&
target.IsInRange(self.CenterPosition, this.info.VisionRange))
{
this.camera = self.World.CreateActor("camera", new TypeDictionary
{
new LocationInit(target.CenterPosition.ToCPos()),
new OwnerInit(self.Owner),
});
}
else if (this.camera != null &&
!target.IsInRange(self.CenterPosition, this.info.VisionRange))
{
self.World.Remove(this.camera);
this.camera = null;
}
// Bombs drop anywhere in range
foreach (var a in Armaments.Where(a => a.Info.Name == info.Bombs))
{
@@ -72,6 +92,15 @@ namespace OpenRA.Mods.RA
public void SetTarget(WPos pos) { target = Target.FromPos(pos); }
public void Killed(Actor self, AttackInfo e)
{
if (this.camera != null)
{
self.World.Remove(this.camera);
this.camera = null;
}
}
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
{
// TODO: Player controlled units want this too!

View File

@@ -192,8 +192,6 @@ A10:
HP: 150
Armor:
Type: Heavy
RevealsShroud:
Range: 12
RenderUnit:
WithShadow:
AttackBomber:

View File

@@ -39,4 +39,13 @@ waypoint:
Waypoint:
RenderEditorOnly:
BodyOrientation:
CAMERA:
Aircraft:
Health:
HP: 1000
RevealsShroud:
Range: 10
ProximityCaptor:
Types: Camera
BodyOrientation: