more ui and bugfixes
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-08-04 17:21:17 -04:00
parent aca8c36732
commit cdfa594c06
7 changed files with 68 additions and 10 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}
}
}

View File

@ -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();

View File

@ -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;
}

View File

@ -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){

View File

@ -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;
}

View File

@ -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);