Convert SmokeTrailWhenDamaged to world coords.
This commit is contained in:
@@ -8,14 +8,16 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class SmokeTrailWhenDamagedInfo : ITraitInfo
|
||||
class SmokeTrailWhenDamagedInfo : ITraitInfo, Requires<LocalCoordinatesModelInfo>
|
||||
{
|
||||
public readonly int[] Offset = { 0, 0 };
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
public readonly int Interval = 3;
|
||||
|
||||
public object Create(ActorInitializer init) { return new SmokeTrailWhenDamaged(init.self, this); }
|
||||
@@ -23,34 +25,30 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
class SmokeTrailWhenDamaged : ITick
|
||||
{
|
||||
Turret smokeTurret;
|
||||
PPos position;
|
||||
int interval;
|
||||
ILocalCoordinatesModel coords;
|
||||
SmokeTrailWhenDamagedInfo info;
|
||||
int ticks;
|
||||
|
||||
public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info)
|
||||
{
|
||||
smokeTurret = new Turret(info.Offset);
|
||||
interval = info.Interval;
|
||||
this.info = info;
|
||||
coords = self.Trait<ILocalCoordinatesModel>();
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (--ticks <= 0)
|
||||
{
|
||||
var move = self.Trait<IMove>();
|
||||
if (move.Altitude > 0 && self.GetDamageState() >= DamageState.Heavy)
|
||||
var position = self.CenterPosition;
|
||||
if (position.Z > 0 && self.GetDamageState() >= DamageState.Heavy &&
|
||||
self.World.RenderedShroud.IsVisible(new CPos(position)))
|
||||
{
|
||||
var facing = self.Trait<IFacing>();
|
||||
var altitude = new PVecInt(0, move.Altitude);
|
||||
position = (self.CenterLocation - (PVecInt)smokeTurret.PxPosition(self, facing).ToInt2());
|
||||
|
||||
if (self.World.RenderedShroud.IsVisible(position.ToCPos()))
|
||||
self.World.AddFrameEndTask(
|
||||
w => w.Add(new Smoke(w, position - altitude, "smokey")));
|
||||
var offset = info.Offset.Rotate(coords.QuantizeOrientation(self, self.Orientation));
|
||||
var pos = PPos.FromWPosHackZ(position + coords.LocalToWorld(offset));
|
||||
self.World.AddFrameEndTask(w => w.Add(new Smoke(w, pos, "smokey")));
|
||||
}
|
||||
|
||||
ticks = interval;
|
||||
ticks = info.Interval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
RearmBuildings: starporta,starporto,starporth
|
||||
MinimalLandAltitude: 25
|
||||
SmokeTrailWhenDamaged@0:
|
||||
Offset: 15, -12
|
||||
Offset: -512,640,0
|
||||
Interval: 3
|
||||
SmokeTrailWhenDamaged@1:
|
||||
Offset: -15, -12
|
||||
Offset: -512,-640,0
|
||||
Interval: 3
|
||||
RenderUnit:
|
||||
RenderCargo:
|
||||
@@ -103,7 +103,7 @@ ORNI:
|
||||
Moves: yes
|
||||
Explosion: UnitExplodeScale
|
||||
SmokeTrailWhenDamaged:
|
||||
Offset: 0,-10
|
||||
Offset: -427,0,0
|
||||
|
||||
ORNI.bomber:
|
||||
CarpetBomb:
|
||||
@@ -133,7 +133,7 @@ ORNI.bomber:
|
||||
Moves: yes
|
||||
Explosion: UnitExplodeScale
|
||||
SmokeTrailWhenDamaged:
|
||||
Offset: 0,-10
|
||||
Offset: -427,0,0
|
||||
|
||||
CARRYALL.infantry:
|
||||
ParaDrop:
|
||||
@@ -149,10 +149,10 @@ CARRYALL.infantry:
|
||||
RepairBuildings: repair
|
||||
RearmBuildings: starporta,starporto,starporth
|
||||
SmokeTrailWhenDamaged@0:
|
||||
Offset: 15, -12
|
||||
Offset: -512,540,0
|
||||
Interval: 3
|
||||
SmokeTrailWhenDamaged@1:
|
||||
Offset: -15, -12
|
||||
Offset: -512,-640,0
|
||||
Interval: 3
|
||||
RenderUnit:
|
||||
Image: carryall
|
||||
|
||||
@@ -28,10 +28,10 @@ BADR:
|
||||
Moves: yes
|
||||
Explosion: UnitExplode
|
||||
SmokeTrailWhenDamaged@0:
|
||||
Offset: 11, -11
|
||||
Offset: -469,469,0
|
||||
Interval: 2
|
||||
SmokeTrailWhenDamaged@1:
|
||||
Offset: -11, -11
|
||||
Offset: -469,-469,0
|
||||
Interval: 2
|
||||
-EjectOnDeath:
|
||||
-GpsDot:
|
||||
@@ -67,10 +67,10 @@ BADR.bomber:
|
||||
Moves: yes
|
||||
Explosion: UnitExplode
|
||||
SmokeTrailWhenDamaged@0:
|
||||
Offset: 11, -11
|
||||
Offset: -469,469,0
|
||||
Interval: 2
|
||||
SmokeTrailWhenDamaged@1:
|
||||
Offset: -11, -11
|
||||
Offset: -469,-469,0
|
||||
Interval: 2
|
||||
-EjectOnDeath:
|
||||
-GpsDot:
|
||||
@@ -124,7 +124,7 @@ MIG:
|
||||
Moves: yes
|
||||
Explosion: UnitExplode
|
||||
SmokeTrailWhenDamaged:
|
||||
Offset: 0,-20,0,-4
|
||||
Offset: -853,0,171
|
||||
Interval: 2
|
||||
|
||||
YAK:
|
||||
@@ -177,7 +177,7 @@ YAK:
|
||||
Moves: yes
|
||||
Explosion: UnitExplode
|
||||
SmokeTrailWhenDamaged:
|
||||
Offset: 0, -20
|
||||
Offset: -853,0,0
|
||||
Interval: 2
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ HELI:
|
||||
FallsToEarth:
|
||||
Explosion: UnitExplode
|
||||
SmokeTrailWhenDamaged:
|
||||
Offset: 0,-10
|
||||
Offset: -427,0,0
|
||||
|
||||
HIND:
|
||||
Inherits: ^Helicopter
|
||||
@@ -330,7 +330,7 @@ HIND:
|
||||
FallsToEarth:
|
||||
Explosion: UnitExplode
|
||||
SmokeTrailWhenDamaged:
|
||||
Offset: 0,-10
|
||||
Offset: -427,0,0
|
||||
|
||||
U2:
|
||||
Inherits: ^Plane
|
||||
@@ -355,5 +355,5 @@ U2:
|
||||
Moves: yes
|
||||
Explosion: UnitExplode
|
||||
SmokeTrailWhenDamaged:
|
||||
Offset: 0,-25
|
||||
Offset: -1c43,0,0
|
||||
Interval: 2
|
||||
Reference in New Issue
Block a user