voxel selection item
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-09-20 20:59:23 -04:00
parent e0a73fc057
commit ccaaa47127
33 changed files with 272 additions and 31 deletions

View File

@ -97,6 +97,9 @@
"offset": [0, 0, 0.15] "offset": [0, 0, 0.15]
} }
] ]
},
"itemBlockData": {
}, },
"equipData": { "equipData": {
"equipClass" : "weapon2H" "equipClass" : "weapon2H"
@ -313,6 +316,33 @@
"offsetZ" : 0 "offsetZ" : 0
}, },
"iconPath" : "Textures/icons/itemIconItemGeneric.png" "iconPath" : "Textures/icons/itemIconItemGeneric.png"
},
{
"id" : "terrainTool",
"modelPath": "Models/basic/geometry/unitvector.glb",
"tokens" : [
"GRAVITY",
"TARGETABLE"
],
"equipData": {
"equipClass" : "tool"
},
"clientSidePrimary": "OPEN_VOXEL",
"collidable": {
"type" : "CUBE",
"dimension1" : 0.1,
"dimension2" : 0.1,
"dimension3" : 0.35,
"rotX": 0,
"rotY": 0,
"rotZ": 0,
"rotW": 1,
"offsetX" : 0,
"offsetY" : 0.05,
"offsetZ" : 0
},
"iconPath" : "Textures/icons/itemIconItemGeneric.png"
} }

View File

@ -24,6 +24,16 @@
"itemId" : "Katana2H" "itemId" : "Katana2H"
} }
] ]
},
{
"id" : "skeletonSwordsman",
"creatureId" : "skeleton",
"equipment" : [
{
"pointId" : "handsCombined",
"itemId" : "Katana2H"
}
]
} }
] ]
} }

View File

@ -29,6 +29,11 @@ Progress on the human creature
- [ ] CrouchStrafeLeft - [ ] CrouchStrafeLeft
- [ ] CrouchStrafeRight - [ ] CrouchStrafeRight
- [ ] CrouchJump - [ ] CrouchJump
- [ ] ClimbIdle
- [ ] ClimbUp
- [ ] ClimbLeft
- [ ] ClimbDown
- [ ] ClimbRight
- [X] Sit (Ground) - [X] Sit (Ground)
- [ ] Sit (Chair) - [ ] Sit (Chair)
- [X] HoldItemRH - [X] HoldItemRH

View File

@ -29,6 +29,11 @@ Progress on the skeleton creature
- [ ] CrouchStrafeLeft - [ ] CrouchStrafeLeft
- [ ] CrouchStrafeRight - [ ] CrouchStrafeRight
- [ ] CrouchJump - [ ] CrouchJump
- [ ] ClimbIdle
- [ ] ClimbUp
- [ ] ClimbLeft
- [ ] ClimbDown
- [ ] ClimbRight
- [X] Sit (Ground) - [X] Sit (Ground)
- [ ] Sit (Chair) - [ ] Sit (Chair)
- [X] HoldItemRH - [X] HoldItemRH

View File

@ -35,9 +35,13 @@
- Spawn player in a town with a quest to complete a nearby dungeon - Spawn player in a town with a quest to complete a nearby dungeon
+ bug fixes + bug fixes
Fix ui audio playing at world origin
Fix light cluster mapping for foliage shader Fix light cluster mapping for foliage shader
Fix lights not being deleted
- Not sending a "light count" var to light calculations, so the data stays in buffer even though it is not being updated
Fix ui elements not storing default discrete world size on level editor menu Fix ui elements not storing default discrete world size on level editor menu
Fix static friction coeff causing player to slide on shallow slopes Fix static friction coeff causing player to slide on shallow slopes
- Probably need to look into using capsules
Fix skeleton right strafe Fix skeleton right strafe
Fix block tree preventing initiating an attack Fix block tree preventing initiating an attack
Fix return to title menu synchronization bug Fix return to title menu synchronization bug

View File

@ -818,6 +818,10 @@ Point light offsets
(09/20/2024) (09/20/2024)
Light manager buffer overflow bugfix Light manager buffer overflow bugfix
Particle Emitter data definitions
Torch w/ particle + lighting
Fix text input collapsing while typing
Voxel selection item
# TODO # TODO
@ -836,7 +840,6 @@ Bug Fixes
- Fix typescript load error - Fix typescript load error
- Calculate bounding sphere for meshes by deforming vertices with bone default pose instead of no bone deform - Calculate bounding sphere for meshes by deforming vertices with bone default pose instead of no bone deform
- Fix character creation menu - Fix character creation menu
- Fix text input collapsing while typing
- Fix threads not synchronizing when returning to main menu (rendering still running when player entity deleted, race condition) - Fix threads not synchronizing when returning to main menu (rendering still running when player entity deleted, race condition)
Startup Performance Startup Performance

View File

@ -11,7 +11,6 @@ import electrosphere.engine.Globals;
import electrosphere.entity.ClientEntityUtils; import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.types.fluid.FluidChunk; import electrosphere.entity.types.fluid.FluidChunk;
import electrosphere.renderer.shader.ShaderProgram; import electrosphere.renderer.shader.ShaderProgram;
import electrosphere.server.terrain.manager.ServerTerrainChunk; import electrosphere.server.terrain.manager.ServerTerrainChunk;
@ -86,7 +85,7 @@ public class FluidCell {
public void destroy(){ public void destroy(){
CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine(); CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine();
collisionEngine.destroyPhysics(modelEntity); collisionEngine.destroyPhysics(modelEntity);
EntityUtils.cleanUpEntity(modelEntity); ClientEntityUtils.destroyEntity(modelEntity);
//destruct model //destruct model
String modelPath = (String)modelEntity.getData(EntityDataStrings.DATA_STRING_MODEL_PATH); String modelPath = (String)modelEntity.getData(EntityDataStrings.DATA_STRING_MODEL_PATH);
Globals.assetManager.deregisterModelPath(modelPath); Globals.assetManager.deregisterModelPath(modelPath);

View File

@ -21,6 +21,7 @@ import org.lwjgl.BufferUtils;
import electrosphere.client.entity.camera.CameraEntityUtils; import electrosphere.client.entity.camera.CameraEntityUtils;
import electrosphere.client.terrain.cache.ChunkData; import electrosphere.client.terrain.cache.ChunkData;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityCreationUtils; import electrosphere.entity.EntityCreationUtils;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
@ -193,7 +194,7 @@ public class FoliageCell {
*/ */
protected void destroy(){ protected void destroy(){
for(Entity entity : containedEntities){ for(Entity entity : containedEntities){
EntityUtils.cleanUpEntity(entity); ClientEntityUtils.destroyEntity(entity);
} }
clearEntities(); clearEntities();
} }

View File

@ -1,6 +1,13 @@
package electrosphere.client.item; package electrosphere.client.item;
import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.client.ui.menu.ingame.MenuGeneratorsTerrainEditing;
import electrosphere.controls.ControlHandler.ControlsState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.game.data.item.type.Item;
import electrosphere.net.parser.net.message.InventoryMessage; import electrosphere.net.parser.net.message.InventoryMessage;
/** /**
@ -26,6 +33,19 @@ public class ItemActions {
//tell the server we want the secondary hand item to START doing something //tell the server we want the secondary hand item to START doing something
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage("handRight", ITEM_ACTION_CODE_SECONDARY, ITEM_ACTION_CODE_STATE_ON)); Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage("handRight", ITEM_ACTION_CODE_SECONDARY, ITEM_ACTION_CODE_STATE_ON));
//TODO: do any immediate client side calculations here (ie start playing an animation until we get response from server) //TODO: do any immediate client side calculations here (ie start playing an animation until we get response from server)
ClientEquipState clientEquipState = ClientEquipState.getClientEquipState(Globals.playerEntity);
Entity rightHandItem = clientEquipState.getEquippedItemAtPoint("handRight");
if(rightHandItem != null && Globals.gameConfigCurrent.getItemMap().getItem(rightHandItem) != null){
Item data = Globals.gameConfigCurrent.getItemMap().getItem(rightHandItem);
if(data.getClientSidePrimary() != null){
switch(data.getClientSidePrimary()){
case "OPEN_VOXEL": {
WindowUtils.replaceWindow(WindowStrings.VOXEL_TYPE_SELECTION,MenuGeneratorsTerrainEditing.createVoxelTypeSelectionPanel());
Globals.controlHandler.hintUpdateControlState(ControlsState.IN_GAME_MAIN_MENU);
} break;
}
}
}
} }
/** /**

View File

@ -9,7 +9,6 @@ import electrosphere.collision.CollisionEngine;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.ClientEntityUtils; import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.types.terrain.TerrainChunk; import electrosphere.entity.types.terrain.TerrainChunk;
import electrosphere.renderer.meshgen.TransvoxelModelGeneration.TransvoxelChunkData; import electrosphere.renderer.meshgen.TransvoxelModelGeneration.TransvoxelChunkData;
@ -98,7 +97,7 @@ public class DrawCell {
public void destroy(){ public void destroy(){
CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine(); CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine();
collisionEngine.destroyPhysics(modelEntity); collisionEngine.destroyPhysics(modelEntity);
EntityUtils.cleanUpEntity(modelEntity); ClientEntityUtils.destroyEntity(modelEntity);
} }

View File

@ -4,6 +4,7 @@ import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.entity.state.inventory.InventoryUtils; import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.types.item.ItemUtils; import electrosphere.entity.types.item.ItemUtils;
import electrosphere.game.data.item.type.Item; import electrosphere.game.data.item.type.Item;
@ -32,7 +33,7 @@ public class MenuGeneratorsInventory {
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 {
Globals.virtualAudioSourceManager.createVirtualAudioSource("/Audio/inventorySlotItem.ogg", VirtualAudioSourceType.UI, false); Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
} }
} }
//clear ui //clear ui

View File

@ -5,6 +5,7 @@ import java.util.function.Consumer;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.controls.ControlHandler.ControlsState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.game.data.voxel.VoxelData; import electrosphere.game.data.voxel.VoxelData;
@ -69,6 +70,7 @@ public class MenuGeneratorsTerrainEditing {
//nav logic //nav logic
terrainEditingSidePanelWindow.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){ terrainEditingSidePanelWindow.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){
WindowUtils.closeWindow(WindowStrings.VOXEL_TYPE_SELECTION); WindowUtils.closeWindow(WindowStrings.VOXEL_TYPE_SELECTION);
Globals.controlHandler.hintUpdateControlState(ControlsState.MAIN_GAME);
MenuGeneratorsLevelEditor.voxelWindowOpen = false; MenuGeneratorsLevelEditor.voxelWindowOpen = false;
return false; return false;
}}); }});

View File

@ -62,6 +62,7 @@ import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_LEFT;
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_RIGHT; import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_RIGHT;
import static org.lwjgl.glfw.GLFW.glfwGetCursorPos; import static org.lwjgl.glfw.GLFW.glfwGetCursorPos;
import static org.lwjgl.glfw.GLFW.glfwSetInputMode; import static org.lwjgl.glfw.GLFW.glfwSetInputMode;
import org.lwjgl.glfw.GLFW;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -324,7 +325,7 @@ public class ControlHandler {
handler.addControl(INPUT_CODE_WALK, new Control(ControlType.KEY,GLFW_KEY_LEFT_ALT,false,"Walk (hold)","Causes the player to walk")); handler.addControl(INPUT_CODE_WALK, new Control(ControlType.KEY,GLFW_KEY_LEFT_ALT,false,"Walk (hold)","Causes the player to walk"));
handler.addControl(INPUT_CODE_INTERACT, new Control(ControlType.KEY,GLFW_KEY_E,false,"Interact","Interacts with whatever is targeted currently")); handler.addControl(INPUT_CODE_INTERACT, new Control(ControlType.KEY,GLFW_KEY_E,false,"Interact","Interacts with whatever is targeted currently"));
handler.addControl(INPUT_CODE_DROP, new Control(ControlType.KEY,GLFW_KEY_Y,false,"Drop","Drops the currently equipped item")); handler.addControl(INPUT_CODE_DROP, new Control(ControlType.KEY,GLFW_KEY_Y,false,"Drop","Drops the currently equipped item"));
handler.addControl(INPUT_CODE_INVENTORY_OPEN, new Control(ControlType.KEY,GLFW_KEY_I,false,"Inventory","Opens the player's inventory")); handler.addControl(INPUT_CODE_INVENTORY_OPEN, new Control(ControlType.KEY,GLFW.GLFW_KEY_TAB,false,"Inventory","Opens the player's inventory"));
handler.addControl(ITEM_SECONDARY, new Control(ControlType.MOUSE_BUTTON,GLFW_MOUSE_BUTTON_RIGHT,false,"Secondary","Uses the secondary equipped item")); handler.addControl(ITEM_SECONDARY, new Control(ControlType.MOUSE_BUTTON,GLFW_MOUSE_BUTTON_RIGHT,false,"Secondary","Uses the secondary equipped item"));
/* /*
@ -856,6 +857,10 @@ public class ControlHandler {
} }
}}); }});
/**
* Item actions
*/
mainGameControlList.add(controls.get(ITEM_SECONDARY)); mainGameControlList.add(controls.get(ITEM_SECONDARY));
controls.get(ITEM_SECONDARY).setOnPress(new ControlMethod() {public void execute() { controls.get(ITEM_SECONDARY).setOnPress(new ControlMethod() {public void execute() {
ItemActions.attemptSecondaryItemAction(); ItemActions.attemptSecondaryItemAction();

View File

@ -174,7 +174,7 @@ public class LoadingUtils {
template.putAttributeValue(attribute.getAttributeId(), attribute.getVariants().get(0).getId()); template.putAttributeValue(attribute.getAttributeId(), attribute.getVariants().get(0).getId());
} }
} }
template.getCreatureEquipData().setSlotItem("handsCombined",new EquippedItem(71, "Katana2H")); template.getCreatureEquipData().setSlotItem("handRight",new EquippedItem(71, "terrainTool"));
//set player character template //set player character template
serverPlayerConnection.setCreatureTemplate(template); serverPlayerConnection.setCreatureTemplate(template);
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage()); Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage());

View File

@ -269,6 +269,7 @@ public class EntityDataStrings {
Inventory in general Inventory in general
*/ */
public static final String NATURAL_INVENTORY = "inventoryNatural"; public static final String NATURAL_INVENTORY = "inventoryNatural";
public static final String INVENTORY_TOOLBAR = "inventoryToolbar";
public static final String CLIENT_INVENTORY_STATE = "clientInventoryState"; public static final String CLIENT_INVENTORY_STATE = "clientInventoryState";
public static final String SERVER_INVENTORY_STATE = "serverInventoryState"; public static final String SERVER_INVENTORY_STATE = "serverInventoryState";

View File

@ -32,7 +32,7 @@ public class EntityUtils {
* Cleans up the entity and deregisters it from all tracking datastructures * Cleans up the entity and deregisters it from all tracking datastructures
* @param e The entity to clean up * @param e The entity to clean up
*/ */
public static void cleanUpEntity(Entity e){ protected static void cleanUpEntity(Entity e){
//remove from client //remove from client
if(Globals.clientSceneWrapper != null){ if(Globals.clientSceneWrapper != null){
Globals.clientSceneWrapper.getScene().deregisterEntity(e); Globals.clientSceneWrapper.getScene().deregisterEntity(e);

View File

@ -8,6 +8,7 @@ import java.util.Map;
import electrosphere.collision.PhysicsEntityUtils; import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityCreationUtils; import electrosphere.entity.EntityCreationUtils;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
@ -350,7 +351,7 @@ public class ClientEquipState implements BehaviorTree {
} else { } else {
//does not depend on the type of creature //does not depend on the type of creature
AttachUtils.clientDetatchEntityFromEntityAtBone(parent, equipped); AttachUtils.clientDetatchEntityFromEntityAtBone(parent, equipped);
EntityUtils.cleanUpEntity(equipped); ClientEntityUtils.destroyEntity(equipped);
} }
//interrupt animation //interrupt animation

View File

@ -418,7 +418,7 @@ public class ServerEquipState implements BehaviorTree {
BlockSystem blockData = blockTree.getBlockSystem(); BlockSystem blockData = blockTree.getBlockSystem();
for(EquipPoint point : pointsThatCanBlock){ for(EquipPoint point : pointsThatCanBlock){
Entity item = getEquippedItemAtPoint(point.getEquipPointId()); Entity item = getEquippedItemAtPoint(point.getEquipPointId());
if(item != null){ if(item != null && Globals.gameConfigCurrent.getItemMap().getItem(item) != null && Globals.gameConfigCurrent.getItemMap().getItem(item).getItemBlockData() != null){
BlockVariant blockVariant = blockData.getVariantForPointWithItem(point.getEquipPointId(),ItemUtils.getEquipClass(item)); BlockVariant blockVariant = blockData.getVariantForPointWithItem(point.getEquipPointId(),ItemUtils.getEquipClass(item));
//TODO: refactor to allow sending more than one variant at a time //TODO: refactor to allow sending more than one variant at a time

View File

@ -4,8 +4,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.types.item.ItemUtils; import electrosphere.entity.types.item.ItemUtils;
@ -85,6 +85,9 @@ public class ClientInventoryState implements BehaviorTree {
equipInventory.removeItemSlot(equipPointId); equipInventory.removeItemSlot(equipPointId);
} }
} break; } break;
case InventoryProtocol.INVENTORY_TYPE_TOOLBAR: {
throw new UnsupportedOperationException("todo");
}
} }
//once we've switched the items around, redraw the inventory to reflect the updated contents //once we've switched the items around, redraw the inventory to reflect the updated contents
WindowUtils.attemptRedrawInventoryWindows(); WindowUtils.attemptRedrawInventoryWindows();
@ -96,7 +99,7 @@ public class ClientInventoryState implements BehaviorTree {
Entity entityInSlot = equipState.getEquippedItemAtPoint(message.getequipPointId()); Entity entityInSlot = equipState.getEquippedItemAtPoint(message.getequipPointId());
equipState.clientTransformUnequipPoint(message.getequipPointId()); equipState.clientTransformUnequipPoint(message.getequipPointId());
//destroy the in-world manifestation of said item //destroy the in-world manifestation of said item
EntityUtils.cleanUpEntity(entityInSlot); ClientEntityUtils.destroyEntity(entityInSlot);
} }
} break; } break;
case CLIENTREQUESTEQUIPITEM: case CLIENTREQUESTEQUIPITEM:

View File

@ -55,6 +55,11 @@ public class InventoryUtils {
return (UnrelationalInventoryState)target.getData(EntityDataStrings.NATURAL_INVENTORY); return (UnrelationalInventoryState)target.getData(EntityDataStrings.NATURAL_INVENTORY);
} }
/**
* Checks if the entity has an equip inventory
* @param target The entity
* @return true if it has an equip inventory, false if it does not
*/
public static boolean hasEquipInventory(Entity target){ public static boolean hasEquipInventory(Entity target){
return target.containsKey(EntityDataStrings.EQUIP_INVENTORY); return target.containsKey(EntityDataStrings.EQUIP_INVENTORY);
} }
@ -80,6 +85,36 @@ public class InventoryUtils {
return (RelationalInventoryState)target.getData(EntityDataStrings.EQUIP_INVENTORY); return (RelationalInventoryState)target.getData(EntityDataStrings.EQUIP_INVENTORY);
} }
/**
* Checks if the entity has a toolbar inventory
* @param target The entity
* @return true if it has a toolbar inventory, false if it does not
*/
public static boolean hasToolbarInventory(Entity target){
return target.containsKey(EntityDataStrings.INVENTORY_TOOLBAR);
}
/**
* Sets the toolbar inventory of the entity
* @param target The target
* @param inventoryState The inventory
*/
public static void setToolbarInventory(Entity target, RelationalInventoryState inventoryState){
target.putData(EntityDataStrings.INVENTORY_TOOLBAR, inventoryState);
}
/**
* Gets the toolbar inventory of the entity
* @param target The entity
* @return The inventory if it exists, null otherwise
*/
public static RelationalInventoryState getToolbarInventory(Entity target){
if(!target.containsKey(EntityDataStrings.INVENTORY_TOOLBAR)){
return null;
}
return (RelationalInventoryState)target.getData(EntityDataStrings.INVENTORY_TOOLBAR);
}
/** /**
* Gets the current inventory state * Gets the current inventory state
* @param target the entity to get inventory state from * @param target the entity to get inventory state from

View File

@ -12,6 +12,11 @@ import electrosphere.logger.LoggerInterface;
public class RelationalInventoryState { public class RelationalInventoryState {
/**
* The size of the toolbar
*/
static final int TOOLBAR_SIZE = 10;
Map<String,Entity> items = new HashMap<String,Entity>(); Map<String,Entity> items = new HashMap<String,Entity>();
Map<String,List<String>> slotWhitelists = new HashMap<String,List<String>>(); Map<String,List<String>> slotWhitelists = new HashMap<String,List<String>>();
Map<String,EquipPoint> equipPoints = new HashMap<String,EquipPoint>(); Map<String,EquipPoint> equipPoints = new HashMap<String,EquipPoint>();
@ -24,6 +29,11 @@ public class RelationalInventoryState {
// return rVal; // return rVal;
// } // }
/**
* Builds a relational inventory state based on a list of equip points
* @param points The equip points
* @return The relational inventory state
*/
public static RelationalInventoryState buildRelationalInventoryStateFromEquipList(List<EquipPoint> points){ public static RelationalInventoryState buildRelationalInventoryStateFromEquipList(List<EquipPoint> points){
RelationalInventoryState rVal = new RelationalInventoryState(); RelationalInventoryState rVal = new RelationalInventoryState();
for(EquipPoint point : points){ for(EquipPoint point : points){
@ -34,16 +44,44 @@ public class RelationalInventoryState {
return rVal; return rVal;
} }
/**
* Builds a relational inventory state based on a list of equip points
* @param points The equip points
* @return The relational inventory state
*/
public static RelationalInventoryState buildToolbarInventory(){
RelationalInventoryState rVal = new RelationalInventoryState();
for(int i = 0; i < TOOLBAR_SIZE; i ++){
rVal.items.put("" + i,null);
}
return rVal;
}
/**
* Adds an item to the relational inventory state
* @param slot The slot to add to
* @param item The item
*/
public void addItem(String slot, Entity item){ public void addItem(String slot, Entity item){
items.put(slot,item); items.put(slot,item);
} }
/**
* Removes the item from a slot in the inventory
* @param slot The slot
* @return The item that was removed, or null if no item was removed
*/
public Entity removeItemSlot(String slot){ public Entity removeItemSlot(String slot){
Entity rVal = items.remove(slot); Entity rVal = items.remove(slot);
items.put(slot,null); items.put(slot,null);
return rVal; return rVal;
} }
/**
* Gets the item in a given relational inventory state
* @param slot The slot
* @return The item if it exists, null otherwise
*/
public Entity getItemSlot(String slot){ public Entity getItemSlot(String slot){
return items.get(slot); return items.get(slot);
} }
@ -67,15 +105,29 @@ public class RelationalInventoryState {
return null; return null;
} }
/**
* Checks if the relational inventory has an item in a slot
* @param slot The slot
* @return true if there is an item in that slot, false otherwise
*/
public boolean hasItemInSlot(String slot){ public boolean hasItemInSlot(String slot){
//if the slot is a key return if the value at the key isn't null, otherwise return false //if the slot is a key return if the value at the key isn't null, otherwise return false
return items.containsKey(slot) ? items.get(slot) != null : false; return items.containsKey(slot) ? items.get(slot) != null : false;
} }
/**
* Gets the slots in the relational inventory state
* @return The list of slots
*/
public List<String> getSlots(){ public List<String> getSlots(){
return new LinkedList<String>(items.keySet()); return new LinkedList<String>(items.keySet());
} }
/**
* Tries removing an item from the inventory
* @param item The item
* @return The item if it was removed, null if it was not
*/
public Entity tryRemoveItem(Entity item){ public Entity tryRemoveItem(Entity item){
if(items.containsValue(item)){ if(items.containsValue(item)){
for(String slot : items.keySet()){ for(String slot : items.keySet()){

View File

@ -43,7 +43,7 @@ public class ProjectileTree implements BehaviorTree {
lifeCurrent++; lifeCurrent++;
if(lifeCurrent >= maxLife){ if(lifeCurrent >= maxLife){
EntityUtils.cleanUpEntity(parent); // EntityUtils.cleanUpEntity(parent);
ServerBehaviorTreeUtils.detatchBTreeFromEntity(parent,this); ServerBehaviorTreeUtils.detatchBTreeFromEntity(parent,this);
} }

View File

@ -269,7 +269,8 @@ public class CommonEntityUtils {
if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){ if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){
ClientEquipState.attachTree(entity, rawType.getEquipPoints()); ClientEquipState.attachTree(entity, rawType.getEquipPoints());
entity.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints())); InventoryUtils.setEquipInventory(entity, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints()));
InventoryUtils.setToolbarInventory(entity, RelationalInventoryState.buildToolbarInventory());
} }
if(rawType.getBlockSystem() != null){ if(rawType.getBlockSystem() != null){
ClientBlockTree.attachTree(entity, rawType.getBlockSystem()); ClientBlockTree.attachTree(entity, rawType.getBlockSystem());
@ -541,7 +542,8 @@ public class CommonEntityUtils {
// //
if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){ if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){
ServerEquipState.attachTree(entity, rawType.getEquipPoints()); ServerEquipState.attachTree(entity, rawType.getEquipPoints());
entity.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints())); InventoryUtils.setEquipInventory(entity, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints()));
InventoryUtils.setToolbarInventory(entity, RelationalInventoryState.buildToolbarInventory());
} }
// //

View File

@ -9,6 +9,7 @@ import org.ode4j.ode.DBody;
import electrosphere.collision.PhysicsEntityUtils; import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.collision.collidable.Collidable; import electrosphere.collision.collidable.Collidable;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityCreationUtils; import electrosphere.entity.EntityCreationUtils;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
@ -326,6 +327,9 @@ public class ItemUtils {
* @return The type * @return The type
*/ */
public static String getType(Entity item){ public static String getType(Entity item){
if(item == null){
return null;
}
return CommonEntityUtils.getEntitySubtype(item); return CommonEntityUtils.getEntitySubtype(item);
} }
@ -449,7 +453,7 @@ public class ItemUtils {
//destroy hitboxes //destroy hitboxes
HitboxCollectionState.destroyHitboxState(item); HitboxCollectionState.destroyHitboxState(item);
//destroy graphics //destroy graphics
EntityUtils.cleanUpEntity(item); ClientEntityUtils.destroyEntity(item);
} }
} }
} }

View File

@ -22,6 +22,16 @@ public class Item extends CommonEntityType {
*/ */
ItemAudio itemAudio; ItemAudio itemAudio;
/**
* A function that should be performed client-side when the player uses this as their primary item
*/
String clientSidePrimary;
/**
* The block data for this item
*/
ItemBlockData itemBlockData;
/** /**
* the idle animation for the item * the idle animation for the item
* @return * @return
@ -62,4 +72,20 @@ public class Item extends CommonEntityType {
return itemAudio; return itemAudio;
} }
/**
* Gets the client side primary action to perform
* @return The action
*/
public String getClientSidePrimary(){
return clientSidePrimary;
}
/**
* Gets the block data for the item
* @return THe block data
*/
public ItemBlockData getItemBlockData(){
return this.itemBlockData;
}
} }

View File

@ -0,0 +1,9 @@
package electrosphere.game.data.item.type;
/**
* Block data for the item
*/
public class ItemBlockData {
}

View File

@ -1,5 +1,7 @@
package electrosphere.game.data.item.type.model; package electrosphere.game.data.item.type.model;
import electrosphere.entity.Entity;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.game.data.item.type.Item; import electrosphere.game.data.item.type.Item;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
@ -25,4 +27,16 @@ public class ItemTypeMap {
return rVal; return rVal;
} }
/**
* Gets the item data of the item
* @param item The item entity
* @return The type
*/
public Item getItem(Entity item){
if(item != null && ItemUtils.isItem(item) && ItemUtils.getType(item) != null){
return getItem(ItemUtils.getType(item));
}
return null;
}
} }

View File

@ -9,7 +9,6 @@ import org.joml.Vector3d;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.ClientEntityUtils; import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.attach.AttachUtils; import electrosphere.entity.state.attach.AttachUtils;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.inventory.InventoryUtils; import electrosphere.entity.state.inventory.InventoryUtils;
@ -144,7 +143,7 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
case DESTROY: { case DESTROY: {
Entity entity = Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID()); Entity entity = Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID());
if(entity != null){ if(entity != null){
EntityUtils.cleanUpEntity(entity); ClientEntityUtils.destroyEntity(entity);
} }
} break; } break;

View File

@ -19,6 +19,8 @@ public class InventoryProtocol implements ServerProtocolTemplate<InventoryMessag
public static final int INVENTORY_TYPE_EQUIP = 0; public static final int INVENTORY_TYPE_EQUIP = 0;
//the natural inventory of the entity //the natural inventory of the entity
public static final int INVENTORY_TYPE_NATURAL = 1; public static final int INVENTORY_TYPE_NATURAL = 1;
//the toolbar
public static final int INVENTORY_TYPE_TOOLBAR = 2;
@Override @Override
public InventoryMessage handleAsyncMessage(ServerConnectionHandler connectionHandler, InventoryMessage message) { public InventoryMessage handleAsyncMessage(ServerConnectionHandler connectionHandler, InventoryMessage message) {

View File

@ -6,6 +6,7 @@ import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
@ -59,7 +60,7 @@ public class EquipmentInventoryPanel {
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 {
Globals.virtualAudioSourceManager.createVirtualAudioSource("/Audio/inventorySlotItem.ogg", VirtualAudioSourceType.UI, false); Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
} }
} }
//null out global state //null out global state
@ -155,7 +156,7 @@ public class EquipmentInventoryPanel {
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIGrabAudio() != null){ if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIGrabAudio() != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIGrabAudio(), VirtualAudioSourceType.UI, false); Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIGrabAudio(), VirtualAudioSourceType.UI, false);
} else { } else {
Globals.virtualAudioSourceManager.createVirtualAudioSource("/Audio/inventoryGrabItem.ogg", VirtualAudioSourceType.UI, false); Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_GRAB, VirtualAudioSourceType.UI, false);
} }
} }
return false; return false;
@ -194,10 +195,10 @@ public class EquipmentInventoryPanel {
//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));
if(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);
} else { } else {
Globals.virtualAudioSourceManager.createVirtualAudioSource("/Audio/inventorySlotItem.ogg", 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.draggedItem, slots.get(itemId))){
@ -213,7 +214,7 @@ public class EquipmentInventoryPanel {
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 {
Globals.virtualAudioSourceManager.createVirtualAudioSource("/Audio/inventorySlotItem.ogg", VirtualAudioSourceType.UI, false); Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
} }
} }
//update ui //update ui

View File

@ -4,6 +4,7 @@ import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
import electrosphere.client.ui.menu.WindowStrings; import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.engine.signal.Signal.SignalType; import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
@ -83,7 +84,7 @@ public class NaturalInventoryPanel {
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 {
Globals.virtualAudioSourceManager.createVirtualAudioSource("/Audio/inventorySlotItem.ogg", VirtualAudioSourceType.UI, false); Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
} }
} }
//clear ui //clear ui
@ -155,7 +156,7 @@ public class NaturalInventoryPanel {
if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIGrabAudio() != null){ if(itemData.getItemAudio() != null && itemData.getItemAudio().getUIGrabAudio() != null){
Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIGrabAudio(), VirtualAudioSourceType.UI, false); Globals.virtualAudioSourceManager.createVirtualAudioSource(itemData.getItemAudio().getUIGrabAudio(), VirtualAudioSourceType.UI, false);
} else { } else {
Globals.virtualAudioSourceManager.createVirtualAudioSource("/Audio/inventoryGrabItem.ogg", VirtualAudioSourceType.UI, false); Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_GRAB, VirtualAudioSourceType.UI, false);
} }
} }
return false; return false;
@ -195,7 +196,7 @@ public class NaturalInventoryPanel {
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 {
Globals.virtualAudioSourceManager.createVirtualAudioSource("/Audio/inventorySlotItem.ogg", VirtualAudioSourceType.UI, false); Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.UI_SFX_ITEM_RELEASE, VirtualAudioSourceType.UI, false);
} }
//update ui //update ui
Globals.dragSourceInventory = null; Globals.dragSourceInventory = null;

View File

@ -254,12 +254,18 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
} }
} }
} else { } else {
this.setText(this.text + keyEvent.getKey()); String newVal = this.text + keyEvent.getKey();
this.setText(newVal);
if(Globals.virtualAudioSourceManager != null && this.audioPathOnType != null){ if(Globals.virtualAudioSourceManager != null && this.audioPathOnType != null){
Globals.virtualAudioSourceManager.createUI(this.audioPathOnType); Globals.virtualAudioSourceManager.createUI(this.audioPathOnType);
} }
} }
Globals.signalSystem.post(SignalType.YOGA_APPLY, this); //apply yoga at the window level
Element parent = this.getParent();
while(parent.getParent() != null){
parent = parent.getParent();
}
Globals.signalSystem.post(SignalType.YOGA_APPLY, parent);
//fire value change event //fire value change event
Globals.elementService.fireEventNoPosition(new ValueChangeEvent(text), this); Globals.elementService.fireEventNoPosition(new ValueChangeEvent(text), this);
return false; return false;

View File

@ -14,6 +14,7 @@ import org.joml.Vector3i;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.threads.LabeledThread.ThreadLabel; import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.game.server.world.ServerWorldData; import electrosphere.game.server.world.ServerWorldData;
@ -305,7 +306,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
serverContentManager.saveContentToDisk(key, cell.getScene().getEntityList()); serverContentManager.saveContentToDisk(key, cell.getScene().getEntityList());
//clear all entities in cell //clear all entities in cell
for(Entity entity : cell.getScene().getEntityList()){ for(Entity entity : cell.getScene().getEntityList()){
EntityUtils.cleanUpEntity(entity); ClientEntityUtils.destroyEntity(entity);
} }
//save terrain to disk //save terrain to disk
serverTerrainManager.savePositionToDisk(worldPos); serverTerrainManager.savePositionToDisk(worldPos);