Drag husks to their final location. Fixes #730.

This commit is contained in:
Paul Chote
2011-07-25 23:50:11 +12:00
parent 49cbaeb1d2
commit 0a5f81c39e
3 changed files with 110 additions and 24 deletions

View File

@@ -8,8 +8,9 @@
*/
#endregion
using OpenRA.Traits;
using OpenRA.FileFormats;
using OpenRA.Traits;
using OpenRA.Mods.RA.Move;
namespace OpenRA.Mods.RA
{
@@ -24,24 +25,30 @@ namespace OpenRA.Mods.RA
public void Killed(Actor self, AttackInfo e)
{
self.World.AddFrameEndTask(w =>
{
var info = self.Info.Traits.Get<LeavesHuskInfo>();
var td = new TypeDictionary()
{
var info = self.Info.Traits.Get<LeavesHuskInfo>();
var td = new TypeDictionary
{
new LocationInit( self.Location ),
new OwnerInit( self.Owner ),
new SkipMakeAnimsInit()
};
if (self.HasTrait<IFacing>())
td.Add(new FacingInit( self.Trait<IFacing>().Facing ));
new LocationInit( self.Location ),
new CenterLocationInit(self.CenterLocation),
new OwnerInit( self.Owner ),
new SkipMakeAnimsInit()
};
var husk = w.CreateActor(info.HuskActor, td);
var turreted = self.TraitOrDefault<Turreted>();
if (turreted != null)
foreach (var p in husk.TraitsImplementing<ThrowsParticle>())
p.InitialFacing = turreted.turretFacing;
});
if (self.HasTrait<IFacing>())
td.Add(new FacingInit( self.Trait<IFacing>().Facing ));
// Allows the husk to drag to its final position
var mobile = self.TraitOrDefault<Mobile>();
if (mobile != null)
td.Add(new HuskSpeedInit(mobile.MovementSpeedForCell(self, self.Location)));
var husk = w.CreateActor(info.HuskActor, td);
var turreted = self.TraitOrDefault<Turreted>();
if (turreted != null)
foreach (var p in husk.TraitsImplementing<ThrowsParticle>())
p.InitialFacing = turreted.turretFacing;
});
}
}
}