captured cards are now flipped in groups instead of one at a time.

This commit is contained in:
trunksbomb
2026-03-23 12:34:02 -04:00
parent 261f540317
commit 316ffebe1f
2 changed files with 26 additions and 12 deletions

View File

@@ -45,7 +45,7 @@ public class DuelTableBlockEntity extends BlockEntity {
private UUID firstParticipantId; private UUID firstParticipantId;
private UUID secondParticipantId; private UUID secondParticipantId;
private AnimationType animationType = AnimationType.NONE; private AnimationType animationType = AnimationType.NONE;
private int animationSlot = -1; private int[] animationSlots = new int[0];
private int animationTargetOwner = OWNER_NONE; private int animationTargetOwner = OWNER_NONE;
private int animationAge; private int animationAge;
private int animationDuration; private int animationDuration;
@@ -95,7 +95,16 @@ public class DuelTableBlockEntity extends BlockEntity {
} }
public int animationSlot() { public int animationSlot() {
return animationSlot; return animationSlots.length > 0 ? animationSlots[0] : -1;
}
public boolean isAnimatingSlot(int slot) {
for (int animatedSlot : animationSlots) {
if (animatedSlot == slot) {
return true;
}
}
return false;
} }
public float animationProgress(float partialTick) { public float animationProgress(float partialTick) {
@@ -188,9 +197,12 @@ public class DuelTableBlockEntity extends BlockEntity {
return; return;
} }
pendingAnimations.addLast(new AnimationStep(AnimationType.PLACEMENT, moveResult.playedCell().index(), owner)); pendingAnimations.addLast(new AnimationStep(AnimationType.PLACEMENT, new int[] {moveResult.playedCell().index()}, owner));
for (BoardCell capturedCell : moveResult.capturedCells()) { if (!moveResult.capturedCells().isEmpty()) {
pendingAnimations.addLast(new AnimationStep(AnimationType.CAPTURE, capturedCell.index(), owner)); int[] captureSlots = moveResult.capturedCells().stream()
.mapToInt(BoardCell::index)
.toArray();
pendingAnimations.addLast(new AnimationStep(AnimationType.CAPTURE, captureSlots, owner));
} }
advanceAnimationStep(); advanceAnimationStep();
} }
@@ -219,7 +231,9 @@ public class DuelTableBlockEntity extends BlockEntity {
&& blockEntity.animationType == AnimationType.CAPTURE && blockEntity.animationType == AnimationType.CAPTURE
&& !blockEntity.animationOwnerApplied && !blockEntity.animationOwnerApplied
&& blockEntity.animationAge >= Math.max(1, blockEntity.animationDuration / 2)) { && blockEntity.animationAge >= Math.max(1, blockEntity.animationDuration / 2)) {
blockEntity.setOwner(blockEntity.animationSlot, blockEntity.animationTargetOwner); for (int slot : blockEntity.animationSlots) {
blockEntity.setOwner(slot, blockEntity.animationTargetOwner);
}
blockEntity.animationOwnerApplied = true; blockEntity.animationOwnerApplied = true;
blockEntity.sync(); blockEntity.sync();
} }
@@ -349,7 +363,7 @@ public class DuelTableBlockEntity extends BlockEntity {
private void saveAnimation(CompoundTag tag) { private void saveAnimation(CompoundTag tag) {
tag.putString("AnimationType", animationType.name()); tag.putString("AnimationType", animationType.name());
tag.putInt("AnimationSlot", animationSlot); tag.putIntArray("AnimationSlots", animationSlots);
tag.putInt("AnimationTargetOwner", animationTargetOwner); tag.putInt("AnimationTargetOwner", animationTargetOwner);
tag.putInt("AnimationAge", animationAge); tag.putInt("AnimationAge", animationAge);
tag.putInt("AnimationDuration", animationDuration); tag.putInt("AnimationDuration", animationDuration);
@@ -358,7 +372,7 @@ public class DuelTableBlockEntity extends BlockEntity {
private void loadAnimation(CompoundTag tag) { private void loadAnimation(CompoundTag tag) {
animationType = AnimationType.valueOf(tag.getString("AnimationType").isEmpty() ? AnimationType.NONE.name() : tag.getString("AnimationType")); animationType = AnimationType.valueOf(tag.getString("AnimationType").isEmpty() ? AnimationType.NONE.name() : tag.getString("AnimationType"));
animationSlot = tag.getInt("AnimationSlot"); animationSlots = tag.getIntArray("AnimationSlots");
animationTargetOwner = tag.getInt("AnimationTargetOwner"); animationTargetOwner = tag.getInt("AnimationTargetOwner");
animationAge = tag.getInt("AnimationAge"); animationAge = tag.getInt("AnimationAge");
animationDuration = tag.getInt("AnimationDuration"); animationDuration = tag.getInt("AnimationDuration");
@@ -386,7 +400,7 @@ public class DuelTableBlockEntity extends BlockEntity {
} }
animationType = nextStep.type(); animationType = nextStep.type();
animationSlot = nextStep.slot(); animationSlots = nextStep.slots();
animationTargetOwner = nextStep.targetOwner(); animationTargetOwner = nextStep.targetOwner();
animationAge = 0; animationAge = 0;
animationDuration = nextStep.type() == AnimationType.PLACEMENT ? PLACEMENT_DURATION : CAPTURE_DURATION; animationDuration = nextStep.type() == AnimationType.PLACEMENT ? PLACEMENT_DURATION : CAPTURE_DURATION;
@@ -396,7 +410,7 @@ public class DuelTableBlockEntity extends BlockEntity {
private void clearAnimationState() { private void clearAnimationState() {
animationType = AnimationType.NONE; animationType = AnimationType.NONE;
animationSlot = -1; animationSlots = new int[0];
animationTargetOwner = OWNER_NONE; animationTargetOwner = OWNER_NONE;
animationAge = 0; animationAge = 0;
animationDuration = 0; animationDuration = 0;
@@ -486,6 +500,6 @@ public class DuelTableBlockEntity extends BlockEntity {
CLEARING CLEARING
} }
private record AnimationStep(AnimationType type, int slot, int targetOwner) { private record AnimationStep(AnimationType type, int[] slots, int targetOwner) {
} }
} }

View File

@@ -35,7 +35,7 @@ public class DuelTableBlockEntityRenderer implements BlockEntityRenderer<DuelTab
float extraFlip = 0.0F; float extraFlip = 0.0F;
boolean hideCard = false; boolean hideCard = false;
float idleOffset = idleBob(blockEntity, slot, partialTick); float idleOffset = idleBob(blockEntity, slot, partialTick);
if (blockEntity.animationSlot() == slot) { if (blockEntity.isAnimatingSlot(slot)) {
float progress = blockEntity.animationProgress(partialTick); float progress = blockEntity.animationProgress(partialTick);
if (blockEntity.isPlacementAnimation()) { if (blockEntity.isPlacementAnimation()) {
y += (1.0F - progress) * 0.18F; y += (1.0F - progress) * 0.18F;