From aca8c36732c527f70f069681bc79e33dd8905c05 Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 4 Aug 2024 16:24:20 -0400 Subject: [PATCH] server play equiped animations --- .../entity/state/equip/ServerEquipState.java | 16 ++++++++++++++++ .../entity/types/creature/CreatureUtils.java | 3 +-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/electrosphere/entity/state/equip/ServerEquipState.java b/src/main/java/electrosphere/entity/state/equip/ServerEquipState.java index 0f25213e..d2540807 100644 --- a/src/main/java/electrosphere/entity/state/equip/ServerEquipState.java +++ b/src/main/java/electrosphere/entity/state/equip/ServerEquipState.java @@ -27,6 +27,7 @@ import electrosphere.entity.state.inventory.UnrelationalInventoryState; import electrosphere.entity.types.attach.AttachUtils; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.item.ItemUtils; +import electrosphere.game.data.common.TreeDataAnimation; import electrosphere.game.data.creature.type.block.BlockSystem; import electrosphere.game.data.creature.type.block.BlockVariant; import electrosphere.game.data.creature.type.equip.EquipPoint; @@ -41,6 +42,7 @@ import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.ServerDataCell; import electrosphere.server.datacell.utils.DataCellSearchUtils; import electrosphere.server.datacell.utils.ServerEntityTagUtils; +import electrosphere.server.poseactor.PoseActor; import electrosphere.server.utils.ServerScriptUtils; @SynchronizedBehaviorTree(name = "serverEquipState", isServer = true, correspondingTree="clientEquipState") @@ -424,6 +426,20 @@ public class ServerEquipState implements BehaviorTree { @Override public void simulate(float deltaTime) { + PoseActor thirdPersonActor = EntityUtils.getPoseActor(parent); + //play animations for equip points that have items equipped + for(EquipPoint point : this.equipPoints){ + if(this.hasEquippedAtPoint(point.getEquipPointId()) && point.getEquippedAnimation() != null){ + TreeDataAnimation animation = point.getEquippedAnimation(); + //play third person + if(!thirdPersonActor.isPlayingAnimation() || !thirdPersonActor.isPlayingAnimation(animation)){ + if(animation != null){ + thirdPersonActor.playAnimation(animation); + } + thirdPersonActor.incrementAnimationTime(0.0001); + } + } + } } /** diff --git a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java index e888a1f7..7c9a3ac3 100644 --- a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java +++ b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java @@ -49,7 +49,6 @@ import electrosphere.game.data.collidable.CollidableTemplate; import electrosphere.game.data.creature.type.CreatureData; import electrosphere.game.data.creature.type.SprintSystem; import electrosphere.game.data.creature.type.attack.AttackMove; -import electrosphere.game.data.creature.type.movement.AirplaneMovementSystem; import electrosphere.game.data.creature.type.movement.FallMovementSystem; import electrosphere.game.data.creature.type.movement.GroundMovementSystem; import electrosphere.game.data.creature.type.movement.JumpMovementSystem; @@ -469,7 +468,7 @@ public class CreatureUtils { } } if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){ - ServerEquipState.setEquipState(rVal, new ServerEquipState(rVal,rawType.getEquipPoints())); + ServerEquipState.attachTree(rVal, rawType.getEquipPoints()); rVal.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints())); } if(rawType.getBlockSystem() != null){