Creature attributes

This commit is contained in:
austin 2022-02-10 00:17:05 -05:00
parent 83f7609b2f
commit ff231c1c1d
10 changed files with 83 additions and 84 deletions

View File

@ -7,32 +7,6 @@
{
"creatureId" : "goblin",
"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",
@ -160,12 +134,6 @@
{
"creatureId" : "CUBE_MAN",
"bodyParts" : [
{
"name" : "CUBE",
"type" : "CUBE_MAN"
}
],
"hitboxes" : [],
"tokens" : [
"BLENDER_TRANSFORM",
@ -210,16 +178,6 @@
{
"creatureId" : "Deer",
"bodyParts" : [
{
"name" : "Head",
"type" : "Head"
},
{
"name" : "Torso",
"type" : "Torso"
}
],
"hitboxes" : [
{
"type": "hurt",

View File

@ -2,32 +2,6 @@
"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",
@ -83,6 +57,20 @@
"TARGETABLE",
"CAN_EQUIP"
],
"visualAttributes" : [
{
"attributeId" : "hair",
"variants" : [
{
"id" : "hairshort1",
"model" : "Models/hairshort1.fbx",
"meshes" : [
"Hair"
]
}
]
}
],
"movementSystems" : [
{
"type" : "GROUND",

View File

@ -627,7 +627,7 @@ public class LoadingThread extends Thread {
Entity shorts = ItemUtils.spawnBasicItem("boots1");
EntityUtils.getPosition(shorts).set(new Vector3f(2,1,1));
Entity hair = ItemUtils.spawnBasicItem("shirt1");
Entity hair = ItemUtils.spawnBasicItem("hairshort1");
EntityUtils.getPosition(hair).set(new Vector3f(1,1,1));
// goblin = CreatureUtils.spawnBasicCreature("Goblin");

View File

@ -37,6 +37,7 @@ public class EntityDataStrings {
public static final String DATA_STRING_VELOCITY = "velocity";
public static final String DATA_STRING_ACCELERATION = "acceleration";
public static final String DATA_STRING_MAX_NATURAL_VELOCITY = "velocityMaxNatural";
public static final String CREATURE_ATTRIBUTE_VARIANT = "creatureAttributeVariant";
/*
All Camera Types

View File

@ -23,6 +23,8 @@ import electrosphere.game.collision.collidable.Collidable;
import electrosphere.game.data.creature.type.AttackMove;
import electrosphere.game.data.creature.type.CollidableTemplate;
import electrosphere.game.data.creature.type.SprintSystem;
import electrosphere.game.data.creature.type.visualattribute.AttributeVariant;
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
import electrosphere.logger.LoggerInterface;
import electrosphere.main.Globals;
import electrosphere.main.Main;
@ -66,6 +68,7 @@ public class CreatureUtils {
public static Entity spawnBasicCreature(String type){
CreatureType rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(type);
Entity rVal = EntityUtils.spawnDrawableEntity(rawType.getModelPath());
Actor creatureActor = EntityUtils.getActor(rVal);
for(HitboxData hitboxdata : rawType.getHitboxes()){
if(hitboxdata.getType().equals("hit")){
Globals.hitboxManager.registerHitbox(HitboxUtils.spawnRegularHitbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius()));
@ -161,6 +164,21 @@ public class CreatureUtils {
break;
}
}
//variants
if(rawType.getVisualAttributes() != null){
for(VisualAttribute attributeType : rawType.getVisualAttributes()){
if(attributeType.getVariants() != null && attributeType.getVariants().size() > 0){
AttributeVariant variant = attributeType.getVariants().get(0);
// attributeType.getAttributeId();
// variant.getId();
rVal.putData(EntityDataStrings.CREATURE_ATTRIBUTE_VARIANT + attributeType.getAttributeId(), variant.getId());
Globals.assetManager.addModelPathToQueue(variant.getModel());
for(String mesh : variant.getMeshes()){
creatureActor.getMeshMask().queueMesh(variant.getModel(), mesh);
}
}
}
}
//add all attack moves
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
for(AttackMove attackMove : rawType.getAttackMoves()){

View File

@ -1,6 +0,0 @@
package electrosphere.game.data.creature.type;
public class BodyPart {
int bodyPartClass;
}

View File

@ -2,14 +2,15 @@ package electrosphere.game.data.creature.type;
import electrosphere.entity.types.hitbox.HitboxData;
import electrosphere.game.data.creature.type.rotator.RotatorSystem;
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
import java.util.List;
public class CreatureType {
String creatureId;
List<BodyPart> bodyParts;
List<HitboxData> hitboxes;
List<String> tokens;
List<VisualAttribute> visualAttributes;
List<MovementSystem> movementSystems;
RotatorSystem rotatorSystem;
CollidableTemplate collidable;
@ -22,10 +23,6 @@ public class CreatureType {
return creatureId;
}
public List<BodyPart> getBodyParts() {
return bodyParts;
}
public List<HitboxData> getHitboxes() {
return hitboxes;
}
@ -34,6 +31,10 @@ public class CreatureType {
return tokens;
}
public List<VisualAttribute> getVisualAttributes(){
return visualAttributes;
}
public String getModelPath() {
return modelPath;
}

View File

@ -0,0 +1,22 @@
package electrosphere.game.data.creature.type.visualattribute;
import java.util.List;
public class AttributeVariant {
String id;
String model;
List<String> meshes;
public String getId(){
return id;
}
public String getModel(){
return model;
}
public List<String> getMeshes(){
return meshes;
}
}

View File

@ -0,0 +1,17 @@
package electrosphere.game.data.creature.type.visualattribute;
import java.util.List;
public class VisualAttribute {
String attributeId;
List<AttributeVariant> variants;
public String getAttributeId(){
return attributeId;
}
public List<AttributeVariant> getVariants(){
return variants;
}
}

View File

@ -168,10 +168,10 @@ public class Actor {
boolean hasDrawn = false;
if(model != null){
applyAnimationMasks(model);
if(!meshMask.isEmpty()){
meshMask.processMeshMaskQueue();
model.setMeshMask(meshMask);
}
meshMask.processMeshMaskQueue();
model.setMeshMask(meshMask);
// if(!meshMask.isEmpty()){
// }
// if(animation != null){
// model.playAnimation(animation);
// model.incrementTime(0.001);