charge work
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-04-30 14:10:11 -04:00
parent ac47a4db83
commit bd2f49ab09
13 changed files with 151 additions and 71 deletions

View File

@ -19,6 +19,7 @@
], ],
"files": [ "files": [
"Data/game/recipes/weapons.json", "Data/game/recipes/weapons.json",
"Data/game/recipes/tools.json" "Data/game/recipes/tools.json",
"Data/game/recipes/fabs.json"
] ]
} }

View File

@ -0,0 +1,23 @@
{
"recipes": [
{
"displayName": "Wooden Floor",
"craftingTag" : "HAND",
"ingredients": [
{
"itemType": "Log",
"count": 1
}
],
"products": [
{
"itemType": "fab:woodfloor",
"count": 1
}
]
}
],
"files": [
]
}

View File

@ -1613,6 +1613,12 @@ Smaller wall section
First proper house~! First proper house~!
Rect area selection expands each axis independently Rect area selection expands each axis independently
Control to toggle mouse release (ie for eventual on-screen controls) Control to toggle mouse release (ie for eventual on-screen controls)
Undo state transition "fix" that broke harvest interaction
Undo voxel "fix" that messed up terrain smooth transitions
Craftable wooden floor fab
Using up charges destroys the item (including toolbar instances)

View File

@ -104,7 +104,7 @@ public class ControlCategoryMainGame {
handler.addControl(ITEM_SECONDARY, new Control(ControlType.MOUSE_BUTTON,GLFW.GLFW_MOUSE_BUTTON_RIGHT,false,"Secondary","Uses the secondary equipped item")); handler.addControl(ITEM_SECONDARY, new Control(ControlType.MOUSE_BUTTON,GLFW.GLFW_MOUSE_BUTTON_RIGHT,false,"Secondary","Uses the secondary equipped item"));
handler.addControl(TOOLBAR_SCROLL, new Control(ControlType.MOUSE_SCROLL,0,false,"","")); handler.addControl(TOOLBAR_SCROLL, new Control(ControlType.MOUSE_SCROLL,0,false,"",""));
handler.addControl(OPEN_CRAFTING, new Control(ControlType.KEY,GLFW.GLFW_KEY_C,true,"Open Crafting Menu", "Opens the crafting menu")); handler.addControl(OPEN_CRAFTING, new Control(ControlType.KEY,GLFW.GLFW_KEY_C,true,"Open Crafting Menu", "Opens the crafting menu"));
handler.addControl(TOGGLE_RELEASE_MOUSE, new Control(ControlType.KEY,GLFW.GLFW_KEY_LEFT_ALT,true,"Toggle Mouse", "Toggles whether the mouse is visible or not")); handler.addControl(TOGGLE_RELEASE_MOUSE, new Control(ControlType.KEY,GLFW.GLFW_KEY_RIGHT_ALT,true,"Toggle Mouse", "Toggles whether the mouse is visible or not"));
} }
/** /**

View File

@ -316,28 +316,44 @@ public class StateTransitionUtil {
*/ */
public static class StateTransitionUtilItem { public static class StateTransitionUtilItem {
//The enum value for this state /**
* The enum value for this state
*/
Object stateEnum; Object stateEnum;
//The animation to play /**
* The animation to play
*/
TreeDataAnimation animation; TreeDataAnimation animation;
//Gets the first person animation /**
* Gets the first person animation
*/
Supplier<TreeDataAnimation> getAnimation; Supplier<TreeDataAnimation> getAnimation;
//The audio data /**
* The audio data
*/
TreeDataAudio audioData; TreeDataAudio audioData;
//Gets the audio to play /**
* Gets the audio to play
*/
Supplier<TreeDataAudio> getAudio; Supplier<TreeDataAudio> getAudio;
//The function to fire on completion (ie to transition to the next state) /**
* The function to fire on completion (ie to transition to the next state)
*/
Runnable onComplete; Runnable onComplete;
//Controls whether the state transition util should loop or not /**
* Controls whether the state transition util should loop or not
*/
boolean loop = true; boolean loop = true;
//Tracks whether the animation has been played or not /**
* Tracks whether the animation has been played or not
*/
boolean startedAnimation = false; boolean startedAnimation = false;
/** /**
@ -473,7 +489,6 @@ public class StateTransitionUtil {
onComplete onComplete
); );
} else { } else {
LoggerInterface.loggerEngine.WARNING("Creating state transition item with no tree data! " + stateEnum);
rVal = new StateTransitionUtilItem( rVal = new StateTransitionUtilItem(
stateEnum, stateEnum,
(TreeDataAnimation)null, (TreeDataAnimation)null,
@ -505,7 +520,6 @@ public class StateTransitionUtil {
loop loop
); );
} else { } else {
LoggerInterface.loggerEngine.WARNING("Creating state transition item with no tree data! " + stateEnum);
rVal = new StateTransitionUtilItem( rVal = new StateTransitionUtilItem(
stateEnum, stateEnum,
(TreeDataAnimation)null, (TreeDataAnimation)null,

View File

@ -204,9 +204,8 @@ public class ClientToolbarState implements BehaviorTree {
/** /**
* Performs the actual logic to turn meshes on/off when unequipping an item * Performs the actual logic to turn meshes on/off when unequipping an item
* @param pointId The equipment point to unequip
*/ */
public void unequip(String pointId){ public void unequip(){
if(this.equippedEntity != null){ if(this.equippedEntity != null){
boolean targetHasWhitelist = ItemUtils.hasEquipList(this.equippedEntity); boolean targetHasWhitelist = ItemUtils.hasEquipList(this.equippedEntity);
RelationalInventoryState equipInventoryState = InventoryUtils.getEquipInventory(parent); RelationalInventoryState equipInventoryState = InventoryUtils.getEquipInventory(parent);
@ -269,11 +268,25 @@ public class ClientToolbarState implements BehaviorTree {
Globals.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerBlockCursor, EntityTags.DRAWABLE); Globals.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerBlockCursor, EntityTags.DRAWABLE);
} }
//hide cursors
CursorState.hide();
//null out the attached entity //null out the attached entity
this.equippedEntity = null; this.equippedEntity = null;
} }
} }
/**
* Updates the toolbar state based on the inventory (ie, should call this after editing the inventory directly)
*/
public void update(){
RelationalInventoryState inventory = InventoryUtils.getToolbarInventory(this.parent);
Entity inventoryEquipped = inventory.getItemSlot("" + this.selectedSlot);
if(inventoryEquipped == null && this.equippedEntity != null){
this.unequip();
}
}
/** /**
* Gets the current primary item if it exists, null otherwise * Gets the current primary item if it exists, null otherwise
* @return The item * @return The item

View File

@ -93,7 +93,7 @@ public class ServerToolbarState implements BehaviorTree {
this.unequip(inInventoryEntity); this.unequip(inInventoryEntity);
toolbarInventory.addItem(slotId + "", inInventoryEntity); toolbarInventory.addItem(slotId + "", inInventoryEntity);
if(slotId == selectedSlot){ if(slotId == selectedSlot){
visuallyEquipCurrentSlot(); this.visuallyEquipCurrentSlot();
} }
//if they're a player, let the player know that the item has moved container //if they're a player, let the player know that the item has moved container
if(CreatureUtils.hasControllerPlayerId(parent)){ if(CreatureUtils.hasControllerPlayerId(parent)){
@ -274,6 +274,17 @@ public class ServerToolbarState implements BehaviorTree {
} }
} }
/**
* Updates the toolbar state based on the inventory (ie, should call this after editing the inventory directly)
*/
public void update(){
RelationalInventoryState inventory = InventoryUtils.getToolbarInventory(this.parent);
Entity inventoryEquipped = inventory.getItemSlot("" + this.selectedSlot);
if(inventoryEquipped == null && this.realWorldItem != null){
this.unequip(this.realWorldItem);
}
}
/** /**
* Removes visuals for the currently equipped item if they exist * Removes visuals for the currently equipped item if they exist
*/ */

View File

@ -148,7 +148,7 @@ public class ClientInventoryState implements BehaviorTree {
case InventoryProtocol.INVENTORY_TYPE_TOOLBAR: { case InventoryProtocol.INVENTORY_TYPE_TOOLBAR: {
if(ClientToolbarState.getClientToolbarState(parent) != null){ if(ClientToolbarState.getClientToolbarState(parent) != null){
ClientToolbarState clientToolbarState = ClientToolbarState.getClientToolbarState(parent); ClientToolbarState clientToolbarState = ClientToolbarState.getClientToolbarState(parent);
clientToolbarState.unequip(message.getequipPointId()); clientToolbarState.unequip();
} }
} break; } break;
} }

View File

@ -11,6 +11,7 @@ import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.ServerEntityUtils; import electrosphere.entity.ServerEntityUtils;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.equip.ClientToolbarState;
import electrosphere.entity.state.equip.ServerEquipState; import electrosphere.entity.state.equip.ServerEquipState;
import electrosphere.entity.state.equip.ServerToolbarState; import electrosphere.entity.state.equip.ServerToolbarState;
import electrosphere.entity.state.gravity.GravityUtils; import electrosphere.entity.state.gravity.GravityUtils;
@ -521,23 +522,25 @@ public class InventoryUtils {
if(item == null){ if(item == null){
throw new Error("Item is null!"); throw new Error("Item is null!");
} }
//verify creature is creature, item is item, inventory exists, and item is in inventory if(!CreatureUtils.isCreature(creature)){
boolean creatureIsCreature = CreatureUtils.isCreature(creature); throw new Error("Creature is not a creature!");
boolean itemIsItem = ItemUtils.isItem(item); }
boolean hasNaturalInventory = hasNaturalInventory(creature); if(!ItemUtils.isItem(item)){
boolean hasEquipInventory = hasEquipInventory(creature); throw new Error("Item is not an item!");
}
if(!ItemUtils.itemIsInInventory(item)){
throw new Error("Item is not in an inventory!");
}
//check if the item is in an inventory //check if the item is in an inventory
boolean itemIsInInventory = ItemUtils.itemIsInInventory(item); if(InventoryUtils.hasNaturalInventory(creature)){
if(creatureIsCreature && itemIsItem && itemIsInInventory){
if(hasNaturalInventory){
//get inventory //get inventory
UnrelationalInventoryState inventory = getNaturalInventory(creature); UnrelationalInventoryState inventory = InventoryUtils.getNaturalInventory(creature);
//remove item from inventory //remove item from inventory
inventory.removeItem(item); inventory.removeItem(item);
} }
if(hasEquipInventory){ if(InventoryUtils.hasEquipInventory(creature)){
//get inventory //get inventory
RelationalInventoryState inventory = getEquipInventory(creature); RelationalInventoryState inventory = InventoryUtils.getEquipInventory(creature);
//get real world item //get real world item
Entity realWorldItem = ItemUtils.getRealWorldEntity(item); Entity realWorldItem = ItemUtils.getRealWorldEntity(item);
if(realWorldItem != null){ if(realWorldItem != null){
@ -548,6 +551,11 @@ public class InventoryUtils {
//remove item from inventory //remove item from inventory
inventory.tryRemoveItem(item); inventory.tryRemoveItem(item);
} }
if(InventoryUtils.hasToolbarInventory(creature)){
RelationalInventoryState toolbarInventory = InventoryUtils.getToolbarInventory(creature);
toolbarInventory.tryRemoveItem(item);
Globals.cursorState.hintClearBlockCursor();
ClientToolbarState.getClientToolbarState(creature).update();
} }
} }

View File

@ -3,12 +3,18 @@ package electrosphere.entity.state.item;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.equip.ServerToolbarState; import electrosphere.entity.state.equip.ServerToolbarState;
import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.state.inventory.RelationalInventoryState;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.ServerEntityUtils;
import electrosphere.net.synchronization.enums.FieldIdEnums; import electrosphere.net.synchronization.enums.FieldIdEnums;
import electrosphere.server.datacell.utils.DataCellSearchUtils; import electrosphere.server.datacell.utils.DataCellSearchUtils;
import electrosphere.net.parser.net.message.InventoryMessage;
import electrosphere.net.parser.net.message.SynchronizationMessage; import electrosphere.net.parser.net.message.SynchronizationMessage;
import electrosphere.net.server.player.Player;
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums; import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils; import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.net.synchronization.annotation.SyncedField; import electrosphere.net.synchronization.annotation.SyncedField;
@ -66,7 +72,17 @@ public class ServerChargeState implements BehaviorTree {
if(serverChargeState.getCharges() - charges > 0){ if(serverChargeState.getCharges() - charges > 0){
serverChargeState.setCharges(serverChargeState.getCharges() - charges); serverChargeState.setCharges(serverChargeState.getCharges() - charges);
} else { } else {
throw new Error("Undefined! " + charges + serverChargeState.getCharges()); if(CreatureUtils.hasControllerPlayerId(parent)){
//get the player
int controllerPlayerID = CreatureUtils.getControllerPlayerId(parent);
Player controllerPlayer = Globals.playerManager.getPlayerFromId(controllerPlayerID);
//send message
controllerPlayer.addMessage(InventoryMessage.constructremoveItemFromInventoryMessage(inventoryItem.getId()));
}
RelationalInventoryState toolbarInventory = InventoryUtils.getToolbarInventory(parent);
toolbarInventory.tryRemoveItem(inventoryItem);
serverToolbarState.update();
ServerEntityUtils.destroyEntity(inventoryItem);
} }
} }
} }

View File

@ -113,19 +113,13 @@ public class ClientLifeTree implements BehaviorTree {
public ClientLifeTree(Entity parent, Object ... params){ public ClientLifeTree(Entity parent, Object ... params){
this.parent = parent; this.parent = parent;
this.healthSystem = (HealthSystem)params[0]; this.healthSystem = (HealthSystem)params[0];
StateTransitionUtilItem[] stateData = null; this.stateTransitionUtil = StateTransitionUtil.create(parent, false, new StateTransitionUtilItem[]{
if(this.healthSystem.getDyingState() != null){
stateData = new StateTransitionUtilItem[]{
StateTransitionUtilItem.create( StateTransitionUtilItem.create(
LifeStateEnum.DYING, LifeStateEnum.DYING,
this.healthSystem.getDyingState(), this.healthSystem.getDyingState(),
() -> {} () -> {}
) )
}; });
} else {
stateData = new StateTransitionUtilItem[0];
}
this.stateTransitionUtil = StateTransitionUtil.create(parent, false, stateData);
} }
/** /**

View File

@ -313,9 +313,7 @@ public class ServerLifeTree implements BehaviorTree {
this.lifeCurrent = this.lifeMax; this.lifeCurrent = this.lifeMax;
this.iFrameMaxCount = this.healthSystem.getOnDamageIFrames(); this.iFrameMaxCount = this.healthSystem.getOnDamageIFrames();
this.iFrameCurrent = 0; this.iFrameCurrent = 0;
StateTransitionUtilItem[] stateData = null; this.stateTransitionUtil = StateTransitionUtil.create(parent, true, new StateTransitionUtilItem[]{
if(this.healthSystem.getDyingState() != null){
stateData = new StateTransitionUtilItem[]{
StateTransitionUtilItem.create( StateTransitionUtilItem.create(
LifeStateEnum.DYING, LifeStateEnum.DYING,
this.healthSystem.getDyingState(), this.healthSystem.getDyingState(),
@ -323,11 +321,7 @@ public class ServerLifeTree implements BehaviorTree {
this.setState(LifeStateEnum.DEAD); this.setState(LifeStateEnum.DEAD);
} }
) )
}; });
} else {
stateData = new StateTransitionUtilItem[0];
}
this.stateTransitionUtil = StateTransitionUtil.create(parent, true, stateData);
} }
/** /**

View File

@ -106,7 +106,7 @@ public class NoiseVoxelGen implements VoxelGenerator {
if(surfacePercent > 1.0 || surfacePercent < 0){ if(surfacePercent > 1.0 || surfacePercent < 0){
throw new Error("surfacePercent " + surfacePercent + " " + realY + " " + surfaceHeight + " " + heightDiff + " " + strideMultiplier); throw new Error("surfacePercent " + surfacePercent + " " + realY + " " + surfaceHeight + " " + heightDiff + " " + strideMultiplier);
} }
double finalHeight = sample * surfacePercent * 2; double finalHeight = sample * surfacePercent * 2 - 1;
voxel.weight = (float)(finalHeight * sample); voxel.weight = (float)(finalHeight * sample);
voxel.type = floorEl.getVoxelId(); voxel.type = floorEl.getVoxelId();
} }