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

Make WithVoxelWalkerBody PausableConditional. #19932

Merged
merged 1 commit into from Feb 18, 2022
Merged
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
14 changes: 8 additions & 6 deletions OpenRA.Mods.Cnc/Traits/Render/WithVoxelWalkerBody.cs
Expand Up @@ -20,7 +20,7 @@

namespace OpenRA.Mods.Cnc.Traits.Render
{
public class WithVoxelWalkerBodyInfo : TraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>, Requires<IMoveInfo>, Requires<IFacingInfo>
public class WithVoxelWalkerBodyInfo : PausableConditionalTraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>, Requires<IMoveInfo>, Requires<IFacingInfo>
{
public readonly string Sequence = "idle";

Expand All @@ -44,9 +44,8 @@ public class WithVoxelWalkerBodyInfo : TraitInfo, IRenderActorPreviewVoxelsInfo,
}
}

public class WithVoxelWalkerBody : ITick, IActorPreviewInitModifier, IAutoMouseBounds
public class WithVoxelWalkerBody : PausableConditionalTrait<WithVoxelWalkerBodyInfo>, ITick, IActorPreviewInitModifier, IAutoMouseBounds
{
readonly WithVoxelWalkerBodyInfo info;
readonly IMove movement;
readonly ModelAnimation modelAnimation;
readonly RenderVoxels rv;
Expand All @@ -55,8 +54,8 @@ public class WithVoxelWalkerBody : ITick, IActorPreviewInitModifier, IAutoMouseB
readonly uint frames;

public WithVoxelWalkerBody(Actor self, WithVoxelWalkerBodyInfo info)
: base(info)
{
this.info = info;
movement = self.Trait<IMove>();

var body = self.Trait<BodyOrientation>();
Expand All @@ -66,18 +65,21 @@ public WithVoxelWalkerBody(Actor self, WithVoxelWalkerBodyInfo info)
frames = model.Frames;
modelAnimation = new ModelAnimation(model, () => WVec.Zero,
() => body.QuantizeOrientation(self, self.Orientation),
() => false, () => frame, info.ShowShadow);
() => IsTraitDisabled, () => frame, info.ShowShadow);

rv.Add(modelAnimation);
}

void ITick.Tick(Actor self)
{
if (IsTraitDisabled || IsTraitPaused)
return;

if (movement.CurrentMovementTypes.HasMovementType(MovementType.Horizontal)
|| movement.CurrentMovementTypes.HasMovementType(MovementType.Turn))
tick++;

if (tick < info.TickRate)
if (tick < Info.TickRate)
return;

tick = 0;
Expand Down