crafting work
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
ccc767618c
commit
7bc23c1c95
@ -75,7 +75,8 @@
|
|||||||
},
|
},
|
||||||
"buttonInteraction" : {
|
"buttonInteraction" : {
|
||||||
"onInteract" : "menu",
|
"onInteract" : "menu",
|
||||||
"windowTarget" : "crafting"
|
"windowTarget" : "crafting",
|
||||||
|
"windowData" : "Workbench"
|
||||||
},
|
},
|
||||||
"spawnItem" : {
|
"spawnItem" : {
|
||||||
"graphicsTemplate" : {
|
"graphicsTemplate" : {
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
"recipes": [
|
"recipes": [
|
||||||
{
|
{
|
||||||
"displayName": "Workbench",
|
"displayName": "Workbench",
|
||||||
|
"craftingTag" : "HAND",
|
||||||
"ingredients": [
|
"ingredients": [
|
||||||
{
|
{
|
||||||
"itemType": "Log",
|
"itemType": "Log",
|
||||||
@ -17,6 +18,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"files": [
|
"files": [
|
||||||
"Data/game/recipes/weapons.json"
|
"Data/game/recipes/weapons.json",
|
||||||
|
"Data/game/recipes/tools.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
27
assets/Data/game/recipes/tools.json
Normal file
27
assets/Data/game/recipes/tools.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"recipes": [
|
||||||
|
{
|
||||||
|
"displayName": "Stone Axe",
|
||||||
|
"craftingTag" : "HAND",
|
||||||
|
"ingredients": [
|
||||||
|
{
|
||||||
|
"itemType": "Stick",
|
||||||
|
"count": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"itemType": "Rock",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"products": [
|
||||||
|
{
|
||||||
|
"itemType": "Stone Axe",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@
|
|||||||
"recipes": [
|
"recipes": [
|
||||||
{
|
{
|
||||||
"displayName": "Katana (Two Hand)",
|
"displayName": "Katana (Two Hand)",
|
||||||
|
"craftingTag" : "DEBUG",
|
||||||
"ingredients": [
|
"ingredients": [
|
||||||
{
|
{
|
||||||
"itemType": "katana2H",
|
"itemType": "katana2H",
|
||||||
@ -17,6 +18,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "Katana (One Hand)",
|
"displayName": "Katana (One Hand)",
|
||||||
|
"craftingTag" : "DEBUG",
|
||||||
"ingredients": [
|
"ingredients": [
|
||||||
{
|
{
|
||||||
"itemType": "katana",
|
"itemType": "katana",
|
||||||
|
|||||||
@ -1473,6 +1473,8 @@ Voxel type work
|
|||||||
Inventory sounds for some materials
|
Inventory sounds for some materials
|
||||||
Inventory audio work
|
Inventory audio work
|
||||||
Comment out script engine file watching for testing purposes
|
Comment out script engine file watching for testing purposes
|
||||||
|
Crafting panel recipe filtering by tag
|
||||||
|
Stone Axe crafting
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -54,10 +54,11 @@ public class CraftingPanel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the crafting panel component
|
* Creates the crafting panel component
|
||||||
|
* @param craftingTag The tag to filter recipes by
|
||||||
* @param onCraft Called when an item is crafted
|
* @param onCraft Called when an item is crafted
|
||||||
* @return The component
|
* @return The component
|
||||||
*/
|
*/
|
||||||
public static Element createCraftingPanelComponent(Consumer<RecipeData> onCraft){
|
public static Element createCraftingPanelComponent(String craftingTag, Consumer<RecipeData> onCraft){
|
||||||
|
|
||||||
//top level element
|
//top level element
|
||||||
Div rVal = Div.createCol();
|
Div rVal = Div.createCol();
|
||||||
@ -84,7 +85,10 @@ public class CraftingPanel {
|
|||||||
|
|
||||||
//the scrollable containing the list of recipes to select
|
//the scrollable containing the list of recipes to select
|
||||||
VirtualScrollable recipeScrollable = new VirtualScrollable(SCROLLABLE_WIDTH, SCROLLABLE_HEIGHT);
|
VirtualScrollable recipeScrollable = new VirtualScrollable(SCROLLABLE_WIDTH, SCROLLABLE_HEIGHT);
|
||||||
Globals.gameConfigCurrent.getRecipeMap().getTypes().forEach((RecipeData recipe) -> {
|
Globals.gameConfigCurrent.getRecipeMap().getTypes()
|
||||||
|
.stream()
|
||||||
|
.filter(recipe -> recipe.getCraftingTag().matches(craftingTag))
|
||||||
|
.forEach((RecipeData recipe) -> {
|
||||||
Button recipeButton = Button.createButton(recipe.getDisplayName(), () -> {
|
Button recipeButton = Button.createButton(recipe.getDisplayName(), () -> {
|
||||||
CraftingPanel.setDetails(rVal, recipeDetailsSection, recipe);
|
CraftingPanel.setDetails(rVal, recipeDetailsSection, recipe);
|
||||||
selectedRecipe = recipe;
|
selectedRecipe = recipe;
|
||||||
|
|||||||
@ -282,11 +282,12 @@ public class WindowUtils {
|
|||||||
/**
|
/**
|
||||||
* Opens an interaction menu
|
* Opens an interaction menu
|
||||||
* @param windowName The name of the window
|
* @param windowName The name of the window
|
||||||
|
* @param windowData The data for the window
|
||||||
*/
|
*/
|
||||||
public static void openInteractionMenu(String windowName){
|
public static void openInteractionMenu(String windowName, String windowData){
|
||||||
switch(windowName){
|
switch(windowName){
|
||||||
case WindowStrings.CRAFTING: {
|
case WindowStrings.CRAFTING: {
|
||||||
Window craftingWindow = CraftingWindow.createCraftingWindow();
|
Window craftingWindow = CraftingWindow.createCraftingWindow(windowData);
|
||||||
Globals.elementService.registerWindow(WindowStrings.CRAFTING, craftingWindow);
|
Globals.elementService.registerWindow(WindowStrings.CRAFTING, craftingWindow);
|
||||||
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.CRAFTING), true);
|
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.CRAFTING), true);
|
||||||
Globals.elementService.focusFirstElement();
|
Globals.elementService.focusFirstElement();
|
||||||
|
|||||||
@ -31,11 +31,16 @@ public class CraftingWindow {
|
|||||||
*/
|
*/
|
||||||
public static final int MIN_HEIGHT = 500;
|
public static final int MIN_HEIGHT = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The data for crafting with your hands
|
||||||
|
*/
|
||||||
|
public static final String HAND_CRAFTING_DATA = "HAND";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a character customizer panel
|
* Creates a character customizer panel
|
||||||
* @return The panel component
|
* @return The panel component
|
||||||
*/
|
*/
|
||||||
public static Window createCraftingWindow(){
|
public static Window createCraftingWindow(String data){
|
||||||
int width = MIN_WIDTH;
|
int width = MIN_WIDTH;
|
||||||
int height = MIN_HEIGHT;
|
int height = MIN_HEIGHT;
|
||||||
|
|
||||||
@ -63,12 +68,22 @@ public class CraftingWindow {
|
|||||||
//
|
//
|
||||||
//contents
|
//contents
|
||||||
//
|
//
|
||||||
rVal.addChild(CraftingPanel.createCraftingPanelComponent((RecipeData recipe) -> {
|
rVal.addChild(CraftingPanel.createCraftingPanelComponent(
|
||||||
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestCraftMessage(
|
data,
|
||||||
Globals.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()),
|
(RecipeData recipe) -> {
|
||||||
Globals.clientSceneWrapper.mapClientToServerId(Globals.interactionTarget.getId()),
|
if(Globals.interactionTarget != null){
|
||||||
recipe.getId()
|
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestCraftMessage(
|
||||||
));
|
Globals.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()),
|
||||||
|
Globals.clientSceneWrapper.mapClientToServerId(Globals.interactionTarget.getId()),
|
||||||
|
recipe.getId()
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestCraftMessage(
|
||||||
|
Globals.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()),
|
||||||
|
Globals.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()),
|
||||||
|
recipe.getId()
|
||||||
|
));
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import electrosphere.client.ui.components.NaturalInventoryPanel;
|
|||||||
import electrosphere.client.ui.components.SpawnSelectionPanel;
|
import electrosphere.client.ui.components.SpawnSelectionPanel;
|
||||||
import electrosphere.client.ui.components.VoxelSelectionPanel;
|
import electrosphere.client.ui.components.VoxelSelectionPanel;
|
||||||
import electrosphere.client.ui.menu.WindowUtils;
|
import electrosphere.client.ui.menu.WindowUtils;
|
||||||
|
import electrosphere.client.ui.menu.ingame.CraftingWindow;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
@ -167,7 +168,9 @@ public class MenuGeneratorsUITesting {
|
|||||||
}));
|
}));
|
||||||
} break;
|
} break;
|
||||||
case "CraftingPanel": {
|
case "CraftingPanel": {
|
||||||
formEl.addChild(CraftingPanel.createCraftingPanelComponent((RecipeData recipe) -> {
|
formEl.addChild(CraftingPanel.createCraftingPanelComponent(
|
||||||
|
CraftingWindow.HAND_CRAFTING_DATA,
|
||||||
|
(RecipeData recipe) -> {
|
||||||
System.out.println("Craft " + recipe.getDisplayName());
|
System.out.println("Craft " + recipe.getDisplayName());
|
||||||
}));
|
}));
|
||||||
} break;
|
} break;
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import electrosphere.client.interact.ItemActions;
|
|||||||
import electrosphere.client.ui.components.PlayerInventoryWindow;
|
import electrosphere.client.ui.components.PlayerInventoryWindow;
|
||||||
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.client.ui.menu.ingame.CraftingWindow;
|
||||||
import electrosphere.client.ui.menu.ingame.MenuGeneratorsInGame;
|
import electrosphere.client.ui.menu.ingame.MenuGeneratorsInGame;
|
||||||
import electrosphere.controls.Control;
|
import electrosphere.controls.Control;
|
||||||
import electrosphere.controls.Control.ControlMethod;
|
import electrosphere.controls.Control.ControlMethod;
|
||||||
@ -621,7 +622,7 @@ public class ControlCategoryMainGame {
|
|||||||
InteractionData interactionData = CommonEntityUtils.getCommonData(target).getButtonInteraction();
|
InteractionData interactionData = CommonEntityUtils.getCommonData(target).getButtonInteraction();
|
||||||
switch(interactionData.getOnInteract()){
|
switch(interactionData.getOnInteract()){
|
||||||
case InteractionData.ON_INTERACT_MENU: {
|
case InteractionData.ON_INTERACT_MENU: {
|
||||||
WindowUtils.openInteractionMenu(interactionData.getWindowTarget());
|
WindowUtils.openInteractionMenu(interactionData.getWindowTarget(), interactionData.getWindowData());
|
||||||
} break;
|
} break;
|
||||||
case InteractionData.ON_INTERACT_HARVEST: {
|
case InteractionData.ON_INTERACT_HARVEST: {
|
||||||
int serverEntityId = Globals.clientSceneWrapper.mapClientToServerId(target.getId());
|
int serverEntityId = Globals.clientSceneWrapper.mapClientToServerId(target.getId());
|
||||||
@ -735,7 +736,7 @@ public class ControlCategoryMainGame {
|
|||||||
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.interactionTarget = null;
|
||||||
WindowUtils.openInteractionMenu(WindowStrings.CRAFTING);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,11 @@ public class InteractionData {
|
|||||||
*/
|
*/
|
||||||
String windowTarget;
|
String windowTarget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The data to pass alongside the window
|
||||||
|
*/
|
||||||
|
String windowData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The collidable shape used for ray casting to pick entities to interact with
|
* The collidable shape used for ray casting to pick entities to interact with
|
||||||
*/
|
*/
|
||||||
@ -56,4 +61,14 @@ public class InteractionData {
|
|||||||
return interactionShape;
|
return interactionShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the data to pass alongside the window
|
||||||
|
* @return the data to pass alongside the window
|
||||||
|
*/
|
||||||
|
public String getWindowData() {
|
||||||
|
return windowData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,11 @@ public class RecipeData {
|
|||||||
* The display name for the recipe
|
* The display name for the recipe
|
||||||
*/
|
*/
|
||||||
String displayName;
|
String displayName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tag to determine when to display this recipe in the crafting menu
|
||||||
|
*/
|
||||||
|
String craftingTag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ingredients required for the recipe
|
* The ingredients required for the recipe
|
||||||
@ -83,6 +88,24 @@ public class RecipeData {
|
|||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the crafting tag
|
||||||
|
* @return the crafting tag
|
||||||
|
*/
|
||||||
|
public String getCraftingTag() {
|
||||||
|
return craftingTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the crafting tag
|
||||||
|
* @param craftingTag the crafting tag
|
||||||
|
*/
|
||||||
|
public void setCraftingTag(String craftingTag) {
|
||||||
|
this.craftingTag = craftingTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -147,6 +147,9 @@ public class InventoryProtocol implements ServerProtocolTemplate<InventoryMessag
|
|||||||
}
|
}
|
||||||
if(toolbarInventory != null){
|
if(toolbarInventory != null){
|
||||||
for(Entity itemEnt : toolbarInventory.getItems()){
|
for(Entity itemEnt : toolbarInventory.getItems()){
|
||||||
|
if(itemEnt == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(itemMap.getItem(itemEnt).getId().matches(ingredient.getItemType())){
|
if(itemMap.getItem(itemEnt).getId().matches(ingredient.getItemType())){
|
||||||
found++;
|
found++;
|
||||||
reagentList.add(itemEnt);
|
reagentList.add(itemEnt);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user