Added a camera to the A10. That spawns as they attack, and is destroyed as they leave

This commit is contained in:
Ian T. Jacobsen
2014-02-23 20:55:30 +00:00
parent 9dcf5c3dbb
commit 6d4eada679
3 changed files with 29 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA
[Desc("Armament name")] [Desc("Armament name")]
public readonly string Guns = "secondary"; public readonly string Guns = "secondary";
public readonly int FacingTolerance = 2; public readonly int FacingTolerance = 2;
public readonly WRange VisionRange = WRange.FromCells(10);
public override object Create(ActorInitializer init) { return new AttackBomber(init.self, this); } public override object Create(ActorInitializer init) { return new AttackBomber(init.self, this); }
} }
@@ -30,12 +31,14 @@ namespace OpenRA.Mods.RA
class AttackBomber : AttackBase, ISync class AttackBomber : AttackBase, ISync
{ {
AttackBomberInfo info; AttackBomberInfo info;
Actor camera;
[Sync] Target target; [Sync] Target target;
public AttackBomber(Actor self, AttackBomberInfo info) public AttackBomber(Actor self, AttackBomberInfo info)
: base(self) : base(self)
{ {
this.info = info; this.info = info;
this.camera = null;
} }
public override void Tick(Actor self) public override void Tick(Actor self)
@@ -46,6 +49,23 @@ namespace OpenRA.Mods.RA
var cp = self.CenterPosition; var cp = self.CenterPosition;
var bombTarget = Target.FromPos(cp - new WVec(0, 0, cp.Z)); 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 // Bombs drop anywhere in range
foreach (var a in Armaments.Where(a => a.Info.Name == info.Bombs)) foreach (var a in Armaments.Where(a => a.Info.Name == info.Bombs))
{ {

View File

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

View File

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