massive entity spawning refactor
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
42bc5d38b9
commit
8408d84055
@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
{
|
||||
"creatureId" : "CUBE_MAN",
|
||||
"id" : "CUBE_MAN",
|
||||
"hitboxes" : [],
|
||||
"tokens" : [
|
||||
"SENTIENT",
|
||||
@ -41,9 +41,9 @@
|
||||
|
||||
],
|
||||
"files" : [
|
||||
"Data/creatures/human.json",
|
||||
"Data/creatures/animals.json",
|
||||
"Data/creatures/test.json"
|
||||
"Data/entity/creatures/human.json",
|
||||
"Data/entity/creatures/animals.json",
|
||||
"Data/entity/creatures/test.json"
|
||||
]
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"creatures" : [
|
||||
{
|
||||
"creatureId" : "Deer",
|
||||
"id" : "Deer",
|
||||
"hitboxes" : [
|
||||
{
|
||||
"type": "hurt",
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"creatures" : [
|
||||
{
|
||||
"creatureId" : "elf",
|
||||
"id" : "elf",
|
||||
"hitboxes" : [
|
||||
{
|
||||
"type": "hurt",
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"creatures" : [
|
||||
{
|
||||
"creatureId" : "goblin",
|
||||
"id" : "goblin",
|
||||
"hitboxes" : [
|
||||
{
|
||||
"type": "hurt",
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"creatures" : [
|
||||
{
|
||||
"creatureId" : "human",
|
||||
"id" : "human",
|
||||
"hitboxes" : [
|
||||
{
|
||||
"type": "hurt",
|
||||
@ -63,7 +63,8 @@
|
||||
"CAN_EQUIP",
|
||||
"INVENTORY",
|
||||
"OUTLINE",
|
||||
"PLAYABLE"
|
||||
"PLAYABLE",
|
||||
"UNIT_CONTROLS"
|
||||
],
|
||||
"visualAttributes" : [
|
||||
{
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"foliageList" : [
|
||||
{
|
||||
"name" : "FallOak1",
|
||||
"id" : "FallOak1",
|
||||
"tokens" : [
|
||||
"BLENDER_ROTATION"
|
||||
],
|
||||
@ -19,7 +19,7 @@
|
||||
"modelPath" : "Models/falloak1.fbx"
|
||||
},
|
||||
{
|
||||
"name" : "Green Grass",
|
||||
"id" : "Green Grass",
|
||||
"tokens" : [
|
||||
"AMBIENT",
|
||||
"REACTS_TO_WIND",
|
||||
@ -32,12 +32,13 @@
|
||||
"modelPath" : "Models/foliage/grass2.fbx"
|
||||
},
|
||||
{
|
||||
"name" : "oak",
|
||||
"id" : "oak",
|
||||
"tokens" : [
|
||||
"TREE",
|
||||
"REACTS_TO_WIND",
|
||||
"GROWS_BACK",
|
||||
"FLAMMABLE"
|
||||
"FLAMMABLE",
|
||||
"SEEDED"
|
||||
],
|
||||
"growthModel": {
|
||||
"growthRate" : 0.001
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
{
|
||||
"itemId" : "Katana",
|
||||
"id" : "Katana",
|
||||
"modelPath" : "Models/items/weapons/katana1alt.fbx",
|
||||
"weaponData" : {
|
||||
"weaponClass" : "sword1h",
|
||||
@ -53,7 +53,7 @@
|
||||
"iconPath" : "Textures/icons/itemIconWeapon.png"
|
||||
},
|
||||
{
|
||||
"itemId" : "Katana2H",
|
||||
"id" : "Katana2H",
|
||||
"modelPath" : "Models/items/weapons/katana1alt.glb",
|
||||
"weaponData" : {
|
||||
"weaponClass" : "sword2h",
|
||||
@ -124,7 +124,7 @@
|
||||
"iconPath" : "Textures/icons/itemIconWeapon.png"
|
||||
},
|
||||
{
|
||||
"itemId" : "bow1",
|
||||
"id" : "bow1",
|
||||
"modelPath": "Models/bow1.fbx",
|
||||
"weaponData" : {
|
||||
"weaponClass" : "bow2h",
|
||||
@ -157,7 +157,7 @@
|
||||
},
|
||||
|
||||
{
|
||||
"itemId" : "shorts1",
|
||||
"id" : "shorts1",
|
||||
"modelPath": "Models/items/itemEntityShorts.fbx",
|
||||
"equipData": {
|
||||
"equipClass" : "clothing",
|
||||
@ -195,7 +195,7 @@
|
||||
},
|
||||
|
||||
{
|
||||
"itemId" : "hairshort1",
|
||||
"id" : "hairshort1",
|
||||
"modelPath": "Models/itemEntityShorts.fbx",
|
||||
"equipData": {
|
||||
"equipClass" : "trait",
|
||||
@ -233,7 +233,7 @@
|
||||
},
|
||||
|
||||
{
|
||||
"itemId" : "boots1",
|
||||
"id" : "boots1",
|
||||
"modelPath": "Models/boots1.glb",
|
||||
"tokens" : [
|
||||
"GRAVITY",
|
||||
@ -272,7 +272,7 @@
|
||||
},
|
||||
|
||||
{
|
||||
"itemId" : "shirt1",
|
||||
"id" : "shirt1",
|
||||
"modelPath": "Models/itemEntityShorts.fbx",
|
||||
"tokens" : [
|
||||
"GRAVITY",
|
||||
@ -739,6 +739,7 @@ SSBO implementation
|
||||
Rearch instanced actor
|
||||
ParticleService implementation
|
||||
Fix SSBO implementation misusing BufferUtils
|
||||
Massive entity spawning refactor to collapse entity type permutations
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
@ -121,14 +121,6 @@
|
||||
"name" : "propertyValue",
|
||||
"type" : "FIXED_INT"
|
||||
},
|
||||
{
|
||||
"name" : "treeType",
|
||||
"type" : "FIXED_INT"
|
||||
},
|
||||
{
|
||||
"name" : "treeStatus",
|
||||
"type" : "FIXED_INT"
|
||||
},
|
||||
{
|
||||
"name" : "time",
|
||||
"type" : "FIXED_LONG"
|
||||
@ -145,79 +137,19 @@
|
||||
"name" : "bTreeID",
|
||||
"type" : "FIXED_INT"
|
||||
},
|
||||
{
|
||||
"name" : "propertyID",
|
||||
"type" : "FIXED_INT"
|
||||
},
|
||||
{
|
||||
"name" : "propertyValueInt",
|
||||
"type" : "FIXED_INT"
|
||||
},
|
||||
{
|
||||
"name" : "propertyValueFloat",
|
||||
"type" : "FIXED_FLOAT"
|
||||
},
|
||||
{
|
||||
"name" : "propertyValueDouble",
|
||||
"type" : "FIXED_DOUBLE"
|
||||
},
|
||||
{
|
||||
"name" : "propertyValueString",
|
||||
"type" : "VAR_STRING"
|
||||
},
|
||||
{
|
||||
"name" : "foliageSeed",
|
||||
"type" : "FIXED_LONG"
|
||||
}
|
||||
],
|
||||
"messageTypes" : [
|
||||
{
|
||||
"messageName" : "Create",
|
||||
"description" : "Spawns an empty entity on the client",
|
||||
"description" : "Spawns an entity on the client",
|
||||
"data" : [
|
||||
"entityID",
|
||||
"entityCategory",
|
||||
"entitySubtype",
|
||||
"positionX",
|
||||
"positionY",
|
||||
"positionZ"
|
||||
]
|
||||
},
|
||||
{
|
||||
"messageName" : "SpawnCreature",
|
||||
"description" : "Spawns a creature on the client",
|
||||
"data" : [
|
||||
"entityID",
|
||||
"creatureTemplate",
|
||||
"positionX",
|
||||
"positionY",
|
||||
"positionZ",
|
||||
"rotationX",
|
||||
"rotationY",
|
||||
"rotationZ",
|
||||
"rotationW"
|
||||
]
|
||||
},
|
||||
{
|
||||
"messageName" : "SpawnItem",
|
||||
"description" : "Spawns an item on the client",
|
||||
"data" : [
|
||||
"entityID",
|
||||
"creatureTemplate",
|
||||
"positionX",
|
||||
"positionY",
|
||||
"positionZ",
|
||||
"rotationX",
|
||||
"rotationY",
|
||||
"rotationZ",
|
||||
"rotationW"
|
||||
]
|
||||
},
|
||||
{
|
||||
"messageName" : "SpawnObject",
|
||||
"description" : "Spawns a generic object",
|
||||
"data" : [
|
||||
"entityID",
|
||||
"creatureTemplate",
|
||||
"positionX",
|
||||
"positionY",
|
||||
@ -301,22 +233,6 @@
|
||||
"targetID"
|
||||
]
|
||||
},
|
||||
{
|
||||
"messageName" : "SpawnFoliageSeed",
|
||||
"description" : "Spawns a foliage object on the client with a given seed value",
|
||||
"data" : [
|
||||
"entityID",
|
||||
"creatureTemplate",
|
||||
"foliageSeed",
|
||||
"positionX",
|
||||
"positionY",
|
||||
"positionZ",
|
||||
"rotationX",
|
||||
"rotationY",
|
||||
"rotationZ",
|
||||
"rotationW"
|
||||
]
|
||||
},
|
||||
{
|
||||
"messageName" : "updateEntityViewDir",
|
||||
"description" : "Updates the server's value for where the player is looking",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package electrosphere.audio;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.util.math.MathUtils;
|
||||
|
||||
|
||||
@ -10,8 +10,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
|
||||
/**
|
||||
|
||||
@ -9,7 +9,6 @@ import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.entity.types.object.ObjectUtils;
|
||||
import electrosphere.game.data.collidable.HitboxData;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
|
||||
@ -134,8 +133,8 @@ public class HitboxAudioService {
|
||||
String message = "Getting audio for unhandled hurtbox collision type!\n" +
|
||||
"Is creature: " + CreatureUtils.isCreature(receiverEntity) + "\n" +
|
||||
"Is item: " + ItemUtils.isItem(receiverEntity) + "\n" +
|
||||
"Is weapon: " + ItemUtils.isWeapon(receiverEntity) + "\n" +
|
||||
"Is object: " + ObjectUtils.isObject(receiverEntity);
|
||||
"Is weapon: " + ItemUtils.isWeapon(receiverEntity)
|
||||
;
|
||||
if(ItemUtils.isItem(receiverEntity)){
|
||||
message = message + "\nItem Type: " + ItemUtils.getType(receiverEntity);
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.entity.types.object.ObjectUtils;
|
||||
import electrosphere.game.data.collidable.HitboxData;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
|
||||
@ -111,8 +110,8 @@ public class ClientHitboxCollision {
|
||||
String message = "Getting audio for unhandled hurtbox collision type!\n" +
|
||||
"Is creature: " + CreatureUtils.isCreature(receiverEntity) + "\n" +
|
||||
"Is item: " + ItemUtils.isItem(receiverEntity) + "\n" +
|
||||
"Is weapon: " + ItemUtils.isWeapon(receiverEntity) + "\n" +
|
||||
"Is object: " + ObjectUtils.isObject(receiverEntity);
|
||||
"Is weapon: " + ItemUtils.isWeapon(receiverEntity)
|
||||
;
|
||||
if(ItemUtils.isItem(receiverEntity)){
|
||||
message = message + "\nItem Type: " + ItemUtils.getType(receiverEntity);
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package electrosphere.client.effects;
|
||||
|
||||
import electrosphere.client.entity.particle.ParticleUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.ClientEntityUtils;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.particle.ParticleUtils;
|
||||
import electrosphere.game.data.particle.ParticleData;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.entity.types.camera;
|
||||
package electrosphere.client.entity.camera;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
@ -1,11 +1,11 @@
|
||||
package electrosphere.client.targeting.crosshair;
|
||||
package electrosphere.client.entity.crosshair;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
|
||||
@ -25,7 +25,7 @@ public class Crosshair {
|
||||
public static void initCrossHairEntity(){
|
||||
crossHairEntity = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(crossHairEntity, "/Models/engine/lockoncrosshair1.fbx");
|
||||
EntityUtils.setVisible(crossHairEntity, false);
|
||||
// EntityUtils.setVisible(crossHairEntity, false);
|
||||
}
|
||||
|
||||
|
||||
@ -49,10 +49,10 @@ public class Crosshair {
|
||||
if(target != null){
|
||||
// System.out.println("Found target!");
|
||||
currentTarget = target;
|
||||
EntityUtils.setVisible(crossHairEntity, true);
|
||||
// EntityUtils.setVisible(crossHairEntity, true);
|
||||
} else {
|
||||
currentTarget = null;
|
||||
EntityUtils.setVisible(crossHairEntity, false);
|
||||
// EntityUtils.setVisible(crossHairEntity, false);
|
||||
}
|
||||
}
|
||||
// } else {
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.entity.types.debug;
|
||||
package electrosphere.client.entity.debug;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.entity.types.instance;
|
||||
package electrosphere.client.entity.instance;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.entity.types.instance;
|
||||
package electrosphere.client.entity.instance;
|
||||
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Vector3d;
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.entity.types.particle;
|
||||
package electrosphere.client.entity.particle;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.DrawableUtils;
|
||||
@ -18,13 +18,13 @@ import org.joml.Vector3f;
|
||||
import org.joml.Vector3i;
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.client.terrain.cache.ChunkData;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.foliage.AmbientFoliage;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.game.data.foliage.type.FoliageType;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
import electrosphere.renderer.RenderPipelineState;
|
||||
|
||||
@ -4,11 +4,11 @@ import java.util.Set;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.renderer.actor.instance.InstancedActor;
|
||||
|
||||
/**
|
||||
|
||||
@ -2,9 +2,10 @@ package electrosphere.client.sim;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.client.entity.crosshair.Crosshair;
|
||||
import electrosphere.client.fluid.manager.ClientFluidManager;
|
||||
import electrosphere.client.instancing.InstanceUpdater;
|
||||
import electrosphere.client.targeting.crosshair.Crosshair;
|
||||
import electrosphere.client.terrain.manager.ClientTerrainManager;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
@ -13,7 +14,6 @@ import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.collidable.ClientCollidableTree;
|
||||
import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
|
||||
@ -4,12 +4,12 @@ import org.joml.Quaternionf;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.client.targeting.crosshair.Crosshair;
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.client.entity.crosshair.Crosshair;
|
||||
import electrosphere.collision.CollisionEngine;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.renderer.ui.events.MouseEvent;
|
||||
import electrosphere.util.math.MathUtils;
|
||||
|
||||
@ -73,8 +73,9 @@ import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.client.entity.crosshair.Crosshair;
|
||||
import electrosphere.client.item.ItemActions;
|
||||
import electrosphere.client.targeting.crosshair.Crosshair;
|
||||
import electrosphere.client.terrain.editing.TerrainEditing;
|
||||
import electrosphere.collision.CollisionEngine;
|
||||
import electrosphere.controls.Control.ControlMethod;
|
||||
@ -94,7 +95,6 @@ import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.M
|
||||
import electrosphere.entity.state.movement.jump.ClientJumpTree;
|
||||
import electrosphere.entity.state.movement.sprint.ClientSprintTree;
|
||||
import electrosphere.entity.state.movement.walk.ClientWalkTree;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.menu.WindowStrings;
|
||||
|
||||
@ -5,10 +5,11 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.client.entity.crosshair.Crosshair;
|
||||
import electrosphere.client.fluid.cells.FluidCellManager;
|
||||
import electrosphere.client.foliagemanager.ClientFoliageManager;
|
||||
import electrosphere.client.sim.ClientSimulation;
|
||||
import electrosphere.client.targeting.crosshair.Crosshair;
|
||||
import electrosphere.client.terrain.cells.DrawCellManager;
|
||||
import electrosphere.controls.ControlHandler;
|
||||
import electrosphere.engine.Globals;
|
||||
@ -19,7 +20,6 @@ import electrosphere.entity.DrawableUtils;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.menu.MenuGenerators;
|
||||
import electrosphere.menu.WindowStrings;
|
||||
|
||||
@ -158,7 +158,7 @@ public class LoadingUtils {
|
||||
//
|
||||
//send default template back
|
||||
String race = Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces().get(0);
|
||||
CreatureData type = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(race);
|
||||
CreatureData type = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(race);
|
||||
CreatureTemplate template = CreatureTemplate.create(race);
|
||||
for(VisualAttribute attribute : type.getVisualAttributes()){
|
||||
if(attribute.getType().equals(VisualAttribute.TYPE_BONE)){
|
||||
|
||||
@ -14,6 +14,18 @@ import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
||||
import electrosphere.server.poseactor.PoseActorUtils;
|
||||
|
||||
public class EntityCreationUtils {
|
||||
|
||||
/**
|
||||
* Spawns an entity that has a position in the world, but isn't necessarily drawable
|
||||
* @return the entity
|
||||
*/
|
||||
protected static Entity spawnSpatialEntity(){
|
||||
Entity rVal = new Entity();
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(0,0,0));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaterniond().identity());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a server entity in the given realm and position. This uses spatial entity as a server entity can't (currently) exist outside of a realm.
|
||||
@ -22,7 +34,7 @@ public class EntityCreationUtils {
|
||||
* @return The entity
|
||||
*/
|
||||
public static Entity createServerEntity(Realm realm, Vector3d position){
|
||||
Entity rVal = EntityUtils.spawnSpatialEntity();
|
||||
Entity rVal = EntityCreationUtils.spawnSpatialEntity();
|
||||
//register to global entity id lookup table
|
||||
EntityLookupUtils.registerServerEntity(rVal);
|
||||
//assign to realm
|
||||
@ -63,7 +75,7 @@ public class EntityCreationUtils {
|
||||
* @return The entity
|
||||
*/
|
||||
public static Entity createClientSpatialEntity(){
|
||||
Entity rVal = EntityUtils.spawnSpatialEntity();
|
||||
Entity rVal = EntityCreationUtils.spawnSpatialEntity();
|
||||
Globals.clientSceneWrapper.getScene().registerEntity(rVal);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -4,6 +4,12 @@ package electrosphere.entity;
|
||||
* Data strings for entities
|
||||
*/
|
||||
public class EntityDataStrings {
|
||||
|
||||
/**
|
||||
* Serialization
|
||||
*/
|
||||
public static final String SHOULD_SERIALIZE = "shouldSerialize";
|
||||
public static final String SHOULD_SYNCHRONIZE = "shouldSynchronize";
|
||||
|
||||
|
||||
/*
|
||||
@ -236,18 +242,11 @@ public class EntityDataStrings {
|
||||
*/
|
||||
public static final String IS_PARTICLE = "isParticle";
|
||||
public static final String TREE_CLIENTPARTICLETREE = "treeClientParticleTree";
|
||||
|
||||
|
||||
/*
|
||||
Structure entity
|
||||
*/
|
||||
public static final String STRUCTURE_IS_STRUCTURE = "structureIsStructure";
|
||||
public static final String STRUCTURE_TYPE = "structureType";
|
||||
|
||||
|
||||
/*
|
||||
Foliage entity
|
||||
*/
|
||||
public static final String FOLIAGE_IS_FOLIAGE = "foliageIsFoliage";
|
||||
public static final String FOLIAGE_TYPE = "foliageType";
|
||||
public static final String FOLIAGE_AMBIENT_TREE = "foliageAmbientTree";
|
||||
public static final String FOLIAGE_SEED = "foliageSeed";
|
||||
|
||||
@ -2,13 +2,10 @@ package electrosphere.entity;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.ActorUtils;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.datacell.ServerDataCell;
|
||||
import electrosphere.server.datacell.utils.EntityLookupUtils;
|
||||
import electrosphere.server.poseactor.PoseActor;
|
||||
import electrosphere.server.poseactor.PoseActorUtils;
|
||||
import electrosphere.util.math.MathUtils;
|
||||
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Vector3d;
|
||||
@ -31,88 +28,6 @@ public class EntityUtils {
|
||||
return (Vector3f)e.getData(EntityDataStrings.DATA_STRING_SCALE);
|
||||
}
|
||||
|
||||
public static String getModelPath(Entity e){
|
||||
return (String)e.getData(EntityDataStrings.DATA_STRING_MODEL_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an entity with an associated actor
|
||||
* @param modelPath The model path of the model for the actor
|
||||
* @return The entity
|
||||
*/
|
||||
protected static Entity spawnDrawableEntity(String modelPath){
|
||||
Entity rVal = new Entity();
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ACTOR, ActorUtils.createActorFromModelPath(modelPath));
|
||||
// rVal.putData(EntityDataStrings.DATA_STRING_MODEL_PATH, modelPath);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(0,0,0));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaterniond().identity());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||
rVal.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
||||
Globals.clientScene.registerEntity(rVal);
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.DRAWABLE);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an entity with an actor based on a model that already exists or is actively being loaded, not sure
|
||||
* @param modelPath The path to the model in asset manager
|
||||
* @return The entity
|
||||
*/
|
||||
protected static Entity spawnDrawableEntityWithPreexistingModel(String modelPath){
|
||||
Entity rVal = new Entity();
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ACTOR, ActorUtils.createActorOfLoadingModel(modelPath));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(0,0,0));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaterniond().rotateAxis(0, MathUtils.getOriginVector()));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||
rVal.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
||||
Globals.clientScene.registerEntity(rVal);
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.DRAWABLE);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns an entity with a backing pose actor (server side presumably)
|
||||
* @param modelPath The model path to back the pose actor
|
||||
* @return The entity
|
||||
*/
|
||||
protected static Entity spawnPoseableEntity(String modelPath){
|
||||
Entity rVal = new Entity();
|
||||
rVal.putData(EntityDataStrings.POSE_ACTOR, PoseActorUtils.createPoseActorFromModelPath(modelPath));
|
||||
// rVal.putData(EntityDataStrings.DATA_STRING_MODEL_PATH, modelPath);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(0,0,0));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaterniond().identity());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||
rVal.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
protected static Entity spawnUIEntity(String modelPath){
|
||||
Entity rVal = new Entity();
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ACTOR, ActorUtils.createActorFromModelPath(modelPath));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(0,0,0));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaterniond().rotateAxis(0, MathUtils.getOriginVector()));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_UI_ELEMENT, true);
|
||||
Globals.clientScene.registerEntity(rVal);
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.UI);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns an entity that has a position in the world, but isn't necessarily drawable
|
||||
* @return the entity
|
||||
*/
|
||||
protected static Entity spawnSpatialEntity(){
|
||||
Entity rVal = new Entity();
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(0,0,0));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaterniond().identity());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up the entity and deregisters it from all tracking datastructures
|
||||
* @param e The entity to clean up
|
||||
@ -157,52 +72,4 @@ public class EntityUtils {
|
||||
return (PoseActor)e.getData(EntityDataStrings.POSE_ACTOR);
|
||||
}
|
||||
|
||||
public static void setVisible(Entity entity, boolean visible){
|
||||
entity.putData(EntityDataStrings.DATA_STRING_DRAW, visible);
|
||||
}
|
||||
|
||||
public static void setDraw(Entity entity, boolean draw){
|
||||
entity.putData(EntityDataStrings.DATA_STRING_DRAW, draw);
|
||||
}
|
||||
|
||||
public static boolean getDraw(Entity entity){
|
||||
return (boolean)entity.getData(EntityDataStrings.DATA_STRING_DRAW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of the entity
|
||||
* @param entity The entity
|
||||
* @return The type
|
||||
*/
|
||||
public static int getEntityType(Entity entity){
|
||||
return (int)entity.getData(EntityDataStrings.ENTITY_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the entity type
|
||||
* @param entity the entity
|
||||
* @param type the type
|
||||
*/
|
||||
public static void setEntityType(Entity entity, int type){
|
||||
entity.putData(EntityDataStrings.ENTITY_TYPE, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subtype of this entity
|
||||
* @param entity The entity
|
||||
* @return The subtype
|
||||
*/
|
||||
public static String getEntitySubtype(Entity entity){
|
||||
return (String)entity.getData(EntityDataStrings.ENTITY_SUBTYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subtype of this entity
|
||||
* @param entity The entity
|
||||
* @param subtype The subtype
|
||||
*/
|
||||
public static void setEntitySubtype(Entity entity, String subtype){
|
||||
entity.putData(EntityDataStrings.ENTITY_SUBTYPE, subtype);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,9 +7,9 @@ import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.TreeDataAudio;
|
||||
import electrosphere.game.data.common.TreeDataState;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAudio;
|
||||
import electrosphere.game.data.common.treedata.TreeDataState;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.server.poseactor.PoseActor;
|
||||
|
||||
@ -5,9 +5,9 @@ import org.joml.Vector3d;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.entity.types.object.ObjectUtils;
|
||||
import electrosphere.game.server.world.ServerWorldData;
|
||||
import electrosphere.server.content.ServerContentManager;
|
||||
import electrosphere.server.datacell.GriddedDataCellManager;
|
||||
@ -100,7 +100,7 @@ public class SceneLoader {
|
||||
|
||||
case EntityDescriptor.TYPE_OBJECT: {
|
||||
Vector3d position = new Vector3d(descriptor.posX,descriptor.posY,descriptor.posZ);
|
||||
Entity newEntity = ObjectUtils.serverSpawnBasicObject(realm, position, descriptor.subtype);
|
||||
Entity newEntity = CommonEntityUtils.serverSpawnBasicObject(realm, position, descriptor.subtype);
|
||||
EntityUtils.getPosition(newEntity).set(descriptor.posX,descriptor.posY,descriptor.posZ);
|
||||
EntityUtils.getRotation(newEntity).set((float)descriptor.rotX, (float)descriptor.rotY, (float)descriptor.rotZ, (float)descriptor.rotW);
|
||||
} break;
|
||||
|
||||
@ -17,7 +17,7 @@ import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.game.data.common.TreeDataState;
|
||||
import electrosphere.game.data.common.treedata.TreeDataState;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.item.type.WeaponData;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
|
||||
@ -25,7 +25,7 @@ import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.entity.types.projectile.ProjectileUtils;
|
||||
import electrosphere.game.data.common.TreeDataState;
|
||||
import electrosphere.game.data.common.treedata.TreeDataState;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.game.data.item.type.WeaponData;
|
||||
|
||||
@ -5,7 +5,7 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
|
||||
/**
|
||||
|
||||
@ -19,7 +19,7 @@ import electrosphere.entity.state.gravity.GravityUtils;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.game.data.item.type.EquipWhitelist;
|
||||
import electrosphere.game.data.item.type.Item;
|
||||
@ -155,8 +155,6 @@ public class ClientEquipState implements BehaviorTree {
|
||||
if(PhysicsEntityUtils.containsDBody(toEquip) && toEquip.containsKey(EntityDataStrings.PHYSICS_COLLIDABLE)){
|
||||
Globals.clientSceneWrapper.getCollisionEngine().destroyPhysics(toEquip);
|
||||
}
|
||||
//hide toEquip actor
|
||||
EntityUtils.setDraw(toEquip, false);
|
||||
//make untargetable
|
||||
Globals.clientSceneWrapper.getScene().removeEntityFromTag(toEquip, EntityTags.TARGETABLE);
|
||||
break;
|
||||
|
||||
@ -26,7 +26,7 @@ import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
import electrosphere.game.data.creature.type.block.BlockSystem;
|
||||
import electrosphere.game.data.creature.type.block.BlockVariant;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
@ -130,8 +130,6 @@ public class ServerEquipState implements BehaviorTree {
|
||||
Realm inWorldRealm = Globals.realmManager.getEntityRealm(inWorldItem);
|
||||
inWorldRealm.getCollisionEngine().destroyPhysics(inWorldItem);
|
||||
}
|
||||
//hide toEquip actor
|
||||
EntityUtils.setDraw(inWorldItem, false);
|
||||
//make untargetable
|
||||
ServerEntityTagUtils.removeTagFromEntity(inWorldItem, EntityTags.TARGETABLE);
|
||||
break;
|
||||
|
||||
@ -47,7 +47,7 @@ public class ClientIdleTree implements BehaviorTree {
|
||||
state = IdleTreeState.IDLE;
|
||||
parent = e;
|
||||
//check if this is a creature, if so add its idle data
|
||||
CreatureData creatureType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(CreatureUtils.getType(parent));
|
||||
CreatureData creatureType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(CreatureUtils.getType(parent));
|
||||
if(creatureType != null){
|
||||
idleData = creatureType.getIdleData();
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ import electrosphere.entity.btree.StateTransitionUtil;
|
||||
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
|
||||
import electrosphere.entity.state.gravity.ServerGravityTree;
|
||||
import electrosphere.entity.state.movement.jump.ServerJumpTree;
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
import electrosphere.game.data.creature.type.movement.FallMovementSystem;
|
||||
import electrosphere.server.poseactor.PoseActor;
|
||||
|
||||
|
||||
@ -4,10 +4,10 @@ package electrosphere.entity.state.movement.groundmove;
|
||||
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||
import electrosphere.net.parser.net.message.SynchronizationMessage;
|
||||
import electrosphere.entity.state.gravity.GravityUtils;
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.collision.collidable.Collidable;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.game.data.creature.type.movement.GroundMovementSystem;
|
||||
import electrosphere.entity.Entity;
|
||||
|
||||
@ -4,6 +4,7 @@ import org.joml.Quaterniond;
|
||||
import org.joml.Vector3d;
|
||||
import org.ode4j.ode.DBody;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.collision.PhysicsUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
@ -11,7 +12,6 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
|
||||
|
||||
@ -2,12 +2,12 @@ package electrosphere.entity.state.server;
|
||||
|
||||
import org.joml.Quaterniond;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.controls.CameraHandler;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
|
||||
|
||||
|
||||
73
src/main/java/electrosphere/entity/types/EntityTypes.java
Normal file
73
src/main/java/electrosphere/entity/types/EntityTypes.java
Normal file
@ -0,0 +1,73 @@
|
||||
package electrosphere.entity.types;
|
||||
|
||||
/**
|
||||
* Types of entities
|
||||
*/
|
||||
public class EntityTypes {
|
||||
|
||||
|
||||
/**
|
||||
* <p> The distinct types of entities </p>
|
||||
* The non-common entity types have a unique creation flow
|
||||
*/
|
||||
public static enum EntityType {
|
||||
/**
|
||||
* A creature
|
||||
*/
|
||||
CREATURE(0),
|
||||
/**
|
||||
* An item
|
||||
*/
|
||||
ITEM(1),
|
||||
/**
|
||||
* The common entity type
|
||||
*/
|
||||
COMMON(2),
|
||||
/**
|
||||
* A piece of foliage
|
||||
*/
|
||||
FOLIAGE(3);
|
||||
|
||||
/**
|
||||
* the value of the enum
|
||||
*/
|
||||
private final int value;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param newValue The value
|
||||
*/
|
||||
EntityType(final int newValue){
|
||||
value = newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the enum
|
||||
* @return The value
|
||||
*/
|
||||
public int getValue(){
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an entity type from a value
|
||||
* @param value The value
|
||||
* @return The corresponding entity type
|
||||
*/
|
||||
public static EntityType fromInt(int value){
|
||||
switch(value){
|
||||
case 0:
|
||||
return EntityType.CREATURE;
|
||||
case 1:
|
||||
return EntityType.ITEM;
|
||||
case 2:
|
||||
return EntityType.COMMON;
|
||||
case 3:
|
||||
return EntityType.FOLIAGE;
|
||||
}
|
||||
throw new IllegalArgumentException("Trying to get invalid entity type! " + value);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,20 +2,16 @@ package electrosphere.entity.types.collision;
|
||||
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
import org.ode4j.ode.DBody;
|
||||
|
||||
import electrosphere.collision.CollisionBodyCreation;
|
||||
import electrosphere.collision.CollisionEngine;
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.collision.PhysicsUtils;
|
||||
import electrosphere.collision.collidable.Collidable;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
|
||||
/**
|
||||
@ -23,207 +19,6 @@ import electrosphere.server.datacell.Realm;
|
||||
*/
|
||||
public class CollisionObjUtils {
|
||||
|
||||
public static Entity clientSpawnCollisionPlane(Vector3f scale, Vector3d position, Quaterniond rotation){
|
||||
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||
|
||||
float mass = 1.0f;
|
||||
|
||||
DBody planeObject = CollisionBodyCreation.createPlaneBody(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT);
|
||||
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, planeObject);
|
||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
|
||||
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(planeObject, collidable);
|
||||
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_PLANE, true);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, rotation);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, scale);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLISION_OBJECT, planeObject);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLIDABLE, collidable);
|
||||
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity serverSpawnCollisionPlane(Realm realm, Vector3f scale, Vector3d position, Quaterniond rotation){
|
||||
Entity rVal = EntityCreationUtils.createServerEntity(realm, new Vector3d(position));
|
||||
|
||||
float mass = 1.0f;
|
||||
|
||||
DBody planeObject = CollisionBodyCreation.createPlaneBody(realm.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT);
|
||||
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, planeObject);
|
||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
|
||||
realm.getCollisionEngine().registerCollisionObject(planeObject, collidable);
|
||||
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_PLANE, true);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, rotation);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, scale);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLISION_OBJECT, planeObject);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLIDABLE, collidable);
|
||||
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
public static Entity clientSpawnCollisionCube(Vector3f scale, Vector3d position, Quaterniond rotation){
|
||||
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||
|
||||
float mass = 1.0f;
|
||||
|
||||
DBody cubeObject = CollisionBodyCreation.createCubeBody(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT);
|
||||
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, cubeObject);
|
||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
|
||||
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
||||
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CUBE, true);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, rotation);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, scale);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLISION_OBJECT, cubeObject);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLIDABLE, collidable);
|
||||
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity serverSpawnCollisionCube(Realm realm, Vector3f scale, Vector3d position, Quaterniond rotation){
|
||||
Entity rVal = EntityCreationUtils.createServerEntity(realm, new Vector3d(position));
|
||||
|
||||
float mass = 1.0f;
|
||||
|
||||
DBody cubeObject = CollisionBodyCreation.createCubeBody(realm.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT);
|
||||
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, cubeObject);
|
||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
|
||||
realm.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
||||
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CUBE, true);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, rotation);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, scale);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLISION_OBJECT, cubeObject);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLIDABLE, collidable);
|
||||
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity clientSpawnCollisionCylinder(Vector3f scale, Vector3d position, Quaterniond rotation){
|
||||
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||
|
||||
float mass = 1.0f;
|
||||
DBody cubeObject = CollisionBodyCreation.createCylinderBody(Globals.clientSceneWrapper.getCollisionEngine(),scale.x,scale.y,Collidable.TYPE_STATIC_BIT);
|
||||
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, cubeObject);
|
||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
|
||||
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
||||
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CYLINDER, true);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, rotation);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, scale);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLISION_OBJECT, cubeObject);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLIDABLE, collidable);
|
||||
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity serverSpawnCollisionCylinder(Realm realm, Vector3f scale, Vector3d position, Quaterniond rotation){
|
||||
Entity rVal = EntityCreationUtils.createServerEntity(realm, new Vector3d(position));
|
||||
|
||||
float mass = 1.0f;
|
||||
DBody cubeObject = CollisionBodyCreation.createCylinderBody(realm.getCollisionEngine(),scale.x,scale.y,Collidable.TYPE_STATIC_BIT);
|
||||
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, cubeObject);
|
||||
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
|
||||
realm.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
|
||||
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CYLINDER, true);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, rotation);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, scale);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLISION_OBJECT, cubeObject);
|
||||
rVal.putData(EntityDataStrings.COLLISION_ENTITY_COLLIDABLE, collidable);
|
||||
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
public static Entity clientAttachCollisionPlane(Vector3f scale, Vector3d position, Quaterniond rotation, Entity parent){
|
||||
Entity rVal = clientSpawnCollisionPlane(scale, position, rotation);
|
||||
|
||||
AttachUtils.attachEntityToEntity(parent, rVal);
|
||||
|
||||
float mass = 1.0f;
|
||||
parent.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity serverAttachCollisionPlane(Vector3f scale, Vector3d position, Quaterniond rotation, Entity parent){
|
||||
Realm parentRealm = Globals.realmManager.getEntityRealm(parent);
|
||||
Entity rVal = serverSpawnCollisionPlane(parentRealm, scale, position, rotation);
|
||||
|
||||
AttachUtils.attachEntityToEntity(parent, rVal);
|
||||
|
||||
float mass = 1.0f;
|
||||
parent.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity clientAttachCollisionCube(Vector3f scale, Vector3d position, Quaterniond rotation, Entity parent){
|
||||
Entity rVal = clientSpawnCollisionCube(scale, position, rotation);
|
||||
|
||||
AttachUtils.attachEntityToEntity(parent, rVal);
|
||||
|
||||
float mass = 1.0f;
|
||||
parent.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity serverAttachCollisionCube(Vector3f scale, Vector3d position, Quaterniond rotation, Entity parent){
|
||||
Realm parentRealm = Globals.realmManager.getEntityRealm(parent);
|
||||
Entity rVal = serverSpawnCollisionCube(parentRealm, scale, position, rotation);
|
||||
|
||||
AttachUtils.attachEntityToEntity(parent, rVal);
|
||||
|
||||
float mass = 1.0f;
|
||||
parent.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity clientAttachCollisionCylinder(Vector3f scale, Vector3d position, Quaterniond rotation, Entity parent){
|
||||
Entity rVal = clientSpawnCollisionCylinder(scale, position, rotation);
|
||||
|
||||
AttachUtils.attachEntityToEntity(parent, rVal);
|
||||
|
||||
float mass = 1.0f;
|
||||
parent.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity serverAttachCollisionCylinder(Vector3f scale, Vector3d position, Quaterniond rotation, Entity parent){
|
||||
Realm parentRealm = Globals.realmManager.getEntityRealm(parent);
|
||||
Entity rVal = serverSpawnCollisionCylinder(parentRealm, scale, position, rotation);
|
||||
|
||||
AttachUtils.attachEntityToEntity(parent, rVal);
|
||||
|
||||
float mass = 1.0f;
|
||||
parent.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a collision object to a provided entity
|
||||
* @param entity The entity to attach a collision object to
|
||||
@ -234,7 +29,6 @@ public class CollisionObjUtils {
|
||||
public static void clientAttachCollisionObjectToEntity(Entity entity, DBody collisionObject, float mass, String collidableType){
|
||||
Vector3d position = EntityUtils.getPosition(entity);
|
||||
Quaterniond rotation = EntityUtils.getRotation(entity);
|
||||
Vector3f scale = EntityUtils.getScale(entity);
|
||||
Collidable collidable = new Collidable(entity, collidableType, true);
|
||||
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(collisionObject, collidable);
|
||||
|
||||
@ -257,7 +51,6 @@ public class CollisionObjUtils {
|
||||
*/
|
||||
public static void serverAttachCollisionObjectToEntity(Entity entity, DBody collisionObject, float mass, String collidableType){
|
||||
Vector3d position = EntityUtils.getPosition(entity);
|
||||
Vector3f scale = EntityUtils.getScale(entity);
|
||||
Collidable collidable = new Collidable(entity, collidableType, true);
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
realm.getCollisionEngine().registerCollisionObject(collisionObject, collidable);
|
||||
|
||||
@ -0,0 +1,823 @@
|
||||
package electrosphere.entity.types.common;
|
||||
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Vector3d;
|
||||
import org.ode4j.ode.DBody;
|
||||
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.collision.collidable.Collidable;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.assetmanager.PhysicsMeshQueueItem;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||
import electrosphere.entity.state.attack.ShooterTree;
|
||||
import electrosphere.entity.state.block.ClientBlockTree;
|
||||
import electrosphere.entity.state.block.ServerBlockTree;
|
||||
import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.state.equip.ServerEquipState;
|
||||
import electrosphere.entity.state.gravity.ClientGravityTree;
|
||||
import electrosphere.entity.state.gravity.ServerGravityTree;
|
||||
import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
||||
import electrosphere.entity.state.idle.ClientIdleTree;
|
||||
import electrosphere.entity.state.idle.ServerIdleTree;
|
||||
import electrosphere.entity.state.inventory.ClientInventoryState;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
||||
import electrosphere.entity.state.inventory.ServerInventoryState;
|
||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
import electrosphere.entity.state.life.ClientLifeTree;
|
||||
import electrosphere.entity.state.life.ServerLifeTree;
|
||||
import electrosphere.entity.state.movement.fall.ClientFallTree;
|
||||
import electrosphere.entity.state.movement.fall.ServerFallTree;
|
||||
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
|
||||
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
|
||||
import electrosphere.entity.state.movement.jump.ClientJumpTree;
|
||||
import electrosphere.entity.state.movement.jump.ServerJumpTree;
|
||||
import electrosphere.entity.state.movement.sprint.ClientSprintTree;
|
||||
import electrosphere.entity.state.movement.sprint.ServerSprintTree;
|
||||
import electrosphere.entity.state.movement.walk.ClientWalkTree;
|
||||
import electrosphere.entity.state.movement.walk.ServerWalkTree;
|
||||
import electrosphere.entity.state.physicssync.upright.ClientAlwaysUprightTree;
|
||||
import electrosphere.entity.state.physicssync.upright.ServerAlwaysUprightTree;
|
||||
import electrosphere.entity.state.rotator.RotatorHierarchyNode;
|
||||
import electrosphere.entity.state.rotator.RotatorTree;
|
||||
import electrosphere.entity.state.rotator.ServerRotatorTree;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.game.data.collidable.CollidableTemplate;
|
||||
import electrosphere.game.data.common.CommonEntityType;
|
||||
import electrosphere.game.data.creature.type.CreatureData;
|
||||
import electrosphere.game.data.creature.type.SprintSystem;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.movement.FallMovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.GroundMovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.JumpMovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.MovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.WalkMovementSystem;
|
||||
import electrosphere.game.data.creature.type.rotator.RotatorConstraint;
|
||||
import electrosphere.game.data.creature.type.rotator.RotatorItem;
|
||||
import electrosphere.game.data.creature.type.rotator.RotatorSystem;
|
||||
import electrosphere.game.data.foliage.type.FoliageType;
|
||||
import electrosphere.game.data.item.type.Item;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.net.parser.net.message.NetworkMessage;
|
||||
import electrosphere.net.server.player.Player;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.ActorBoneRotator;
|
||||
import electrosphere.renderer.actor.ActorUtils;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
||||
import electrosphere.server.poseactor.PoseActor;
|
||||
import electrosphere.util.math.MathUtils;
|
||||
|
||||
/**
|
||||
* Utilities for creating all entity types
|
||||
*/
|
||||
public class CommonEntityUtils {
|
||||
|
||||
/**
|
||||
* Performs transforms common to all entity types given an entity and a template
|
||||
* @param entity The entity to perform transforms on
|
||||
* @param template The type of entity
|
||||
* @return The entity
|
||||
*/
|
||||
public static Entity clientSpawnBasicCreature(Entity entity, CommonEntityType rawType){
|
||||
|
||||
//
|
||||
//Set typing stuff
|
||||
//
|
||||
CommonEntityUtils.setTyping(entity,rawType);
|
||||
|
||||
//tracks whether to generate a drawable or not
|
||||
boolean generateDrawable = true;
|
||||
|
||||
//
|
||||
//
|
||||
// Tokens that should be processed before other work is done
|
||||
//
|
||||
//
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "GENERATE_COLLISION_OBJECT": {
|
||||
Globals.assetManager.addCollisionMeshToQueue(new PhysicsMeshQueueItem(Globals.clientSceneWrapper.getCollisionEngine(),rawType.getModelPath()));
|
||||
Globals.clientSceneWrapper.getScene().registerBehaviorTree(new BehaviorTree() {public void simulate(float deltaTime) {
|
||||
DBody collisionObject = Globals.assetManager.fetchCollisionObject(Globals.clientSceneWrapper.getCollisionEngine(),rawType.getModelPath());
|
||||
if(collisionObject != null){
|
||||
Globals.clientSceneWrapper.getScene().deregisterBehaviorTree(this);
|
||||
CollisionObjUtils.clientAttachCollisionObjectToEntity(entity, collisionObject, 0, Collidable.TYPE_OBJECT);
|
||||
}
|
||||
}});
|
||||
} break;
|
||||
case "GENERATE_COLLISION_TERRAIN": {
|
||||
Globals.assetManager.addCollisionMeshToQueue(new PhysicsMeshQueueItem(Globals.clientSceneWrapper.getCollisionEngine(),rawType.getModelPath()));
|
||||
Globals.clientSceneWrapper.getScene().registerBehaviorTree(new BehaviorTree() {public void simulate(float deltaTime) {
|
||||
DBody collisionObject = Globals.assetManager.fetchCollisionObject(Globals.clientSceneWrapper.getCollisionEngine(),rawType.getModelPath());
|
||||
if(collisionObject != null){
|
||||
Globals.clientSceneWrapper.getScene().deregisterBehaviorTree(this);
|
||||
CollisionObjUtils.clientAttachCollisionObjectToEntity(entity, collisionObject, 0, Collidable.TYPE_TERRAIN);
|
||||
}
|
||||
}});
|
||||
} break;
|
||||
case "SEEDED": {
|
||||
generateDrawable = false;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//Drawable stuff
|
||||
//
|
||||
//
|
||||
if(rawType.getModelPath() != null && EntityUtils.getActor(entity) == null && generateDrawable == true){
|
||||
EntityCreationUtils.makeEntityDrawable(entity, rawType.getModelPath());
|
||||
entity.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
|
||||
}
|
||||
Actor creatureActor = EntityUtils.getActor(entity);
|
||||
|
||||
///
|
||||
///
|
||||
/// HITBOX DATA
|
||||
///
|
||||
///
|
||||
if(rawType.getHitboxes() != null){
|
||||
HitboxCollectionState.attachHitboxState(Globals.clientSceneWrapper.getHitboxManager(), false, entity, rawType.getHitboxes());
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// PHYSICS
|
||||
//
|
||||
//
|
||||
if(rawType.getCollidable() != null){
|
||||
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
||||
PhysicsEntityUtils.clientAttachCollidableTemplate(entity, physicsTemplate);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// MOVEMENT SYSTEMS
|
||||
//
|
||||
//
|
||||
if(rawType.getMovementSystems() != null){
|
||||
for(MovementSystem movementSystem : rawType.getMovementSystems()){
|
||||
switch(movementSystem.getType()){
|
||||
//
|
||||
// Generic ground
|
||||
case GroundMovementSystem.GROUND_MOVEMENT_SYSTEM:
|
||||
GroundMovementSystem groundMovementSystem = (GroundMovementSystem)movementSystem;
|
||||
ClientGroundMovementTree moveTree = ClientGroundMovementTree.attachTree(entity, CollisionObjUtils.getCollidable(entity), groundMovementSystem);
|
||||
if(groundMovementSystem.getAnimationStartup() != null){
|
||||
moveTree.setAnimationStartUp(groundMovementSystem.getAnimationStartup().getNameThirdPerson());
|
||||
}
|
||||
if(groundMovementSystem.getAnimationLoop() != null){
|
||||
moveTree.setAnimationMain(groundMovementSystem.getAnimationLoop().getNameThirdPerson());
|
||||
}
|
||||
if(groundMovementSystem.getAnimationWindDown()!= null){
|
||||
moveTree.setAnimationSlowDown(groundMovementSystem.getAnimationWindDown().getNameThirdPerson());
|
||||
}
|
||||
//sprint system
|
||||
if(groundMovementSystem.getSprintSystem() != null){
|
||||
SprintSystem sprintSystem = groundMovementSystem.getSprintSystem();
|
||||
ClientSprintTree sprintTree = ClientSprintTree.attachTree(entity, sprintSystem);
|
||||
if(sprintSystem.getAnimationStartUp()!= null){
|
||||
moveTree.setAnimationSprintStartUp(sprintSystem.getAnimationStartUp().getNameThirdPerson());
|
||||
}
|
||||
if(sprintSystem.getAnimationMain()!= null){
|
||||
moveTree.setAnimationSprint(sprintSystem.getAnimationMain().getNameThirdPerson());
|
||||
}
|
||||
if(sprintSystem.getAnimationWindDown()!= null){
|
||||
moveTree.setAnimationSprintWindDown(sprintSystem.getAnimationWindDown().getNameThirdPerson());
|
||||
}
|
||||
moveTree.setSprintTree(sprintTree);
|
||||
Globals.clientScene.registerEntityToTag(entity, EntityTags.SPRINTABLE);
|
||||
}
|
||||
//round out end of move system
|
||||
entity.putData(EntityDataStrings.CLIENT_MOVEMENT_BT, moveTree);
|
||||
CreatureUtils.setFacingVector(entity, MathUtils.getOriginVector());
|
||||
entity.putData(EntityDataStrings.DATA_STRING_MAX_NATURAL_VELOCITY, groundMovementSystem.getMaxVelocity());
|
||||
entity.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration());
|
||||
entity.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f);
|
||||
Globals.clientScene.registerBehaviorTree(moveTree);
|
||||
Globals.clientScene.registerEntityToTag(entity, EntityTags.MOVEABLE);
|
||||
break;
|
||||
//
|
||||
// Jump
|
||||
case JumpMovementSystem.JUMP_MOVEMENT_SYSTEM:
|
||||
JumpMovementSystem jumpMovementSystem = (JumpMovementSystem)movementSystem;
|
||||
ClientJumpTree jumpTree = ClientJumpTree.attachTree(entity, jumpMovementSystem);
|
||||
if(jumpMovementSystem.getAnimationJump() != null){
|
||||
jumpTree.setAnimationJump(jumpMovementSystem.getAnimationJump().getNameThirdPerson());
|
||||
}
|
||||
if(CreatureUtils.clientGetEntityMovementTree(entity) != null && CreatureUtils.clientGetEntityMovementTree(entity) instanceof ClientGroundMovementTree){
|
||||
((ClientGroundMovementTree)CreatureUtils.clientGetEntityMovementTree(entity)).setClientJumpTree(jumpTree);
|
||||
}
|
||||
if(ClientFallTree.getFallTree(entity)!=null){
|
||||
ClientFallTree.getFallTree(entity).setJumpTree(jumpTree);
|
||||
}
|
||||
break;
|
||||
//
|
||||
// Falling
|
||||
case FallMovementSystem.FALL_MOVEMENT_SYSTEM:
|
||||
FallMovementSystem fallMovementSystem = (FallMovementSystem)movementSystem;
|
||||
ClientFallTree fallTree = new ClientFallTree(entity, fallMovementSystem);
|
||||
if(CreatureUtils.clientGetEntityMovementTree(entity) != null && CreatureUtils.clientGetEntityMovementTree(entity) instanceof ClientGroundMovementTree){
|
||||
((ClientGroundMovementTree)CreatureUtils.clientGetEntityMovementTree(entity)).setClientFallTree(fallTree);
|
||||
}
|
||||
if(ClientJumpTree.getClientJumpTree(entity)!=null){
|
||||
fallTree.setJumpTree(ClientJumpTree.getClientJumpTree(entity));
|
||||
}
|
||||
entity.putData(EntityDataStrings.FALL_TREE, fallTree);
|
||||
Globals.clientScene.registerBehaviorTree(fallTree);
|
||||
break;
|
||||
case WalkMovementSystem.WALK_MOVEMENT_SYSTEM: {
|
||||
ClientWalkTree.attachTree(entity, (WalkMovementSystem)movementSystem);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){
|
||||
ClientEquipState.attachTree(entity, rawType.getEquipPoints());
|
||||
entity.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints()));
|
||||
}
|
||||
if(rawType.getBlockSystem() != null){
|
||||
ClientBlockTree.attachTree(entity, rawType.getBlockSystem());
|
||||
}
|
||||
if(rawType.getTokens() != null){
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "ATTACKER":
|
||||
ClientAttackTree.attachTree(entity);
|
||||
entity.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
|
||||
Globals.clientScene.registerEntityToTag(entity, EntityTags.ATTACKER);
|
||||
//add all attack moves
|
||||
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
|
||||
for(AttackMove attackMove : rawType.getAttackMoves()){
|
||||
entity.putData(attackMove.getType(), rawType.getAttackMoveResolver().getMoveset(attackMove.getType()));
|
||||
// switch(attackMove.getType()){
|
||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||
// rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND));
|
||||
// break;
|
||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_BOW_TWO_HAND:
|
||||
// rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND));
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "SHOOTER": {
|
||||
ShooterTree shooterTree = new ShooterTree(entity);
|
||||
ShooterTree.setShooterTree(entity, shooterTree);
|
||||
Globals.clientScene.registerBehaviorTree(shooterTree);
|
||||
} break;
|
||||
case "GRAVITY": {
|
||||
Collidable collidable = (Collidable)entity.getData(EntityDataStrings.PHYSICS_COLLIDABLE);
|
||||
DBody collisionObject = PhysicsEntityUtils.getDBody(entity);
|
||||
ClientGravityTree.attachTree(entity, collidable, collisionObject, 30);
|
||||
entity.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
||||
} break;
|
||||
case "TARGETABLE": {
|
||||
Globals.clientScene.registerEntityToTag(entity, EntityTags.TARGETABLE);
|
||||
} break;
|
||||
case "INVENTORY":
|
||||
entity.putData(EntityDataStrings.NATURAL_INVENTORY,UnrelationalInventoryState.createUnrelationalInventory(10));
|
||||
InventoryUtils.clientSetInventoryState(entity, ClientInventoryState.clientCreateInventoryState(entity));
|
||||
break;
|
||||
case "OUTLINE": {
|
||||
entity.putData(EntityDataStrings.DRAW_OUTLINE, true);
|
||||
} break;
|
||||
case "UNIT_CONTROLS": {
|
||||
ClientAlwaysUprightTree.attachTree(entity);
|
||||
CreatureUtils.setFacingVector(entity, MathUtils.getOriginVector());
|
||||
} break;
|
||||
case "TERRAIN_COLLISION": {
|
||||
CollisionObjUtils.getCollidable(entity).overrideType(Collidable.TYPE_TERRAIN);
|
||||
} break;
|
||||
case "BLENDER_ROTATION": {
|
||||
ActorUtils.applyBlenderRotation(entity);
|
||||
} break;
|
||||
case "SPAWNPOINT": {
|
||||
//ignore on client
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//rotator system
|
||||
if(rawType.getRotatorSystem() != null){
|
||||
RotatorSystem system = rawType.getRotatorSystem();
|
||||
RotatorTree rotatorTree = new RotatorTree(entity);
|
||||
for(RotatorItem item : system.getRotatorItems()){
|
||||
//put actor rotator
|
||||
ActorBoneRotator newRotator = new ActorBoneRotator();
|
||||
creatureActor.addBoneRotator(item.getBoneName(), newRotator);
|
||||
//construct node for tree
|
||||
RotatorHierarchyNode hierarchyNode = new RotatorHierarchyNode();
|
||||
hierarchyNode.setBone(item.getBoneName());
|
||||
for(RotatorConstraint constraint : item.getConstraints()){
|
||||
hierarchyNode.addRotatorConstraint(new electrosphere.entity.state.rotator.RotatorConstraint(constraint));
|
||||
}
|
||||
rotatorTree.addRotatorNode(hierarchyNode);
|
||||
}
|
||||
entity.putData(EntityDataStrings.CLIENT_ROTATOR_TREE, rotatorTree);
|
||||
Globals.clientScene.registerBehaviorTree(rotatorTree);
|
||||
}
|
||||
//bone groups
|
||||
if(rawType.getBoneGroups() != null){
|
||||
creatureActor.setBoneGroups(rawType.getBoneGroups());
|
||||
}
|
||||
//add health system
|
||||
if(rawType.getHealthSystem() != null){
|
||||
ClientLifeTree.attachTree(entity,rawType.getHealthSystem());
|
||||
Globals.clientScene.registerEntityToTag(entity, EntityTags.LIFE_STATE);
|
||||
}
|
||||
//idle tree & generic stuff all creatures have
|
||||
if(rawType.getIdleData() != null){
|
||||
ClientIdleTree idleTree = new ClientIdleTree(entity);
|
||||
entity.putData(EntityDataStrings.TREE_IDLE, idleTree);
|
||||
Globals.clientScene.registerBehaviorTree(idleTree);
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Spawns a server-side creature
|
||||
* @param realm The realm to spawn the creature in
|
||||
* @param position The position of the creature in that realm
|
||||
* @param type The type of creature
|
||||
* @param template The creature template to use
|
||||
* @return The creature entity
|
||||
*/
|
||||
public static Entity serverSpawnBasicCreature(Realm realm, Vector3d position, Entity entity, CommonEntityType rawType){
|
||||
|
||||
//
|
||||
//Set typing stuff
|
||||
//
|
||||
CommonEntityUtils.setTyping(entity,rawType);
|
||||
CommonEntityUtils.serverAttachToTag(entity,rawType);
|
||||
|
||||
//tracks whether to generate a drawable or not
|
||||
boolean generateDrawable = true;
|
||||
|
||||
//
|
||||
//
|
||||
// Tokens that should be processed before other work is done
|
||||
//
|
||||
//
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "GENERATE_COLLISION_OBJECT": {
|
||||
Globals.assetManager.addCollisionMeshToQueue(new PhysicsMeshQueueItem(realm.getCollisionEngine(),rawType.getModelPath()));
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(entity, new BehaviorTree() {public void simulate(float deltaTime) {
|
||||
DBody collisionObject = Globals.assetManager.fetchCollisionObject(realm.getCollisionEngine(),rawType.getModelPath());
|
||||
if(collisionObject != null){
|
||||
ServerBehaviorTreeUtils.detatchBTreeFromEntity(entity, this);
|
||||
CollisionObjUtils.serverAttachCollisionObjectToEntity(entity, collisionObject, 0, Collidable.TYPE_OBJECT);
|
||||
}
|
||||
}});
|
||||
} break;
|
||||
case "GENERATE_COLLISION_TERRAIN": {
|
||||
Globals.assetManager.addCollisionMeshToQueue(new PhysicsMeshQueueItem(realm.getCollisionEngine(),rawType.getModelPath()));
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(entity, new BehaviorTree() {public void simulate(float deltaTime) {
|
||||
DBody collisionObject = Globals.assetManager.fetchCollisionObject(realm.getCollisionEngine(),rawType.getModelPath());
|
||||
if(collisionObject != null){
|
||||
ServerBehaviorTreeUtils.detatchBTreeFromEntity(entity, this);
|
||||
CollisionObjUtils.serverAttachCollisionObjectToEntity(entity, collisionObject, 0, Collidable.TYPE_TERRAIN);
|
||||
}
|
||||
}});
|
||||
} break;
|
||||
case "SEEDED": {
|
||||
generateDrawable = false;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//Posing stuff
|
||||
//
|
||||
//
|
||||
if(rawType.getModelPath() != null && EntityUtils.getPoseActor(entity) == null && generateDrawable == true){
|
||||
EntityCreationUtils.makeEntityPoseable(entity, rawType.getModelPath());
|
||||
}
|
||||
PoseActor creatureActor = EntityUtils.getPoseActor(entity);
|
||||
//
|
||||
//
|
||||
// Hitbox stuff
|
||||
//
|
||||
//
|
||||
if(rawType.getHitboxes() != null){
|
||||
HitboxCollectionState.attachHitboxState(realm.getHitboxManager(), true, entity, rawType.getHitboxes());
|
||||
}
|
||||
//
|
||||
//
|
||||
// Physics stuff
|
||||
//
|
||||
//
|
||||
if(rawType.getCollidable() != null){
|
||||
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
||||
PhysicsEntityUtils.serverAttachCollidableTemplate(realm, entity, physicsTemplate);
|
||||
}
|
||||
//
|
||||
//
|
||||
// MOVEMENT SYSTEMS
|
||||
//
|
||||
//
|
||||
if(rawType.getMovementSystems() != null){
|
||||
for(MovementSystem movementSystem : rawType.getMovementSystems()){
|
||||
switch(movementSystem.getType()){
|
||||
//
|
||||
// Generic ground
|
||||
case GroundMovementSystem.GROUND_MOVEMENT_SYSTEM:
|
||||
GroundMovementSystem groundMovementSystem = (GroundMovementSystem)movementSystem;
|
||||
ServerGroundMovementTree moveTree = ServerGroundMovementTree.attachTree(entity,CollisionObjUtils.getCollidable(entity),groundMovementSystem);
|
||||
if(groundMovementSystem.getAnimationStartup() != null){
|
||||
moveTree.setAnimationStartUp(groundMovementSystem.getAnimationStartup().getNameThirdPerson());
|
||||
}
|
||||
if(groundMovementSystem.getAnimationLoop() != null){
|
||||
moveTree.setAnimationMain(groundMovementSystem.getAnimationLoop().getNameThirdPerson());
|
||||
}
|
||||
if(groundMovementSystem.getAnimationWindDown()!= null){
|
||||
moveTree.setAnimationSlowDown(groundMovementSystem.getAnimationWindDown().getNameThirdPerson());
|
||||
}
|
||||
//sprint system
|
||||
if(groundMovementSystem.getSprintSystem() != null){
|
||||
SprintSystem sprintSystem = groundMovementSystem.getSprintSystem();
|
||||
ServerSprintTree sprintTree = ServerSprintTree.attachTree(entity, sprintSystem);
|
||||
if(sprintSystem.getAnimationStartUp()!= null){
|
||||
moveTree.setAnimationSprintStartUp(sprintSystem.getAnimationStartUp().getNameThirdPerson());
|
||||
}
|
||||
if(sprintSystem.getAnimationMain()!= null){
|
||||
moveTree.setAnimationSprint(sprintSystem.getAnimationMain().getNameThirdPerson());
|
||||
}
|
||||
if(sprintSystem.getAnimationWindDown()!= null){
|
||||
moveTree.setAnimationSprintWindDown(sprintSystem.getAnimationWindDown().getNameThirdPerson());
|
||||
}
|
||||
sprintTree.setServerGroundMovementTree(moveTree);
|
||||
moveTree.setServerSprintTree(sprintTree);
|
||||
ServerEntityTagUtils.attachTagToEntity(entity, EntityTags.SPRINTABLE);
|
||||
}
|
||||
//round out end of move system
|
||||
entity.putData(EntityDataStrings.SERVER_MOVEMENT_BT, moveTree);
|
||||
CreatureUtils.setFacingVector(entity, MathUtils.getOriginVector());
|
||||
entity.putData(EntityDataStrings.DATA_STRING_MAX_NATURAL_VELOCITY, groundMovementSystem.getMaxVelocity());
|
||||
entity.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration());
|
||||
entity.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f);
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(entity, moveTree);
|
||||
ServerEntityTagUtils.attachTagToEntity(entity, EntityTags.MOVEABLE);
|
||||
break;
|
||||
//
|
||||
// Jump
|
||||
case JumpMovementSystem.JUMP_MOVEMENT_SYSTEM:
|
||||
JumpMovementSystem jumpMovementSystem = (JumpMovementSystem)movementSystem;
|
||||
ServerJumpTree jumpTree = ServerJumpTree.attachTree(entity, jumpMovementSystem);
|
||||
if(jumpMovementSystem.getAnimationJump() != null){
|
||||
jumpTree.setAnimationJump(jumpMovementSystem.getAnimationJump().getNameThirdPerson());
|
||||
}
|
||||
if(CreatureUtils.serverGetEntityMovementTree(entity) != null && CreatureUtils.serverGetEntityMovementTree(entity) instanceof ClientGroundMovementTree){
|
||||
((ServerGroundMovementTree)CreatureUtils.serverGetEntityMovementTree(entity)).setServerJumpTree(jumpTree);
|
||||
}
|
||||
if(ServerFallTree.getFallTree(entity)!=null){
|
||||
ServerFallTree.getFallTree(entity).setServerJumpTree(jumpTree);
|
||||
}
|
||||
break;
|
||||
//
|
||||
// Falling
|
||||
case FallMovementSystem.FALL_MOVEMENT_SYSTEM:
|
||||
FallMovementSystem fallMovementSystem = (FallMovementSystem)movementSystem;
|
||||
ServerFallTree fallTree = new ServerFallTree(entity,fallMovementSystem);
|
||||
if(CreatureUtils.serverGetEntityMovementTree(entity) != null && CreatureUtils.serverGetEntityMovementTree(entity) instanceof ClientGroundMovementTree){
|
||||
((ServerGroundMovementTree)CreatureUtils.serverGetEntityMovementTree(entity)).setServerFallTree(fallTree);
|
||||
}
|
||||
if(ServerJumpTree.getServerJumpTree(entity)!=null){
|
||||
fallTree.setServerJumpTree(ServerJumpTree.getServerJumpTree(entity));
|
||||
}
|
||||
entity.putData(EntityDataStrings.FALL_TREE, fallTree);
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(entity, fallTree);
|
||||
break;
|
||||
case WalkMovementSystem.WALK_MOVEMENT_SYSTEM: {
|
||||
ServerWalkTree.attachTree(entity, (WalkMovementSystem)movementSystem);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// EQUIP STATE
|
||||
//
|
||||
//
|
||||
if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){
|
||||
ServerEquipState.attachTree(entity, rawType.getEquipPoints());
|
||||
entity.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints()));
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// BLOCK STATE
|
||||
//
|
||||
//
|
||||
if(rawType.getBlockSystem() != null){
|
||||
ServerBlockTree.attachTree(entity, rawType.getBlockSystem());
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// TOKENS
|
||||
//
|
||||
//
|
||||
if(rawType.getTokens() != null){
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "ATTACKER": {
|
||||
ServerAttackTree.attachTree(entity);
|
||||
entity.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
|
||||
ServerEntityTagUtils.attachTagToEntity(entity, EntityTags.ATTACKER);
|
||||
//add all attack moves
|
||||
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
|
||||
for(AttackMove attackMove : rawType.getAttackMoves()){
|
||||
entity.putData(attackMove.getType(), rawType.getAttackMoveResolver().getMoveset(attackMove.getType()));
|
||||
// switch(attackMove.getType()){
|
||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||
// rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND));
|
||||
// break;
|
||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_BOW_TWO_HAND:
|
||||
// rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND));
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case "SHOOTER": {
|
||||
ShooterTree shooterTree = new ShooterTree(entity);
|
||||
ShooterTree.setShooterTree(entity, shooterTree);
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(entity, shooterTree);
|
||||
} break;
|
||||
case "GRAVITY": {
|
||||
Collidable collidable = (Collidable)entity.getData(EntityDataStrings.PHYSICS_COLLIDABLE);
|
||||
DBody collisionObject = PhysicsEntityUtils.getDBody(entity);
|
||||
ServerGravityTree.attachTree(entity, collidable, collisionObject, 30);
|
||||
entity.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
||||
} break;
|
||||
case "TARGETABLE": {
|
||||
ServerEntityTagUtils.attachTagToEntity(entity, EntityTags.TARGETABLE);
|
||||
} break;
|
||||
case "INVENTORY": {
|
||||
entity.putData(EntityDataStrings.NATURAL_INVENTORY,UnrelationalInventoryState.createUnrelationalInventory(10));
|
||||
InventoryUtils.serverSetInventoryState(entity, ServerInventoryState.serverCreateInventoryState(entity));
|
||||
} break;
|
||||
case "OUTLINE": {
|
||||
entity.putData(EntityDataStrings.DRAW_OUTLINE, true);
|
||||
} break;
|
||||
case "UNIT_CONTROLS": {
|
||||
ServerAlwaysUprightTree.attachTree(entity);
|
||||
CreatureUtils.setFacingVector(entity, MathUtils.getOriginVector());
|
||||
} break;
|
||||
case "TERRAIN_COLLISION": {
|
||||
CollisionObjUtils.getCollidable(entity).overrideType(Collidable.TYPE_TERRAIN);
|
||||
} break;
|
||||
case "BLENDER_ROTATION": {
|
||||
ActorUtils.applyBlenderRotation(entity);
|
||||
} break;
|
||||
case "SPAWNPOINT": {
|
||||
realm.registerSpawnPoint(position);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//rotator system
|
||||
if(rawType.getRotatorSystem() != null){
|
||||
RotatorSystem system = rawType.getRotatorSystem();
|
||||
ServerRotatorTree rotatorTree = new ServerRotatorTree(entity);
|
||||
for(RotatorItem item : system.getRotatorItems()){
|
||||
//put actor rotator
|
||||
ActorBoneRotator newRotator = new ActorBoneRotator();
|
||||
creatureActor.addBoneRotator(item.getBoneName(), newRotator);
|
||||
//construct node for tree
|
||||
RotatorHierarchyNode hierarchyNode = new RotatorHierarchyNode();
|
||||
hierarchyNode.setBone(item.getBoneName());
|
||||
for(RotatorConstraint constraint : item.getConstraints()){
|
||||
hierarchyNode.addRotatorConstraint(new electrosphere.entity.state.rotator.RotatorConstraint(constraint));
|
||||
}
|
||||
rotatorTree.addRotatorNode(hierarchyNode);
|
||||
}
|
||||
entity.putData(EntityDataStrings.SERVER_ROTATOR_TREE, rotatorTree);
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(entity, rotatorTree);
|
||||
}
|
||||
|
||||
//bone groups
|
||||
if(rawType.getBoneGroups() != null){
|
||||
creatureActor.setBoneGroups(rawType.getBoneGroups());
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
/// AI (This SHOULD only be applied on the server with the way AI architected currently)
|
||||
///
|
||||
///
|
||||
if(rawType.getAITrees() != null){
|
||||
Globals.aiManager.attachAI(entity, rawType.getAITrees());
|
||||
}
|
||||
|
||||
//add health system
|
||||
if(rawType.getHealthSystem() != null){
|
||||
ServerLifeTree.attachTree(entity, rawType.getHealthSystem());
|
||||
ServerEntityTagUtils.attachTagToEntity(entity, EntityTags.LIFE_STATE);
|
||||
}
|
||||
//idle tree & generic stuff all creatures have
|
||||
if(rawType.getIdleData() != null){
|
||||
ServerIdleTree.attachTree(entity, rawType.getIdleData());
|
||||
}
|
||||
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns an object in the client scene
|
||||
* @param type The type of object
|
||||
* @return The object entity
|
||||
*/
|
||||
public static Entity clientSpawnBasicObject(String type){
|
||||
CommonEntityType rawType = Globals.gameConfigCurrent.getObjectTypeMap().getType(type);
|
||||
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||
//
|
||||
//
|
||||
//Common entity transforms
|
||||
//
|
||||
//
|
||||
CommonEntityUtils.clientSpawnBasicCreature(rVal, rawType);
|
||||
|
||||
//
|
||||
//
|
||||
//Object specific transforms
|
||||
//
|
||||
//
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Spawns a server-side object
|
||||
* @param type The type of object to spawn
|
||||
* @return The object
|
||||
*/
|
||||
public static Entity serverSpawnBasicObject(Realm realm, Vector3d position, String type){
|
||||
CommonEntityType rawType = Globals.gameConfigCurrent.getObjectTypeMap().getType(type);
|
||||
Entity rVal = EntityCreationUtils.createServerEntity(realm, position);
|
||||
|
||||
//
|
||||
//
|
||||
//Common entity transforms
|
||||
//
|
||||
//
|
||||
CommonEntityUtils.serverSpawnBasicCreature(realm, position, rVal, rawType);
|
||||
|
||||
//
|
||||
//
|
||||
//Object specific transforms
|
||||
//
|
||||
//
|
||||
|
||||
//position entity
|
||||
//this needs to be called at the end of this function.
|
||||
//Burried underneath this is function call to initialize a server side entity.
|
||||
//The server initialization logic checks what type of entity this is, if this function is called prior to its type being stored
|
||||
//the server will not be able to synchronize it properly.
|
||||
ServerEntityUtils.initiallyPositionEntity(realm,rVal,position);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the object to a given player
|
||||
* @param player The player
|
||||
* @param item The object entity
|
||||
*/
|
||||
public static void sendEntityToPlayer(Player player, Entity object){
|
||||
int id = object.getId();
|
||||
String type = CommonEntityUtils.getEntitySubtype(object);
|
||||
Vector3d position = EntityUtils.getPosition(object);
|
||||
Quaterniond rotation = EntityUtils.getRotation(object);
|
||||
//construct the spawn message and attach to player
|
||||
NetworkMessage message = EntityMessage.constructCreateMessage(
|
||||
id,
|
||||
EntityType.COMMON.getValue(),
|
||||
type,
|
||||
"",
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
rotation.x,
|
||||
rotation.y,
|
||||
rotation.z,
|
||||
rotation.w
|
||||
);
|
||||
player.addMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the typing data
|
||||
* @param entity The entity
|
||||
* @param type The type
|
||||
*/
|
||||
private static void setTyping(Entity entity, CommonEntityType type){
|
||||
if(type instanceof CreatureData){
|
||||
CommonEntityUtils.setEntityType(entity, EntityType.CREATURE);
|
||||
CommonEntityUtils.setEntitySubtype(entity, type.getId());
|
||||
} else if(type instanceof Item){
|
||||
CommonEntityUtils.setEntityType(entity, EntityType.ITEM);
|
||||
CommonEntityUtils.setEntitySubtype(entity, type.getId());
|
||||
} else if(type instanceof FoliageType){
|
||||
CommonEntityUtils.setEntityType(entity, EntityType.FOLIAGE);
|
||||
CommonEntityUtils.setEntitySubtype(entity, type.getId());
|
||||
} else {
|
||||
CommonEntityUtils.setEntityType(entity, EntityType.COMMON);
|
||||
CommonEntityUtils.setEntitySubtype(entity, type.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachs the entity to the specified tag
|
||||
* @param entity The entity
|
||||
* @param type The type
|
||||
*/
|
||||
private static void serverAttachToTag(Entity entity, CommonEntityType type){
|
||||
if(type instanceof CreatureData){
|
||||
ServerEntityTagUtils.attachTagToEntity(entity, EntityTags.CREATURE);
|
||||
} else if(type instanceof Item){
|
||||
ServerEntityTagUtils.attachTagToEntity(entity, EntityTags.ITEM);
|
||||
} else if(type instanceof FoliageType){
|
||||
ServerEntityTagUtils.attachTagToEntity(entity, EntityTags.FOLIAGE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of the entity
|
||||
* @param entity The entity
|
||||
* @return The type
|
||||
*/
|
||||
public static EntityType getEntityType(Entity entity){
|
||||
return (EntityType)entity.getData(EntityDataStrings.ENTITY_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the entity type
|
||||
* @param entity the entity
|
||||
* @param type the type
|
||||
*/
|
||||
public static void setEntityType(Entity entity, EntityType type){
|
||||
entity.putData(EntityDataStrings.ENTITY_TYPE, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subtype of this entity
|
||||
* @param entity The entity
|
||||
* @return The subtype
|
||||
*/
|
||||
public static String getEntitySubtype(Entity entity){
|
||||
return (String)entity.getData(EntityDataStrings.ENTITY_SUBTYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subtype of this entity
|
||||
* @param entity The entity
|
||||
* @param subtype The subtype
|
||||
*/
|
||||
public static void setEntitySubtype(Entity entity, String subtype){
|
||||
entity.putData(EntityDataStrings.ENTITY_SUBTYPE, subtype);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entity should be serialized
|
||||
* @param entity The entity
|
||||
* @return true if should be serialized, false otherwise
|
||||
*/
|
||||
public static boolean shouldBeSerialized(Entity entity){
|
||||
return entity.containsKey(EntityDataStrings.SHOULD_SERIALIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entity should be synchronized between server and client
|
||||
* @param entity The entity
|
||||
* @return true if should be synchronized, false otherwise
|
||||
*/
|
||||
public static boolean shouldBeSynchronized(Entity entity){
|
||||
return entity.containsKey(EntityDataStrings.SHOULD_SYNCHRONIZE);
|
||||
}
|
||||
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class CreatureTemplate {
|
||||
*/
|
||||
public static CreatureTemplate createDefault(String creatureType){
|
||||
CreatureTemplate storedTemplate = CreatureTemplate.create(creatureType);
|
||||
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(creatureType);
|
||||
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(creatureType);
|
||||
if(rawType.getVisualAttributes() != null){
|
||||
for(VisualAttribute attributeType : rawType.getVisualAttributes()){
|
||||
if(attributeType.getType().equals("remesh")){
|
||||
|
||||
@ -2,10 +2,7 @@ package electrosphere.entity.types.creature;
|
||||
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Vector3d;
|
||||
import org.ode4j.ode.DBody;
|
||||
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.collision.collidable.Collidable;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
@ -16,54 +13,16 @@ import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||
import electrosphere.entity.state.attack.ShooterTree;
|
||||
import electrosphere.entity.state.block.ClientBlockTree;
|
||||
import electrosphere.entity.state.block.ServerBlockTree;
|
||||
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
|
||||
import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.state.equip.ServerEquipState;
|
||||
import electrosphere.entity.state.gravity.ClientGravityTree;
|
||||
import electrosphere.entity.state.gravity.ServerGravityTree;
|
||||
import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
||||
import electrosphere.entity.state.idle.ClientIdleTree;
|
||||
import electrosphere.entity.state.idle.ServerIdleTree;
|
||||
import electrosphere.entity.state.inventory.ClientInventoryState;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
||||
import electrosphere.entity.state.inventory.ServerInventoryState;
|
||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
import electrosphere.entity.state.life.ClientLifeTree;
|
||||
import electrosphere.entity.state.life.ServerLifeTree;
|
||||
import electrosphere.entity.state.movement.fall.ClientFallTree;
|
||||
import electrosphere.entity.state.movement.fall.ServerFallTree;
|
||||
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
|
||||
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
|
||||
import electrosphere.entity.state.movement.jump.ClientJumpTree;
|
||||
import electrosphere.entity.state.movement.jump.ServerJumpTree;
|
||||
import electrosphere.entity.state.movement.sprint.ServerSprintTree;
|
||||
import electrosphere.entity.state.movement.sprint.ClientSprintTree;
|
||||
import electrosphere.entity.state.movement.walk.ClientWalkTree;
|
||||
import electrosphere.entity.state.movement.walk.ServerWalkTree;
|
||||
import electrosphere.entity.state.physicssync.upright.ClientAlwaysUprightTree;
|
||||
import electrosphere.entity.state.physicssync.upright.ServerAlwaysUprightTree;
|
||||
import electrosphere.entity.state.rotator.RotatorHierarchyNode;
|
||||
import electrosphere.entity.state.rotator.RotatorTree;
|
||||
import electrosphere.entity.state.rotator.ServerRotatorTree;
|
||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureEquipData.EquippedItem;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.game.data.collidable.CollidableTemplate;
|
||||
import electrosphere.game.data.creature.type.CreatureData;
|
||||
import electrosphere.game.data.creature.type.SprintSystem;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.movement.FallMovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.GroundMovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.JumpMovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.MovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.WalkMovementSystem;
|
||||
import electrosphere.game.data.creature.type.rotator.RotatorConstraint;
|
||||
import electrosphere.game.data.creature.type.rotator.RotatorItem;
|
||||
import electrosphere.game.data.creature.type.rotator.RotatorSystem;
|
||||
import electrosphere.game.data.creature.type.visualattribute.AttributeVariant;
|
||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
@ -73,22 +32,15 @@ import electrosphere.net.parser.net.message.NetworkMessage;
|
||||
import electrosphere.net.server.player.Player;
|
||||
import electrosphere.net.synchronization.transport.StateCollection;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.ActorBoneRotator;
|
||||
import electrosphere.renderer.actor.ActorStaticMorph;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
||||
import electrosphere.server.poseactor.PoseActor;
|
||||
import electrosphere.util.Utilities;
|
||||
import electrosphere.util.math.MathUtils;
|
||||
|
||||
/**
|
||||
* Utilities for creating creatures on the client and server
|
||||
*/
|
||||
public class CreatureUtils {
|
||||
|
||||
//The entity type int for creatures
|
||||
public static final int ENTITY_TYPE_CREATURE = 0;
|
||||
|
||||
/**
|
||||
* Spawns a client-side creature entity
|
||||
@ -97,166 +49,21 @@ public class CreatureUtils {
|
||||
* @return The creature entity
|
||||
*/
|
||||
public static Entity clientSpawnBasicCreature(String type, CreatureTemplate template){
|
||||
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(type);
|
||||
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(type);
|
||||
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(rVal, rawType.getModelPath());
|
||||
Actor creatureActor = EntityUtils.getActor(rVal);
|
||||
EntityUtils.setEntityType(rVal, ENTITY_TYPE_CREATURE);
|
||||
EntityUtils.setEntitySubtype(rVal, type);
|
||||
|
||||
|
||||
///
|
||||
///
|
||||
/// HITBOX DATA
|
||||
///
|
||||
///
|
||||
HitboxCollectionState.attachHitboxState(Globals.clientSceneWrapper.getHitboxManager(), false, rVal, rawType.getHitboxes());
|
||||
|
||||
|
||||
//
|
||||
//perform common transforms
|
||||
//
|
||||
// PHYSICS
|
||||
//
|
||||
//
|
||||
if(rawType.getCollidable() != null){
|
||||
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
||||
PhysicsEntityUtils.clientAttachCollidableTemplate(rVal, physicsTemplate);
|
||||
ClientAlwaysUprightTree.attachTree(rVal);
|
||||
}
|
||||
CommonEntityUtils.clientSpawnBasicCreature(rVal, rawType);
|
||||
|
||||
//
|
||||
//Perform creature-specific transforms
|
||||
//
|
||||
// MOVEMENT SYSTEMS
|
||||
//
|
||||
//
|
||||
for(MovementSystem movementSystem : rawType.getMovementSystems()){
|
||||
switch(movementSystem.getType()){
|
||||
//
|
||||
// Generic ground
|
||||
case GroundMovementSystem.GROUND_MOVEMENT_SYSTEM:
|
||||
GroundMovementSystem groundMovementSystem = (GroundMovementSystem)movementSystem;
|
||||
ClientGroundMovementTree moveTree = ClientGroundMovementTree.attachTree(rVal, CollisionObjUtils.getCollidable(rVal), groundMovementSystem);
|
||||
if(groundMovementSystem.getAnimationStartup() != null){
|
||||
moveTree.setAnimationStartUp(groundMovementSystem.getAnimationStartup().getNameThirdPerson());
|
||||
}
|
||||
if(groundMovementSystem.getAnimationLoop() != null){
|
||||
moveTree.setAnimationMain(groundMovementSystem.getAnimationLoop().getNameThirdPerson());
|
||||
}
|
||||
if(groundMovementSystem.getAnimationWindDown()!= null){
|
||||
moveTree.setAnimationSlowDown(groundMovementSystem.getAnimationWindDown().getNameThirdPerson());
|
||||
}
|
||||
//sprint system
|
||||
if(groundMovementSystem.getSprintSystem() != null){
|
||||
SprintSystem sprintSystem = groundMovementSystem.getSprintSystem();
|
||||
ClientSprintTree sprintTree = ClientSprintTree.attachTree(rVal, sprintSystem);
|
||||
if(sprintSystem.getAnimationStartUp()!= null){
|
||||
moveTree.setAnimationSprintStartUp(sprintSystem.getAnimationStartUp().getNameThirdPerson());
|
||||
}
|
||||
if(sprintSystem.getAnimationMain()!= null){
|
||||
moveTree.setAnimationSprint(sprintSystem.getAnimationMain().getNameThirdPerson());
|
||||
}
|
||||
if(sprintSystem.getAnimationWindDown()!= null){
|
||||
moveTree.setAnimationSprintWindDown(sprintSystem.getAnimationWindDown().getNameThirdPerson());
|
||||
}
|
||||
moveTree.setSprintTree(sprintTree);
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.SPRINTABLE);
|
||||
}
|
||||
//round out end of move system
|
||||
rVal.putData(EntityDataStrings.CLIENT_MOVEMENT_BT, moveTree);
|
||||
CreatureUtils.setFacingVector(rVal, MathUtils.getOriginVector());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_MAX_NATURAL_VELOCITY, groundMovementSystem.getMaxVelocity());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f);
|
||||
Globals.clientScene.registerBehaviorTree(moveTree);
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.MOVEABLE);
|
||||
break;
|
||||
//
|
||||
// Jump
|
||||
case JumpMovementSystem.JUMP_MOVEMENT_SYSTEM:
|
||||
JumpMovementSystem jumpMovementSystem = (JumpMovementSystem)movementSystem;
|
||||
ClientJumpTree jumpTree = ClientJumpTree.attachTree(rVal, jumpMovementSystem);
|
||||
if(jumpMovementSystem.getAnimationJump() != null){
|
||||
jumpTree.setAnimationJump(jumpMovementSystem.getAnimationJump().getNameThirdPerson());
|
||||
}
|
||||
if(CreatureUtils.clientGetEntityMovementTree(rVal) != null && CreatureUtils.clientGetEntityMovementTree(rVal) instanceof ClientGroundMovementTree){
|
||||
((ClientGroundMovementTree)CreatureUtils.clientGetEntityMovementTree(rVal)).setClientJumpTree(jumpTree);
|
||||
}
|
||||
if(ClientFallTree.getFallTree(rVal)!=null){
|
||||
ClientFallTree.getFallTree(rVal).setJumpTree(jumpTree);
|
||||
}
|
||||
break;
|
||||
//
|
||||
// Falling
|
||||
case FallMovementSystem.FALL_MOVEMENT_SYSTEM:
|
||||
FallMovementSystem fallMovementSystem = (FallMovementSystem)movementSystem;
|
||||
ClientFallTree fallTree = new ClientFallTree(rVal, fallMovementSystem);
|
||||
if(CreatureUtils.clientGetEntityMovementTree(rVal) != null && CreatureUtils.clientGetEntityMovementTree(rVal) instanceof ClientGroundMovementTree){
|
||||
((ClientGroundMovementTree)CreatureUtils.clientGetEntityMovementTree(rVal)).setClientFallTree(fallTree);
|
||||
}
|
||||
if(ClientJumpTree.getClientJumpTree(rVal)!=null){
|
||||
fallTree.setJumpTree(ClientJumpTree.getClientJumpTree(rVal));
|
||||
}
|
||||
rVal.putData(EntityDataStrings.FALL_TREE, fallTree);
|
||||
Globals.clientScene.registerBehaviorTree(fallTree);
|
||||
break;
|
||||
case WalkMovementSystem.WALK_MOVEMENT_SYSTEM: {
|
||||
ClientWalkTree.attachTree(rVal, (WalkMovementSystem)movementSystem);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){
|
||||
ClientEquipState.attachTree(rVal, rawType.getEquipPoints());
|
||||
rVal.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints()));
|
||||
}
|
||||
if(rawType.getBlockSystem() != null){
|
||||
ClientBlockTree.attachTree(rVal, rawType.getBlockSystem());
|
||||
}
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "ATTACKER":
|
||||
ClientAttackTree.attachTree(rVal);
|
||||
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.ATTACKER);
|
||||
//add all attack moves
|
||||
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
|
||||
for(AttackMove attackMove : rawType.getAttackMoves()){
|
||||
rVal.putData(attackMove.getType(), rawType.getAttackMoveResolver().getMoveset(attackMove.getType()));
|
||||
// switch(attackMove.getType()){
|
||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||
// rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND));
|
||||
// break;
|
||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_BOW_TWO_HAND:
|
||||
// rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND));
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "SHOOTER": {
|
||||
ShooterTree shooterTree = new ShooterTree(rVal);
|
||||
ShooterTree.setShooterTree(rVal, shooterTree);
|
||||
Globals.clientScene.registerBehaviorTree(shooterTree);
|
||||
} break;
|
||||
case "GRAVITY":
|
||||
Collidable collidable = (Collidable)rVal.getData(EntityDataStrings.PHYSICS_COLLIDABLE);
|
||||
DBody collisionObject = PhysicsEntityUtils.getDBody(rVal);
|
||||
ClientGravityTree.attachTree(rVal, collidable, collisionObject, 30);
|
||||
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
||||
break;
|
||||
case "TARGETABLE":
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.TARGETABLE);
|
||||
break;
|
||||
case "INVENTORY":
|
||||
rVal.putData(EntityDataStrings.NATURAL_INVENTORY,UnrelationalInventoryState.createUnrelationalInventory(10));
|
||||
InventoryUtils.clientSetInventoryState(rVal, ClientInventoryState.clientCreateInventoryState(rVal));
|
||||
break;
|
||||
case "OUTLINE":
|
||||
rVal.putData(EntityDataStrings.DRAW_OUTLINE, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Actor creatureActor = EntityUtils.getActor(rVal);
|
||||
|
||||
//variants
|
||||
CreatureTemplate storedTemplate = CreatureTemplate.create(rawType.getCreatureId());
|
||||
CreatureTemplate storedTemplate = CreatureTemplate.create(rawType.getId());
|
||||
if(rawType.getVisualAttributes() != null){
|
||||
ActorStaticMorph staticMorph = null;
|
||||
for(VisualAttribute attributeType : rawType.getVisualAttributes()){
|
||||
@ -321,44 +128,12 @@ public class CreatureUtils {
|
||||
}
|
||||
}
|
||||
//set race
|
||||
storedTemplate.creatureType = rawType.getCreatureId();
|
||||
storedTemplate.creatureType = rawType.getId();
|
||||
//store template on creature
|
||||
CreatureUtils.setCreatureTemplate(rVal, storedTemplate);
|
||||
//rotator system
|
||||
if(rawType.getRotatorSystem() != null){
|
||||
RotatorSystem system = rawType.getRotatorSystem();
|
||||
RotatorTree rotatorTree = new RotatorTree(rVal);
|
||||
for(RotatorItem item : system.getRotatorItems()){
|
||||
//put actor rotator
|
||||
ActorBoneRotator newRotator = new ActorBoneRotator();
|
||||
creatureActor.addBoneRotator(item.getBoneName(), newRotator);
|
||||
//construct node for tree
|
||||
RotatorHierarchyNode hierarchyNode = new RotatorHierarchyNode();
|
||||
hierarchyNode.setBone(item.getBoneName());
|
||||
for(RotatorConstraint constraint : item.getConstraints()){
|
||||
hierarchyNode.addRotatorConstraint(new electrosphere.entity.state.rotator.RotatorConstraint(constraint));
|
||||
}
|
||||
rotatorTree.addRotatorNode(hierarchyNode);
|
||||
}
|
||||
rVal.putData(EntityDataStrings.CLIENT_ROTATOR_TREE, rotatorTree);
|
||||
Globals.clientScene.registerBehaviorTree(rotatorTree);
|
||||
}
|
||||
//bone groups
|
||||
if(rawType.getBoneGroups() != null){
|
||||
creatureActor.setBoneGroups(rawType.getBoneGroups());
|
||||
}
|
||||
//add health system
|
||||
if(rawType.getHealthSystem() != null){
|
||||
ClientLifeTree.attachTree(rVal,rawType.getHealthSystem());
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.LIFE_STATE);
|
||||
}
|
||||
//idle tree & generic stuff all creatures have
|
||||
ClientIdleTree idleTree = new ClientIdleTree(rVal);
|
||||
rVal.putData(EntityDataStrings.TREE_IDLE, idleTree);
|
||||
Globals.clientScene.registerBehaviorTree(idleTree);
|
||||
|
||||
//register to correct tag
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.CREATURE);
|
||||
CreatureUtils.setFacingVector(rVal, MathUtils.getOriginVector());
|
||||
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -372,179 +147,26 @@ public class CreatureUtils {
|
||||
* @return The creature entity
|
||||
*/
|
||||
public static Entity serverSpawnBasicCreature(Realm realm, Vector3d position, String type, CreatureTemplate template){
|
||||
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(type);
|
||||
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(type);
|
||||
Entity rVal = EntityCreationUtils.createServerEntity(realm, position);
|
||||
EntityCreationUtils.makeEntityPoseable(rVal, rawType.getModelPath());
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//Common transforms
|
||||
//
|
||||
//
|
||||
CommonEntityUtils.serverSpawnBasicCreature(realm, position, rVal, rawType);
|
||||
|
||||
//
|
||||
//
|
||||
//Creature specific transforms
|
||||
//
|
||||
//
|
||||
PoseActor creatureActor = EntityUtils.getPoseActor(rVal);
|
||||
//
|
||||
//
|
||||
// Hitbox stuff
|
||||
//
|
||||
//
|
||||
HitboxCollectionState.attachHitboxState(realm.getHitboxManager(), true, rVal, rawType.getHitboxes());
|
||||
//
|
||||
//
|
||||
// Physics stuff
|
||||
//
|
||||
//
|
||||
if(rawType.getCollidable() != null){
|
||||
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
||||
PhysicsEntityUtils.serverAttachCollidableTemplate(realm, rVal, physicsTemplate);
|
||||
ServerAlwaysUprightTree.attachTree(rVal);
|
||||
}
|
||||
//
|
||||
//
|
||||
// MOVEMENT SYSTEMS
|
||||
//
|
||||
//
|
||||
for(MovementSystem movementSystem : rawType.getMovementSystems()){
|
||||
switch(movementSystem.getType()){
|
||||
//
|
||||
// Generic ground
|
||||
case GroundMovementSystem.GROUND_MOVEMENT_SYSTEM:
|
||||
GroundMovementSystem groundMovementSystem = (GroundMovementSystem)movementSystem;
|
||||
ServerGroundMovementTree moveTree = ServerGroundMovementTree.attachTree(rVal,CollisionObjUtils.getCollidable(rVal),groundMovementSystem);
|
||||
if(groundMovementSystem.getAnimationStartup() != null){
|
||||
moveTree.setAnimationStartUp(groundMovementSystem.getAnimationStartup().getNameThirdPerson());
|
||||
}
|
||||
if(groundMovementSystem.getAnimationLoop() != null){
|
||||
moveTree.setAnimationMain(groundMovementSystem.getAnimationLoop().getNameThirdPerson());
|
||||
}
|
||||
if(groundMovementSystem.getAnimationWindDown()!= null){
|
||||
moveTree.setAnimationSlowDown(groundMovementSystem.getAnimationWindDown().getNameThirdPerson());
|
||||
}
|
||||
//sprint system
|
||||
if(groundMovementSystem.getSprintSystem() != null){
|
||||
SprintSystem sprintSystem = groundMovementSystem.getSprintSystem();
|
||||
ServerSprintTree sprintTree = ServerSprintTree.attachTree(rVal, sprintSystem);
|
||||
if(sprintSystem.getAnimationStartUp()!= null){
|
||||
moveTree.setAnimationSprintStartUp(sprintSystem.getAnimationStartUp().getNameThirdPerson());
|
||||
}
|
||||
if(sprintSystem.getAnimationMain()!= null){
|
||||
moveTree.setAnimationSprint(sprintSystem.getAnimationMain().getNameThirdPerson());
|
||||
}
|
||||
if(sprintSystem.getAnimationWindDown()!= null){
|
||||
moveTree.setAnimationSprintWindDown(sprintSystem.getAnimationWindDown().getNameThirdPerson());
|
||||
}
|
||||
sprintTree.setServerGroundMovementTree(moveTree);
|
||||
moveTree.setServerSprintTree(sprintTree);
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.SPRINTABLE);
|
||||
}
|
||||
//round out end of move system
|
||||
rVal.putData(EntityDataStrings.SERVER_MOVEMENT_BT, moveTree);
|
||||
CreatureUtils.setFacingVector(rVal, MathUtils.getOriginVector());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_MAX_NATURAL_VELOCITY, groundMovementSystem.getMaxVelocity());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f);
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, moveTree);
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.MOVEABLE);
|
||||
break;
|
||||
//
|
||||
// Jump
|
||||
case JumpMovementSystem.JUMP_MOVEMENT_SYSTEM:
|
||||
JumpMovementSystem jumpMovementSystem = (JumpMovementSystem)movementSystem;
|
||||
ServerJumpTree jumpTree = ServerJumpTree.attachTree(rVal, jumpMovementSystem);
|
||||
if(jumpMovementSystem.getAnimationJump() != null){
|
||||
jumpTree.setAnimationJump(jumpMovementSystem.getAnimationJump().getNameThirdPerson());
|
||||
}
|
||||
if(CreatureUtils.serverGetEntityMovementTree(rVal) != null && CreatureUtils.serverGetEntityMovementTree(rVal) instanceof ClientGroundMovementTree){
|
||||
((ServerGroundMovementTree)CreatureUtils.serverGetEntityMovementTree(rVal)).setServerJumpTree(jumpTree);
|
||||
}
|
||||
if(ServerFallTree.getFallTree(rVal)!=null){
|
||||
ServerFallTree.getFallTree(rVal).setServerJumpTree(jumpTree);
|
||||
}
|
||||
break;
|
||||
//
|
||||
// Falling
|
||||
case FallMovementSystem.FALL_MOVEMENT_SYSTEM:
|
||||
FallMovementSystem fallMovementSystem = (FallMovementSystem)movementSystem;
|
||||
ServerFallTree fallTree = new ServerFallTree(rVal,fallMovementSystem);
|
||||
if(CreatureUtils.serverGetEntityMovementTree(rVal) != null && CreatureUtils.serverGetEntityMovementTree(rVal) instanceof ClientGroundMovementTree){
|
||||
((ServerGroundMovementTree)CreatureUtils.serverGetEntityMovementTree(rVal)).setServerFallTree(fallTree);
|
||||
}
|
||||
if(ServerJumpTree.getServerJumpTree(rVal)!=null){
|
||||
fallTree.setServerJumpTree(ServerJumpTree.getServerJumpTree(rVal));
|
||||
}
|
||||
rVal.putData(EntityDataStrings.FALL_TREE, fallTree);
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, fallTree);
|
||||
break;
|
||||
case WalkMovementSystem.WALK_MOVEMENT_SYSTEM: {
|
||||
ServerWalkTree.attachTree(rVal, (WalkMovementSystem)movementSystem);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// EQUIP STATE
|
||||
//
|
||||
//
|
||||
if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){
|
||||
ServerEquipState.attachTree(rVal, rawType.getEquipPoints());
|
||||
rVal.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints()));
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// BLOCK STATE
|
||||
//
|
||||
//
|
||||
if(rawType.getBlockSystem() != null){
|
||||
ServerBlockTree.attachTree(rVal, rawType.getBlockSystem());
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// TOKENS
|
||||
//
|
||||
//
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "ATTACKER": {
|
||||
ServerAttackTree.attachTree(rVal);
|
||||
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.ATTACKER);
|
||||
//add all attack moves
|
||||
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
|
||||
for(AttackMove attackMove : rawType.getAttackMoves()){
|
||||
rVal.putData(attackMove.getType(), rawType.getAttackMoveResolver().getMoveset(attackMove.getType()));
|
||||
// switch(attackMove.getType()){
|
||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||
// rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND));
|
||||
// break;
|
||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_BOW_TWO_HAND:
|
||||
// rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND));
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case "SHOOTER": {
|
||||
ShooterTree shooterTree = new ShooterTree(rVal);
|
||||
ShooterTree.setShooterTree(rVal, shooterTree);
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, shooterTree);
|
||||
} break;
|
||||
case "GRAVITY": {
|
||||
Collidable collidable = (Collidable)rVal.getData(EntityDataStrings.PHYSICS_COLLIDABLE);
|
||||
DBody collisionObject = PhysicsEntityUtils.getDBody(rVal);
|
||||
ServerGravityTree.attachTree(rVal, collidable, collisionObject, 30);
|
||||
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
||||
} break;
|
||||
case "TARGETABLE": {
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.TARGETABLE);
|
||||
} break;
|
||||
case "INVENTORY": {
|
||||
rVal.putData(EntityDataStrings.NATURAL_INVENTORY,UnrelationalInventoryState.createUnrelationalInventory(10));
|
||||
InventoryUtils.serverSetInventoryState(rVal, ServerInventoryState.serverCreateInventoryState(rVal));
|
||||
} break;
|
||||
case "OUTLINE": {
|
||||
rVal.putData(EntityDataStrings.DRAW_OUTLINE, true);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
//variants
|
||||
CreatureTemplate storedTemplate = CreatureTemplate.create(rawType.getCreatureId());
|
||||
CreatureTemplate storedTemplate = CreatureTemplate.create(rawType.getId());
|
||||
if(rawType.getVisualAttributes() != null){
|
||||
ActorStaticMorph staticMorph = null;
|
||||
for(VisualAttribute attributeType : rawType.getVisualAttributes()){
|
||||
@ -608,59 +230,10 @@ public class CreatureUtils {
|
||||
}
|
||||
}
|
||||
//set race
|
||||
storedTemplate.creatureType = rawType.getCreatureId();
|
||||
storedTemplate.creatureType = rawType.getId();
|
||||
//store template on creature
|
||||
CreatureUtils.setCreatureTemplate(rVal, storedTemplate);
|
||||
//rotator system
|
||||
if(rawType.getRotatorSystem() != null){
|
||||
RotatorSystem system = rawType.getRotatorSystem();
|
||||
ServerRotatorTree rotatorTree = new ServerRotatorTree(rVal);
|
||||
for(RotatorItem item : system.getRotatorItems()){
|
||||
//put actor rotator
|
||||
ActorBoneRotator newRotator = new ActorBoneRotator();
|
||||
creatureActor.addBoneRotator(item.getBoneName(), newRotator);
|
||||
//construct node for tree
|
||||
RotatorHierarchyNode hierarchyNode = new RotatorHierarchyNode();
|
||||
hierarchyNode.setBone(item.getBoneName());
|
||||
for(RotatorConstraint constraint : item.getConstraints()){
|
||||
hierarchyNode.addRotatorConstraint(new electrosphere.entity.state.rotator.RotatorConstraint(constraint));
|
||||
}
|
||||
rotatorTree.addRotatorNode(hierarchyNode);
|
||||
}
|
||||
rVal.putData(EntityDataStrings.SERVER_ROTATOR_TREE, rotatorTree);
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, rotatorTree);
|
||||
}
|
||||
|
||||
//bone groups
|
||||
if(rawType.getBoneGroups() != null){
|
||||
creatureActor.setBoneGroups(rawType.getBoneGroups());
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
/// AI (This SHOULD only be applied on the server with the way AI architected currently)
|
||||
///
|
||||
///
|
||||
if(rawType.getAITrees() != null){
|
||||
Globals.aiManager.attachAI(rVal, rawType.getAITrees());
|
||||
}
|
||||
|
||||
//add health system
|
||||
if(rawType.getHealthSystem() != null){
|
||||
ServerLifeTree.attachTree(rVal, rawType.getHealthSystem());
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.LIFE_STATE);
|
||||
}
|
||||
//idle tree & generic stuff all creatures have
|
||||
if(rawType.getIdleData() != null){
|
||||
ServerIdleTree.attachTree(rVal, rawType.getIdleData());
|
||||
}
|
||||
CreatureUtils.setFacingVector(rVal, MathUtils.getOriginVector());
|
||||
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
|
||||
|
||||
//required for synchronization manager
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.CREATURE);
|
||||
EntityUtils.setEntityType(rVal, ENTITY_TYPE_CREATURE);
|
||||
EntityUtils.setEntitySubtype(rVal, type);
|
||||
|
||||
//position entity
|
||||
//this needs to be called at the end of this function.
|
||||
@ -687,7 +260,7 @@ public class CreatureUtils {
|
||||
String type,
|
||||
CreatureTemplate template
|
||||
){
|
||||
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(type);
|
||||
CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(type);
|
||||
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||
|
||||
if(rawType.getViewModelData() != null){
|
||||
@ -718,8 +291,10 @@ public class CreatureUtils {
|
||||
Vector3d position = EntityUtils.getPosition(creature);
|
||||
Quaterniond rotation = EntityUtils.getRotation(creature);
|
||||
String template = Utilities.stringify(CreatureUtils.getCreatureTemplate(creature));
|
||||
NetworkMessage message = EntityMessage.constructSpawnCreatureMessage(
|
||||
NetworkMessage message = EntityMessage.constructCreateMessage(
|
||||
id,
|
||||
EntityType.CREATURE.getValue(),
|
||||
CreatureUtils.getType(creature),
|
||||
template,
|
||||
position.x,
|
||||
position.y,
|
||||
@ -800,7 +375,7 @@ public class CreatureUtils {
|
||||
* @return the type
|
||||
*/
|
||||
public static String getType(Entity e){
|
||||
return (String)EntityUtils.getEntitySubtype(e);
|
||||
return (String)CommonEntityUtils.getEntitySubtype(e);
|
||||
}
|
||||
|
||||
public static int getControllerPlayerId(Entity e){
|
||||
@ -821,10 +396,7 @@ public class CreatureUtils {
|
||||
* @return true if it is a creature, false otherwise
|
||||
*/
|
||||
public static boolean isCreature(Entity e){
|
||||
if(!e.containsKey(EntityDataStrings.ENTITY_TYPE)){
|
||||
return false;
|
||||
}
|
||||
return (int)e.getData(EntityDataStrings.ENTITY_TYPE) == ENTITY_TYPE_CREATURE;
|
||||
return CommonEntityUtils.getEntityType(e) == EntityType.CREATURE;
|
||||
}
|
||||
|
||||
public static ClientAttackTree clientGetAttackTree(Entity e){
|
||||
|
||||
@ -8,13 +8,14 @@ import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.entity.state.client.ambientaudio.ClientAmbientAudioTree;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||
import electrosphere.entity.types.tree.ProceduralTree;
|
||||
import electrosphere.game.data.foliage.type.AmbientAudio;
|
||||
import electrosphere.game.data.foliage.type.FoliageType;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.net.parser.net.message.NetworkMessage;
|
||||
import electrosphere.net.server.player.Player;
|
||||
import electrosphere.renderer.actor.ActorUtils;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
||||
|
||||
@ -26,9 +27,6 @@ import org.joml.Vector3d;
|
||||
*/
|
||||
public class FoliageUtils {
|
||||
|
||||
//the entity type value
|
||||
public static final int ENTITY_TYPE_FOLIAGE = 3;
|
||||
|
||||
/**
|
||||
* Spawns a basic foliage object
|
||||
* @param type The type of foliage object
|
||||
@ -43,22 +41,25 @@ public class FoliageUtils {
|
||||
rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(rVal, rawType.getModelPath());
|
||||
}
|
||||
//
|
||||
//
|
||||
//Common entity transforms
|
||||
//
|
||||
//
|
||||
CommonEntityUtils.clientSpawnBasicCreature(rVal, rawType);
|
||||
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "BLENDER_ROTATION":
|
||||
ActorUtils.applyBlenderRotation(rVal);
|
||||
break;
|
||||
case "PARTICLE_SPAWNER":
|
||||
|
||||
break;
|
||||
}
|
||||
//
|
||||
//
|
||||
//Foliage specific transforms
|
||||
//
|
||||
//
|
||||
|
||||
//audio
|
||||
if(rawType.getAmbientAudio()!=null){
|
||||
AmbientAudio ambientAudio = rawType.getAmbientAudio();
|
||||
ClientAmbientAudioTree.attachTree(rVal, ambientAudio);
|
||||
}
|
||||
//idle tree & generic stuff all creatures have
|
||||
// rVal.putData(EntityDataStrings.IDLE_TREE, new IdleTree(rVal));
|
||||
// Globals.entityManager.registerCreatureEntity(rVal);
|
||||
rVal.putData(EntityDataStrings.FOLIAGE_IS_FOLIAGE, true);
|
||||
rVal.putData(EntityDataStrings.FOLIAGE_TYPE, type);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -75,24 +76,20 @@ public class FoliageUtils {
|
||||
FoliageType rawType = Globals.gameConfigCurrent.getFoliageMap().getFoliage(type);
|
||||
Entity rVal = ProceduralTree.serverGenerateProceduralTree(realm, position, rawType, seed);
|
||||
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "BLENDER_ROTATION":
|
||||
ActorUtils.applyBlenderRotation(rVal);
|
||||
break;
|
||||
case "PARTICLE_SPAWNER":
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
//audio
|
||||
if(rawType.getAmbientAudio()!=null){
|
||||
AmbientAudio ambientAudio = rawType.getAmbientAudio();
|
||||
ClientAmbientAudioTree.attachTree(rVal, ambientAudio);
|
||||
}
|
||||
//
|
||||
//
|
||||
//Common entity transforms
|
||||
//
|
||||
//
|
||||
CommonEntityUtils.serverSpawnBasicCreature(realm, position, rVal, rawType);
|
||||
|
||||
//
|
||||
//
|
||||
//Foliage specific transforms
|
||||
//
|
||||
//
|
||||
//
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.FOLIAGE);
|
||||
rVal.putData(EntityDataStrings.FOLIAGE_IS_FOLIAGE, true);
|
||||
rVal.putData(EntityDataStrings.FOLIAGE_TYPE, rawType);
|
||||
rVal.putData(EntityDataStrings.FOLIAGE_SEED, seed);
|
||||
rVal.putData(EntityDataStrings.FOLIAGE_IS_SEEDED, true);
|
||||
@ -132,7 +129,7 @@ public class FoliageUtils {
|
||||
* @return true if is foliage, false otherwise
|
||||
*/
|
||||
public static boolean isFoliage(Entity entity){
|
||||
return entity.getData(EntityDataStrings.FOLIAGE_IS_FOLIAGE)!=null;
|
||||
return CommonEntityUtils.getEntityType(entity) == EntityType.FOLIAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,10 +154,11 @@ public class FoliageUtils {
|
||||
Quaterniond rotation = EntityUtils.getRotation(foliage);
|
||||
if(FoliageUtils.hasSeed(foliage)){
|
||||
long seed = FoliageUtils.getFoliageSeed(foliage);
|
||||
NetworkMessage message = EntityMessage.constructSpawnFoliageSeedMessage(
|
||||
NetworkMessage message = EntityMessage.constructCreateMessage(
|
||||
id,
|
||||
type.getName(),
|
||||
seed,
|
||||
EntityType.FOLIAGE.getValue(),
|
||||
type.getId(),
|
||||
seed + "",
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
|
||||
@ -16,11 +16,11 @@ import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.entity.state.AnimationPriorities;
|
||||
import electrosphere.entity.state.gravity.ClientGravityTree;
|
||||
import electrosphere.entity.state.gravity.ServerGravityTree;
|
||||
import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.game.data.collidable.CollidableTemplate;
|
||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||
import electrosphere.game.data.item.type.EquipData;
|
||||
import electrosphere.game.data.item.type.EquipWhitelist;
|
||||
import electrosphere.game.data.item.type.Item;
|
||||
@ -39,16 +39,25 @@ import electrosphere.server.poseactor.PoseActor;
|
||||
*/
|
||||
public class ItemUtils {
|
||||
|
||||
//The item creature type
|
||||
public static final int ENTITY_TYPE_ITEM = 1;
|
||||
|
||||
//generic item icon filepath
|
||||
static final String genericItemIconPath = "Textures/icons/itemIconItemGeneric.png";
|
||||
|
||||
public static Entity clientSpawnBasicItem(String name){
|
||||
Item item = Globals.gameConfigCurrent.getItemMap().getItem(name);
|
||||
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(rVal, item.getModelPath());
|
||||
|
||||
//
|
||||
//
|
||||
//Common entity transforms
|
||||
//
|
||||
//
|
||||
CommonEntityUtils.clientSpawnBasicCreature(rVal, item);
|
||||
|
||||
//
|
||||
//
|
||||
//Item specific transforms
|
||||
//
|
||||
//
|
||||
if(item.getWeaponData() != null){
|
||||
rVal.putData(EntityDataStrings.ITEM_IS_WEAPON, true);
|
||||
WeaponData weaponData = item.getWeaponData();
|
||||
@ -58,28 +67,6 @@ public class ItemUtils {
|
||||
rVal.putData(EntityDataStrings.ITEM_WEAPON_CLASS,weaponData.getWeaponClass());
|
||||
rVal.putData(EntityDataStrings.ITEM_WEAPON_DATA_RAW,weaponData);
|
||||
}
|
||||
//physics
|
||||
if(item.getCollidable() != null){
|
||||
CollidableTemplate physicsTemplate = item.getCollidable();
|
||||
PhysicsEntityUtils.clientAttachCollidableTemplate(rVal, physicsTemplate);
|
||||
}
|
||||
//tokens
|
||||
for(String token : item.getTokens()){
|
||||
switch(token){
|
||||
case "GRAVITY":
|
||||
Collidable collidable = (Collidable)rVal.getData(EntityDataStrings.PHYSICS_COLLIDABLE);
|
||||
DBody collisionObject = PhysicsEntityUtils.getDBody(rVal);
|
||||
ClientGravityTree.attachTree(rVal, collidable, collisionObject, 30);
|
||||
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
||||
break;
|
||||
case "TARGETABLE":
|
||||
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.TARGETABLE);
|
||||
break;
|
||||
case "OUTLINE":
|
||||
rVal.putData(EntityDataStrings.DRAW_OUTLINE, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(item.getIdleAnim() != null){
|
||||
rVal.putData(EntityDataStrings.ANIM_IDLE,item.getIdleAnim());
|
||||
}
|
||||
@ -103,12 +90,8 @@ public class ItemUtils {
|
||||
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS,equipData.getEquipClass());
|
||||
}
|
||||
}
|
||||
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
|
||||
EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM);
|
||||
rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, false);
|
||||
EntityUtils.setEntitySubtype(rVal, name);
|
||||
// rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(0.005f,0.005f,0.005f));
|
||||
// rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaternionf().identity().rotateY((float)(-Math.PI/2)).rotateZ(-(float)(Math.PI/2)));
|
||||
|
||||
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.ITEM);
|
||||
return rVal;
|
||||
}
|
||||
@ -126,8 +109,19 @@ public class ItemUtils {
|
||||
Item item = Globals.gameConfigCurrent.getItemMap().getItem(name);
|
||||
//must correct the position such that it spawns inside the realm
|
||||
Vector3d correctedPosition = ServerEntityUtils.guaranteePositionIsInBounds(realm, position);
|
||||
Entity rVal = EntityCreationUtils.createServerEntity(realm, correctedPosition);// EntityUtils.spawnDrawableEntity(item.getModelPath());
|
||||
EntityCreationUtils.makeEntityPoseable(rVal, item.getModelPath());
|
||||
Entity rVal = EntityCreationUtils.createServerEntity(realm, correctedPosition);
|
||||
//
|
||||
//
|
||||
//Common entity transforms
|
||||
//
|
||||
//
|
||||
CommonEntityUtils.serverSpawnBasicCreature(realm, position, rVal, item);
|
||||
|
||||
//
|
||||
//
|
||||
//Item specific transforms
|
||||
//
|
||||
//
|
||||
if(item.getWeaponData() != null){
|
||||
rVal.putData(EntityDataStrings.ITEM_IS_WEAPON, true);
|
||||
WeaponData weaponData = item.getWeaponData();
|
||||
@ -137,11 +131,6 @@ public class ItemUtils {
|
||||
rVal.putData(EntityDataStrings.ITEM_WEAPON_CLASS,weaponData.getWeaponClass());
|
||||
rVal.putData(EntityDataStrings.ITEM_WEAPON_DATA_RAW,weaponData);
|
||||
}
|
||||
//physics
|
||||
if(item.getCollidable() != null){
|
||||
CollidableTemplate physicsTemplate = item.getCollidable();
|
||||
PhysicsEntityUtils.serverAttachCollidableTemplate(realm, rVal, physicsTemplate);
|
||||
}
|
||||
//tokens
|
||||
for(String token : item.getTokens()){
|
||||
switch(token){
|
||||
@ -181,17 +170,9 @@ public class ItemUtils {
|
||||
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS,equipData.getEquipClass());
|
||||
}
|
||||
}
|
||||
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
|
||||
rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, false);
|
||||
// rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(0.005f,0.005f,0.005f));
|
||||
// rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaternionf().identity().rotateY((float)(-Math.PI/2)).rotateZ(-(float)(Math.PI/2)));
|
||||
|
||||
|
||||
//required for synchronization manager
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.ITEM);
|
||||
EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM);
|
||||
EntityUtils.setEntitySubtype(rVal, name);
|
||||
|
||||
|
||||
//position entity
|
||||
//this needs to be called at the end of this function.
|
||||
@ -264,23 +245,28 @@ public class ItemUtils {
|
||||
}
|
||||
|
||||
public static void sendEntityToPlayer(Player player, Entity item){
|
||||
int id = item.getId();
|
||||
String type = ItemUtils.getType(item);
|
||||
Vector3d position = EntityUtils.getPosition(item);
|
||||
Quaterniond rotation = EntityUtils.getRotation(item);
|
||||
//construct the spawn message and attach to player
|
||||
NetworkMessage message = EntityMessage.constructSpawnItemMessage(
|
||||
id,
|
||||
type,
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
rotation.x,
|
||||
rotation.y,
|
||||
rotation.z,
|
||||
rotation.w
|
||||
);
|
||||
player.addMessage(message);
|
||||
boolean shouldSend = ItemUtils.itemShouldBeSentToClient(item);
|
||||
if(shouldSend){
|
||||
int id = item.getId();
|
||||
String type = ItemUtils.getType(item);
|
||||
Vector3d position = EntityUtils.getPosition(item);
|
||||
Quaterniond rotation = EntityUtils.getRotation(item);
|
||||
//construct the spawn message and attach to player
|
||||
NetworkMessage message = EntityMessage.constructCreateMessage(
|
||||
id,
|
||||
EntityType.ITEM.getValue(),
|
||||
type,
|
||||
"",
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
rotation.x,
|
||||
rotation.y,
|
||||
rotation.z,
|
||||
rotation.w
|
||||
);
|
||||
player.addMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -293,10 +279,7 @@ public class ItemUtils {
|
||||
if(e == null){
|
||||
return false;
|
||||
}
|
||||
if(!e.containsKey(EntityDataStrings.ENTITY_TYPE)){
|
||||
return false;
|
||||
}
|
||||
return (int)e.getData(EntityDataStrings.ENTITY_TYPE) == ENTITY_TYPE_ITEM;
|
||||
return CommonEntityUtils.getEntityType(e) == EntityType.ITEM;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -333,7 +316,7 @@ public class ItemUtils {
|
||||
* @return The type
|
||||
*/
|
||||
public static String getType(Entity item){
|
||||
return EntityUtils.getEntitySubtype(item);
|
||||
return CommonEntityUtils.getEntitySubtype(item);
|
||||
}
|
||||
|
||||
public static boolean isWeapon(Entity item){
|
||||
@ -410,10 +393,10 @@ public class ItemUtils {
|
||||
}
|
||||
rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item));
|
||||
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS, item.getData(EntityDataStrings.ITEM_EQUIP_CLASS));
|
||||
EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM);
|
||||
CommonEntityUtils.setEntityType(rVal, EntityType.ITEM);
|
||||
rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, true);
|
||||
ItemUtils.setContainingParent(rVal, containingParent);
|
||||
EntityUtils.setEntitySubtype(rVal, EntityUtils.getEntitySubtype(item));
|
||||
CommonEntityUtils.setEntitySubtype(rVal, CommonEntityUtils.getEntitySubtype(item));
|
||||
Globals.clientSceneWrapper.getScene().registerEntity(rVal);
|
||||
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.ITEM);
|
||||
return rVal;
|
||||
@ -436,10 +419,10 @@ public class ItemUtils {
|
||||
}
|
||||
rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item));
|
||||
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS, item.getData(EntityDataStrings.ITEM_EQUIP_CLASS));
|
||||
EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM);
|
||||
CommonEntityUtils.setEntityType(rVal, EntityType.ITEM);
|
||||
rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, true);
|
||||
ItemUtils.setContainingParent(rVal, containingParent);
|
||||
EntityUtils.setEntitySubtype(rVal, EntityUtils.getEntitySubtype(item));
|
||||
CommonEntityUtils.setEntitySubtype(rVal, CommonEntityUtils.getEntitySubtype(item));
|
||||
return rVal;
|
||||
} else {
|
||||
return null;
|
||||
|
||||
@ -1,265 +1,8 @@
|
||||
package electrosphere.entity.types.object;
|
||||
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Vector3d;
|
||||
import org.ode4j.ode.DBody;
|
||||
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.collision.collidable.Collidable;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.assetmanager.PhysicsMeshQueueItem;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.gravity.ClientGravityTree;
|
||||
import electrosphere.entity.state.gravity.ServerGravityTree;
|
||||
import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
||||
import electrosphere.entity.state.idle.ClientIdleTree;
|
||||
import electrosphere.entity.state.inventory.ClientInventoryState;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
import electrosphere.entity.state.inventory.ServerInventoryState;
|
||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.game.data.collidable.CollidableTemplate;
|
||||
import electrosphere.game.data.object.type.ObjectData;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.net.parser.net.message.NetworkMessage;
|
||||
import electrosphere.net.server.player.Player;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
||||
|
||||
public class ObjectUtils {
|
||||
|
||||
//the entity type value
|
||||
public static final int ENTITY_TYPE_OBJECT = 2;
|
||||
|
||||
/**
|
||||
* Spawns an object in the client scene
|
||||
* @param type The type of object
|
||||
* @return The object entity
|
||||
*/
|
||||
public static Entity clientSpawnBasicObject(String type){
|
||||
ObjectData rawType = Globals.gameConfigCurrent.getObjectTypeLoader().getObject(type);
|
||||
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||
if(rawType.getModelPath() != null){
|
||||
EntityCreationUtils.makeEntityDrawable(rVal, rawType.getModelPath());
|
||||
}
|
||||
//forward-searching tokens
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "GENERATE_COLLISION_OBJECT": {
|
||||
Globals.assetManager.addCollisionMeshToQueue(new PhysicsMeshQueueItem(Globals.clientSceneWrapper.getCollisionEngine(),rawType.getModelPath()));
|
||||
Globals.clientSceneWrapper.getScene().registerBehaviorTree(new BehaviorTree() {public void simulate(float deltaTime) {
|
||||
DBody collisionObject = Globals.assetManager.fetchCollisionObject(Globals.clientSceneWrapper.getCollisionEngine(),rawType.getModelPath());
|
||||
if(collisionObject != null){
|
||||
Globals.clientSceneWrapper.getScene().deregisterBehaviorTree(this);
|
||||
CollisionObjUtils.clientAttachCollisionObjectToEntity(rVal, collisionObject, 0, Collidable.TYPE_OBJECT);
|
||||
}
|
||||
}});
|
||||
} break;
|
||||
case "GENERATE_COLLISION_TERRAIN": {
|
||||
Globals.assetManager.addCollisionMeshToQueue(new PhysicsMeshQueueItem(Globals.clientSceneWrapper.getCollisionEngine(),rawType.getModelPath()));
|
||||
Globals.clientSceneWrapper.getScene().registerBehaviorTree(new BehaviorTree() {public void simulate(float deltaTime) {
|
||||
DBody collisionObject = Globals.assetManager.fetchCollisionObject(Globals.clientSceneWrapper.getCollisionEngine(),rawType.getModelPath());
|
||||
if(collisionObject != null){
|
||||
Globals.clientSceneWrapper.getScene().deregisterBehaviorTree(this);
|
||||
CollisionObjUtils.clientAttachCollisionObjectToEntity(rVal, collisionObject, 0, Collidable.TYPE_TERRAIN);
|
||||
}
|
||||
}});
|
||||
} break;
|
||||
}
|
||||
}
|
||||
//
|
||||
//main entity construction
|
||||
//physics
|
||||
if(rawType.getCollidable() != null){
|
||||
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
||||
PhysicsEntityUtils.clientAttachCollidableTemplate(rVal, physicsTemplate);
|
||||
}
|
||||
//tokens
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "GRAVITY":
|
||||
Collidable collidable = (Collidable)rVal.getData(EntityDataStrings.PHYSICS_COLLIDABLE);
|
||||
DBody collisionObject = PhysicsEntityUtils.getDBody(rVal);
|
||||
ClientGravityTree.attachTree(rVal, collidable, collisionObject, 30);
|
||||
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
||||
break;
|
||||
case "TARGETABLE":
|
||||
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.TARGETABLE);
|
||||
break;
|
||||
case "INVENTORY":
|
||||
rVal.putData(EntityDataStrings.NATURAL_INVENTORY,UnrelationalInventoryState.createUnrelationalInventory(10));
|
||||
InventoryUtils.clientSetInventoryState(rVal, ClientInventoryState.clientCreateInventoryState(rVal));
|
||||
break;
|
||||
case "OUTLINE":
|
||||
rVal.putData(EntityDataStrings.DRAW_OUTLINE, true);
|
||||
break;
|
||||
case "TERRAIN_COLLISION": {
|
||||
CollisionObjUtils.getCollidable(rVal).overrideType(Collidable.TYPE_TERRAIN);
|
||||
} break;
|
||||
case "SPAWNPOINT": {
|
||||
//ignore on client
|
||||
} break;
|
||||
}
|
||||
}
|
||||
if(rawType.getHitboxData() != null){
|
||||
HitboxCollectionState.attachHitboxState(Globals.clientSceneWrapper.getHitboxManager(), false, rVal, rawType.getHitboxData());
|
||||
}
|
||||
//add health system
|
||||
// rVal.putData(EntityDataStrings.LIFE_STATE, new LifeState(rVal, rawType.getHealthSystem()));
|
||||
// Globals.entityManager.registerLifeStateEntity(rVal);
|
||||
//idle tree & generic stuff all objects have
|
||||
rVal.putData(EntityDataStrings.TREE_IDLE, new ClientIdleTree(rVal));
|
||||
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
|
||||
rVal.putData(EntityDataStrings.ENTITY_TYPE, ENTITY_TYPE_OBJECT);
|
||||
rVal.putData(EntityDataStrings.ENTITY_SUBTYPE, type);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Spawns a server-side object
|
||||
* @param type The type of object to spawn
|
||||
* @return The object
|
||||
*/
|
||||
public static Entity serverSpawnBasicObject(Realm realm, Vector3d position, String type){
|
||||
ObjectData rawType = Globals.gameConfigCurrent.getObjectTypeLoader().getObject(type);
|
||||
Entity rVal = EntityCreationUtils.createServerEntity(realm, position);
|
||||
|
||||
if(rawType.getModelPath() != null){
|
||||
EntityCreationUtils.makeEntityPoseable(rVal, rawType.getModelPath());
|
||||
}
|
||||
//forward-searching tokens
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "GENERATE_COLLISION_OBJECT": {
|
||||
Globals.assetManager.addCollisionMeshToQueue(new PhysicsMeshQueueItem(realm.getCollisionEngine(),rawType.getModelPath()));
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, new BehaviorTree() {public void simulate(float deltaTime) {
|
||||
DBody collisionObject = Globals.assetManager.fetchCollisionObject(realm.getCollisionEngine(),rawType.getModelPath());
|
||||
if(collisionObject != null){
|
||||
ServerBehaviorTreeUtils.detatchBTreeFromEntity(rVal, this);
|
||||
CollisionObjUtils.serverAttachCollisionObjectToEntity(rVal, collisionObject, 0, Collidable.TYPE_OBJECT);
|
||||
}
|
||||
}});
|
||||
} break;
|
||||
case "GENERATE_COLLISION_TERRAIN": {
|
||||
Globals.assetManager.addCollisionMeshToQueue(new PhysicsMeshQueueItem(realm.getCollisionEngine(),rawType.getModelPath()));
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, new BehaviorTree() {public void simulate(float deltaTime) {
|
||||
DBody collisionObject = Globals.assetManager.fetchCollisionObject(realm.getCollisionEngine(),rawType.getModelPath());
|
||||
if(collisionObject != null){
|
||||
ServerBehaviorTreeUtils.detatchBTreeFromEntity(rVal, this);
|
||||
CollisionObjUtils.serverAttachCollisionObjectToEntity(rVal, collisionObject, 0, Collidable.TYPE_TERRAIN);
|
||||
}
|
||||
}});
|
||||
} break;
|
||||
}
|
||||
}
|
||||
//
|
||||
//main entity construction
|
||||
//physics
|
||||
if(rawType.getCollidable() != null){
|
||||
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
||||
PhysicsEntityUtils.serverAttachCollidableTemplate(realm, rVal, physicsTemplate);
|
||||
}
|
||||
//tokens
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "GRAVITY":
|
||||
Collidable collidable = (Collidable)rVal.getData(EntityDataStrings.PHYSICS_COLLIDABLE);
|
||||
DBody collisionObject = PhysicsEntityUtils.getDBody(rVal);
|
||||
ServerGravityTree.attachTree(rVal, collidable, collisionObject, 30);
|
||||
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
||||
break;
|
||||
case "TARGETABLE":
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.TARGETABLE);
|
||||
break;
|
||||
case "INVENTORY":
|
||||
rVal.putData(EntityDataStrings.NATURAL_INVENTORY,UnrelationalInventoryState.createUnrelationalInventory(10));
|
||||
InventoryUtils.serverSetInventoryState(rVal, ServerInventoryState.serverCreateInventoryState(rVal));
|
||||
break;
|
||||
case "OUTLINE":
|
||||
rVal.putData(EntityDataStrings.DRAW_OUTLINE, true);
|
||||
break;
|
||||
case "TERRAIN_COLLISION": {
|
||||
CollisionObjUtils.getCollidable(rVal).overrideType(Collidable.TYPE_TERRAIN);
|
||||
} break;
|
||||
case "SPAWNPOINT": {
|
||||
realm.registerSpawnPoint(position);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
if(rawType.getHitboxData() != null){
|
||||
HitboxCollectionState.attachHitboxState(realm.getHitboxManager(), true, rVal, rawType.getHitboxData());
|
||||
}
|
||||
|
||||
|
||||
//required for synchronization manager
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.OBJECT);
|
||||
EntityUtils.setEntityType(rVal, ENTITY_TYPE_OBJECT);
|
||||
EntityUtils.setEntitySubtype(rVal, type);
|
||||
|
||||
|
||||
//position entity
|
||||
//this needs to be called at the end of this function.
|
||||
//Burried underneath this is function call to initialize a server side entity.
|
||||
//The server initialization logic checks what type of entity this is, if this function is called prior to its type being stored
|
||||
//the server will not be able to synchronize it properly.
|
||||
ServerEntityUtils.initiallyPositionEntity(realm,rVal,position);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided entity is an object
|
||||
* @param entity The entity
|
||||
* @return true if it is an object, false otherwise
|
||||
*/
|
||||
public static boolean isObject(Entity entity){
|
||||
if(!entity.containsKey(EntityDataStrings.ENTITY_TYPE)){
|
||||
return false;
|
||||
}
|
||||
return (int)entity.getData(EntityDataStrings.ENTITY_TYPE) == ENTITY_TYPE_OBJECT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of object
|
||||
* @param e the entity
|
||||
* @return the type
|
||||
*/
|
||||
public static String getType(Entity e){
|
||||
return (String)EntityUtils.getEntitySubtype(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the object to a given player
|
||||
* @param player The player
|
||||
* @param item The object entity
|
||||
*/
|
||||
public static void sendEntityToPlayer(Player player, Entity object){
|
||||
int id = object.getId();
|
||||
String type = ObjectUtils.getType(object);
|
||||
Vector3d position = EntityUtils.getPosition(object);
|
||||
Quaterniond rotation = EntityUtils.getRotation(object);
|
||||
//construct the spawn message and attach to player
|
||||
NetworkMessage message = EntityMessage.constructSpawnObjectMessage(
|
||||
id,
|
||||
type,
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
rotation.x,
|
||||
rotation.y,
|
||||
rotation.z,
|
||||
rotation.w
|
||||
);
|
||||
player.addMessage(message);
|
||||
}
|
||||
public static final int ENTITY_TYPE_COMMON = 2;
|
||||
|
||||
}
|
||||
|
||||
@ -1,101 +0,0 @@
|
||||
package electrosphere.entity.types.structure;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.game.data.structure.type.model.CollisionObjectTemplate;
|
||||
import electrosphere.game.data.structure.type.model.StructureType;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.net.parser.net.message.NetworkMessage;
|
||||
import electrosphere.net.server.player.Player;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
/**
|
||||
* Structure entity utility functions
|
||||
*/
|
||||
public class StructureUtils {
|
||||
|
||||
//the entity type value
|
||||
public static final int ENTITY_TYPE_STRUCTURE = 4;
|
||||
|
||||
|
||||
public static Entity clientSpawnBasicStructure(String type, Vector3f position, Quaternionf rotation){
|
||||
StructureType rawType = Globals.gameConfigCurrent.getStructureTypeMap().getType(type);
|
||||
Entity rVal = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(rVal, rawType.getModelPath());
|
||||
EntityUtils.getPosition(rVal).set(position);
|
||||
EntityUtils.getRotation(rVal).set(rotation);
|
||||
for(CollisionObjectTemplate template : rawType.getCollision()){
|
||||
switch(template.getType()){
|
||||
case CollisionObjectTemplate.TYPE_CUBE:
|
||||
Matrix4f rotationTransform = new Matrix4f().rotate(rotation);
|
||||
Vector4f rotatedPosition = rotationTransform.transform(new Vector4f(template.getPositionX(),template.getPositionY(),template.getPositionZ(),1.0f));
|
||||
Vector3d cubePosition = new Vector3d(position).add(rotatedPosition.x,rotatedPosition.y,rotatedPosition.z);
|
||||
Quaterniond cubeRotation = new Quaterniond(rotation).mul(new Quaterniond(template.getRotationX(),template.getRotationY(),template.getRotationZ(),template.getRotationW())).normalize();
|
||||
CollisionObjUtils.clientAttachCollisionCube(new Vector3f(template.getScaleX(),template.getScaleY(),template.getScaleZ()), cubePosition, cubeRotation, rVal);
|
||||
// Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
||||
// Globals.collisionEngine.registerPhysicsEntity(rVal);
|
||||
// Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
||||
break;
|
||||
case CollisionObjectTemplate.TYPE_PLANE:
|
||||
throw new UnsupportedOperationException("Haven't implemented plane collision on structures");
|
||||
}
|
||||
}
|
||||
rVal.putData(EntityDataStrings.STRUCTURE_IS_STRUCTURE,true);
|
||||
rVal.putData(EntityDataStrings.STRUCTURE_TYPE,type);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity serverSpawnBasicStructure(String type, Realm realm, Vector3d position, Quaternionf rotation){
|
||||
StructureType rawType = Globals.gameConfigCurrent.getStructureTypeMap().getType(type);
|
||||
Entity rVal = EntityCreationUtils.createServerEntity(realm, position);
|
||||
EntityCreationUtils.makeEntityPoseable(rVal, rawType.getModelPath());
|
||||
EntityUtils.getPosition(rVal).set(position);
|
||||
EntityUtils.getRotation(rVal).set(rotation);
|
||||
for(CollisionObjectTemplate template : rawType.getCollision()){
|
||||
switch(template.getType()){
|
||||
case CollisionObjectTemplate.TYPE_CUBE:
|
||||
Matrix4f rotationTransform = new Matrix4f().rotate(rotation);
|
||||
Vector4f rotatedPosition = rotationTransform.transform(new Vector4f(template.getPositionX(),template.getPositionY(),template.getPositionZ(),1.0f));
|
||||
Vector3d cubePosition = new Vector3d((float)position.x,(float)position.y,(float)position.z).add(rotatedPosition.x,rotatedPosition.y,rotatedPosition.z);
|
||||
Quaterniond cubeRotation = new Quaterniond(rotation).mul(new Quaterniond(template.getRotationX(),template.getRotationY(),template.getRotationZ(),template.getRotationW())).normalize();
|
||||
CollisionObjUtils.serverAttachCollisionCube(new Vector3f(template.getScaleX(),template.getScaleY(),template.getScaleZ()), cubePosition, cubeRotation, rVal);
|
||||
// Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE);
|
||||
// Globals.collisionEngine.registerPhysicsEntity(rVal);
|
||||
// Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
||||
break;
|
||||
case CollisionObjectTemplate.TYPE_PLANE:
|
||||
throw new UnsupportedOperationException("Haven't implemented plane collision on structures");
|
||||
}
|
||||
}
|
||||
rVal.putData(EntityDataStrings.STRUCTURE_IS_STRUCTURE,true);
|
||||
rVal.putData(EntityDataStrings.STRUCTURE_TYPE,type);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static boolean isStructure(Entity entity){
|
||||
return entity.containsKey(EntityDataStrings.STRUCTURE_IS_STRUCTURE);
|
||||
}
|
||||
|
||||
public static String getType(Entity structure){
|
||||
return (String)structure.getData(EntityDataStrings.STRUCTURE_TYPE);
|
||||
}
|
||||
|
||||
public static void sendStructureToPlayer(Player player, Entity structure){
|
||||
int id = structure.getId();
|
||||
String type = StructureUtils.getType(structure);
|
||||
Vector3d position = EntityUtils.getPosition(structure);
|
||||
NetworkMessage message = EntityMessage.constructCreateMessage(id, EntityDataStrings.ENTITY_CATEGORY_STRUCTURE, type, (float)position.x, (float)position.y, (float)position.z);
|
||||
player.addMessage(message);
|
||||
}
|
||||
}
|
||||
@ -16,6 +16,8 @@ import org.joml.Vector4d;
|
||||
import org.joml.Vector4f;
|
||||
import org.ode4j.ode.DBody;
|
||||
|
||||
import electrosphere.client.entity.instance.InstanceTemplate;
|
||||
import electrosphere.client.entity.instance.InstancedEntityUtils;
|
||||
import electrosphere.collision.CollisionBodyCreation;
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.collision.collidable.Collidable;
|
||||
@ -26,8 +28,6 @@ import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.instance.InstanceTemplate;
|
||||
import electrosphere.entity.types.instance.InstancedEntityUtils;
|
||||
import electrosphere.game.data.foliage.type.FoliageType;
|
||||
import electrosphere.game.data.foliage.type.TreeModel;
|
||||
import electrosphere.renderer.actor.instance.InstancedActor;
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
package electrosphere.entity.types.waypoint;
|
||||
|
||||
/**
|
||||
* Waypoint entity utility functions
|
||||
*/
|
||||
public class WaypointUtils {
|
||||
|
||||
}
|
||||
@ -4,15 +4,15 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import electrosphere.game.data.audio.SurfaceAudioCollection;
|
||||
import electrosphere.game.data.common.CommonEntityLoader;
|
||||
import electrosphere.game.data.common.CommonEntityMap;
|
||||
import electrosphere.game.data.common.CommonEntityType;
|
||||
import electrosphere.game.data.creature.type.CreatureData;
|
||||
import electrosphere.game.data.creature.type.CreatureTypeLoader;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMoveResolver;
|
||||
import electrosphere.game.data.creature.type.model.CreatureTypeMap;
|
||||
import electrosphere.game.data.foliage.type.model.FoliageTypeMap;
|
||||
import electrosphere.game.data.item.type.model.ItemTypeMap;
|
||||
import electrosphere.game.data.object.type.ObjectData;
|
||||
import electrosphere.game.data.object.type.model.ObjectTypeLoader;
|
||||
import electrosphere.game.data.object.type.model.ObjectTypeMap;
|
||||
import electrosphere.game.data.particle.ParticleDefinition;
|
||||
import electrosphere.game.data.projectile.ProjectileTypeHolder;
|
||||
import electrosphere.game.data.structure.type.model.StructureTypeMap;
|
||||
@ -33,7 +33,7 @@ public class Config {
|
||||
StructureTypeMap structureTypeMap;
|
||||
ItemTypeMap itemMap;
|
||||
FoliageTypeMap foliageMap;
|
||||
ObjectTypeLoader objectTypeLoader;
|
||||
CommonEntityMap objectTypeLoader;
|
||||
SymbolMap symbolMap;
|
||||
RaceMap raceMap;
|
||||
ProjectileTypeHolder projectileTypeHolder;
|
||||
@ -65,20 +65,20 @@ public class Config {
|
||||
*/
|
||||
public static Config loadDefaultConfig(){
|
||||
Config config = new Config();
|
||||
config.creatureTypeLoader = loadCreatureTypes("Data/creatures.json");
|
||||
config.itemMap = FileUtils.loadObjectFromAssetPath("Data/items.json", ItemTypeMap.class);
|
||||
config.structureTypeMap = FileUtils.loadObjectFromAssetPath("Data/structures.json", StructureTypeMap.class);
|
||||
config.foliageMap = FileUtils.loadObjectFromAssetPath("Data/foliage.json", FoliageTypeMap.class);
|
||||
config.objectTypeLoader = loadObjectTypes("Data/objects.json");
|
||||
config.symbolMap = FileUtils.loadObjectFromAssetPath("Data/symbolism.json", SymbolMap.class);
|
||||
config.raceMap = FileUtils.loadObjectFromAssetPath("Data/races.json", RaceMap.class);
|
||||
config.voxelData = FileUtils.loadObjectFromAssetPath("Data/voxelTypes.json", VoxelData.class);
|
||||
config.projectileTypeHolder = FileUtils.loadObjectFromAssetPath("Data/projectile.json", ProjectileTypeHolder.class);
|
||||
config.creatureTypeLoader = loadCreatureTypes("Data/entity/creatures.json");
|
||||
config.itemMap = FileUtils.loadObjectFromAssetPath("Data/entity/items.json", ItemTypeMap.class);
|
||||
config.structureTypeMap = FileUtils.loadObjectFromAssetPath("Data/entity/structures.json", StructureTypeMap.class);
|
||||
config.foliageMap = FileUtils.loadObjectFromAssetPath("Data/entity/foliage.json", FoliageTypeMap.class);
|
||||
config.objectTypeLoader = loadCommonEntityTypes("Data/entity/objects.json");
|
||||
config.symbolMap = FileUtils.loadObjectFromAssetPath("Data/game/symbolism.json", SymbolMap.class);
|
||||
config.raceMap = FileUtils.loadObjectFromAssetPath("Data/game/races.json", RaceMap.class);
|
||||
config.voxelData = FileUtils.loadObjectFromAssetPath("Data/game/voxelTypes.json", VoxelData.class);
|
||||
config.projectileTypeHolder = FileUtils.loadObjectFromAssetPath("Data/entity/projectile.json", ProjectileTypeHolder.class);
|
||||
config.hintData = FileUtils.loadObjectFromAssetPath("Data/tutorial/hints.json", HintDefinition.class);
|
||||
config.surfaceAudioCollection = FileUtils.loadObjectFromAssetPath("Data/audio/surface.json", SurfaceAudioCollection.class);
|
||||
config.particleDefinition = FileUtils.loadObjectFromAssetPath("Data/particles.json", ParticleDefinition.class);
|
||||
config.particleDefinition = FileUtils.loadObjectFromAssetPath("Data/entity/particles.json", ParticleDefinition.class);
|
||||
config.projectileTypeHolder.init();
|
||||
config.unitLoader = UnitLoader.create(FileUtils.loadObjectFromAssetPath("Data/units/units.json", UnitDefinitionFile.class));
|
||||
config.unitLoader = UnitLoader.create(FileUtils.loadObjectFromAssetPath("Data/game/units/units.json", UnitDefinitionFile.class));
|
||||
|
||||
//validate
|
||||
ConfigValidator.valdiate(config);
|
||||
@ -87,6 +87,42 @@ public class Config {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a child entity defintion file
|
||||
* @param filename The filename
|
||||
* @return The list of entities in the file
|
||||
*/
|
||||
static List<CommonEntityType> recursiveReadEntityLoader(String filename){
|
||||
List<CommonEntityType> typeList = new LinkedList<CommonEntityType>();
|
||||
CommonEntityLoader loaderFile = FileUtils.loadObjectFromAssetPath(filename, CommonEntityLoader.class);
|
||||
//push the types from this file
|
||||
for(CommonEntityType type : loaderFile.getEntities()){
|
||||
typeList.add(type);
|
||||
}
|
||||
//push types from any other files
|
||||
for(String filepath : loaderFile.getFiles()){
|
||||
List<CommonEntityType> parsedTypeList = recursiveReadEntityLoader(filepath);
|
||||
for(CommonEntityType type : parsedTypeList){
|
||||
typeList.add(type);
|
||||
}
|
||||
}
|
||||
return typeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all common entity definition files recursively
|
||||
* @param initialPath The initial path to recurse from
|
||||
* @return The common entity defintion interface
|
||||
*/
|
||||
static CommonEntityMap loadCommonEntityTypes(String initialPath) {
|
||||
CommonEntityMap rVal = new CommonEntityMap();
|
||||
List<CommonEntityType> typeList = recursiveReadEntityLoader(initialPath);
|
||||
for(CommonEntityType type : typeList){
|
||||
rVal.putType(type.getId(), type);
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a child creature defintion file
|
||||
* @param filename The filename
|
||||
@ -121,53 +157,17 @@ public class Config {
|
||||
if(type.getAttackMoves() != null){
|
||||
type.setAttackMoveResolver(new AttackMoveResolver(type.getAttackMoves()));
|
||||
}
|
||||
loader.putCreature(type.getCreatureId(), type);
|
||||
loader.putType(type.getId(), type);
|
||||
//loop through all creatures and add ones with PLAYABLE token to list of playable races
|
||||
for(String token : type.getTokens()){
|
||||
if(token.contains("PLAYABLE")){
|
||||
loader.putPlayableRace(type.getCreatureId());
|
||||
loader.putPlayableRace(type.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a file that define object entity types
|
||||
* @param filename The filename to read
|
||||
* @return The list of object definitions
|
||||
*/
|
||||
static List<ObjectData> readObjectTypeFile(String filename){
|
||||
List<ObjectData> typeList = new LinkedList<ObjectData>();
|
||||
ObjectTypeMap typeMap = FileUtils.loadObjectFromAssetPath(filename, ObjectTypeMap.class);
|
||||
//push the types from this file
|
||||
for(ObjectData type : typeMap.getObjects()){
|
||||
typeList.add(type);
|
||||
}
|
||||
//push types from any other files
|
||||
for(String filepath : typeMap.getFiles()){
|
||||
List<ObjectData> parsedTypeList = readObjectTypeFile(filepath);
|
||||
for(ObjectData type : parsedTypeList){
|
||||
typeList.add(type);
|
||||
}
|
||||
}
|
||||
return typeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively reads files that define object entities
|
||||
* @param initialPath The initial path to start recursing from
|
||||
* @return The object entity interface
|
||||
*/
|
||||
static ObjectTypeLoader loadObjectTypes(String initialPath) {
|
||||
ObjectTypeLoader loader = new ObjectTypeLoader();
|
||||
List<ObjectData> typeList = readObjectTypeFile(initialPath);
|
||||
for(ObjectData type : typeList){
|
||||
loader.putObject(type.getObjectId(), type);
|
||||
}
|
||||
return loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the interface for creature definitions loaded into memory
|
||||
* @return The interface
|
||||
@ -220,7 +220,7 @@ public class Config {
|
||||
* Gets the definitions of all object entities in memory
|
||||
* @return The objects
|
||||
*/
|
||||
public ObjectTypeLoader getObjectTypeLoader() {
|
||||
public CommonEntityMap getObjectTypeMap() {
|
||||
return objectTypeLoader;
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ public class ConfigValidator {
|
||||
public static void valdiate(Config config){
|
||||
//validate the creatures
|
||||
CreatureTypeLoader creatureTypeLoader = config.getCreatureTypeLoader();
|
||||
for(CreatureData creatureData : creatureTypeLoader.getCreatures()){
|
||||
for(CreatureData creatureData : creatureTypeLoader.getTypes()){
|
||||
CreatureDataValidator.validate(creatureData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package electrosphere.game.data.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A recursive file structure for loading types of entities
|
||||
*/
|
||||
public class CommonEntityLoader {
|
||||
|
||||
/**
|
||||
* The entities in this file
|
||||
*/
|
||||
List<CommonEntityType> objects;
|
||||
|
||||
/**
|
||||
* All child files of this one
|
||||
*/
|
||||
List<String> files;
|
||||
|
||||
/**
|
||||
* Gets the entities stored in this file
|
||||
* @return The list of entities
|
||||
*/
|
||||
public List<CommonEntityType> getEntities(){
|
||||
return objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all child files of this one
|
||||
* @return The list of all child files
|
||||
*/
|
||||
public List<String> getFiles(){
|
||||
return files;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package electrosphere.game.data.common;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A loader from a common entity type
|
||||
*/
|
||||
public class CommonEntityMap {
|
||||
|
||||
/**
|
||||
* The map of entity id -> entity data
|
||||
*/
|
||||
Map<String,CommonEntityType> idTypeMap = new HashMap<String,CommonEntityType>();
|
||||
|
||||
/**
|
||||
* Adds entity data to the loader
|
||||
* @param name The id of the entity
|
||||
* @param type The entity data
|
||||
*/
|
||||
public void putType(String name, CommonEntityType type){
|
||||
idTypeMap.put(name,type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets entity data from the id of the type
|
||||
* @param id The id of the type
|
||||
* @return The entity data if it exists, null otherwise
|
||||
*/
|
||||
public CommonEntityType getType(String id){
|
||||
return idTypeMap.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the collection of all entity data
|
||||
* @return the collection of all entity data
|
||||
*/
|
||||
public Collection<CommonEntityType> getTypes(){
|
||||
return idTypeMap.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set of all entity data id's stored in the loader
|
||||
* @return the set of all entity data ids
|
||||
*/
|
||||
public Set<String> getTypeIds(){
|
||||
return idTypeMap.keySet();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,310 @@
|
||||
package electrosphere.game.data.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electrosphere.game.data.collidable.CollidableTemplate;
|
||||
import electrosphere.game.data.collidable.HitboxData;
|
||||
import electrosphere.game.data.creature.type.HealthSystem;
|
||||
import electrosphere.game.data.creature.type.IdleData;
|
||||
import electrosphere.game.data.creature.type.LookAtSystem;
|
||||
import electrosphere.game.data.creature.type.ViewModelData;
|
||||
import electrosphere.game.data.creature.type.ai.AITreeData;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMoveResolver;
|
||||
import electrosphere.game.data.creature.type.block.BlockSystem;
|
||||
import electrosphere.game.data.creature.type.bonegroups.BoneGroup;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.game.data.creature.type.movement.MovementSystem;
|
||||
import electrosphere.game.data.creature.type.rotator.RotatorSystem;
|
||||
import electrosphere.game.data.foliage.type.AmbientAudio;
|
||||
import electrosphere.game.data.foliage.type.GrowthModel;
|
||||
import electrosphere.game.data.foliage.type.TreeModel;
|
||||
import electrosphere.game.data.graphics.GraphicsTemplate;
|
||||
|
||||
/**
|
||||
* Common data that all entity types use
|
||||
*/
|
||||
public class CommonEntityType {
|
||||
|
||||
/**
|
||||
* The id of the creature
|
||||
*/
|
||||
String id;
|
||||
|
||||
/**
|
||||
* The list of hitboxes on the creature
|
||||
*/
|
||||
List<HitboxData> hitboxes;
|
||||
|
||||
/**
|
||||
* Various tokens
|
||||
*/
|
||||
List<String> tokens;
|
||||
|
||||
/**
|
||||
* The movement systems available to this creature type
|
||||
*/
|
||||
List<MovementSystem> movementSystems;
|
||||
|
||||
/**
|
||||
* Rotator systems available to this creature type
|
||||
*/
|
||||
RotatorSystem rotatorSystem;
|
||||
|
||||
/**
|
||||
* The list of equip points on this creature
|
||||
*/
|
||||
List<EquipPoint> equipPoints;
|
||||
|
||||
/**
|
||||
* The collidable used for this creature type
|
||||
*/
|
||||
CollidableTemplate collidable;
|
||||
|
||||
/**
|
||||
* The list of attack moves available to this creature
|
||||
*/
|
||||
List<AttackMove> attackMoves;
|
||||
|
||||
/**
|
||||
* The health system available to this creature
|
||||
*/
|
||||
HealthSystem healthSystem;
|
||||
|
||||
/**
|
||||
* The look at system available for this creature
|
||||
*/
|
||||
LookAtSystem lookAtSystem;
|
||||
|
||||
/**
|
||||
* The model path for this creature
|
||||
*/
|
||||
String modelPath;
|
||||
|
||||
/**
|
||||
* The view model data for this creature
|
||||
*/
|
||||
ViewModelData viewModelData;
|
||||
|
||||
/**
|
||||
* The idle data for this creature
|
||||
*/
|
||||
IdleData idleData;
|
||||
|
||||
/**
|
||||
* The block system for this creature
|
||||
*/
|
||||
BlockSystem blockSystem;
|
||||
|
||||
/**
|
||||
* The configuration data for the ai trees associated with this creature
|
||||
*/
|
||||
List<AITreeData> aiTrees;
|
||||
|
||||
/**
|
||||
* The attack move resolver for this creature type
|
||||
*/
|
||||
AttackMoveResolver attackMoveResolver;
|
||||
|
||||
/**
|
||||
* The list of bone groups for this creature
|
||||
*/
|
||||
List<BoneGroup> boneGroups;
|
||||
|
||||
/**
|
||||
* the model of growth characterists
|
||||
*/
|
||||
GrowthModel growthModel;
|
||||
|
||||
/**
|
||||
* The model for a tree
|
||||
*/
|
||||
TreeModel treeModel;
|
||||
|
||||
/**
|
||||
* The ambient audio model
|
||||
*/
|
||||
AmbientAudio ambientAudio;
|
||||
|
||||
/**
|
||||
* The graphics template for this object
|
||||
*/
|
||||
GraphicsTemplate graphicsTemplate;
|
||||
|
||||
/**
|
||||
* Gets the id for this creature type
|
||||
* @return The id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of hitboxes for this creature
|
||||
* @return The list of hitbox data
|
||||
*/
|
||||
public List<HitboxData> getHitboxes() {
|
||||
return hitboxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tokens for this creature
|
||||
* @return The tokens
|
||||
*/
|
||||
public List<String> getTokens() {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path for the model for this creature
|
||||
* @return The model path
|
||||
*/
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of data of movement types available to this creature
|
||||
* @return The list of movement type data
|
||||
*/
|
||||
public List<MovementSystem> getMovementSystems() {
|
||||
return movementSystems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of attack moves available to this creature type
|
||||
* @return The list of attack moves
|
||||
*/
|
||||
public List<AttackMove> getAttackMoves() {
|
||||
return attackMoves;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the health system data for this creature type
|
||||
* @return The health system data
|
||||
*/
|
||||
public HealthSystem getHealthSystem() {
|
||||
return healthSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the collidable data for this creature type
|
||||
* @return The collidable data
|
||||
*/
|
||||
public CollidableTemplate getCollidable() {
|
||||
return collidable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the look at system configuration for this creature type
|
||||
* @return The look at system data
|
||||
*/
|
||||
public LookAtSystem getLookAtSystem() {
|
||||
return lookAtSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rotator data for this creature type
|
||||
* @return The rotator data
|
||||
*/
|
||||
public RotatorSystem getRotatorSystem() {
|
||||
return rotatorSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of equip points for this creature type
|
||||
* @return The list of equip points
|
||||
*/
|
||||
public List<EquipPoint> getEquipPoints(){
|
||||
return equipPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attack move resolver for this creature type
|
||||
* @param resolver The resolver
|
||||
*/
|
||||
public void setAttackMoveResolver(AttackMoveResolver resolver){
|
||||
attackMoveResolver = resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attack move resolver for this creature type
|
||||
* @return The attack move resolver
|
||||
*/
|
||||
public AttackMoveResolver getAttackMoveResolver(){
|
||||
return attackMoveResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first-person view model data for this creature type
|
||||
* @return The first-person view model data
|
||||
*/
|
||||
public ViewModelData getViewModelData(){
|
||||
return viewModelData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the idle data for this creature type (ie animation data)
|
||||
* @return The idle data
|
||||
*/
|
||||
public IdleData getIdleData(){
|
||||
return idleData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the block system data for this creature type
|
||||
* @return The block system data
|
||||
*/
|
||||
public BlockSystem getBlockSystem(){
|
||||
return blockSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AI tree data associated with this creature type
|
||||
* @return The list of ai tree data
|
||||
*/
|
||||
public List<AITreeData> getAITrees(){
|
||||
return aiTrees;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of bone groups for this creature
|
||||
* @return The list of bone groups
|
||||
*/
|
||||
public List<BoneGroup> getBoneGroups(){
|
||||
return boneGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graphics template for this object
|
||||
* @return the graphics template
|
||||
*/
|
||||
public GraphicsTemplate getGraphicsTemplate(){
|
||||
return graphicsTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the growth model
|
||||
* @return The growth model
|
||||
*/
|
||||
public GrowthModel getGrowthModel(){
|
||||
return growthModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tree model
|
||||
* @return The tree model
|
||||
*/
|
||||
public TreeModel getTreeModel(){
|
||||
return treeModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ambient audio model
|
||||
* @return The ambient audio model
|
||||
*/
|
||||
public AmbientAudio getAmbientAudio(){
|
||||
return ambientAudio;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.data.common;
|
||||
package electrosphere.game.data.common.treedata;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.data.common;
|
||||
package electrosphere.game.data.common.treedata;
|
||||
|
||||
/**
|
||||
* Audio data to use when running a given tree state
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.data.common;
|
||||
package electrosphere.game.data.common.treedata;
|
||||
|
||||
/**
|
||||
* A simple tree state
|
||||
@ -1,15 +1,6 @@
|
||||
package electrosphere.game.data.creature.type;
|
||||
|
||||
import electrosphere.game.data.collidable.CollidableTemplate;
|
||||
import electrosphere.game.data.collidable.HitboxData;
|
||||
import electrosphere.game.data.creature.type.ai.AITreeData;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMoveResolver;
|
||||
import electrosphere.game.data.creature.type.block.BlockSystem;
|
||||
import electrosphere.game.data.creature.type.bonegroups.BoneGroup;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.game.data.creature.type.movement.MovementSystem;
|
||||
import electrosphere.game.data.creature.type.rotator.RotatorSystem;
|
||||
import electrosphere.game.data.common.CommonEntityType;
|
||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||
|
||||
import java.util.List;
|
||||
@ -17,121 +8,17 @@ import java.util.List;
|
||||
/**
|
||||
* A given type of creature
|
||||
*/
|
||||
public class CreatureData {
|
||||
public class CreatureData extends CommonEntityType {
|
||||
|
||||
/**
|
||||
* The id of the creature
|
||||
*/
|
||||
String creatureId;
|
||||
|
||||
/**
|
||||
* The list of hitboxes on the creature
|
||||
*/
|
||||
List<HitboxData> hitboxes;
|
||||
|
||||
/**
|
||||
* Various tokens
|
||||
*/
|
||||
List<String> tokens;
|
||||
|
||||
/**
|
||||
* The visual attributes that can be configured on this creature type
|
||||
*/
|
||||
List<VisualAttribute> visualAttributes;
|
||||
|
||||
/**
|
||||
* The movement systems available to this creature type
|
||||
*/
|
||||
List<MovementSystem> movementSystems;
|
||||
|
||||
/**
|
||||
* Rotator systems available to this creature type
|
||||
*/
|
||||
RotatorSystem rotatorSystem;
|
||||
|
||||
/**
|
||||
* The list of equip points on this creature
|
||||
*/
|
||||
List<EquipPoint> equipPoints;
|
||||
|
||||
/**
|
||||
* The collidable used for this creature type
|
||||
*/
|
||||
CollidableTemplate collidable;
|
||||
|
||||
/**
|
||||
* The list of attack moves available to this creature
|
||||
*/
|
||||
List<AttackMove> attackMoves;
|
||||
|
||||
/**
|
||||
* The health system available to this creature
|
||||
*/
|
||||
HealthSystem healthSystem;
|
||||
|
||||
/**
|
||||
* The look at system available for this creature
|
||||
*/
|
||||
LookAtSystem lookAtSystem;
|
||||
|
||||
/**
|
||||
* The model path for this creature
|
||||
*/
|
||||
String modelPath;
|
||||
|
||||
/**
|
||||
* The view model data for this creature
|
||||
*/
|
||||
ViewModelData viewModelData;
|
||||
|
||||
/**
|
||||
* The idle data for this creature
|
||||
*/
|
||||
IdleData idleData;
|
||||
|
||||
/**
|
||||
* The block system for this creature
|
||||
*/
|
||||
BlockSystem blockSystem;
|
||||
|
||||
/**
|
||||
* The configuration data for the ai trees associated with this creature
|
||||
*/
|
||||
List<AITreeData> aiTrees;
|
||||
|
||||
/**
|
||||
* The attack move resolver for this creature type
|
||||
*/
|
||||
AttackMoveResolver attackMoveResolver;
|
||||
|
||||
/**
|
||||
* The list of bone groups for this creature
|
||||
*/
|
||||
List<BoneGroup> boneGroups;
|
||||
|
||||
/**
|
||||
* Gets the id for this creature type
|
||||
* @return The id
|
||||
*/
|
||||
public String getCreatureId() {
|
||||
return creatureId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of hitboxes for this creature
|
||||
* @return The list of hitbox data
|
||||
*/
|
||||
public List<HitboxData> getHitboxes() {
|
||||
return hitboxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tokens for this creature
|
||||
* @return The tokens
|
||||
*/
|
||||
public List<String> getTokens() {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configurable visual attributes for this creature type
|
||||
@ -141,125 +28,7 @@ public class CreatureData {
|
||||
return visualAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path for the model for this creature
|
||||
* @return The model path
|
||||
*/
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of data of movement types available to this creature
|
||||
* @return The list of movement type data
|
||||
*/
|
||||
public List<MovementSystem> getMovementSystems() {
|
||||
return movementSystems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of attack moves available to this creature type
|
||||
* @return The list of attack moves
|
||||
*/
|
||||
public List<AttackMove> getAttackMoves() {
|
||||
return attackMoves;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the health system data for this creature type
|
||||
* @return The health system data
|
||||
*/
|
||||
public HealthSystem getHealthSystem() {
|
||||
return healthSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the collidable data for this creature type
|
||||
* @return The collidable data
|
||||
*/
|
||||
public CollidableTemplate getCollidable() {
|
||||
return collidable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the look at system configuration for this creature type
|
||||
* @return The look at system data
|
||||
*/
|
||||
public LookAtSystem getLookAtSystem() {
|
||||
return lookAtSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rotator data for this creature type
|
||||
* @return The rotator data
|
||||
*/
|
||||
public RotatorSystem getRotatorSystem() {
|
||||
return rotatorSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of equip points for this creature type
|
||||
* @return The list of equip points
|
||||
*/
|
||||
public List<EquipPoint> getEquipPoints(){
|
||||
return equipPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attack move resolver for this creature type
|
||||
* @param resolver The resolver
|
||||
*/
|
||||
public void setAttackMoveResolver(AttackMoveResolver resolver){
|
||||
attackMoveResolver = resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attack move resolver for this creature type
|
||||
* @return The attack move resolver
|
||||
*/
|
||||
public AttackMoveResolver getAttackMoveResolver(){
|
||||
return attackMoveResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first-person view model data for this creature type
|
||||
* @return The first-person view model data
|
||||
*/
|
||||
public ViewModelData getViewModelData(){
|
||||
return viewModelData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the idle data for this creature type (ie animation data)
|
||||
* @return The idle data
|
||||
*/
|
||||
public IdleData getIdleData(){
|
||||
return idleData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the block system data for this creature type
|
||||
* @return The block system data
|
||||
*/
|
||||
public BlockSystem getBlockSystem(){
|
||||
return blockSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AI tree data associated with this creature type
|
||||
* @return The list of ai tree data
|
||||
*/
|
||||
public List<AITreeData> getAITrees(){
|
||||
return aiTrees;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of bone groups for this creature
|
||||
* @return The list of bone groups
|
||||
*/
|
||||
public List<BoneGroup> getBoneGroups(){
|
||||
return boneGroups;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package electrosphere.game.data.creature.type;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.bonegroups.BoneGroup;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
@ -47,7 +47,7 @@ public class CreatureDataValidator {
|
||||
String message = "Two bone groups have the same bone in them!\n" +
|
||||
"Bone name: " + boneName + "\n" +
|
||||
"Second group: " + group.getId() + "\n" +
|
||||
"Creature name: " + data.getCreatureId()
|
||||
"Creature name: " + data.getId()
|
||||
;
|
||||
LoggerInterface.loggerEngine.WARNING(message);
|
||||
} else {
|
||||
@ -64,7 +64,7 @@ public class CreatureDataValidator {
|
||||
String message = "Two bone groups have the same bone in them!\n" +
|
||||
"Bone name: " + boneName + "\n" +
|
||||
"Second group: " + group.getId() + "\n" +
|
||||
"Creature name: " + data.getCreatureId()
|
||||
"Creature name: " + data.getId()
|
||||
;
|
||||
LoggerInterface.loggerEngine.WARNING(message);
|
||||
} else {
|
||||
@ -132,7 +132,7 @@ public class CreatureDataValidator {
|
||||
if(animation.getPriority() == null && animation.getPriorityCategory() == null){
|
||||
//same bone used in multiple groups
|
||||
String message = "Animation does not have priority defined!\n" +
|
||||
"Creature name: " + data.getCreatureId() + "\n" +
|
||||
"Creature name: " + data.getId() + "\n" +
|
||||
"Animation first person name: " + animation.getNameFirstPerson() + "\n" +
|
||||
"Animation third person name: " + animation.getNameThirdPerson() + "\n"
|
||||
;
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
/**
|
||||
@ -12,10 +13,10 @@ import java.util.concurrent.Semaphore;
|
||||
*/
|
||||
public class CreatureTypeLoader {
|
||||
|
||||
/**
|
||||
* The map of creature name -> creature data
|
||||
/**
|
||||
* The map of entity id -> entity data
|
||||
*/
|
||||
Map<String,CreatureData> creatureMap = new HashMap<String,CreatureData>();
|
||||
Map<String,CreatureData> idTypeMap = new HashMap<String,CreatureData>();
|
||||
|
||||
/**
|
||||
* The list of playable races
|
||||
@ -27,15 +28,6 @@ public class CreatureTypeLoader {
|
||||
*/
|
||||
Semaphore playableRaceLock = new Semaphore(1);
|
||||
|
||||
/**
|
||||
* Adds creature data to the loader
|
||||
* @param name The name of the creature
|
||||
* @param type The creature data
|
||||
*/
|
||||
public void putCreature(String name, CreatureData type){
|
||||
creatureMap.put(name,type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a playable race to the loader
|
||||
* @param name The race name
|
||||
@ -44,23 +36,6 @@ public class CreatureTypeLoader {
|
||||
playableRaceNames.add(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets creature data from the name of a creature
|
||||
* @param name The name of the creature
|
||||
* @return The creature data if it exists, null otherwise
|
||||
*/
|
||||
public CreatureData getCreature(String name){
|
||||
return creatureMap.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the collection of all creature data
|
||||
* @return the collection of all creature data
|
||||
*/
|
||||
public Collection<CreatureData> getCreatures(){
|
||||
return creatureMap.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of playable races
|
||||
* @return The list of playable race names
|
||||
@ -90,5 +65,39 @@ public class CreatureTypeLoader {
|
||||
playableRaceLock.release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds entity data to the loader
|
||||
* @param name The id of the entity
|
||||
* @param type The entity data
|
||||
*/
|
||||
public void putType(String name, CreatureData type){
|
||||
idTypeMap.put(name,type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets entity data from the id of the type
|
||||
* @param id The id of the type
|
||||
* @return The entity data if it exists, null otherwise
|
||||
*/
|
||||
public CreatureData getType(String id){
|
||||
return idTypeMap.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the collection of all entity data
|
||||
* @return the collection of all entity data
|
||||
*/
|
||||
public Collection<CreatureData> getTypes(){
|
||||
return idTypeMap.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set of all entity data id's stored in the loader
|
||||
* @return the set of all entity data ids
|
||||
*/
|
||||
public Set<String> getTypeIds(){
|
||||
return idTypeMap.keySet();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package electrosphere.game.data.creature.type;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataState;
|
||||
import electrosphere.game.data.common.treedata.TreeDataState;
|
||||
|
||||
/**
|
||||
* Data about the health of a creature
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package electrosphere.game.data.creature.type;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
|
||||
/**
|
||||
* Data about how the creature will behave when in idle state
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package electrosphere.game.data.creature.type;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
|
||||
/**
|
||||
* Sprint data
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package electrosphere.game.data.creature.type.attack;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataState;
|
||||
import electrosphere.game.data.common.treedata.TreeDataState;
|
||||
|
||||
/**
|
||||
* Data about a single attack move this creature is capable of
|
||||
|
||||
@ -2,8 +2,8 @@ package electrosphere.game.data.creature.type.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.TreeDataAudio;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAudio;
|
||||
|
||||
/**
|
||||
* A variant of data that can be loaded into the block system. Variants are for different types of equip states.
|
||||
|
||||
@ -2,7 +2,7 @@ package electrosphere.game.data.creature.type.equip;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
|
||||
/**
|
||||
* A portion of the creature that can have an item attached to it
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package electrosphere.game.data.creature.type.movement;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataState;
|
||||
import electrosphere.game.data.common.treedata.TreeDataState;
|
||||
|
||||
/**
|
||||
* Data about a falling movement system
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package electrosphere.game.data.creature.type.movement;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
import electrosphere.game.data.creature.type.SprintSystem;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package electrosphere.game.data.creature.type.movement;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.treedata.TreeDataAnimation;
|
||||
|
||||
/**
|
||||
* A jump tree's data
|
||||
|
||||
@ -2,46 +2,20 @@ package electrosphere.game.data.foliage.type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electrosphere.game.data.common.CommonEntityType;
|
||||
|
||||
/**
|
||||
* A foliage object, ambient or otherwise
|
||||
*/
|
||||
public class FoliageType {
|
||||
public class FoliageType extends CommonEntityType {
|
||||
|
||||
//Denotes an ambient foliage that will be placed on a voxel
|
||||
public static final String TOKEN_AMBIENT = "AMBIENT";
|
||||
//Denotes an tree object
|
||||
public static final String TOKEN_TREE = "TREE";
|
||||
|
||||
//the name of the foliage type
|
||||
String name;
|
||||
//the model path of the foliage
|
||||
String modelPath;
|
||||
//the physics object(s) for the foliage
|
||||
List<PhysicsObject> physicsObjects;
|
||||
//the model of growth characterists
|
||||
GrowthModel growthModel;
|
||||
//the list of tokens
|
||||
List<String> tokens;
|
||||
//The model for a tree
|
||||
TreeModel treeModel;
|
||||
//The ambient audio model
|
||||
AmbientAudio ambientAudio;
|
||||
|
||||
/**
|
||||
* Gets the name of the foliage type
|
||||
* @return The name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the model path of the foliage type
|
||||
* @return The model path
|
||||
*/
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the physics object(s)
|
||||
@ -50,37 +24,5 @@ public class FoliageType {
|
||||
public List<PhysicsObject> getPhysicsObjects() {
|
||||
return physicsObjects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tokens
|
||||
* @return The tokens
|
||||
*/
|
||||
public List<String> getTokens() {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the growth model
|
||||
* @return The growth model
|
||||
*/
|
||||
public GrowthModel getGrowthModel(){
|
||||
return growthModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tree model
|
||||
* @return The tree model
|
||||
*/
|
||||
public TreeModel getTreeModel(){
|
||||
return treeModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ambient audio model
|
||||
* @return The ambient audio model
|
||||
*/
|
||||
public AmbientAudio getAmbientAudio(){
|
||||
return ambientAudio;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ public class FoliageTypeMap {
|
||||
*/
|
||||
public FoliageType getFoliage(String name){
|
||||
for(FoliageType foliage : foliageList){
|
||||
if(foliage.getName().matches(name)){
|
||||
if(foliage.getId().matches(name)){
|
||||
return foliage;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,22 +1,12 @@
|
||||
package electrosphere.game.data.item.type;
|
||||
|
||||
import electrosphere.game.data.collidable.CollidableTemplate;
|
||||
|
||||
import java.util.List;
|
||||
import electrosphere.game.data.common.CommonEntityType;
|
||||
|
||||
/**
|
||||
* Data on a given item
|
||||
*/
|
||||
public class Item {
|
||||
public class Item extends CommonEntityType {
|
||||
|
||||
//the id of the item
|
||||
String itemId;
|
||||
//the model path of the item
|
||||
String modelPath;
|
||||
//tokens associated with this item type
|
||||
List<String> tokens;
|
||||
//the collidable data for the item
|
||||
CollidableTemplate collidable;
|
||||
//the idle animation for the item
|
||||
String idleAnim;
|
||||
//the path for the icon texture for this item
|
||||
@ -26,37 +16,6 @@ public class Item {
|
||||
//The data defining how this item is equipped
|
||||
EquipData equipData;
|
||||
|
||||
/**
|
||||
* the id of the item
|
||||
* @return
|
||||
*/
|
||||
public String getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* the model path of the item
|
||||
* @return
|
||||
*/
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
/*
|
||||
* tokens associated with this item type
|
||||
*/
|
||||
public List<String> getTokens() {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* the collidable data for the item
|
||||
* @return
|
||||
*/
|
||||
public CollidableTemplate getCollidable(){
|
||||
return collidable;
|
||||
}
|
||||
|
||||
/**
|
||||
* the idle animation for the item
|
||||
* @return
|
||||
|
||||
@ -15,10 +15,10 @@ public class ItemTypeMap {
|
||||
public Item getItem(String name){
|
||||
Item rVal = null;
|
||||
for(Item item : items){
|
||||
if(item.getItemId().equals(name)){
|
||||
if(item.getId().equals(name)){
|
||||
rVal = item;
|
||||
break;
|
||||
} else if(item.getItemId().equalsIgnoreCase(name)){
|
||||
} else if(item.getId().equalsIgnoreCase(name)){
|
||||
LoggerInterface.loggerEngine.WARNING("Failed to fetch item type data; however, item with different-capitalized name exists! May be a capitalization error!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,75 +0,0 @@
|
||||
package electrosphere.game.data.object.type;
|
||||
|
||||
import electrosphere.game.data.collidable.CollidableTemplate;
|
||||
import electrosphere.game.data.collidable.HitboxData;
|
||||
import electrosphere.game.data.graphics.GraphicsTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Metadata about a type of object
|
||||
*/
|
||||
public class ObjectData {
|
||||
|
||||
//the id of the object
|
||||
String objectId;
|
||||
//the path for the model for this object
|
||||
String modelPath;
|
||||
//tokens associated with this object
|
||||
List<String> tokens;
|
||||
//the collidable template for this object
|
||||
CollidableTemplate collidable;
|
||||
//the graphics template for this object
|
||||
GraphicsTemplate graphicsTemplate;
|
||||
//the hitbox data for this object
|
||||
List<HitboxData> hitboxData;
|
||||
|
||||
/**
|
||||
* Gets the id of the object
|
||||
* @return the id
|
||||
*/
|
||||
public String getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the model path of the object
|
||||
* @return the model path
|
||||
*/
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all tokens associated with this object
|
||||
* @return the list of all tokens
|
||||
*/
|
||||
public List<String> getTokens() {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the collidable data for this object
|
||||
* @return the collidable data
|
||||
*/
|
||||
public CollidableTemplate getCollidable(){
|
||||
return collidable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graphics template for this object
|
||||
* @return the graphics template
|
||||
*/
|
||||
public GraphicsTemplate getGraphicsTemplate(){
|
||||
return graphicsTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hitbox data for this object
|
||||
* @return the hitbox data
|
||||
*/
|
||||
public List<HitboxData> getHitboxData(){
|
||||
return this.hitboxData;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
package electrosphere.game.data.object.type.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import electrosphere.game.data.object.type.ObjectData;
|
||||
|
||||
/**
|
||||
* An interface for grabbing data about objects available to the game engine
|
||||
*/
|
||||
public class ObjectTypeLoader {
|
||||
|
||||
//the map that stores all object types by name
|
||||
Map<String,ObjectData> objectMap = new HashMap<String,ObjectData>();
|
||||
|
||||
//the list of all object data
|
||||
List<ObjectData> objectList = new LinkedList<ObjectData>();
|
||||
|
||||
/**
|
||||
* Gets the list of all object types loaded into memory
|
||||
* @return The list
|
||||
*/
|
||||
public List<ObjectData> getAllObjectTypes(){
|
||||
return objectList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts an object in the map
|
||||
* @param name The name of the object
|
||||
* @param type The object type data
|
||||
*/
|
||||
public void putObject(String name, ObjectData type){
|
||||
objectMap.put(name,type);
|
||||
objectList.add(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets object data by its name
|
||||
* @param name The name of the object type
|
||||
* @return The object data if it exists, otherwise null
|
||||
*/
|
||||
public ObjectData getObject(String name){
|
||||
return objectMap.get(name);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
package electrosphere.game.data.object.type.model;
|
||||
|
||||
import electrosphere.game.data.object.type.ObjectData;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The raw list of object data read from disk
|
||||
*/
|
||||
public class ObjectTypeMap {
|
||||
|
||||
//the objects stored in this file
|
||||
List<ObjectData> objects;
|
||||
//all children files to recursively parse for more object data
|
||||
List<String> files;
|
||||
|
||||
/**
|
||||
* Gets the list of all objects in this file
|
||||
* @return the list
|
||||
*/
|
||||
public List<ObjectData> getObjects() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object data for an object in this file by its name
|
||||
* @param name the name of the object
|
||||
* @return The object data
|
||||
*/
|
||||
public ObjectData getObject(String name){
|
||||
ObjectData rVal = null;
|
||||
for(ObjectData item : objects){
|
||||
if(item.getObjectId().equals(name)){
|
||||
rVal = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of all children files of this file
|
||||
* @return The list of all children files
|
||||
*/
|
||||
public List<String> getFiles(){
|
||||
return files;
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,6 +8,7 @@ import org.joml.Quaterniond;
|
||||
import org.joml.Vector3d;
|
||||
import org.ode4j.ode.DBody;
|
||||
|
||||
import electrosphere.client.entity.debug.DebugVisualizerUtils;
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
@ -17,7 +18,6 @@ import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.state.server.ServerPlayerViewDirTree;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.debug.DebugVisualizerUtils;
|
||||
import electrosphere.entity.types.foliage.FoliageUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
@ -617,7 +617,7 @@ public class ImGuiEntityMacros {
|
||||
return ItemUtils.getType(entity);
|
||||
}
|
||||
if(FoliageUtils.isFoliage(entity)){
|
||||
return FoliageUtils.getFoliageType(entity).getName();
|
||||
return FoliageUtils.getFoliageType(entity).getId();
|
||||
}
|
||||
return "Entity";
|
||||
}
|
||||
|
||||
@ -2,13 +2,13 @@ package electrosphere.menu.debug;
|
||||
|
||||
import org.ode4j.ode.DBody;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.server.ServerPlayerViewDirTree;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.renderer.ui.imgui.ImGuiWindow;
|
||||
import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback;
|
||||
|
||||
@ -343,7 +343,7 @@ public class MenuGeneratorsInGame {
|
||||
Entity playerEntity = Globals.playerEntity;
|
||||
Actor playerActor = EntityUtils.getActor(playerEntity);
|
||||
ActorStaticMorph staticMorph = playerActor.getStaticMorph();
|
||||
CreatureData playeCreatureType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(CreatureUtils.getType(playerEntity));
|
||||
CreatureData playeCreatureType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(CreatureUtils.getType(playerEntity));
|
||||
int offset = 0;
|
||||
for(VisualAttribute attribute : playeCreatureType.getVisualAttributes()){
|
||||
int posY = offset * 350 + 100;
|
||||
|
||||
@ -5,19 +5,19 @@ import java.util.Random;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.foliage.FoliageUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.entity.types.object.ObjectUtils;
|
||||
import electrosphere.game.data.common.CommonEntityType;
|
||||
import electrosphere.game.data.creature.type.CreatureData;
|
||||
import electrosphere.game.data.foliage.type.FoliageType;
|
||||
import electrosphere.game.data.item.type.Item;
|
||||
import electrosphere.game.data.object.type.ObjectData;
|
||||
import electrosphere.game.data.units.UnitDefinition;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.menu.WindowStrings;
|
||||
@ -167,15 +167,15 @@ public class MenuGeneratorsLevelEditor {
|
||||
}));
|
||||
|
||||
//button for spawning all creatures
|
||||
for(CreatureData data : Globals.gameConfigCurrent.getCreatureTypeLoader().getCreatures()){
|
||||
for(CreatureData data : Globals.gameConfigCurrent.getCreatureTypeLoader().getTypes()){
|
||||
//spawn creature button
|
||||
scrollable.addChild(Button.createButton("Spawn " + data.getCreatureId(), () -> {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + data.getCreatureId() + "!");
|
||||
scrollable.addChild(Button.createButton("Spawn " + data.getId(), () -> {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + data.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Vector3d cursorPos = realm.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), 5.0).add(cursorVerticalOffset);
|
||||
CreatureUtils.serverSpawnBasicCreature(realm, cursorPos, data.getCreatureId(), null);
|
||||
CreatureUtils.serverSpawnBasicCreature(realm, cursorPos, data.getId(), null);
|
||||
}));
|
||||
}
|
||||
|
||||
@ -230,13 +230,13 @@ public class MenuGeneratorsLevelEditor {
|
||||
//button for spawning all foliage types
|
||||
for(FoliageType data : Globals.gameConfigCurrent.getFoliageMap().getFoliageList()){
|
||||
//spawn foliage button
|
||||
scrollable.addChild(Button.createButton("Spawn " + data.getName(), () -> {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + data.getName() + "!");
|
||||
scrollable.addChild(Button.createButton("Spawn " + data.getId(), () -> {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + data.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Vector3d cursorPos = realm.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), 5.0).add(cursorVerticalOffset);
|
||||
FoliageUtils.serverSpawnTreeFoliage(realm, cursorPos, data.getName(), new Random().nextLong());
|
||||
FoliageUtils.serverSpawnTreeFoliage(realm, cursorPos, data.getId(), new Random().nextLong());
|
||||
}));
|
||||
}
|
||||
|
||||
@ -258,13 +258,13 @@ public class MenuGeneratorsLevelEditor {
|
||||
//button for spawning all foliage types
|
||||
for(Item item : Globals.gameConfigCurrent.getItemMap().getItems()){
|
||||
//spawn foliage button
|
||||
scrollable.addChild(Button.createButton("Spawn " + item.getItemId(), () -> {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + item.getItemId() + "!");
|
||||
scrollable.addChild(Button.createButton("Spawn " + item.getId(), () -> {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + item.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Vector3d cursorPos = realm.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), 5.0).add(cursorVerticalOffset);
|
||||
ItemUtils.serverSpawnBasicItem(realm, cursorPos, item.getItemId());
|
||||
ItemUtils.serverSpawnBasicItem(realm, cursorPos, item.getId());
|
||||
}));
|
||||
}
|
||||
|
||||
@ -285,15 +285,15 @@ public class MenuGeneratorsLevelEditor {
|
||||
}));
|
||||
|
||||
//button for spawning all foliage types
|
||||
for(ObjectData object : Globals.gameConfigCurrent.getObjectTypeLoader().getAllObjectTypes()){
|
||||
for(CommonEntityType object : Globals.gameConfigCurrent.getObjectTypeMap().getTypes()){
|
||||
//spawn foliage button
|
||||
scrollable.addChild(Button.createButton("Spawn " + object.getObjectId(), () -> {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + object.getObjectId() + "!");
|
||||
scrollable.addChild(Button.createButton("Spawn " + object.getId(), () -> {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + object.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Vector3d cursorPos = realm.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), 5.0).add(cursorVerticalOffset);
|
||||
ObjectUtils.serverSpawnBasicObject(realm, cursorPos, object.getObjectId());
|
||||
CommonEntityUtils.serverSpawnBasicObject(realm, cursorPos, object.getId());
|
||||
}));
|
||||
}
|
||||
|
||||
@ -318,7 +318,6 @@ public class MenuGeneratorsLevelEditor {
|
||||
if(
|
||||
CreatureUtils.isCreature(entity) ||
|
||||
ItemUtils.isItem(entity) ||
|
||||
ObjectUtils.isObject(entity) ||
|
||||
FoliageUtils.isFoliage(entity)
|
||||
){
|
||||
Div div = Div.createDiv();
|
||||
@ -363,9 +362,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
} else if(ItemUtils.isItem(e)){
|
||||
return "Object - " + ItemUtils.getType(e);
|
||||
} else if(FoliageUtils.isFoliage(e)){
|
||||
return "Object - " + FoliageUtils.getFoliageType(e).getName();
|
||||
} else if(ObjectUtils.isObject(e)){
|
||||
return "Object - " + ObjectUtils.getType(e);
|
||||
return "Object - " + FoliageUtils.getFoliageType(e).getId();
|
||||
}
|
||||
return "Entity Unknown Type";
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@ import java.util.List;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||
import electrosphere.game.data.creature.type.CreatureData;
|
||||
import electrosphere.game.data.creature.type.visualattribute.AttributeVariant;
|
||||
@ -87,7 +87,7 @@ public class MenuGeneratorsMultiplayer {
|
||||
int horizontalPosition = 300;
|
||||
|
||||
//figure out race data
|
||||
CreatureData selectedRaceType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(race);
|
||||
CreatureData selectedRaceType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(race);
|
||||
|
||||
//spawn camera so renderer doesn't crash (once render pipeline is modularized this shouldn't be necessary)
|
||||
Globals.playerCamera = CameraEntityUtils.spawnBasicCameraEntity(new Vector3f(0,0,0), new Vector3f(0,0.3f,1).normalize());
|
||||
|
||||
@ -2,8 +2,8 @@ package electrosphere.menu.mainmenu;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.menu.WindowUtils;
|
||||
import electrosphere.renderer.actor.ActorUtils;
|
||||
import electrosphere.renderer.ui.elements.ActorPanel;
|
||||
|
||||
@ -13,13 +13,15 @@ import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
import electrosphere.entity.state.physicssync.ClientPhysicsSyncTree;
|
||||
import electrosphere.entity.types.EntityTypes;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureEquipData.EquippedItem;
|
||||
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.foliage.FoliageUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.entity.types.object.ObjectUtils;
|
||||
import electrosphere.game.data.creature.type.CreatureData;
|
||||
import electrosphere.game.data.creature.type.ViewModelData;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
@ -37,10 +39,6 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
|
||||
//Messages to ignore when complaining about messages that have nonexistant entity associated
|
||||
static List<EntityMessageType> idModifyingMessages = Arrays.asList(new EntityMessageType[]{
|
||||
EntityMessageType.CREATE,
|
||||
EntityMessageType.SPAWNCREATURE,
|
||||
EntityMessageType.SPAWNFOLIAGESEED,
|
||||
EntityMessageType.SPAWNITEM,
|
||||
EntityMessageType.SPAWNOBJECT,
|
||||
EntityMessageType.DESTROY,
|
||||
});
|
||||
|
||||
@ -61,7 +59,6 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
|
||||
Globals.clientSceneWrapper.dumpIdData(message.getentityID());
|
||||
}
|
||||
|
||||
Entity newlySpawnedEntity;
|
||||
switch(message.getMessageSubtype()){
|
||||
|
||||
|
||||
@ -75,91 +72,22 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
|
||||
"Spawn ID " + message.getentityID() + " of type " + message.getentityCategory() + " subtype " + message.getentitySubtype() +
|
||||
" @ " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ()
|
||||
);
|
||||
switch(message.getentityCategory()){
|
||||
case 0:
|
||||
// newlySpawnedEntity = CreatureUtils.spawnBasicCreature(message.getentitySubtype());
|
||||
// EntityUtils.getScale(newlySpawnedEntity).set(0.005f);
|
||||
// EntityUtils.getPosition(newlySpawnedEntity).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
||||
// EntityUtils.setEntityID(newlySpawnedEntity, message.getentityID());
|
||||
break;
|
||||
case 1:
|
||||
newlySpawnedEntity = ItemUtils.clientSpawnBasicItem(message.getentitySubtype());
|
||||
EntityUtils.getScale(newlySpawnedEntity).set(0.005f);
|
||||
EntityUtils.getPosition(newlySpawnedEntity).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
||||
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
|
||||
break;
|
||||
EntityType type = EntityTypes.fromInt(message.getentityCategory());
|
||||
switch(type){
|
||||
case CREATURE: {
|
||||
spawnCreature(message);
|
||||
} break;
|
||||
case ITEM: {
|
||||
spawnItem(message);
|
||||
} break;
|
||||
case FOLIAGE: {
|
||||
spawnFoliage(message);
|
||||
} break;
|
||||
case COMMON: {
|
||||
spawnCommon(message);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case SPAWNCREATURE: {
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Spawn Creature " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
||||
CreatureTemplate template = Utilities.deserialize(message.getcreatureTemplate(), CreatureTemplate.class);
|
||||
newlySpawnedEntity = CreatureUtils.clientSpawnBasicCreature(template.getCreatureType(),template);
|
||||
ClientEntityUtils.initiallyPositionEntity(
|
||||
newlySpawnedEntity,
|
||||
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
|
||||
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
|
||||
);
|
||||
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
|
||||
//if the creature template includes an equip section, spawn all the equipped items
|
||||
if(template != null && template.getCreatureEquipData() != null && template.getCreatureEquipData().getSlots() != null){
|
||||
for(String equipSlotId : template.getCreatureEquipData().getSlots()){
|
||||
|
||||
//add the item to the creature's inventory
|
||||
EquippedItem itemDefinition = template.getCreatureEquipData().getSlotItem(equipSlotId);
|
||||
Entity itemInInventory = InventoryUtils.clientConstructInInventoryItem(newlySpawnedEntity,itemDefinition.getItemType());
|
||||
|
||||
//equip the item to the slot defined in the template
|
||||
ClientEquipState clientEquipState = ClientEquipState.getEquipState(newlySpawnedEntity);
|
||||
clientEquipState.attemptEquip(itemInInventory, clientEquipState.getEquipPoint(equipSlotId));
|
||||
|
||||
//map the constructed item to its server id
|
||||
Globals.clientSceneWrapper.mapIdToId(itemInInventory.getId(), itemDefinition.getEntityId());
|
||||
}
|
||||
}
|
||||
//apply state synchronization if present
|
||||
if(template != null && template.getStateCollection() != null && template.getStateCollection().getValues() != null){
|
||||
StateCollection.applyStateCollection(newlySpawnedEntity, template.getStateCollection());
|
||||
}
|
||||
} break;
|
||||
case SPAWNITEM: {
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Spawn Item " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
||||
//spawn item
|
||||
String itemType = message.getcreatureTemplate();
|
||||
newlySpawnedEntity = ItemUtils.clientSpawnBasicItem(itemType);
|
||||
//position
|
||||
ClientEntityUtils.initiallyPositionEntity(
|
||||
newlySpawnedEntity,
|
||||
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
|
||||
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
|
||||
);
|
||||
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
|
||||
} break;
|
||||
case SPAWNFOLIAGESEED: {
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Spawn foliage " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
||||
String type = message.getcreatureTemplate();
|
||||
newlySpawnedEntity = FoliageUtils.spawnBasicFoliage(type,message.getfoliageSeed());
|
||||
ClientEntityUtils.initiallyPositionEntity(
|
||||
newlySpawnedEntity,
|
||||
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
|
||||
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
|
||||
);
|
||||
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
|
||||
} break;
|
||||
case SPAWNOBJECT: {
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Spawn object " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
||||
//spawn item
|
||||
String objectType = message.getcreatureTemplate();
|
||||
newlySpawnedEntity = ObjectUtils.clientSpawnBasicObject(objectType);
|
||||
//position
|
||||
ClientEntityUtils.initiallyPositionEntity(
|
||||
newlySpawnedEntity,
|
||||
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
|
||||
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
|
||||
);
|
||||
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
|
||||
} break;
|
||||
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
@ -247,7 +175,7 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
|
||||
LoggerInterface.loggerNetworking.DEBUG("Set player entity id for entity: " + target.getId() + " to player: " + message.getpropertyValue());
|
||||
CreatureUtils.setControllerPlayerId(target, message.getpropertyValue());
|
||||
String creatureTypeRaw = CreatureUtils.getType(target);
|
||||
CreatureData creatureType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(creatureTypeRaw);
|
||||
CreatureData creatureType = Globals.gameConfigCurrent.getCreatureTypeLoader().getType(creatureTypeRaw);
|
||||
ViewModelData viewModelData = creatureType.getViewModelData();
|
||||
if(Globals.clientPlayer != null && message.getpropertyValue() == Globals.clientPlayer.getId()){
|
||||
LoggerInterface.loggerNetworking.DEBUG("Set this player's entity id!");
|
||||
@ -268,4 +196,100 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns a creature
|
||||
* @param message The message
|
||||
* @return The item
|
||||
*/
|
||||
static Entity spawnCreature(EntityMessage message){
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Spawn Creature " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
||||
CreatureTemplate template = Utilities.deserialize(message.getcreatureTemplate(), CreatureTemplate.class);
|
||||
Entity newlySpawnedEntity = CreatureUtils.clientSpawnBasicCreature(template.getCreatureType(),template);
|
||||
ClientEntityUtils.initiallyPositionEntity(
|
||||
newlySpawnedEntity,
|
||||
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
|
||||
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
|
||||
);
|
||||
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
|
||||
//if the creature template includes an equip section, spawn all the equipped items
|
||||
if(template != null && template.getCreatureEquipData() != null && template.getCreatureEquipData().getSlots() != null){
|
||||
for(String equipSlotId : template.getCreatureEquipData().getSlots()){
|
||||
|
||||
//add the item to the creature's inventory
|
||||
EquippedItem itemDefinition = template.getCreatureEquipData().getSlotItem(equipSlotId);
|
||||
Entity itemInInventory = InventoryUtils.clientConstructInInventoryItem(newlySpawnedEntity,itemDefinition.getItemType());
|
||||
|
||||
//equip the item to the slot defined in the template
|
||||
ClientEquipState clientEquipState = ClientEquipState.getEquipState(newlySpawnedEntity);
|
||||
clientEquipState.attemptEquip(itemInInventory, clientEquipState.getEquipPoint(equipSlotId));
|
||||
|
||||
//map the constructed item to its server id
|
||||
Globals.clientSceneWrapper.mapIdToId(itemInInventory.getId(), itemDefinition.getEntityId());
|
||||
}
|
||||
}
|
||||
//apply state synchronization if present
|
||||
if(template != null && template.getStateCollection() != null && template.getStateCollection().getValues() != null){
|
||||
StateCollection.applyStateCollection(newlySpawnedEntity, template.getStateCollection());
|
||||
}
|
||||
return newlySpawnedEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns an item
|
||||
* @param message The network message
|
||||
* @return The item
|
||||
*/
|
||||
static Entity spawnItem(EntityMessage message){
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Spawn Item " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
||||
//spawn item
|
||||
String itemType = message.getcreatureTemplate();
|
||||
Entity newlySpawnedEntity = ItemUtils.clientSpawnBasicItem(itemType);
|
||||
//position
|
||||
ClientEntityUtils.initiallyPositionEntity(
|
||||
newlySpawnedEntity,
|
||||
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
|
||||
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
|
||||
);
|
||||
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
|
||||
return newlySpawnedEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns a foliage
|
||||
* @param message The network message
|
||||
* @return The foliage
|
||||
*/
|
||||
static Entity spawnFoliage(EntityMessage message){
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Spawn foliage " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
||||
String type = message.getentitySubtype();
|
||||
Entity newlySpawnedEntity = FoliageUtils.spawnBasicFoliage(type,Long.parseLong(message.getcreatureTemplate()));
|
||||
ClientEntityUtils.initiallyPositionEntity(
|
||||
newlySpawnedEntity,
|
||||
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
|
||||
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
|
||||
);
|
||||
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
|
||||
return newlySpawnedEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns a common entity
|
||||
* @param message The message
|
||||
* @return The entity
|
||||
*/
|
||||
static Entity spawnCommon(EntityMessage message){
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Spawn object " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
||||
//spawn item
|
||||
String objectType = message.getcreatureTemplate();
|
||||
Entity newlySpawnedEntity = CommonEntityUtils.clientSpawnBasicObject(objectType);
|
||||
//position
|
||||
ClientEntityUtils.initiallyPositionEntity(
|
||||
newlySpawnedEntity,
|
||||
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
|
||||
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
|
||||
);
|
||||
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
|
||||
return newlySpawnedEntity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,9 +9,6 @@ public class EntityMessage extends NetworkMessage {
|
||||
|
||||
public enum EntityMessageType {
|
||||
CREATE,
|
||||
SPAWNCREATURE,
|
||||
SPAWNITEM,
|
||||
SPAWNOBJECT,
|
||||
MOVEUPDATE,
|
||||
ATTACKUPDATE,
|
||||
STARTATTACK,
|
||||
@ -19,7 +16,6 @@ public class EntityMessage extends NetworkMessage {
|
||||
DESTROY,
|
||||
SETPROPERTY,
|
||||
ATTACHENTITYTOENTITY,
|
||||
SPAWNFOLIAGESEED,
|
||||
UPDATEENTITYVIEWDIR,
|
||||
SYNCPHYSICS,
|
||||
}
|
||||
@ -54,18 +50,11 @@ public class EntityMessage extends NetworkMessage {
|
||||
int treeState;
|
||||
int propertyType;
|
||||
int propertyValue;
|
||||
int treeType;
|
||||
int treeStatus;
|
||||
long time;
|
||||
String bone;
|
||||
int targetID;
|
||||
int bTreeID;
|
||||
int propertyID;
|
||||
int propertyValueInt;
|
||||
float propertyValueFloat;
|
||||
double propertyValueDouble;
|
||||
String propertyValueString;
|
||||
long foliageSeed;
|
||||
|
||||
EntityMessage(EntityMessageType messageType){
|
||||
this.type = MessageType.ENTITY_MESSAGE;
|
||||
@ -308,22 +297,6 @@ public class EntityMessage extends NetworkMessage {
|
||||
this.propertyValue = propertyValue;
|
||||
}
|
||||
|
||||
public int gettreeType() {
|
||||
return treeType;
|
||||
}
|
||||
|
||||
public void settreeType(int treeType) {
|
||||
this.treeType = treeType;
|
||||
}
|
||||
|
||||
public int gettreeStatus() {
|
||||
return treeStatus;
|
||||
}
|
||||
|
||||
public void settreeStatus(int treeStatus) {
|
||||
this.treeStatus = treeStatus;
|
||||
}
|
||||
|
||||
public long gettime() {
|
||||
return time;
|
||||
}
|
||||
@ -356,14 +329,6 @@ public class EntityMessage extends NetworkMessage {
|
||||
this.bTreeID = bTreeID;
|
||||
}
|
||||
|
||||
public int getpropertyID() {
|
||||
return propertyID;
|
||||
}
|
||||
|
||||
public void setpropertyID(int propertyID) {
|
||||
this.propertyID = propertyID;
|
||||
}
|
||||
|
||||
public int getpropertyValueInt() {
|
||||
return propertyValueInt;
|
||||
}
|
||||
@ -372,38 +337,6 @@ public class EntityMessage extends NetworkMessage {
|
||||
this.propertyValueInt = propertyValueInt;
|
||||
}
|
||||
|
||||
public float getpropertyValueFloat() {
|
||||
return propertyValueFloat;
|
||||
}
|
||||
|
||||
public void setpropertyValueFloat(float propertyValueFloat) {
|
||||
this.propertyValueFloat = propertyValueFloat;
|
||||
}
|
||||
|
||||
public double getpropertyValueDouble() {
|
||||
return propertyValueDouble;
|
||||
}
|
||||
|
||||
public void setpropertyValueDouble(double propertyValueDouble) {
|
||||
this.propertyValueDouble = propertyValueDouble;
|
||||
}
|
||||
|
||||
public String getpropertyValueString() {
|
||||
return propertyValueString;
|
||||
}
|
||||
|
||||
public void setpropertyValueString(String propertyValueString) {
|
||||
this.propertyValueString = propertyValueString;
|
||||
}
|
||||
|
||||
public long getfoliageSeed() {
|
||||
return foliageSeed;
|
||||
}
|
||||
|
||||
public void setfoliageSeed(long foliageSeed) {
|
||||
this.foliageSeed = foliageSeed;
|
||||
}
|
||||
|
||||
static void stripPacketHeader(CircularByteBuffer byteBuffer){
|
||||
byteBuffer.read(2);
|
||||
}
|
||||
@ -412,12 +345,6 @@ public class EntityMessage extends NetworkMessage {
|
||||
switch(secondByte){
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_CREATE:
|
||||
return EntityMessage.canParseCreateMessage(byteBuffer);
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNCREATURE:
|
||||
return EntityMessage.canParseSpawnCreatureMessage(byteBuffer);
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNITEM:
|
||||
return EntityMessage.canParseSpawnItemMessage(byteBuffer);
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNOBJECT:
|
||||
return EntityMessage.canParseSpawnObjectMessage(byteBuffer);
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE:
|
||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE){
|
||||
return true;
|
||||
@ -456,8 +383,6 @@ public class EntityMessage extends NetworkMessage {
|
||||
}
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY:
|
||||
return EntityMessage.canParseattachEntityToEntityMessage(byteBuffer);
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED:
|
||||
return EntityMessage.canParseSpawnFoliageSeedMessage(byteBuffer);
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR:
|
||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR_SIZE){
|
||||
return true;
|
||||
@ -496,13 +421,38 @@ public class EntityMessage extends NetworkMessage {
|
||||
if(currentStreamLength < 14 + entitySubtypeSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 22 + entitySubtypeSize){
|
||||
int creatureTemplateSize = 0;
|
||||
if(currentStreamLength < 18){
|
||||
return false;
|
||||
} else {
|
||||
temporaryByteQueue.add(byteBuffer.peek(14 + entitySubtypeSize + 0));
|
||||
temporaryByteQueue.add(byteBuffer.peek(14 + entitySubtypeSize + 1));
|
||||
temporaryByteQueue.add(byteBuffer.peek(14 + entitySubtypeSize + 2));
|
||||
temporaryByteQueue.add(byteBuffer.peek(14 + entitySubtypeSize + 3));
|
||||
creatureTemplateSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
||||
}
|
||||
if(currentStreamLength < 18 + entitySubtypeSize + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 30 + entitySubtypeSize){
|
||||
if(currentStreamLength < 26 + entitySubtypeSize + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 38 + entitySubtypeSize){
|
||||
if(currentStreamLength < 34 + entitySubtypeSize + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 42 + entitySubtypeSize + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 50 + entitySubtypeSize + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 58 + entitySubtypeSize + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 66 + entitySubtypeSize + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 74 + entitySubtypeSize + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -514,231 +464,22 @@ public class EntityMessage extends NetworkMessage {
|
||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||
rVal.setentityCategory(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||
rVal.setentitySubtype(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
||||
rVal.setcreatureTemplate(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
||||
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static EntityMessage constructCreateMessage(int entityID,int entityCategory,String entitySubtype,double positionX,double positionY,double positionZ){
|
||||
public static EntityMessage constructCreateMessage(int entityID,int entityCategory,String entitySubtype,String creatureTemplate,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.CREATE);
|
||||
rVal.setentityID(entityID);
|
||||
rVal.setentityCategory(entityCategory);
|
||||
rVal.setentitySubtype(entitySubtype);
|
||||
rVal.setpositionX(positionX);
|
||||
rVal.setpositionY(positionY);
|
||||
rVal.setpositionZ(positionZ);
|
||||
rVal.serialize();
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static boolean canParseSpawnCreatureMessage(CircularByteBuffer byteBuffer){
|
||||
int currentStreamLength = byteBuffer.getRemaining();
|
||||
List<Byte> temporaryByteQueue = new LinkedList<Byte>();
|
||||
if(currentStreamLength < 6){
|
||||
return false;
|
||||
}
|
||||
int creatureTemplateSize = 0;
|
||||
if(currentStreamLength < 10){
|
||||
return false;
|
||||
} else {
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 0));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 1));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 2));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 3));
|
||||
creatureTemplateSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
||||
}
|
||||
if(currentStreamLength < 10 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 18 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 26 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 34 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 42 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 50 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 58 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 66 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static EntityMessage parseSpawnCreatureMessage(CircularByteBuffer byteBuffer){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNCREATURE);
|
||||
stripPacketHeader(byteBuffer);
|
||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||
rVal.setcreatureTemplate(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
||||
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static EntityMessage constructSpawnCreatureMessage(int entityID,String creatureTemplate,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNCREATURE);
|
||||
rVal.setentityID(entityID);
|
||||
rVal.setcreatureTemplate(creatureTemplate);
|
||||
rVal.setpositionX(positionX);
|
||||
rVal.setpositionY(positionY);
|
||||
rVal.setpositionZ(positionZ);
|
||||
rVal.setrotationX(rotationX);
|
||||
rVal.setrotationY(rotationY);
|
||||
rVal.setrotationZ(rotationZ);
|
||||
rVal.setrotationW(rotationW);
|
||||
rVal.serialize();
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static boolean canParseSpawnItemMessage(CircularByteBuffer byteBuffer){
|
||||
int currentStreamLength = byteBuffer.getRemaining();
|
||||
List<Byte> temporaryByteQueue = new LinkedList<Byte>();
|
||||
if(currentStreamLength < 6){
|
||||
return false;
|
||||
}
|
||||
int creatureTemplateSize = 0;
|
||||
if(currentStreamLength < 10){
|
||||
return false;
|
||||
} else {
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 0));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 1));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 2));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 3));
|
||||
creatureTemplateSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
||||
}
|
||||
if(currentStreamLength < 10 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 18 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 26 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 34 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 42 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 50 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 58 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 66 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static EntityMessage parseSpawnItemMessage(CircularByteBuffer byteBuffer){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNITEM);
|
||||
stripPacketHeader(byteBuffer);
|
||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||
rVal.setcreatureTemplate(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
||||
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static EntityMessage constructSpawnItemMessage(int entityID,String creatureTemplate,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNITEM);
|
||||
rVal.setentityID(entityID);
|
||||
rVal.setcreatureTemplate(creatureTemplate);
|
||||
rVal.setpositionX(positionX);
|
||||
rVal.setpositionY(positionY);
|
||||
rVal.setpositionZ(positionZ);
|
||||
rVal.setrotationX(rotationX);
|
||||
rVal.setrotationY(rotationY);
|
||||
rVal.setrotationZ(rotationZ);
|
||||
rVal.setrotationW(rotationW);
|
||||
rVal.serialize();
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static boolean canParseSpawnObjectMessage(CircularByteBuffer byteBuffer){
|
||||
int currentStreamLength = byteBuffer.getRemaining();
|
||||
List<Byte> temporaryByteQueue = new LinkedList<Byte>();
|
||||
if(currentStreamLength < 6){
|
||||
return false;
|
||||
}
|
||||
int creatureTemplateSize = 0;
|
||||
if(currentStreamLength < 10){
|
||||
return false;
|
||||
} else {
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 0));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 1));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 2));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 3));
|
||||
creatureTemplateSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
||||
}
|
||||
if(currentStreamLength < 10 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 18 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 26 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 34 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 42 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 50 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 58 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 66 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static EntityMessage parseSpawnObjectMessage(CircularByteBuffer byteBuffer){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNOBJECT);
|
||||
stripPacketHeader(byteBuffer);
|
||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||
rVal.setcreatureTemplate(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
||||
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static EntityMessage constructSpawnObjectMessage(int entityID,String creatureTemplate,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNOBJECT);
|
||||
rVal.setentityID(entityID);
|
||||
rVal.setcreatureTemplate(creatureTemplate);
|
||||
rVal.setpositionX(positionX);
|
||||
rVal.setpositionY(positionY);
|
||||
@ -924,84 +665,6 @@ public class EntityMessage extends NetworkMessage {
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static boolean canParseSpawnFoliageSeedMessage(CircularByteBuffer byteBuffer){
|
||||
int currentStreamLength = byteBuffer.getRemaining();
|
||||
List<Byte> temporaryByteQueue = new LinkedList<Byte>();
|
||||
if(currentStreamLength < 6){
|
||||
return false;
|
||||
}
|
||||
int creatureTemplateSize = 0;
|
||||
if(currentStreamLength < 10){
|
||||
return false;
|
||||
} else {
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 0));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 1));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 2));
|
||||
temporaryByteQueue.add(byteBuffer.peek(6 + 3));
|
||||
creatureTemplateSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
||||
}
|
||||
if(currentStreamLength < 10 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 18 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 26 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 34 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 42 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 50 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 58 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 66 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 74 + creatureTemplateSize){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static EntityMessage parseSpawnFoliageSeedMessage(CircularByteBuffer byteBuffer){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNFOLIAGESEED);
|
||||
stripPacketHeader(byteBuffer);
|
||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||
rVal.setcreatureTemplate(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
||||
rVal.setfoliageSeed(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
|
||||
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static EntityMessage constructSpawnFoliageSeedMessage(int entityID,String creatureTemplate,long foliageSeed,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNFOLIAGESEED);
|
||||
rVal.setentityID(entityID);
|
||||
rVal.setcreatureTemplate(creatureTemplate);
|
||||
rVal.setfoliageSeed(foliageSeed);
|
||||
rVal.setpositionX(positionX);
|
||||
rVal.setpositionY(positionY);
|
||||
rVal.setpositionZ(positionZ);
|
||||
rVal.setrotationX(rotationX);
|
||||
rVal.setrotationY(rotationY);
|
||||
rVal.setrotationZ(rotationZ);
|
||||
rVal.setrotationW(rotationW);
|
||||
rVal.serialize();
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static EntityMessage parseupdateEntityViewDirMessage(CircularByteBuffer byteBuffer){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.UPDATEENTITYVIEWDIR);
|
||||
stripPacketHeader(byteBuffer);
|
||||
@ -1084,7 +747,7 @@ public class EntityMessage extends NetworkMessage {
|
||||
byte[] stringBytes;
|
||||
switch(this.messageType){
|
||||
case CREATE:
|
||||
rawBytes = new byte[2+4+4+4+entitySubtype.length()+8+8+8];
|
||||
rawBytes = new byte[2+4+4+4+entitySubtype.length()+4+creatureTemplate.length()+8+8+8+8+8+8+8];
|
||||
//message header
|
||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||
//entity messaage header
|
||||
@ -1105,158 +768,41 @@ public class EntityMessage extends NetworkMessage {
|
||||
for(int i = 0; i < entitySubtype.length(); i++){
|
||||
rawBytes[14+i] = stringBytes[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
||||
for(int i = 0; i < 8; i++){
|
||||
intValues = ByteStreamUtils.serializeIntToBytes(creatureTemplate.length());
|
||||
for(int i = 0; i < 4; i++){
|
||||
rawBytes[14+entitySubtype.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[22+entitySubtype.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[30+entitySubtype.length()+i] = intValues[i];
|
||||
}
|
||||
break;
|
||||
case SPAWNCREATURE:
|
||||
rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8+8+8+8+8];
|
||||
//message header
|
||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||
//entity messaage header
|
||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNCREATURE;
|
||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
||||
for(int i = 0; i < 4; i++){
|
||||
rawBytes[2+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeIntToBytes(creatureTemplate.length());
|
||||
for(int i = 0; i < 4; i++){
|
||||
rawBytes[6+i] = intValues[i];
|
||||
}
|
||||
stringBytes = creatureTemplate.getBytes();
|
||||
for(int i = 0; i < creatureTemplate.length(); i++){
|
||||
rawBytes[10+i] = stringBytes[i];
|
||||
rawBytes[18+entitySubtype.length()+i] = stringBytes[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[10+creatureTemplate.length()+i] = intValues[i];
|
||||
rawBytes[18+entitySubtype.length()+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[18+creatureTemplate.length()+i] = intValues[i];
|
||||
rawBytes[26+entitySubtype.length()+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[26+creatureTemplate.length()+i] = intValues[i];
|
||||
rawBytes[34+entitySubtype.length()+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationX);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[34+creatureTemplate.length()+i] = intValues[i];
|
||||
rawBytes[42+entitySubtype.length()+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationY);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[42+creatureTemplate.length()+i] = intValues[i];
|
||||
rawBytes[50+entitySubtype.length()+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationZ);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[50+creatureTemplate.length()+i] = intValues[i];
|
||||
rawBytes[58+entitySubtype.length()+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationW);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[58+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
break;
|
||||
case SPAWNITEM:
|
||||
rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8+8+8+8+8];
|
||||
//message header
|
||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||
//entity messaage header
|
||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNITEM;
|
||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
||||
for(int i = 0; i < 4; i++){
|
||||
rawBytes[2+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeIntToBytes(creatureTemplate.length());
|
||||
for(int i = 0; i < 4; i++){
|
||||
rawBytes[6+i] = intValues[i];
|
||||
}
|
||||
stringBytes = creatureTemplate.getBytes();
|
||||
for(int i = 0; i < creatureTemplate.length(); i++){
|
||||
rawBytes[10+i] = stringBytes[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[10+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[18+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[26+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationX);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[34+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationY);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[42+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationZ);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[50+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationW);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[58+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
break;
|
||||
case SPAWNOBJECT:
|
||||
rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8+8+8+8+8];
|
||||
//message header
|
||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||
//entity messaage header
|
||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNOBJECT;
|
||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
||||
for(int i = 0; i < 4; i++){
|
||||
rawBytes[2+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeIntToBytes(creatureTemplate.length());
|
||||
for(int i = 0; i < 4; i++){
|
||||
rawBytes[6+i] = intValues[i];
|
||||
}
|
||||
stringBytes = creatureTemplate.getBytes();
|
||||
for(int i = 0; i < creatureTemplate.length(); i++){
|
||||
rawBytes[10+i] = stringBytes[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[10+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[18+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[26+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationX);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[34+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationY);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[42+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationZ);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[50+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationW);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[58+creatureTemplate.length()+i] = intValues[i];
|
||||
rawBytes[66+entitySubtype.length()+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
break;
|
||||
case MOVEUPDATE:
|
||||
@ -1440,57 +986,6 @@ public class EntityMessage extends NetworkMessage {
|
||||
rawBytes[10+bone.length()+i] = intValues[i];
|
||||
}
|
||||
break;
|
||||
case SPAWNFOLIAGESEED:
|
||||
rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8+8+8+8+8+8];
|
||||
//message header
|
||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||
//entity messaage header
|
||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED;
|
||||
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
||||
for(int i = 0; i < 4; i++){
|
||||
rawBytes[2+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeIntToBytes(creatureTemplate.length());
|
||||
for(int i = 0; i < 4; i++){
|
||||
rawBytes[6+i] = intValues[i];
|
||||
}
|
||||
stringBytes = creatureTemplate.getBytes();
|
||||
for(int i = 0; i < creatureTemplate.length(); i++){
|
||||
rawBytes[10+i] = stringBytes[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeLongToBytes(foliageSeed);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[10+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[18+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[26+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[34+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationX);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[42+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationY);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[50+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationZ);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[58+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationW);
|
||||
for(int i = 0; i < 8; i++){
|
||||
rawBytes[66+creatureTemplate.length()+i] = intValues[i];
|
||||
}
|
||||
break;
|
||||
case UPDATEENTITYVIEWDIR:
|
||||
rawBytes = new byte[2+4+8+4+8+8];
|
||||
//message header
|
||||
|
||||
@ -47,21 +47,6 @@ COMBAT_MESSAGE,
|
||||
rVal = EntityMessage.parseCreateMessage(byteBuffer);
|
||||
}
|
||||
break;
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNCREATURE:
|
||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||
rVal = EntityMessage.parseSpawnCreatureMessage(byteBuffer);
|
||||
}
|
||||
break;
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNITEM:
|
||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||
rVal = EntityMessage.parseSpawnItemMessage(byteBuffer);
|
||||
}
|
||||
break;
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNOBJECT:
|
||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||
rVal = EntityMessage.parseSpawnObjectMessage(byteBuffer);
|
||||
}
|
||||
break;
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE:
|
||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||
rVal = EntityMessage.parsemoveUpdateMessage(byteBuffer);
|
||||
@ -97,11 +82,6 @@ COMBAT_MESSAGE,
|
||||
rVal = EntityMessage.parseattachEntityToEntityMessage(byteBuffer);
|
||||
}
|
||||
break;
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED:
|
||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||
rVal = EntityMessage.parseSpawnFoliageSeedMessage(byteBuffer);
|
||||
}
|
||||
break;
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR:
|
||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||
rVal = EntityMessage.parseupdateEntityViewDirMessage(byteBuffer);
|
||||
|
||||
@ -19,19 +19,15 @@ Message categories
|
||||
Entity subcategories
|
||||
*/
|
||||
public static final byte ENTITY_MESSAGE_TYPE_CREATE = 0;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SPAWNCREATURE = 1;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SPAWNITEM = 2;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SPAWNOBJECT = 3;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE = 4;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE = 5;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK = 6;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_KILL = 7;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 8;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 9;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 10;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED = 11;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR = 12;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SYNCPHYSICS = 13;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE = 1;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE = 2;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK = 3;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_KILL = 4;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 5;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 6;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 7;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR = 8;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SYNCPHYSICS = 9;
|
||||
/*
|
||||
Entity packet sizes
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user