Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WithSpriteBody crashes #16610

Merged
merged 1 commit into from May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions OpenRA.Mods.Cnc/Traits/Render/WithEmbeddedTurretSpriteBody.cs
Expand Up @@ -58,6 +58,11 @@ public WithEmbeddedTurretSpriteBody(ActorInitializer init, WithSpriteBodyInfo in
: base(init, info, MakeTurretFacingFunc(init.Self))
{
turreted = init.Self.TraitsImplementing<Turreted>().FirstOrDefault();
}

protected override void TraitEnabled(Actor self)
{
base.TraitEnabled(self);
turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
}

Expand Down
7 changes: 6 additions & 1 deletion OpenRA.Mods.Cnc/Traits/Render/WithGunboatBody.cs
Expand Up @@ -62,13 +62,18 @@ public WithGunboatBody(ActorInitializer init, WithGunboatBodyInfo info)
var name = rs.GetImage(init.Self);
turret = init.Self.TraitsImplementing<Turreted>()
.First(t => t.Name == info.Turret);
turret.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;

wake = new Animation(init.World, name);
wake.PlayRepeating(info.WakeLeftSequence);
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)
{
if (facing.Facing <= 128)
Expand Down
Expand Up @@ -47,7 +47,6 @@ public WithResourceLevelSpriteBody(ActorInitializer init, WithResourceLevelSprit
{
this.info = info;
playerResources = init.Self.Owner.PlayerActor.Trait<PlayerResources>();
ConfigureAnimation(init.Self);
}

void ConfigureAnimation(Actor self)
Expand All @@ -65,7 +64,8 @@ void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newO

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)
Expand Down