This commit is contained in:
parent
ac47a4db83
commit
bd2f49ab09
@ -19,6 +19,7 @@
|
||||
],
|
||||
"files": [
|
||||
"Data/game/recipes/weapons.json",
|
||||
"Data/game/recipes/tools.json"
|
||||
"Data/game/recipes/tools.json",
|
||||
"Data/game/recipes/fabs.json"
|
||||
]
|
||||
}
|
||||
23
assets/Data/game/recipes/fabs.json
Normal file
23
assets/Data/game/recipes/fabs.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"recipes": [
|
||||
{
|
||||
"displayName": "Wooden Floor",
|
||||
"craftingTag" : "HAND",
|
||||
"ingredients": [
|
||||
{
|
||||
"itemType": "Log",
|
||||
"count": 1
|
||||
}
|
||||
],
|
||||
"products": [
|
||||
{
|
||||
"itemType": "fab:woodfloor",
|
||||
"count": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"files": [
|
||||
|
||||
]
|
||||
}
|
||||
@ -1613,6 +1613,12 @@ Smaller wall section
|
||||
First proper house~!
|
||||
Rect area selection expands each axis independently
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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(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(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"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -316,28 +316,44 @@ public class StateTransitionUtil {
|
||||
*/
|
||||
public static class StateTransitionUtilItem {
|
||||
|
||||
//The enum value for this state
|
||||
/**
|
||||
* The enum value for this state
|
||||
*/
|
||||
Object stateEnum;
|
||||
|
||||
//The animation to play
|
||||
/**
|
||||
* The animation to play
|
||||
*/
|
||||
TreeDataAnimation animation;
|
||||
|
||||
//Gets the first person animation
|
||||
/**
|
||||
* Gets the first person animation
|
||||
*/
|
||||
Supplier<TreeDataAnimation> getAnimation;
|
||||
|
||||
//The audio data
|
||||
/**
|
||||
* The audio data
|
||||
*/
|
||||
TreeDataAudio audioData;
|
||||
|
||||
//Gets the audio to play
|
||||
/**
|
||||
* Gets the audio to play
|
||||
*/
|
||||
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;
|
||||
|
||||
//Controls whether the state transition util should loop or not
|
||||
/**
|
||||
* Controls whether the state transition util should loop or not
|
||||
*/
|
||||
boolean loop = true;
|
||||
|
||||
//Tracks whether the animation has been played or not
|
||||
/**
|
||||
* Tracks whether the animation has been played or not
|
||||
*/
|
||||
boolean startedAnimation = false;
|
||||
|
||||
/**
|
||||
@ -473,7 +489,6 @@ public class StateTransitionUtil {
|
||||
onComplete
|
||||
);
|
||||
} else {
|
||||
LoggerInterface.loggerEngine.WARNING("Creating state transition item with no tree data! " + stateEnum);
|
||||
rVal = new StateTransitionUtilItem(
|
||||
stateEnum,
|
||||
(TreeDataAnimation)null,
|
||||
@ -505,7 +520,6 @@ public class StateTransitionUtil {
|
||||
loop
|
||||
);
|
||||
} else {
|
||||
LoggerInterface.loggerEngine.WARNING("Creating state transition item with no tree data! " + stateEnum);
|
||||
rVal = new StateTransitionUtilItem(
|
||||
stateEnum,
|
||||
(TreeDataAnimation)null,
|
||||
|
||||
@ -204,9 +204,8 @@ public class ClientToolbarState implements BehaviorTree {
|
||||
|
||||
/**
|
||||
* 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){
|
||||
boolean targetHasWhitelist = ItemUtils.hasEquipList(this.equippedEntity);
|
||||
RelationalInventoryState equipInventoryState = InventoryUtils.getEquipInventory(parent);
|
||||
@ -268,12 +267,26 @@ public class ClientToolbarState implements BehaviorTree {
|
||||
if(Globals.playerBlockCursor != null){
|
||||
Globals.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerBlockCursor, EntityTags.DRAWABLE);
|
||||
}
|
||||
|
||||
//hide cursors
|
||||
CursorState.hide();
|
||||
|
||||
//null out the attached entity
|
||||
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
|
||||
* @return The item
|
||||
|
||||
@ -93,7 +93,7 @@ public class ServerToolbarState implements BehaviorTree {
|
||||
this.unequip(inInventoryEntity);
|
||||
toolbarInventory.addItem(slotId + "", inInventoryEntity);
|
||||
if(slotId == selectedSlot){
|
||||
visuallyEquipCurrentSlot();
|
||||
this.visuallyEquipCurrentSlot();
|
||||
}
|
||||
//if they're a player, let the player know that the item has moved container
|
||||
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
|
||||
*/
|
||||
|
||||
@ -148,7 +148,7 @@ public class ClientInventoryState implements BehaviorTree {
|
||||
case InventoryProtocol.INVENTORY_TYPE_TOOLBAR: {
|
||||
if(ClientToolbarState.getClientToolbarState(parent) != null){
|
||||
ClientToolbarState clientToolbarState = ClientToolbarState.getClientToolbarState(parent);
|
||||
clientToolbarState.unequip(message.getequipPointId());
|
||||
clientToolbarState.unequip();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.state.equip.ClientToolbarState;
|
||||
import electrosphere.entity.state.equip.ServerEquipState;
|
||||
import electrosphere.entity.state.equip.ServerToolbarState;
|
||||
import electrosphere.entity.state.gravity.GravityUtils;
|
||||
@ -521,33 +522,40 @@ public class InventoryUtils {
|
||||
if(item == null){
|
||||
throw new Error("Item is null!");
|
||||
}
|
||||
//verify creature is creature, item is item, inventory exists, and item is in inventory
|
||||
boolean creatureIsCreature = CreatureUtils.isCreature(creature);
|
||||
boolean itemIsItem = ItemUtils.isItem(item);
|
||||
boolean hasNaturalInventory = hasNaturalInventory(creature);
|
||||
boolean hasEquipInventory = hasEquipInventory(creature);
|
||||
if(!CreatureUtils.isCreature(creature)){
|
||||
throw new Error("Creature is not a creature!");
|
||||
}
|
||||
if(!ItemUtils.isItem(item)){
|
||||
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
|
||||
boolean itemIsInInventory = ItemUtils.itemIsInInventory(item);
|
||||
if(creatureIsCreature && itemIsItem && itemIsInInventory){
|
||||
if(hasNaturalInventory){
|
||||
//get inventory
|
||||
UnrelationalInventoryState inventory = getNaturalInventory(creature);
|
||||
//remove item from inventory
|
||||
inventory.removeItem(item);
|
||||
}
|
||||
if(hasEquipInventory){
|
||||
//get inventory
|
||||
RelationalInventoryState inventory = getEquipInventory(creature);
|
||||
//get real world item
|
||||
Entity realWorldItem = ItemUtils.getRealWorldEntity(item);
|
||||
if(realWorldItem != null){
|
||||
//drop item
|
||||
ClientEquipState equipState = ClientEquipState.getEquipState(creature);
|
||||
equipState.clientTransformUnequipPoint(inventory.getItemSlot(item));
|
||||
}
|
||||
//remove item from inventory
|
||||
inventory.tryRemoveItem(item);
|
||||
if(InventoryUtils.hasNaturalInventory(creature)){
|
||||
//get inventory
|
||||
UnrelationalInventoryState inventory = InventoryUtils.getNaturalInventory(creature);
|
||||
//remove item from inventory
|
||||
inventory.removeItem(item);
|
||||
}
|
||||
if(InventoryUtils.hasEquipInventory(creature)){
|
||||
//get inventory
|
||||
RelationalInventoryState inventory = InventoryUtils.getEquipInventory(creature);
|
||||
//get real world item
|
||||
Entity realWorldItem = ItemUtils.getRealWorldEntity(item);
|
||||
if(realWorldItem != null){
|
||||
//drop item
|
||||
ClientEquipState equipState = ClientEquipState.getEquipState(creature);
|
||||
equipState.clientTransformUnequipPoint(inventory.getItemSlot(item));
|
||||
}
|
||||
//remove item from inventory
|
||||
inventory.tryRemoveItem(item);
|
||||
}
|
||||
if(InventoryUtils.hasToolbarInventory(creature)){
|
||||
RelationalInventoryState toolbarInventory = InventoryUtils.getToolbarInventory(creature);
|
||||
toolbarInventory.tryRemoveItem(item);
|
||||
Globals.cursorState.hintClearBlockCursor();
|
||||
ClientToolbarState.getClientToolbarState(creature).update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,12 +3,18 @@ package electrosphere.entity.state.item;
|
||||
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
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.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.net.synchronization.enums.FieldIdEnums;
|
||||
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
||||
import electrosphere.net.parser.net.message.InventoryMessage;
|
||||
import electrosphere.net.parser.net.message.SynchronizationMessage;
|
||||
import electrosphere.net.server.player.Player;
|
||||
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
|
||||
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||
import electrosphere.net.synchronization.annotation.SyncedField;
|
||||
@ -66,7 +72,17 @@ public class ServerChargeState implements BehaviorTree {
|
||||
if(serverChargeState.getCharges() - charges > 0){
|
||||
serverChargeState.setCharges(serverChargeState.getCharges() - charges);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,19 +113,13 @@ public class ClientLifeTree implements BehaviorTree {
|
||||
public ClientLifeTree(Entity parent, Object ... params){
|
||||
this.parent = parent;
|
||||
this.healthSystem = (HealthSystem)params[0];
|
||||
StateTransitionUtilItem[] stateData = null;
|
||||
if(this.healthSystem.getDyingState() != null){
|
||||
stateData = new StateTransitionUtilItem[]{
|
||||
StateTransitionUtilItem.create(
|
||||
LifeStateEnum.DYING,
|
||||
this.healthSystem.getDyingState(),
|
||||
() -> {}
|
||||
)
|
||||
};
|
||||
} else {
|
||||
stateData = new StateTransitionUtilItem[0];
|
||||
}
|
||||
this.stateTransitionUtil = StateTransitionUtil.create(parent, false, stateData);
|
||||
this.stateTransitionUtil = StateTransitionUtil.create(parent, false, new StateTransitionUtilItem[]{
|
||||
StateTransitionUtilItem.create(
|
||||
LifeStateEnum.DYING,
|
||||
this.healthSystem.getDyingState(),
|
||||
() -> {}
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -313,21 +313,15 @@ public class ServerLifeTree implements BehaviorTree {
|
||||
this.lifeCurrent = this.lifeMax;
|
||||
this.iFrameMaxCount = this.healthSystem.getOnDamageIFrames();
|
||||
this.iFrameCurrent = 0;
|
||||
StateTransitionUtilItem[] stateData = null;
|
||||
if(this.healthSystem.getDyingState() != null){
|
||||
stateData = new StateTransitionUtilItem[]{
|
||||
StateTransitionUtilItem.create(
|
||||
LifeStateEnum.DYING,
|
||||
this.healthSystem.getDyingState(),
|
||||
() -> {
|
||||
this.setState(LifeStateEnum.DEAD);
|
||||
}
|
||||
)
|
||||
};
|
||||
} else {
|
||||
stateData = new StateTransitionUtilItem[0];
|
||||
}
|
||||
this.stateTransitionUtil = StateTransitionUtil.create(parent, true, stateData);
|
||||
this.stateTransitionUtil = StateTransitionUtil.create(parent, true, new StateTransitionUtilItem[]{
|
||||
StateTransitionUtilItem.create(
|
||||
LifeStateEnum.DYING,
|
||||
this.healthSystem.getDyingState(),
|
||||
() -> {
|
||||
this.setState(LifeStateEnum.DEAD);
|
||||
}
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -106,7 +106,7 @@ public class NoiseVoxelGen implements VoxelGenerator {
|
||||
if(surfacePercent > 1.0 || surfacePercent < 0){
|
||||
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.type = floorEl.getVoxelId();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user