recipes in parent entities support
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
c9691beaa9
commit
2f51269148
@ -85,6 +85,15 @@
|
|||||||
"model": {
|
"model": {
|
||||||
"path" : "Models/objects/furniture/workbench1.glb"
|
"path" : "Models/objects/furniture/workbench1.glb"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"recipe" : {
|
||||||
|
"craftingTag" : "HAND",
|
||||||
|
"ingredients": [
|
||||||
|
{
|
||||||
|
"itemType": "mat:Log",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"gridAlignedData" : {
|
"gridAlignedData" : {
|
||||||
|
|||||||
@ -1,21 +1,5 @@
|
|||||||
{
|
{
|
||||||
"recipes": [
|
"recipes": [
|
||||||
{
|
|
||||||
"displayName": "Workbench",
|
|
||||||
"craftingTag" : "HAND",
|
|
||||||
"ingredients": [
|
|
||||||
{
|
|
||||||
"itemType": "mat:Log",
|
|
||||||
"count": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"products": [
|
|
||||||
{
|
|
||||||
"itemType": "Workbench",
|
|
||||||
"count": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"files": [
|
"files": [
|
||||||
"Data/game/recipes/weapons.json",
|
"Data/game/recipes/weapons.json",
|
||||||
|
|||||||
@ -1768,6 +1768,7 @@ Fix styling for inventory panel ui element
|
|||||||
Fix content serialization bug with attached items
|
Fix content serialization bug with attached items
|
||||||
Fix playing audio without item defined in natural inventory panel
|
Fix playing audio without item defined in natural inventory panel
|
||||||
Fix window framebuffer scrunching bug
|
Fix window framebuffer scrunching bug
|
||||||
|
Recipes for spawn items defined in parent entity
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,7 @@ public class ItemActions {
|
|||||||
BlockEditing.destroyBlock();
|
BlockEditing.destroyBlock();
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.INTERACT_SFX_BLOCK_PLACE, VirtualAudioSourceType.CREATURE, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.INTERACT_SFX_BLOCK_PLACE, VirtualAudioSourceType.CREATURE, false);
|
||||||
}
|
}
|
||||||
if(data.getPrimaryUsage().getSuppressServerRequest()){
|
if(data.getPrimaryUsage().getSuppressServerRequest() != null && data.getPrimaryUsage().getSuppressServerRequest() == true){
|
||||||
sendServerMessage = false;
|
sendServerMessage = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ public class ItemActions {
|
|||||||
BlockEditing.editBlock((short)(int)data.getSecondaryUsage().getBlockId(),(short)0);
|
BlockEditing.editBlock((short)(int)data.getSecondaryUsage().getBlockId(),(short)0);
|
||||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.INTERACT_SFX_BLOCK_PLACE, VirtualAudioSourceType.CREATURE, false);
|
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.INTERACT_SFX_BLOCK_PLACE, VirtualAudioSourceType.CREATURE, false);
|
||||||
}
|
}
|
||||||
if(data.getSecondaryUsage().getSuppressServerRequest() != null){
|
if(data.getSecondaryUsage().getSuppressServerRequest() != null && data.getSecondaryUsage().getSuppressServerRequest() == true){
|
||||||
sendServerMessage = false;
|
sendServerMessage = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ public class ItemActions {
|
|||||||
if(data.getSecondaryUsage().getClientHook() != null){
|
if(data.getSecondaryUsage().getClientHook() != null){
|
||||||
ClientScriptUtils.fireSignal(data.getSecondaryUsage().getClientHook());
|
ClientScriptUtils.fireSignal(data.getSecondaryUsage().getClientHook());
|
||||||
}
|
}
|
||||||
if(data.getSecondaryUsage().getSuppressServerRequest()){
|
if(data.getSecondaryUsage().getSuppressServerRequest() != null && data.getSecondaryUsage().getSuppressServerRequest() == true){
|
||||||
sendServerMessage = false;
|
sendServerMessage = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,7 +127,7 @@ public class Config {
|
|||||||
config.structureData = StructureDataLoader.loadStructureFiles("Data/game/structure.json");
|
config.structureData = StructureDataLoader.loadStructureFiles("Data/game/structure.json");
|
||||||
|
|
||||||
//create procedural item types
|
//create procedural item types
|
||||||
ItemDataMap.loadSpawnItems(config.itemMap, config.objectTypeLoader);
|
ItemDataMap.loadSpawnItems(config.itemMap, config.recipeMap, config.objectTypeLoader);
|
||||||
ItemDataMap.generateBlockItems(config.itemMap, config.blockData);
|
ItemDataMap.generateBlockItems(config.itemMap, config.blockData);
|
||||||
ItemDataMap.generateVoxelItems(config.itemMap, config.voxelData);
|
ItemDataMap.generateVoxelItems(config.itemMap, config.voxelData);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package electrosphere.data.common.item;
|
package electrosphere.data.common.item;
|
||||||
|
|
||||||
|
import electrosphere.data.crafting.RecipeData;
|
||||||
import electrosphere.data.graphics.GraphicsTemplate;
|
import electrosphere.data.graphics.GraphicsTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,6 +18,11 @@ public class SpawnItemDescription {
|
|||||||
*/
|
*/
|
||||||
GraphicsTemplate graphicsTemplate;
|
GraphicsTemplate graphicsTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The recipe to create the spawn item
|
||||||
|
*/
|
||||||
|
RecipeData recipe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item icon for this spawn item
|
* Gets the item icon for this spawn item
|
||||||
* @return The item icon
|
* @return The item icon
|
||||||
@ -33,6 +39,13 @@ public class SpawnItemDescription {
|
|||||||
return graphicsTemplate;
|
return graphicsTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the recipe data
|
||||||
|
* @return The recipe data
|
||||||
|
*/
|
||||||
|
public RecipeData getRecipeData(){
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
package electrosphere.data.crafting;
|
package electrosphere.data.crafting;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import electrosphere.data.item.Item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data on a crafting recipe
|
* Data on a crafting recipe
|
||||||
*/
|
*/
|
||||||
@ -32,6 +35,26 @@ public class RecipeData {
|
|||||||
*/
|
*/
|
||||||
List<RecipeIngredientData> products;
|
List<RecipeIngredientData> products;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a spawn item recipe from an existing recipe and the spawn item definition
|
||||||
|
* @param existingRecipe The existing recipe
|
||||||
|
* @param spawnItem The spawn item definition
|
||||||
|
* @param count The number of the spawn item to create
|
||||||
|
* @return The spawn item recipe
|
||||||
|
*/
|
||||||
|
public static RecipeData createSpawnItemRecipe(RecipeData existingRecipe, Item spawnItem, int count){
|
||||||
|
RecipeData rVal = new RecipeData();
|
||||||
|
rVal.displayName = spawnItem.getDisplayName();
|
||||||
|
rVal.craftingTag = existingRecipe.craftingTag;
|
||||||
|
rVal.ingredients = existingRecipe.ingredients;
|
||||||
|
rVal.products = new LinkedList<RecipeIngredientData>();
|
||||||
|
if(existingRecipe.products != null){
|
||||||
|
rVal.products.addAll(existingRecipe.products);
|
||||||
|
}
|
||||||
|
rVal.products.add(new RecipeIngredientData(spawnItem.getId(),count));
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ingredients required for the recipe
|
* Gets the ingredients required for the recipe
|
||||||
* @return The ingredients required for the recipe
|
* @return The ingredients required for the recipe
|
||||||
|
|||||||
@ -24,15 +24,6 @@ public class RecipeDataMap {
|
|||||||
*/
|
*/
|
||||||
Map<Integer,RecipeData> idRecipeMap = new HashMap<Integer,RecipeData>();
|
Map<Integer,RecipeData> idRecipeMap = new HashMap<Integer,RecipeData>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds recipe data to the loader
|
|
||||||
* @param name The id of the recipe
|
|
||||||
* @param type The recipe data
|
|
||||||
*/
|
|
||||||
public void putType(int id, RecipeData type){
|
|
||||||
idRecipeMap.put(id,type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets recipe data from the id of the recipe
|
* Gets recipe data from the id of the recipe
|
||||||
* @param id The id of the recipe
|
* @param id The id of the recipe
|
||||||
@ -69,12 +60,10 @@ public class RecipeDataMap {
|
|||||||
//push the types from this file
|
//push the types from this file
|
||||||
for(RecipeData type : loaderFile.getRecipes()){
|
for(RecipeData type : loaderFile.getRecipes()){
|
||||||
typeList.add(type);
|
typeList.add(type);
|
||||||
type.setId(idIncrementer);
|
|
||||||
idIncrementer++;
|
|
||||||
}
|
}
|
||||||
//push types from any other files
|
//push types from any other files
|
||||||
for(String filepath : loaderFile.getFiles()){
|
for(String filepath : loaderFile.getFiles()){
|
||||||
List<RecipeData> parsedTypeList = recursiveReadRecipeLoader(filepath);
|
List<RecipeData> parsedTypeList = RecipeDataMap.recursiveReadRecipeLoader(filepath);
|
||||||
for(RecipeData type : parsedTypeList){
|
for(RecipeData type : parsedTypeList){
|
||||||
typeList.add(type);
|
typeList.add(type);
|
||||||
}
|
}
|
||||||
@ -89,11 +78,21 @@ public class RecipeDataMap {
|
|||||||
*/
|
*/
|
||||||
public static RecipeDataMap loadRecipeFiles(String initialPath) {
|
public static RecipeDataMap loadRecipeFiles(String initialPath) {
|
||||||
RecipeDataMap rVal = new RecipeDataMap();
|
RecipeDataMap rVal = new RecipeDataMap();
|
||||||
List<RecipeData> typeList = recursiveReadRecipeLoader(initialPath);
|
List<RecipeData> typeList = RecipeDataMap.recursiveReadRecipeLoader(initialPath);
|
||||||
for(RecipeData type : typeList){
|
for(RecipeData type : typeList){
|
||||||
rVal.putType(type.getId(), type);
|
rVal.registerRecipe(type);
|
||||||
}
|
}
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a recipe
|
||||||
|
* @param data The recipe
|
||||||
|
*/
|
||||||
|
public void registerRecipe(RecipeData data){
|
||||||
|
data.setId(idIncrementer);
|
||||||
|
idIncrementer++;
|
||||||
|
idRecipeMap.put(data.getId(),data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,16 @@ public class RecipeIngredientData {
|
|||||||
*/
|
*/
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a recipe ingredient definition
|
||||||
|
* @param type The type of item
|
||||||
|
* @param count The count of that item
|
||||||
|
*/
|
||||||
|
public RecipeIngredientData(String type, int count){
|
||||||
|
this.itemType = type;
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the type of item for the recipe
|
* Gets the type of item for the recipe
|
||||||
* @return The type of item for the recipe
|
* @return The type of item for the recipe
|
||||||
|
|||||||
@ -11,6 +11,8 @@ import electrosphere.data.block.BlockData;
|
|||||||
import electrosphere.data.block.BlockType;
|
import electrosphere.data.block.BlockType;
|
||||||
import electrosphere.data.common.CommonEntityMap;
|
import electrosphere.data.common.CommonEntityMap;
|
||||||
import electrosphere.data.common.CommonEntityType;
|
import electrosphere.data.common.CommonEntityType;
|
||||||
|
import electrosphere.data.crafting.RecipeData;
|
||||||
|
import electrosphere.data.crafting.RecipeDataMap;
|
||||||
import electrosphere.data.voxel.VoxelData;
|
import electrosphere.data.voxel.VoxelData;
|
||||||
import electrosphere.data.voxel.VoxelType;
|
import electrosphere.data.voxel.VoxelType;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
@ -124,12 +126,17 @@ public class ItemDataMap {
|
|||||||
* @param itemDataMap The item data map
|
* @param itemDataMap The item data map
|
||||||
* @param objectMap The object map that contains furniture
|
* @param objectMap The object map that contains furniture
|
||||||
*/
|
*/
|
||||||
public static void loadSpawnItems(ItemDataMap itemDataMap, CommonEntityMap objectMap){
|
public static void loadSpawnItems(ItemDataMap itemDataMap, RecipeDataMap recipeMap, CommonEntityMap objectMap){
|
||||||
for(CommonEntityType objectData : objectMap.getTypes()){
|
for(CommonEntityType objectData : objectMap.getTypes()){
|
||||||
if(objectData.getSpawnItem() != null){
|
if(objectData.getSpawnItem() != null){
|
||||||
Item spawnItem = Item.createSpawnItem(objectData);
|
Item spawnItem = Item.createSpawnItem(objectData);
|
||||||
//create spawn items
|
//create spawn items
|
||||||
itemDataMap.putType(spawnItem.getId(), spawnItem);
|
itemDataMap.putType(spawnItem.getId(), spawnItem);
|
||||||
|
//add recipe if present
|
||||||
|
if(objectData.getSpawnItem().getRecipeData() != null){
|
||||||
|
RecipeData recipeData = RecipeData.createSpawnItemRecipe(objectData.getSpawnItem().getRecipeData(), spawnItem, 1);
|
||||||
|
recipeMap.registerRecipe(recipeData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user