Fix WithSpriteBody crashes
This commit is contained in:
@@ -58,6 +58,11 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
|||||||
: base(init, info, MakeTurretFacingFunc(init.Self))
|
: base(init, info, MakeTurretFacingFunc(init.Self))
|
||||||
{
|
{
|
||||||
turreted = init.Self.TraitsImplementing<Turreted>().FirstOrDefault();
|
turreted = init.Self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void TraitEnabled(Actor self)
|
||||||
|
{
|
||||||
|
base.TraitEnabled(self);
|
||||||
turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,13 +62,18 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
|||||||
var name = rs.GetImage(init.Self);
|
var name = rs.GetImage(init.Self);
|
||||||
turret = init.Self.TraitsImplementing<Turreted>()
|
turret = init.Self.TraitsImplementing<Turreted>()
|
||||||
.First(t => t.Name == info.Turret);
|
.First(t => t.Name == info.Turret);
|
||||||
turret.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
|
||||||
|
|
||||||
wake = new Animation(init.World, name);
|
wake = new Animation(init.World, name);
|
||||||
wake.PlayRepeating(info.WakeLeftSequence);
|
wake.PlayRepeating(info.WakeLeftSequence);
|
||||||
rs.Add(new AnimationWithOffset(wake, null, null, -87));
|
rs.Add(new AnimationWithOffset(wake, null, null, -87));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void TraitEnabled(Actor self)
|
||||||
|
{
|
||||||
|
base.TraitEnabled(self);
|
||||||
|
turret.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
||||||
|
}
|
||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (facing.Facing <= 128)
|
if (facing.Facing <= 128)
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
playerResources = init.Self.Owner.PlayerActor.Trait<PlayerResources>();
|
playerResources = init.Self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
ConfigureAnimation(init.Self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureAnimation(Actor self)
|
void ConfigureAnimation(Actor self)
|
||||||
@@ -65,7 +64,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
|
|
||||||
protected override void TraitEnabled(Actor self)
|
protected override void TraitEnabled(Actor self)
|
||||||
{
|
{
|
||||||
// Do nothing - we just want to disable the default WithSpriteBody implementation
|
base.TraitEnabled(self);
|
||||||
|
ConfigureAnimation(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CancelCustomAnimation(Actor self)
|
public override void CancelCustomAnimation(Actor self)
|
||||||
|
|||||||
Reference in New Issue
Block a user