Rework aircraft destruction to use husks instead of the original actor

This commit is contained in:
ScottNZ
2013-06-07 05:04:47 +12:00
parent 8c9fb382e3
commit 5184cee3ca
9 changed files with 318 additions and 67 deletions

View File

@@ -8,28 +8,26 @@
*/
#endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Air
{
class FallsToEarthInfo : TraitInfo<FallsToEarth>
class FallsToEarthInfo : ITraitInfo
{
[WeaponReference]
public readonly string Explosion = null;
public readonly string Explosion = "UnitExplode";
public readonly bool Spins = true;
public readonly bool Moves = false;
public object Create(ActorInitializer init) { return new FallsToEarth(init.self, this); }
}
class FallsToEarth : INotifyKilled
class FallsToEarth
{
public void Killed(Actor self, AttackInfo e)
public FallsToEarth(Actor self, FallsToEarthInfo info)
{
self.Trait<Health>().RemoveOnDeath = false;
self.CancelActivity();
self.QueueActivity(new FallToEarth(self, self.Info.Traits.Get<FallsToEarthInfo>()));
self.QueueActivity(false, new FallToEarth(self, info));
}
}

View File

@@ -10,8 +10,9 @@
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Traits;
using OpenRA.Mods.RA.Air;
using OpenRA.Mods.RA.Move;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
@@ -35,11 +36,11 @@ namespace OpenRA.Mods.RA
{
self.World.AddFrameEndTask(w =>
{
var td = new TypeDictionary()
var td = new TypeDictionary
{
new LocationInit( self.Location ),
new LocationInit(self.Location),
new CenterLocationInit(self.CenterLocation),
new OwnerInit( self.Owner ),
new OwnerInit(self.Owner),
new SkipMakeAnimsInit()
};
@@ -51,6 +52,10 @@ namespace OpenRA.Mods.RA
td.Add(new HuskSpeedInit(mobile.MovementSpeedForCell(self, self.Location)));
}
var aircraft = self.TraitOrDefault<Aircraft>();
if (aircraft != null)
td.Add(new AltitudeInit(aircraft.Altitude));
var facing = self.TraitOrDefault<IFacing>();
if (facing != null)
td.Add(new FacingInit( facing.Facing ));

View File

@@ -20,6 +20,7 @@ namespace OpenRA.Mods.RA
public readonly WVec Offset = WVec.Zero;
public readonly int Interval = 3;
public readonly string Sprite = "smokey";
public readonly DamageState MinDamage = DamageState.Heavy;
public object Create(ActorInitializer init) { return new SmokeTrailWhenDamaged(init.self, this); }
}
@@ -41,7 +42,7 @@ namespace OpenRA.Mods.RA
if (--ticks <= 0)
{
var position = self.CenterPosition;
if (position.Z > 0 && self.GetDamageState() >= DamageState.Heavy &&
if (position.Z > 0 && self.GetDamageState() >= info.MinDamage &&
!self.World.FogObscures(new CPos(position)))
{
var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));