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")] [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); }
} }
class AttackBomber : AttackBase, ISync class AttackBomber : AttackBase, ISync, INotifyKilled
{ {
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))
{ {
@@ -72,6 +92,15 @@ namespace OpenRA.Mods.RA
public void SetTarget(WPos pos) { target = Target.FromPos(pos); } 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) public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
{ {
// TODO: Player controlled units want this too! // TODO: Player controlled units want this too!

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: