diff --git a/src/main/java/electrosphere/entity/state/client/firstPerson/FirstPersonTree.java b/src/main/java/electrosphere/entity/state/client/firstPerson/FirstPersonTree.java index bd19e079..6808c315 100644 --- a/src/main/java/electrosphere/entity/state/client/firstPerson/FirstPersonTree.java +++ b/src/main/java/electrosphere/entity/state/client/firstPerson/FirstPersonTree.java @@ -167,8 +167,8 @@ public class FirstPersonTree implements BehaviorTree { * @param animation The animation */ public static void conditionallyInterruptAnimation(Entity entity, TreeDataAnimation animation){ - if(entity != null && FirstPersonTree.hasTree(entity)){ - FirstPersonTree.getTree(entity).interruptAnimation(animation); + if(entity != null && entity == Globals.playerEntity && FirstPersonTree.hasTree(Globals.firstPersonEntity)){ + FirstPersonTree.getTree(Globals.firstPersonEntity).interruptAnimation(animation); } } diff --git a/src/main/java/electrosphere/entity/state/equip/ClientEquipState.java b/src/main/java/electrosphere/entity/state/equip/ClientEquipState.java index 3f8ade8f..c03254d2 100644 --- a/src/main/java/electrosphere/entity/state/equip/ClientEquipState.java +++ b/src/main/java/electrosphere/entity/state/equip/ClientEquipState.java @@ -319,6 +319,7 @@ public class ClientEquipState implements BehaviorTree { Entity equipped = equipMap.remove(pointId); if(equipped != null){ boolean targetHasWhitelist = ItemUtils.hasEquipList(equipped); + EquipPoint point = this.getEquipPoint(pointId); // //visual transforms @@ -346,6 +347,24 @@ public class ClientEquipState implements BehaviorTree { AttachUtils.clientDetatchEntityFromEntityAtBone(parent, equipped); EntityUtils.cleanUpEntity(equipped); } + + //interrupt animation + if(point != null){ + Actor thirdPersonActor = EntityUtils.getActor(parent); + if(point.getEquippedAnimation() != null){ + TreeDataAnimation animation = point.getEquippedAnimation(); + //play third person + if(thirdPersonActor.isPlayingAnimation() && thirdPersonActor.isPlayingAnimation(animation)){ + if(animation != null){ + thirdPersonActor.interruptAnimation(animation,true); + } + thirdPersonActor.incrementAnimationTime(0.0001); + } + + //play first person + FirstPersonTree.conditionallyInterruptAnimation(parent, animation); + } + } } } diff --git a/src/main/java/electrosphere/entity/state/equip/ServerEquipState.java b/src/main/java/electrosphere/entity/state/equip/ServerEquipState.java index d2540807..797fb5ca 100644 --- a/src/main/java/electrosphere/entity/state/equip/ServerEquipState.java +++ b/src/main/java/electrosphere/entity/state/equip/ServerEquipState.java @@ -336,6 +336,7 @@ public class ServerEquipState implements BehaviorTree { Entity equipped = equipMap.remove(pointId); if(equipped != null){ boolean targetHasWhitelist = ItemUtils.hasEquipList(equipped); + EquipPoint point = this.getEquipPoint(pointId); // //Visual transforms @@ -377,6 +378,21 @@ public class ServerEquipState implements BehaviorTree { EntityUtils.cleanUpEntity(equipped); } + //interrupt animation + if(point != null){ + PoseActor thirdPersonActor = EntityUtils.getPoseActor(parent); + if(point.getEquippedAnimation() != null){ + TreeDataAnimation animation = point.getEquippedAnimation(); + //play third person + if(thirdPersonActor.isPlayingAnimation() && thirdPersonActor.isPlayingAnimation(animation)){ + if(animation != null){ + thirdPersonActor.interruptAnimation(animation,true); + } + thirdPersonActor.incrementAnimationTime(0.0001); + } + } + } + // //update block state based on what we have equipped this.updateBlockVariant(); diff --git a/src/main/java/electrosphere/entity/state/inventory/ClientInventoryState.java b/src/main/java/electrosphere/entity/state/inventory/ClientInventoryState.java index fd129813..405a92d8 100644 --- a/src/main/java/electrosphere/entity/state/inventory/ClientInventoryState.java +++ b/src/main/java/electrosphere/entity/state/inventory/ClientInventoryState.java @@ -98,10 +98,10 @@ public class ClientInventoryState implements BehaviorTree { //destroy the in-world manifestation of said item EntityUtils.cleanUpEntity(entityInSlot); } - } - break; + } break; case CLIENTREQUESTEQUIPITEM: case CLIENTREQUESTUNEQUIPITEM: + case CLIENTREQUESTPERFORMITEMACTION: case SERVERCOMMANDEQUIPITEM: break; } diff --git a/src/main/java/electrosphere/entity/state/inventory/RelationalInventoryState.java b/src/main/java/electrosphere/entity/state/inventory/RelationalInventoryState.java index d6a689a4..c999df69 100644 --- a/src/main/java/electrosphere/entity/state/inventory/RelationalInventoryState.java +++ b/src/main/java/electrosphere/entity/state/inventory/RelationalInventoryState.java @@ -48,7 +48,15 @@ public class RelationalInventoryState { return items.get(slot); } + /** + * Gets the item slot for a given item + * @param item The item + * @return The item slot if it is contained within this inventory, null otherwise + */ public String getItemSlot(Entity item){ + if(item == null){ + LoggerInterface.loggerEngine.ERROR(new IllegalArgumentException("Trying to get the item slot of null!")); + } if(items.containsValue(item)){ for(String slot : items.keySet()){ if(items.get(slot) == item){ diff --git a/src/main/java/electrosphere/entity/types/attach/AttachUtils.java b/src/main/java/electrosphere/entity/types/attach/AttachUtils.java index 2c188dee..dc8f1a90 100644 --- a/src/main/java/electrosphere/entity/types/attach/AttachUtils.java +++ b/src/main/java/electrosphere/entity/types/attach/AttachUtils.java @@ -531,6 +531,10 @@ public class AttachUtils { if(parent.containsKey(EntityDataStrings.ATTACH_CHILDREN_LIST)){ getChildrenList(parent).remove(toAttach); } + //special case handling for view model + if(parent == Globals.playerEntity && getChildrenList(Globals.firstPersonEntity) != null){ + getChildrenList(Globals.firstPersonEntity).remove(toAttach); + } return bone; } diff --git a/src/main/java/electrosphere/menu/ingame/MenuGeneratorsInventory.java b/src/main/java/electrosphere/menu/ingame/MenuGeneratorsInventory.java index 2d84de4d..ce727931 100644 --- a/src/main/java/electrosphere/menu/ingame/MenuGeneratorsInventory.java +++ b/src/main/java/electrosphere/menu/ingame/MenuGeneratorsInventory.java @@ -283,14 +283,23 @@ public class MenuGeneratorsInventory { for(int i = 0; i < numSlots; i++){ String texturePath = "Textures/icons/itemIconEmpty.png"; boolean hasItem = false; - equipPoint = inventory.getEquipPointFromSlot(slots.get(i)); + String slotId = slots.get(i); + equipPoint = inventory.getEquipPointFromSlot(slotId); if(!equipPoint.isCombinedPoint()){ - if(inventory.getItemSlot(slots.get(i)) != null){ - Entity currentItem = inventory.getItemSlot(slots.get(i)); + if(inventory.getItemSlot(slotId) != null){ + Entity currentItem = inventory.getItemSlot(slotId); //get texture path from item texturePath = ItemUtils.getItemIcon(currentItem); //flag that this isn't an empty slot hasItem = true; + } else if(inventory.getCombinedPoint(slotId) != null && inventory.hasItemInSlot(inventory.getCombinedPoint(slotId).getEquipPointId())){ + Entity currentItem = inventory.getItemSlot(inventory.getCombinedPoint(slotId).getEquipPointId()); + //get texture path from item + texturePath = ItemUtils.getItemIcon(currentItem); + //flag that this isn't an empty slot + hasItem = true; + equipPoint = inventory.getCombinedPoint(slotId); + slotId = equipPoint.getEquipPointId(); } if(!Globals.assetManager.hasLoadedTexture(texturePath)){ Globals.assetManager.addTexturePathtoQueue(texturePath); @@ -307,11 +316,13 @@ public class MenuGeneratorsInventory { ImagePanel panel = new ImagePanel(posX,posY,panelWidth,panelHeight,texturePath); panel.setAbsolutePosition(true); if(hasItem == true){ - int itemId = i; - panel.setOnDragStart(new DragEventCallback() {public boolean execute(DragEvent event){ + //literally just here to get around finality of variable within callback + String finalSlotId = slotId; + panel.setOnDragStart(new DragEventCallback() { + public boolean execute(DragEvent event){ // System.out.println("Drag start"); Globals.dragSourceInventory = inventory; - Globals.draggedItem = inventory.getItemSlot(slots.get(itemId)); + Globals.draggedItem = inventory.getItemSlot(finalSlotId); ContainerElement container = (ContainerElement)panel.getParent(); container.removeChild(panel); WindowUtils.pushItemIconToItemWindow(panel);