Skip to content

Commit

Permalink
Make WithVoxelWalkerBody PausableConditional.
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR authored and reaperrr committed Feb 18, 2022
1 parent 6c33d47 commit 91f626c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions OpenRA.Mods.Cnc/Traits/Render/WithVoxelWalkerBody.cs
Original file line number Diff line number Diff line change
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

0 comments on commit 91f626c

Please sign in to comment.