move more entites into clientState
This commit is contained in:
parent
3755346a7c
commit
76c05d26ae
@ -142,6 +142,31 @@ public class ClientState {
|
|||||||
*/
|
*/
|
||||||
public Entity playerCamera;
|
public Entity playerCamera;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The target of the interaction
|
||||||
|
*/
|
||||||
|
public Entity interactionTarget = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* skybox entity
|
||||||
|
*/
|
||||||
|
public Entity skybox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The inventory entity currently being dragged
|
||||||
|
*/
|
||||||
|
public Entity draggedItem = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The source inventory of the currently dragged inventory item
|
||||||
|
*/
|
||||||
|
public Object dragSourceInventory = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The target container to drop the dragged inventory entity into
|
||||||
|
*/
|
||||||
|
public Entity targetContainer = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public class ButtonInteraction {
|
|||||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
||||||
Entity target = ClientInteractionEngine.rayCast(centerPos, eyePos);
|
Entity target = ClientInteractionEngine.rayCast(centerPos, eyePos);
|
||||||
if(target != null && CommonEntityFlags.isInteractable(target)){
|
if(target != null && CommonEntityFlags.isInteractable(target)){
|
||||||
Globals.interactionTarget = target;
|
Globals.clientState.interactionTarget = target;
|
||||||
ButtonInteraction.performInteraction(target);
|
ButtonInteraction.performInteraction(target);
|
||||||
} else if(ClientEquipState.hasEquipState(Globals.clientState.playerEntity) && Crosshair.hasTarget()){
|
} else if(ClientEquipState.hasEquipState(Globals.clientState.playerEntity) && Crosshair.hasTarget()){
|
||||||
if(InventoryUtils.hasNaturalInventory(Globals.clientState.playerEntity)){
|
if(InventoryUtils.hasNaturalInventory(Globals.clientState.playerEntity)){
|
||||||
|
|||||||
@ -152,8 +152,8 @@ public class ClientSimulation {
|
|||||||
*/
|
*/
|
||||||
private void updateSkyboxPos(){
|
private void updateSkyboxPos(){
|
||||||
Globals.profiler.beginCpuSample("updateSkyboxPos");
|
Globals.profiler.beginCpuSample("updateSkyboxPos");
|
||||||
if(Globals.skybox != null && Globals.clientState.playerEntity != null){
|
if(Globals.clientState.skybox != null && Globals.clientState.playerEntity != null){
|
||||||
EntityUtils.getPosition(Globals.skybox).set(EntityUtils.getPosition(Globals.clientState.playerEntity));
|
EntityUtils.getPosition(Globals.clientState.skybox).set(EntityUtils.getPosition(Globals.clientState.playerEntity));
|
||||||
}
|
}
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,10 +54,10 @@ public class EquipmentInventoryPanel {
|
|||||||
|
|
||||||
div.setOnDragRelease(new DragEventCallback() {public boolean execute(DragEvent event){
|
div.setOnDragRelease(new DragEventCallback() {public boolean execute(DragEvent event){
|
||||||
LoggerInterface.loggerUI.INFO("Character inventory received drag release event");
|
LoggerInterface.loggerUI.INFO("Character inventory received drag release event");
|
||||||
if(Globals.draggedItem != null){
|
if(Globals.clientState.draggedItem != null){
|
||||||
//play sound effect
|
//play sound effect
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.draggedItem));
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.clientState.draggedItem));
|
||||||
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
||||||
} else {
|
} else {
|
||||||
@ -65,8 +65,8 @@ public class EquipmentInventoryPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//null out global state
|
//null out global state
|
||||||
Globals.dragSourceInventory = null;
|
Globals.clientState.dragSourceInventory = null;
|
||||||
Globals.draggedItem = null;
|
Globals.clientState.draggedItem = null;
|
||||||
//clear item container ui
|
//clear item container ui
|
||||||
WindowUtils.cleanItemDraggingWindow();
|
WindowUtils.cleanItemDraggingWindow();
|
||||||
//re-render inventory
|
//re-render inventory
|
||||||
@ -107,13 +107,13 @@ public class EquipmentInventoryPanel {
|
|||||||
Entity currentItem = null;
|
Entity currentItem = null;
|
||||||
equipPoint = inventory.getEquipPointFromSlot(slotId);
|
equipPoint = inventory.getEquipPointFromSlot(slotId);
|
||||||
if(!equipPoint.isCombinedPoint() && !equipPoint.isToolbarSlot()){
|
if(!equipPoint.isCombinedPoint() && !equipPoint.isToolbarSlot()){
|
||||||
if(inventory.getItemSlot(slotId) != null && inventory.getItemSlot(slotId) != Globals.draggedItem){
|
if(inventory.getItemSlot(slotId) != null && inventory.getItemSlot(slotId) != Globals.clientState.draggedItem){
|
||||||
currentItem = inventory.getItemSlot(slotId);
|
currentItem = inventory.getItemSlot(slotId);
|
||||||
//get texture path from item
|
//get texture path from item
|
||||||
texturePath = ItemUtils.getItemIcon(currentItem);
|
texturePath = ItemUtils.getItemIcon(currentItem);
|
||||||
//flag that this isn't an empty slot
|
//flag that this isn't an empty slot
|
||||||
hasItem = true;
|
hasItem = true;
|
||||||
} else if(inventory.getCombinedPoint(slotId) != null && inventory.hasItemInSlot(inventory.getCombinedPoint(slotId).getEquipPointId()) && inventory.getItemSlot(inventory.getCombinedPoint(slotId).getEquipPointId()) != Globals.draggedItem){
|
} else if(inventory.getCombinedPoint(slotId) != null && inventory.hasItemInSlot(inventory.getCombinedPoint(slotId).getEquipPointId()) && inventory.getItemSlot(inventory.getCombinedPoint(slotId).getEquipPointId()) != Globals.clientState.draggedItem){
|
||||||
currentItem = inventory.getItemSlot(inventory.getCombinedPoint(slotId).getEquipPointId());
|
currentItem = inventory.getItemSlot(inventory.getCombinedPoint(slotId).getEquipPointId());
|
||||||
//get texture path from item
|
//get texture path from item
|
||||||
texturePath = ItemUtils.getItemIcon(currentItem);
|
texturePath = ItemUtils.getItemIcon(currentItem);
|
||||||
@ -144,8 +144,8 @@ public class EquipmentInventoryPanel {
|
|||||||
panel.setOnDragStart(new DragEventCallback() {
|
panel.setOnDragStart(new DragEventCallback() {
|
||||||
public boolean execute(DragEvent event){
|
public boolean execute(DragEvent event){
|
||||||
LoggerInterface.loggerUI.DEBUG("Drag start");
|
LoggerInterface.loggerUI.DEBUG("Drag start");
|
||||||
Globals.dragSourceInventory = inventory;
|
Globals.clientState.dragSourceInventory = inventory;
|
||||||
Globals.draggedItem = inventory.getItemSlot(finalSlotId);
|
Globals.clientState.draggedItem = inventory.getItemSlot(finalSlotId);
|
||||||
ContainerElement container = (ContainerElement)panel.getParent();
|
ContainerElement container = (ContainerElement)panel.getParent();
|
||||||
container.removeChild(panel);
|
container.removeChild(panel);
|
||||||
WindowUtils.pushItemIconToItemWindow(panel);
|
WindowUtils.pushItemIconToItemWindow(panel);
|
||||||
@ -184,12 +184,12 @@ public class EquipmentInventoryPanel {
|
|||||||
} else {
|
} else {
|
||||||
int itemId = i;
|
int itemId = i;
|
||||||
panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){
|
panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){
|
||||||
if(Globals.dragSourceInventory instanceof RelationalInventoryState){
|
if(Globals.clientState.dragSourceInventory instanceof RelationalInventoryState){
|
||||||
if(Globals.dragSourceInventory == InventoryUtils.getToolbarInventory(entity)){
|
if(Globals.clientState.dragSourceInventory == InventoryUtils.getToolbarInventory(entity)){
|
||||||
if(inventory.canEquipItemToSlot(Globals.draggedItem, slots.get(itemId))){
|
if(inventory.canEquipItemToSlot(Globals.clientState.draggedItem, slots.get(itemId))){
|
||||||
//fire equip event to equip state
|
//fire equip event to equip state
|
||||||
ClientEquipState equipState = ClientEquipState.getEquipState(Globals.clientState.playerEntity);
|
ClientEquipState equipState = ClientEquipState.getEquipState(Globals.clientState.playerEntity);
|
||||||
equipState.commandAttemptEquip(Globals.draggedItem,inventory.getEquipPointFromSlot(slots.get(itemId)));
|
equipState.commandAttemptEquip(Globals.clientState.draggedItem,inventory.getEquipPointFromSlot(slots.get(itemId)));
|
||||||
//play sound effect
|
//play sound effect
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(finalEnt));
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(finalEnt));
|
||||||
@ -199,20 +199,20 @@ public class EquipmentInventoryPanel {
|
|||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(inventory.canEquipItemToCombinedSlot(Globals.draggedItem, slots.get(itemId))){
|
} else if(inventory.canEquipItemToCombinedSlot(Globals.clientState.draggedItem, slots.get(itemId))){
|
||||||
EquipPoint combinedPoint = inventory.getCombinedPoint(slots.get(itemId));
|
EquipPoint combinedPoint = inventory.getCombinedPoint(slots.get(itemId));
|
||||||
//fire equip event to equip state
|
//fire equip event to equip state
|
||||||
ClientEquipState equipState = ClientEquipState.getEquipState(Globals.clientState.playerEntity);
|
ClientEquipState equipState = ClientEquipState.getEquipState(Globals.clientState.playerEntity);
|
||||||
equipState.commandAttemptEquip(Globals.draggedItem,combinedPoint);
|
equipState.commandAttemptEquip(Globals.clientState.draggedItem,combinedPoint);
|
||||||
}
|
}
|
||||||
} else if(ItemUtils.getContainingParent(Globals.draggedItem) != Globals.clientState.playerEntity){
|
} else if(ItemUtils.getContainingParent(Globals.clientState.draggedItem) != Globals.clientState.playerEntity){
|
||||||
throw new UnsupportedOperationException("Unimplemented!");
|
throw new UnsupportedOperationException("Unimplemented!");
|
||||||
}
|
}
|
||||||
} else if(Globals.dragSourceInventory instanceof UnrelationalInventoryState){
|
} else if(Globals.clientState.dragSourceInventory instanceof UnrelationalInventoryState){
|
||||||
if(inventory.canEquipItemToSlot(Globals.draggedItem, slots.get(itemId))){
|
if(inventory.canEquipItemToSlot(Globals.clientState.draggedItem, slots.get(itemId))){
|
||||||
//fire equip event to equip state
|
//fire equip event to equip state
|
||||||
ClientEquipState equipState = ClientEquipState.getEquipState(Globals.clientState.playerEntity);
|
ClientEquipState equipState = ClientEquipState.getEquipState(Globals.clientState.playerEntity);
|
||||||
equipState.commandAttemptEquip(Globals.draggedItem,inventory.getEquipPointFromSlot(slots.get(itemId)));
|
equipState.commandAttemptEquip(Globals.clientState.draggedItem,inventory.getEquipPointFromSlot(slots.get(itemId)));
|
||||||
//play sound effect
|
//play sound effect
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(finalEnt));
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(finalEnt));
|
||||||
@ -222,16 +222,16 @@ public class EquipmentInventoryPanel {
|
|||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(inventory.canEquipItemToCombinedSlot(Globals.draggedItem, slots.get(itemId))){
|
} else if(inventory.canEquipItemToCombinedSlot(Globals.clientState.draggedItem, slots.get(itemId))){
|
||||||
EquipPoint combinedPoint = inventory.getCombinedPoint(slots.get(itemId));
|
EquipPoint combinedPoint = inventory.getCombinedPoint(slots.get(itemId));
|
||||||
//fire equip event to equip state
|
//fire equip event to equip state
|
||||||
ClientEquipState equipState = ClientEquipState.getEquipState(Globals.clientState.playerEntity);
|
ClientEquipState equipState = ClientEquipState.getEquipState(Globals.clientState.playerEntity);
|
||||||
equipState.commandAttemptEquip(Globals.draggedItem,combinedPoint);
|
equipState.commandAttemptEquip(Globals.clientState.draggedItem,combinedPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//play sound effect
|
//play sound effect
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.draggedItem));
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.clientState.draggedItem));
|
||||||
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
||||||
} else {
|
} else {
|
||||||
@ -239,8 +239,8 @@ public class EquipmentInventoryPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//update ui
|
//update ui
|
||||||
Globals.dragSourceInventory = null;
|
Globals.clientState.dragSourceInventory = null;
|
||||||
Globals.draggedItem = null;
|
Globals.clientState.draggedItem = null;
|
||||||
//clear item container ui
|
//clear item container ui
|
||||||
WindowUtils.cleanItemDraggingWindow();
|
WindowUtils.cleanItemDraggingWindow();
|
||||||
//rerender inventories
|
//rerender inventories
|
||||||
|
|||||||
@ -71,11 +71,11 @@ public class ItemIconPanel {
|
|||||||
panel.setOnDragStart(new DragEventCallback() {public boolean execute(DragEvent event){
|
panel.setOnDragStart(new DragEventCallback() {public boolean execute(DragEvent event){
|
||||||
ItemIconPanel.dragStartContainer = panel.getParent();
|
ItemIconPanel.dragStartContainer = panel.getParent();
|
||||||
// System.out.println("Drag start");
|
// System.out.println("Drag start");
|
||||||
Globals.dragSourceInventory = inventory;
|
Globals.clientState.dragSourceInventory = inventory;
|
||||||
if(inventory instanceof RelationalInventoryState){
|
if(inventory instanceof RelationalInventoryState){
|
||||||
Globals.draggedItem = ((RelationalInventoryState)inventory).getItemSlot("" + itemId);
|
Globals.clientState.draggedItem = ((RelationalInventoryState)inventory).getItemSlot("" + itemId);
|
||||||
} else {
|
} else {
|
||||||
Globals.draggedItem = ((UnrelationalInventoryState)inventory).getItems().get(itemId);
|
Globals.clientState.draggedItem = ((UnrelationalInventoryState)inventory).getItems().get(itemId);
|
||||||
}
|
}
|
||||||
ContainerElement container = (ContainerElement)panel.getParent();
|
ContainerElement container = (ContainerElement)panel.getParent();
|
||||||
container.removeChild(panel);
|
container.removeChild(panel);
|
||||||
@ -115,7 +115,7 @@ public class ItemIconPanel {
|
|||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
panel.setOnHoverCallback(new HoverEventCallback() {public boolean execute(HoverEvent event){
|
panel.setOnHoverCallback(new HoverEventCallback() {public boolean execute(HoverEvent event){
|
||||||
if(event.isHovered() && Globals.draggedItem == null){
|
if(event.isHovered() && Globals.clientState.draggedItem == null){
|
||||||
if(itemTooltip != null){
|
if(itemTooltip != null){
|
||||||
Tooltip.destroy(itemTooltip);
|
Tooltip.destroy(itemTooltip);
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ public class ItemIconPanel {
|
|||||||
panel.setAbsolutePosition(false);
|
panel.setAbsolutePosition(false);
|
||||||
panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){
|
panel.setOnDragRelease(new DragEventCallback(){public boolean execute(DragEvent event){
|
||||||
onReceiveItem.run();
|
onReceiveItem.run();
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.draggedItem));
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.clientState.draggedItem));
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
if(itemData != null && itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
if(itemData != null && itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
||||||
@ -189,8 +189,8 @@ public class ItemIconPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//update ui
|
//update ui
|
||||||
Globals.dragSourceInventory = null;
|
Globals.clientState.dragSourceInventory = null;
|
||||||
Globals.draggedItem = null;
|
Globals.clientState.draggedItem = null;
|
||||||
//clear item container ui
|
//clear item container ui
|
||||||
WindowUtils.cleanItemDraggingWindow();
|
WindowUtils.cleanItemDraggingWindow();
|
||||||
//rerender inventories
|
//rerender inventories
|
||||||
|
|||||||
@ -51,22 +51,22 @@ public class NaturalInventoryPanel {
|
|||||||
|
|
||||||
div.setOnDragRelease(new DragEventCallback() {public boolean execute(DragEvent event){
|
div.setOnDragRelease(new DragEventCallback() {public boolean execute(DragEvent event){
|
||||||
LoggerInterface.loggerUI.INFO("Natural inventory received drag release event");
|
LoggerInterface.loggerUI.INFO("Natural inventory received drag release event");
|
||||||
if(Globals.draggedItem != null){
|
if(Globals.clientState.draggedItem != null){
|
||||||
if(Globals.dragSourceInventory != inventory){
|
if(Globals.clientState.dragSourceInventory != inventory){
|
||||||
if(Globals.dragSourceInventory instanceof RelationalInventoryState){
|
if(Globals.clientState.dragSourceInventory instanceof RelationalInventoryState){
|
||||||
if(ClientEquipState.hasEquipState(entity) && InventoryUtils.hasEquipInventory(entity)){
|
if(ClientEquipState.hasEquipState(entity) && InventoryUtils.hasEquipInventory(entity)){
|
||||||
RelationalInventoryState equipInventory = InventoryUtils.getEquipInventory(entity);
|
RelationalInventoryState equipInventory = InventoryUtils.getEquipInventory(entity);
|
||||||
ClientEquipState equipState = ClientEquipState.getEquipState(entity);
|
ClientEquipState equipState = ClientEquipState.getEquipState(entity);
|
||||||
equipState.commandAttemptUnequip(equipInventory.getItemSlot(Globals.draggedItem));
|
equipState.commandAttemptUnequip(equipInventory.getItemSlot(Globals.clientState.draggedItem));
|
||||||
}
|
}
|
||||||
} if(Globals.dragSourceInventory instanceof UnrelationalInventoryState){
|
} if(Globals.clientState.dragSourceInventory instanceof UnrelationalInventoryState){
|
||||||
//transfer item
|
//transfer item
|
||||||
// sourceInventory.removeItem(Globals.draggedItem);
|
// sourceInventory.removeItem(Globals.draggedItem);
|
||||||
// inventory.addItem(Globals.draggedItem);
|
// inventory.addItem(Globals.draggedItem);
|
||||||
// //null out global state
|
// //null out global state
|
||||||
// Globals.dragSourceInventory = null;
|
// Globals.dragSourceInventory = null;
|
||||||
// Globals.draggedItem = null;
|
// Globals.draggedItem = null;
|
||||||
Entity item = Globals.draggedItem;
|
Entity item = Globals.clientState.draggedItem;
|
||||||
if(ClientEquipState.hasEquipState(entity) && InventoryUtils.hasEquipInventory(entity)){
|
if(ClientEquipState.hasEquipState(entity) && InventoryUtils.hasEquipInventory(entity)){
|
||||||
RelationalInventoryState equipInventory = InventoryUtils.getEquipInventory(entity);
|
RelationalInventoryState equipInventory = InventoryUtils.getEquipInventory(entity);
|
||||||
ClientEquipState equipState = ClientEquipState.getEquipState(entity);
|
ClientEquipState equipState = ClientEquipState.getEquipState(entity);
|
||||||
@ -81,7 +81,7 @@ public class NaturalInventoryPanel {
|
|||||||
}
|
}
|
||||||
//play sound effect
|
//play sound effect
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.draggedItem));
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.clientState.draggedItem));
|
||||||
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
||||||
} else {
|
} else {
|
||||||
@ -116,7 +116,7 @@ public class NaturalInventoryPanel {
|
|||||||
String texturePath = "Textures/ui/uiFrame1.png";
|
String texturePath = "Textures/ui/uiFrame1.png";
|
||||||
boolean hasItem = false;
|
boolean hasItem = false;
|
||||||
Entity currentItem = null;
|
Entity currentItem = null;
|
||||||
if(i < inventory.getItems().size() && inventory.getItems().get(i) != Globals.draggedItem){
|
if(i < inventory.getItems().size() && inventory.getItems().get(i) != Globals.clientState.draggedItem){
|
||||||
currentItem = inventory.getItems().get(i);
|
currentItem = inventory.getItems().get(i);
|
||||||
//get texture path from item
|
//get texture path from item
|
||||||
texturePath = ItemUtils.getItemIcon(currentItem);
|
texturePath = ItemUtils.getItemIcon(currentItem);
|
||||||
@ -129,16 +129,16 @@ public class NaturalInventoryPanel {
|
|||||||
|
|
||||||
//create the actual item panel
|
//create the actual item panel
|
||||||
Div panel = null;
|
Div panel = null;
|
||||||
if(hasItem == true && inventory.getItems().get(i) != Globals.draggedItem){
|
if(hasItem == true && inventory.getItems().get(i) != Globals.clientState.draggedItem){
|
||||||
panel = ItemIconPanel.createPanel(currentItem, i, inventory);
|
panel = ItemIconPanel.createPanel(currentItem, i, inventory);
|
||||||
} else {
|
} else {
|
||||||
panel = ItemIconPanel.createEmptyItemPanel(() -> {
|
panel = ItemIconPanel.createEmptyItemPanel(() -> {
|
||||||
if(Globals.draggedItem != null){
|
if(Globals.clientState.draggedItem != null){
|
||||||
NetworkMessage requestPickupMessage = InventoryMessage.constructclientRequestStoreItemMessage(
|
NetworkMessage requestPickupMessage = InventoryMessage.constructclientRequestStoreItemMessage(
|
||||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(entity.getId()),
|
Globals.clientState.clientSceneWrapper.mapClientToServerId(entity.getId()),
|
||||||
InventoryProtocol.INVENTORY_TYPE_NATURAL,
|
InventoryProtocol.INVENTORY_TYPE_NATURAL,
|
||||||
0 + "",
|
0 + "",
|
||||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.draggedItem.getId())
|
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.clientState.draggedItem.getId())
|
||||||
);
|
);
|
||||||
Globals.clientState.clientConnection.queueOutgoingMessage(requestPickupMessage);
|
Globals.clientState.clientConnection.queueOutgoingMessage(requestPickupMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,22 +61,22 @@ public class ToolbarInventoryPanel {
|
|||||||
|
|
||||||
div.setOnDragRelease(new DragEventCallback() {public boolean execute(DragEvent event){
|
div.setOnDragRelease(new DragEventCallback() {public boolean execute(DragEvent event){
|
||||||
LoggerInterface.loggerUI.INFO("Toolbar inventory received drag release event");
|
LoggerInterface.loggerUI.INFO("Toolbar inventory received drag release event");
|
||||||
if(Globals.draggedItem != null){
|
if(Globals.clientState.draggedItem != null){
|
||||||
if(Globals.dragSourceInventory != inventory){
|
if(Globals.clientState.dragSourceInventory != inventory){
|
||||||
if(Globals.dragSourceInventory instanceof RelationalInventoryState){
|
if(Globals.clientState.dragSourceInventory instanceof RelationalInventoryState){
|
||||||
if(ClientEquipState.hasEquipState(entity) && InventoryUtils.hasEquipInventory(entity)){
|
if(ClientEquipState.hasEquipState(entity) && InventoryUtils.hasEquipInventory(entity)){
|
||||||
RelationalInventoryState equipInventory = InventoryUtils.getEquipInventory(entity);
|
RelationalInventoryState equipInventory = InventoryUtils.getEquipInventory(entity);
|
||||||
ClientEquipState equipState = ClientEquipState.getEquipState(entity);
|
ClientEquipState equipState = ClientEquipState.getEquipState(entity);
|
||||||
equipState.commandAttemptUnequip(equipInventory.getItemSlot(Globals.draggedItem));
|
equipState.commandAttemptUnequip(equipInventory.getItemSlot(Globals.clientState.draggedItem));
|
||||||
}
|
}
|
||||||
} if(Globals.dragSourceInventory instanceof UnrelationalInventoryState){
|
} if(Globals.clientState.dragSourceInventory instanceof UnrelationalInventoryState){
|
||||||
//transfer item
|
//transfer item
|
||||||
// sourceInventory.removeItem(Globals.draggedItem);
|
// sourceInventory.removeItem(Globals.draggedItem);
|
||||||
// inventory.addItem(Globals.draggedItem);
|
// inventory.addItem(Globals.draggedItem);
|
||||||
// //null out global state
|
// //null out global state
|
||||||
// Globals.dragSourceInventory = null;
|
// Globals.dragSourceInventory = null;
|
||||||
// Globals.draggedItem = null;
|
// Globals.draggedItem = null;
|
||||||
Entity item = Globals.draggedItem;
|
Entity item = Globals.clientState.draggedItem;
|
||||||
if(ClientEquipState.hasEquipState(entity) && InventoryUtils.hasEquipInventory(entity)){
|
if(ClientEquipState.hasEquipState(entity) && InventoryUtils.hasEquipInventory(entity)){
|
||||||
RelationalInventoryState equipInventory = InventoryUtils.getEquipInventory(entity);
|
RelationalInventoryState equipInventory = InventoryUtils.getEquipInventory(entity);
|
||||||
ClientEquipState equipState = ClientEquipState.getEquipState(entity);
|
ClientEquipState equipState = ClientEquipState.getEquipState(entity);
|
||||||
@ -91,7 +91,7 @@ public class ToolbarInventoryPanel {
|
|||||||
}
|
}
|
||||||
//play sound effect
|
//play sound effect
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.draggedItem));
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.clientState.draggedItem));
|
||||||
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
||||||
} else {
|
} else {
|
||||||
@ -127,7 +127,7 @@ public class ToolbarInventoryPanel {
|
|||||||
String texturePath = "Textures/ui/uiFrame1.png";
|
String texturePath = "Textures/ui/uiFrame1.png";
|
||||||
boolean hasItem = false;
|
boolean hasItem = false;
|
||||||
Entity currentItem = null;
|
Entity currentItem = null;
|
||||||
if(inventory.getItemSlot("" + i) != Globals.draggedItem && inventory.getItemSlot("" + i) != null){
|
if(inventory.getItemSlot("" + i) != Globals.clientState.draggedItem && inventory.getItemSlot("" + i) != null){
|
||||||
currentItem = inventory.getItemSlot("" + i);
|
currentItem = inventory.getItemSlot("" + i);
|
||||||
//get texture path from item
|
//get texture path from item
|
||||||
texturePath = ItemUtils.getItemIcon(currentItem);
|
texturePath = ItemUtils.getItemIcon(currentItem);
|
||||||
@ -140,7 +140,7 @@ public class ToolbarInventoryPanel {
|
|||||||
|
|
||||||
//create the actual item panel
|
//create the actual item panel
|
||||||
Div panel = null;
|
Div panel = null;
|
||||||
if(hasItem == true && inventory.getItemSlot("" + i) != Globals.draggedItem){
|
if(hasItem == true && inventory.getItemSlot("" + i) != Globals.clientState.draggedItem){
|
||||||
panel = ItemIconPanel.createPanel(currentItem, i, inventory);
|
panel = ItemIconPanel.createPanel(currentItem, i, inventory);
|
||||||
} else {
|
} else {
|
||||||
int slotId = i;
|
int slotId = i;
|
||||||
@ -149,7 +149,7 @@ public class ToolbarInventoryPanel {
|
|||||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(entity.getId()),
|
Globals.clientState.clientSceneWrapper.mapClientToServerId(entity.getId()),
|
||||||
InventoryProtocol.INVENTORY_TYPE_TOOLBAR,
|
InventoryProtocol.INVENTORY_TYPE_TOOLBAR,
|
||||||
slotId + "",
|
slotId + "",
|
||||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.draggedItem.getId())
|
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.clientState.draggedItem.getId())
|
||||||
);
|
);
|
||||||
Globals.clientState.clientConnection.queueOutgoingMessage(requestPickupMessage);
|
Globals.clientState.clientConnection.queueOutgoingMessage(requestPickupMessage);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -199,10 +199,10 @@ public class WindowUtils {
|
|||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.clientState.playerEntity));
|
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.clientState.playerEntity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Globals.targetContainer != null){
|
if(Globals.clientState.targetContainer != null){
|
||||||
if(Globals.elementService.containsWindow(WindowStrings.WINDOW_INVENTORY_TARGET)){
|
if(Globals.elementService.containsWindow(WindowStrings.WINDOW_INVENTORY_TARGET)){
|
||||||
//redraw if necessary
|
//redraw if necessary
|
||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_INVENTORY_TARGET, InventoryMainWindow.createInventoryWindow(Globals.targetContainer));
|
WindowUtils.replaceWindow(WindowStrings.WINDOW_INVENTORY_TARGET, InventoryMainWindow.createInventoryWindow(Globals.clientState.targetContainer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,10 +57,10 @@ public class CraftingWindow {
|
|||||||
rVal.addChild(CraftingPanel.createCraftingPanelComponent(
|
rVal.addChild(CraftingPanel.createCraftingPanelComponent(
|
||||||
data,
|
data,
|
||||||
(RecipeData recipe) -> {
|
(RecipeData recipe) -> {
|
||||||
if(Globals.interactionTarget != null){
|
if(Globals.clientState.interactionTarget != null){
|
||||||
Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestCraftMessage(
|
Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestCraftMessage(
|
||||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.clientState.playerEntity.getId()),
|
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.clientState.playerEntity.getId()),
|
||||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.interactionTarget.getId()),
|
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.clientState.interactionTarget.getId()),
|
||||||
recipe.getId()
|
recipe.getId()
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public class InventoryMainWindow {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(Globals.elementService.getWindow(WindowStrings.WINDOW_INVENTORY_TARGET) == null){
|
if(Globals.elementService.getWindow(WindowStrings.WINDOW_INVENTORY_TARGET) == null){
|
||||||
Globals.targetContainer = entity;
|
Globals.clientState.targetContainer = entity;
|
||||||
//create window
|
//create window
|
||||||
Window mainMenuWindow = InventoryMainWindow.createInventoryWindow(entity);
|
Window mainMenuWindow = InventoryMainWindow.createInventoryWindow(entity);
|
||||||
//register
|
//register
|
||||||
@ -124,7 +124,7 @@ public class InventoryMainWindow {
|
|||||||
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(windowString), false);
|
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(windowString), false);
|
||||||
Globals.elementService.unregisterWindow(windowString);
|
Globals.elementService.unregisterWindow(windowString);
|
||||||
if(windowString.equals(WindowStrings.WINDOW_INVENTORY_TARGET)){
|
if(windowString.equals(WindowStrings.WINDOW_INVENTORY_TARGET)){
|
||||||
Globals.targetContainer = null;
|
Globals.clientState.targetContainer = null;
|
||||||
}
|
}
|
||||||
if(Globals.cameraHandler.getTrackPlayerEntity()){
|
if(Globals.cameraHandler.getTrackPlayerEntity()){
|
||||||
Globals.controlHandler.hintUpdateControlState(ControlsState.MAIN_GAME);
|
Globals.controlHandler.hintUpdateControlState(ControlsState.MAIN_GAME);
|
||||||
|
|||||||
@ -23,12 +23,12 @@ public class MenuGeneratorsInventory {
|
|||||||
Div div = Div.createDiv();
|
Div div = Div.createDiv();
|
||||||
div.setOnDragRelease(new DragEventCallback() {public boolean execute(DragEvent event){
|
div.setOnDragRelease(new DragEventCallback() {public boolean execute(DragEvent event){
|
||||||
LoggerInterface.loggerUI.INFO("World item drop capture window received drag release");
|
LoggerInterface.loggerUI.INFO("World item drop capture window received drag release");
|
||||||
if(Globals.draggedItem != null){
|
if(Globals.clientState.draggedItem != null){
|
||||||
//drop item
|
//drop item
|
||||||
ClientInventoryState.clientAttemptEjectItem(Globals.clientState.playerEntity,Globals.draggedItem);
|
ClientInventoryState.clientAttemptEjectItem(Globals.clientState.playerEntity,Globals.clientState.draggedItem);
|
||||||
//play sound effect
|
//play sound effect
|
||||||
if(Globals.virtualAudioSourceManager != null){
|
if(Globals.virtualAudioSourceManager != null){
|
||||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.draggedItem));
|
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(Globals.clientState.draggedItem));
|
||||||
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIReleaseAudio(), VirtualAudioSourceType.UI, false);
|
||||||
} else {
|
} else {
|
||||||
@ -40,8 +40,8 @@ public class MenuGeneratorsInventory {
|
|||||||
//re-render inventory
|
//re-render inventory
|
||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.clientState.playerEntity));
|
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, InventoryMainWindow.createInventoryWindow(Globals.clientState.playerEntity));
|
||||||
//null globals
|
//null globals
|
||||||
Globals.dragSourceInventory = null;
|
Globals.clientState.dragSourceInventory = null;
|
||||||
Globals.draggedItem = null;
|
Globals.clientState.draggedItem = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -726,7 +726,7 @@ public class ControlCategoryMainGame {
|
|||||||
mainGameControlList.add(controlMap.get(OPEN_CRAFTING));
|
mainGameControlList.add(controlMap.get(OPEN_CRAFTING));
|
||||||
inventoryControlList.add(controlMap.get(OPEN_CRAFTING));
|
inventoryControlList.add(controlMap.get(OPEN_CRAFTING));
|
||||||
controlMap.get(OPEN_CRAFTING).setOnClick(new ControlMethod(){public void execute(MouseState mouseState){
|
controlMap.get(OPEN_CRAFTING).setOnClick(new ControlMethod(){public void execute(MouseState mouseState){
|
||||||
Globals.interactionTarget = null;
|
Globals.clientState.interactionTarget = null;
|
||||||
WindowUtils.openInteractionMenu(WindowStrings.CRAFTING, CraftingWindow.HAND_CRAFTING_DATA);
|
WindowUtils.openInteractionMenu(WindowStrings.CRAFTING, CraftingWindow.HAND_CRAFTING_DATA);
|
||||||
}});
|
}});
|
||||||
controlMap.get(OPEN_CRAFTING).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
controlMap.get(OPEN_CRAFTING).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||||
|
|||||||
@ -38,7 +38,6 @@ import electrosphere.engine.signal.SignalSystem;
|
|||||||
import electrosphere.engine.signal.sync.MainThreadSignalService;
|
import electrosphere.engine.signal.sync.MainThreadSignalService;
|
||||||
import electrosphere.engine.threads.ThreadManager;
|
import electrosphere.engine.threads.ThreadManager;
|
||||||
import electrosphere.engine.time.Timekeeper;
|
import electrosphere.engine.time.Timekeeper;
|
||||||
import electrosphere.entity.Entity;
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.net.config.NetConfig;
|
import electrosphere.net.config.NetConfig;
|
||||||
import electrosphere.net.monitor.NetMonitor;
|
import electrosphere.net.monitor.NetMonitor;
|
||||||
@ -345,23 +344,10 @@ public class Globals {
|
|||||||
//collision world data
|
//collision world data
|
||||||
public static CollisionWorldData commonWorldData;
|
public static CollisionWorldData commonWorldData;
|
||||||
|
|
||||||
/**
|
|
||||||
* The target of the interaction
|
|
||||||
*/
|
|
||||||
public static Entity interactionTarget = null;
|
|
||||||
|
|
||||||
//skybox entity
|
|
||||||
public static Entity skybox;
|
|
||||||
|
|
||||||
|
|
||||||
//ai manager
|
//ai manager
|
||||||
public static AIManager aiManager;
|
public static AIManager aiManager;
|
||||||
|
|
||||||
//drag item state
|
|
||||||
public static Entity draggedItem = null;
|
|
||||||
public static Object dragSourceInventory = null;
|
|
||||||
public static Entity targetContainer = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State for the client
|
* State for the client
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user