Recursive creature type parsing
This commit is contained in:
parent
b308397f5e
commit
83f7609b2f
@ -4,197 +4,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
"creatureId" : "human",
|
|
||||||
"bodyParts" : [
|
|
||||||
{
|
|
||||||
"name" : "Head",
|
|
||||||
"type" : "Head"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "Torso",
|
|
||||||
"type" : "Torso"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "ArmLeft",
|
|
||||||
"type" : "Arm"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "ArmRight",
|
|
||||||
"type" : "Arm"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "LegLeft",
|
|
||||||
"type" : "Leg"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "LegRight",
|
|
||||||
"type" : "Leg"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"hitboxes" : [
|
|
||||||
{
|
|
||||||
"type": "hurt",
|
|
||||||
"bone": "Bone.031",
|
|
||||||
"radius": 0.04
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hurt",
|
|
||||||
"bone": "Bone.012",
|
|
||||||
"radius": 0.04
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hurt",
|
|
||||||
"bone": "Bone.003",
|
|
||||||
"radius": 0.04
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hurt",
|
|
||||||
"bone": "Bone.010",
|
|
||||||
"radius": 0.06
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hurt",
|
|
||||||
"bone": "Bone.001",
|
|
||||||
"radius": 0.06
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hurt",
|
|
||||||
"bone": "Bone.014",
|
|
||||||
"radius": 0.06
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hurt",
|
|
||||||
"bone": "Bone",
|
|
||||||
"radius": 0.08
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hurt",
|
|
||||||
"bone": "Bone.014",
|
|
||||||
"radius": 0.06
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "hurt",
|
|
||||||
"bone": "Bone.019",
|
|
||||||
"radius": 0.04
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tokens" : [
|
|
||||||
"BLENDER_TRANSFORM",
|
|
||||||
"SENTIENT",
|
|
||||||
"ATTACKER",
|
|
||||||
"GRAVITY",
|
|
||||||
"TARGETABLE",
|
|
||||||
"CAN_EQUIP"
|
|
||||||
],
|
|
||||||
"movementSystems" : [
|
|
||||||
{
|
|
||||||
"type" : "GROUND",
|
|
||||||
"acceleration" : 16.0,
|
|
||||||
"maxVelocity" : 3.0,
|
|
||||||
"animationStartup" : {
|
|
||||||
"name" : "Armature|WalkStart",
|
|
||||||
"length" : 1,
|
|
||||||
"loops" : false
|
|
||||||
},
|
|
||||||
"animationLoop" : {
|
|
||||||
"name" : "Armature|Walk",
|
|
||||||
"length" : 1,
|
|
||||||
"loops" : false
|
|
||||||
},
|
|
||||||
"animationWindDown" : {
|
|
||||||
"name" : "Armature|WalkStart",
|
|
||||||
"length" : 1,
|
|
||||||
"loops" : false
|
|
||||||
},
|
|
||||||
"sprintSystem" : {
|
|
||||||
"maxVelocity" : 5.8,
|
|
||||||
"staminaMax" : 500,
|
|
||||||
"animationStartUp" : {
|
|
||||||
"name" : "SprintStart",
|
|
||||||
"length" : 1,
|
|
||||||
"loops" : false
|
|
||||||
},
|
|
||||||
"animationMain" : {
|
|
||||||
"name" : "Sprint",
|
|
||||||
"length" : 1,
|
|
||||||
"loops" : false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"rotatorSystem" : {
|
|
||||||
"rotatorItems" : [
|
|
||||||
{
|
|
||||||
"boneName" : "myTorsoBone",
|
|
||||||
"constraints" : [
|
|
||||||
{
|
|
||||||
"followsView" : true,
|
|
||||||
"followsBone" : false,
|
|
||||||
"parentBone" : "",
|
|
||||||
"allowedMargin" : 0.2
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"boneName" : "myLeftLegBone",
|
|
||||||
"constraints" : [
|
|
||||||
{
|
|
||||||
"followsView" : false,
|
|
||||||
"followsBone" : true,
|
|
||||||
"parentBone" : "myTorsoBone",
|
|
||||||
"allowedMargin" : 0.2
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"boneName" : "myRightLegBone",
|
|
||||||
"constraints" : [
|
|
||||||
{
|
|
||||||
"followsView" : false,
|
|
||||||
"followsBone" : true,
|
|
||||||
"parentBone" : "myTorsoBone",
|
|
||||||
"allowedMargin" : 0.2
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"collidable" : {
|
|
||||||
"type" : "CYLINDER",
|
|
||||||
"dimension1" : 0.1,
|
|
||||||
"dimension2" : 0.45,
|
|
||||||
"dimension3" : 0.1,
|
|
||||||
"offsetX" : 0,
|
|
||||||
"offsetY" : 0.45,
|
|
||||||
"offsetZ" : 0
|
|
||||||
},
|
|
||||||
"attackMoves" : [
|
|
||||||
{
|
|
||||||
"type" : "MELEE_WEAPON_SWING_ONE_HAND",
|
|
||||||
"animationName" : "Armature|SwingWeapon",
|
|
||||||
"damageStartFrame" : 30,
|
|
||||||
"damageEndFrame" : 60
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"healthSystem" : {
|
|
||||||
"maxHealth" : 100,
|
|
||||||
"onDamageIFrames" : 30
|
|
||||||
},
|
|
||||||
"modelPath" : "Models/baseman.fbx"
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"creatureId" : "goblin",
|
"creatureId" : "goblin",
|
||||||
@ -446,12 +255,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
"files" : [
|
||||||
|
"Data/creatures/human.json"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
184
assets/Data/creatures/human.json
Normal file
184
assets/Data/creatures/human.json
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
{
|
||||||
|
"creatures" : [
|
||||||
|
{
|
||||||
|
"creatureId" : "human",
|
||||||
|
"bodyParts" : [
|
||||||
|
{
|
||||||
|
"name" : "Head",
|
||||||
|
"type" : "Head"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "Torso",
|
||||||
|
"type" : "Torso"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "ArmLeft",
|
||||||
|
"type" : "Arm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "ArmRight",
|
||||||
|
"type" : "Arm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "LegLeft",
|
||||||
|
"type" : "Leg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "LegRight",
|
||||||
|
"type" : "Leg"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hitboxes" : [
|
||||||
|
{
|
||||||
|
"type": "hurt",
|
||||||
|
"bone": "Bone.031",
|
||||||
|
"radius": 0.04
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hurt",
|
||||||
|
"bone": "Bone.012",
|
||||||
|
"radius": 0.04
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hurt",
|
||||||
|
"bone": "Bone.003",
|
||||||
|
"radius": 0.04
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hurt",
|
||||||
|
"bone": "Bone.010",
|
||||||
|
"radius": 0.06
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hurt",
|
||||||
|
"bone": "Bone.001",
|
||||||
|
"radius": 0.06
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hurt",
|
||||||
|
"bone": "Bone.014",
|
||||||
|
"radius": 0.06
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hurt",
|
||||||
|
"bone": "Bone",
|
||||||
|
"radius": 0.08
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hurt",
|
||||||
|
"bone": "Bone.014",
|
||||||
|
"radius": 0.06
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hurt",
|
||||||
|
"bone": "Bone.019",
|
||||||
|
"radius": 0.04
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tokens" : [
|
||||||
|
"BLENDER_TRANSFORM",
|
||||||
|
"SENTIENT",
|
||||||
|
"ATTACKER",
|
||||||
|
"GRAVITY",
|
||||||
|
"TARGETABLE",
|
||||||
|
"CAN_EQUIP"
|
||||||
|
],
|
||||||
|
"movementSystems" : [
|
||||||
|
{
|
||||||
|
"type" : "GROUND",
|
||||||
|
"acceleration" : 16.0,
|
||||||
|
"maxVelocity" : 3.0,
|
||||||
|
"animationStartup" : {
|
||||||
|
"name" : "Armature|WalkStart",
|
||||||
|
"length" : 1,
|
||||||
|
"loops" : false
|
||||||
|
},
|
||||||
|
"animationLoop" : {
|
||||||
|
"name" : "Armature|Walk",
|
||||||
|
"length" : 1,
|
||||||
|
"loops" : false
|
||||||
|
},
|
||||||
|
"animationWindDown" : {
|
||||||
|
"name" : "Armature|WalkStart",
|
||||||
|
"length" : 1,
|
||||||
|
"loops" : false
|
||||||
|
},
|
||||||
|
"sprintSystem" : {
|
||||||
|
"maxVelocity" : 5.8,
|
||||||
|
"staminaMax" : 500,
|
||||||
|
"animationStartUp" : {
|
||||||
|
"name" : "SprintStart",
|
||||||
|
"length" : 1,
|
||||||
|
"loops" : false
|
||||||
|
},
|
||||||
|
"animationMain" : {
|
||||||
|
"name" : "Sprint",
|
||||||
|
"length" : 1,
|
||||||
|
"loops" : false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rotatorSystem" : {
|
||||||
|
"rotatorItems" : [
|
||||||
|
{
|
||||||
|
"boneName" : "myTorsoBone",
|
||||||
|
"constraints" : [
|
||||||
|
{
|
||||||
|
"followsView" : true,
|
||||||
|
"followsBone" : false,
|
||||||
|
"parentBone" : "",
|
||||||
|
"allowedMargin" : 0.2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"boneName" : "myLeftLegBone",
|
||||||
|
"constraints" : [
|
||||||
|
{
|
||||||
|
"followsView" : false,
|
||||||
|
"followsBone" : true,
|
||||||
|
"parentBone" : "myTorsoBone",
|
||||||
|
"allowedMargin" : 0.2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"boneName" : "myRightLegBone",
|
||||||
|
"constraints" : [
|
||||||
|
{
|
||||||
|
"followsView" : false,
|
||||||
|
"followsBone" : true,
|
||||||
|
"parentBone" : "myTorsoBone",
|
||||||
|
"allowedMargin" : 0.2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"collidable" : {
|
||||||
|
"type" : "CYLINDER",
|
||||||
|
"dimension1" : 0.1,
|
||||||
|
"dimension2" : 0.45,
|
||||||
|
"dimension3" : 0.1,
|
||||||
|
"offsetX" : 0,
|
||||||
|
"offsetY" : 0.45,
|
||||||
|
"offsetZ" : 0
|
||||||
|
},
|
||||||
|
"attackMoves" : [
|
||||||
|
{
|
||||||
|
"type" : "MELEE_WEAPON_SWING_ONE_HAND",
|
||||||
|
"animationName" : "Armature|SwingWeapon",
|
||||||
|
"damageStartFrame" : 30,
|
||||||
|
"damageEndFrame" : 60
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"healthSystem" : {
|
||||||
|
"maxHealth" : 100,
|
||||||
|
"onDamageIFrames" : 30
|
||||||
|
},
|
||||||
|
"modelPath" : "Models/baseman.fbx"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"files" : []
|
||||||
|
}
|
||||||
@ -64,7 +64,7 @@ public class CreatureUtils {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
public static Entity spawnBasicCreature(String type){
|
public static Entity spawnBasicCreature(String type){
|
||||||
CreatureType rawType = Globals.gameConfigCurrent.getCreatureMap().getCreature(type);
|
CreatureType rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(type);
|
||||||
Entity rVal = EntityUtils.spawnDrawableEntity(rawType.getModelPath());
|
Entity rVal = EntityUtils.spawnDrawableEntity(rawType.getModelPath());
|
||||||
for(HitboxData hitboxdata : rawType.getHitboxes()){
|
for(HitboxData hitboxdata : rawType.getHitboxes()){
|
||||||
if(hitboxdata.getType().equals("hit")){
|
if(hitboxdata.getType().equals("hit")){
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
package electrosphere.game.data;
|
package electrosphere.game.data;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import electrosphere.game.data.creature.type.CreatureType;
|
||||||
|
import electrosphere.game.data.creature.type.CreatureTypeLoader;
|
||||||
import electrosphere.game.data.creature.type.model.CreatureTypeMap;
|
import electrosphere.game.data.creature.type.model.CreatureTypeMap;
|
||||||
import electrosphere.game.data.foliage.type.model.FoliageTypeMap;
|
import electrosphere.game.data.foliage.type.model.FoliageTypeMap;
|
||||||
import electrosphere.game.data.item.type.model.ItemTypeMap;
|
import electrosphere.game.data.item.type.model.ItemTypeMap;
|
||||||
@ -14,7 +19,7 @@ import electrosphere.util.FileUtils;
|
|||||||
*/
|
*/
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
CreatureTypeMap creatureMap;
|
CreatureTypeLoader creatureTypeLoader;
|
||||||
StructureTypeMap structureTypeMap;
|
StructureTypeMap structureTypeMap;
|
||||||
ItemTypeMap itemMap;
|
ItemTypeMap itemMap;
|
||||||
FoliageTypeMap foliageMap;
|
FoliageTypeMap foliageMap;
|
||||||
@ -23,7 +28,7 @@ public class Config {
|
|||||||
|
|
||||||
public static Config loadDefaultConfig(){
|
public static Config loadDefaultConfig(){
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
config.creatureMap = FileUtils.loadObjectFromAssetPath("Data/creatures.json", CreatureTypeMap.class);
|
config.creatureTypeLoader = loadCreatureTypes("Data/creatures.json");
|
||||||
config.itemMap = FileUtils.loadObjectFromAssetPath("Data/items.json", ItemTypeMap.class);
|
config.itemMap = FileUtils.loadObjectFromAssetPath("Data/items.json", ItemTypeMap.class);
|
||||||
config.structureTypeMap = FileUtils.loadObjectFromAssetPath("Data/structures.json", StructureTypeMap.class);
|
config.structureTypeMap = FileUtils.loadObjectFromAssetPath("Data/structures.json", StructureTypeMap.class);
|
||||||
config.foliageMap = FileUtils.loadObjectFromAssetPath("Data/foliage.json", FoliageTypeMap.class);
|
config.foliageMap = FileUtils.loadObjectFromAssetPath("Data/foliage.json", FoliageTypeMap.class);
|
||||||
@ -32,8 +37,34 @@ public class Config {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreatureTypeMap getCreatureMap() {
|
static List<CreatureType> readCreatureTypeFile(String filename){
|
||||||
return creatureMap;
|
List<CreatureType> typeList = new LinkedList<CreatureType>();
|
||||||
|
CreatureTypeMap typeMap = FileUtils.loadObjectFromAssetPath(filename, CreatureTypeMap.class);
|
||||||
|
//push the types from this file
|
||||||
|
for(CreatureType type : typeMap.getCreatures()){
|
||||||
|
typeList.add(type);
|
||||||
|
}
|
||||||
|
//push types from any other files
|
||||||
|
for(String filepath : typeMap.getFiles()){
|
||||||
|
List<CreatureType> parsedTypeList = readCreatureTypeFile(filepath);
|
||||||
|
for(CreatureType type : parsedTypeList){
|
||||||
|
typeList.add(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return typeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CreatureTypeLoader loadCreatureTypes(String initialPath) {
|
||||||
|
CreatureTypeLoader loader = new CreatureTypeLoader();
|
||||||
|
List<CreatureType> typeList = readCreatureTypeFile(initialPath);
|
||||||
|
for(CreatureType type : typeList){
|
||||||
|
loader.putCreature(type.getCreatureId(), type);
|
||||||
|
}
|
||||||
|
return loader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreatureTypeLoader getCreatureTypeLoader() {
|
||||||
|
return creatureTypeLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StructureTypeMap getStructureTypeMap() {
|
public StructureTypeMap getStructureTypeMap() {
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
package electrosphere.game.data.creature.type;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class CreatureTypeLoader {
|
||||||
|
|
||||||
|
Map<String,CreatureType> creatureMap = new HashMap<String,CreatureType>();
|
||||||
|
|
||||||
|
public void putCreature(String name, CreatureType type){
|
||||||
|
creatureMap.put(name,type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreatureType getCreature(String name){
|
||||||
|
return creatureMap.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -6,16 +6,14 @@ import java.util.List;
|
|||||||
public class CreatureTypeMap {
|
public class CreatureTypeMap {
|
||||||
|
|
||||||
List<CreatureType> creatures;
|
List<CreatureType> creatures;
|
||||||
|
List<String> files;
|
||||||
|
|
||||||
public CreatureType getCreature(String name){
|
public List<CreatureType> getCreatures(){
|
||||||
CreatureType rVal = null;
|
return creatures;
|
||||||
for(CreatureType type : creatures){
|
}
|
||||||
if(type.getCreatureId().equals(name)){
|
|
||||||
rVal = type;
|
public List<String> getFiles(){
|
||||||
break;
|
return files;
|
||||||
}
|
|
||||||
}
|
|
||||||
return rVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -834,8 +834,8 @@ public class Mesh {
|
|||||||
currentMat.get(bufferarray);
|
currentMat.get(bufferarray);
|
||||||
GL20.glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, currentUniform), false, bufferarray);
|
GL20.glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, currentUniform), false, bufferarray);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Bonename: " + boneName);
|
// System.out.println("Bonename: " + boneName);
|
||||||
System.exit(1);
|
// System.exit(1);
|
||||||
GL20.glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, currentUniform), false, new float[16]);
|
GL20.glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, currentUniform), false, new float[16]);
|
||||||
}
|
}
|
||||||
incrementer++;
|
incrementer++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user