Part 1 of entitymanager->scene refactor
This commit is contained in:
parent
a895289eb2
commit
5574d9caed
@ -19,7 +19,7 @@ import electrosphere.controls.MouseCallback;
|
|||||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||||
import electrosphere.engine.assetmanager.AssetManager;
|
import electrosphere.engine.assetmanager.AssetManager;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityManager;
|
import electrosphere.entity.Scene;
|
||||||
import electrosphere.entity.types.hitbox.HitboxManager;
|
import electrosphere.entity.types.hitbox.HitboxManager;
|
||||||
import electrosphere.game.client.cells.DrawCellManager;
|
import electrosphere.game.client.cells.DrawCellManager;
|
||||||
import electrosphere.game.client.player.ClientPlayerData;
|
import electrosphere.game.client.player.ClientPlayerData;
|
||||||
@ -229,7 +229,7 @@ public class Globals {
|
|||||||
//Engine - Main managers/variables
|
//Engine - Main managers/variables
|
||||||
//
|
//
|
||||||
//keeps track of all entities in game
|
//keeps track of all entities in game
|
||||||
public static EntityManager entityManager;
|
public static Scene entityManager;
|
||||||
|
|
||||||
//terrain manager
|
//terrain manager
|
||||||
// public static boolean LOAD_TERRAIN = true;
|
// public static boolean LOAD_TERRAIN = true;
|
||||||
@ -336,7 +336,7 @@ public class Globals {
|
|||||||
shaderOptionMap = FileUtils.loadObjectFromAssetPath("Shaders/shaderoptions.json", ShaderOptionMap.class);
|
shaderOptionMap = FileUtils.loadObjectFromAssetPath("Shaders/shaderoptions.json", ShaderOptionMap.class);
|
||||||
shaderOptionMap.debug();
|
shaderOptionMap.debug();
|
||||||
//create entity manager
|
//create entity manager
|
||||||
entityManager = new EntityManager();
|
entityManager = new Scene();
|
||||||
//temporary hold for skybox colors
|
//temporary hold for skybox colors
|
||||||
skyboxColors = new ArrayList<Vector3f>();
|
skyboxColors = new ArrayList<Vector3f>();
|
||||||
//load asset manager
|
//load asset manager
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import electrosphere.auth.AuthenticationManager;
|
|||||||
import electrosphere.controls.ControlHandler;
|
import electrosphere.controls.ControlHandler;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.Scene;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.scene.SceneLoader;
|
import electrosphere.entity.scene.SceneLoader;
|
||||||
import electrosphere.entity.state.movement.ApplyRotationTree;
|
import electrosphere.entity.state.movement.ApplyRotationTree;
|
||||||
@ -43,6 +44,7 @@ import electrosphere.net.client.ClientNetworking;
|
|||||||
import electrosphere.net.server.Server;
|
import electrosphere.net.server.Server;
|
||||||
import electrosphere.net.server.player.Player;
|
import electrosphere.net.server.player.Player;
|
||||||
import electrosphere.renderer.ui.Window;
|
import electrosphere.renderer.ui.Window;
|
||||||
|
import electrosphere.server.ai.creature.adventurer.SeekTown;
|
||||||
import electrosphere.server.datacell.DataCellManager;
|
import electrosphere.server.datacell.DataCellManager;
|
||||||
import electrosphere.server.saves.SaveUtils;
|
import electrosphere.server.saves.SaveUtils;
|
||||||
import electrosphere.server.simulation.MacroSimulation;
|
import electrosphere.server.simulation.MacroSimulation;
|
||||||
@ -264,18 +266,20 @@ public class LoadingThread extends Thread {
|
|||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
||||||
loadingWindow.setVisible(true);
|
loadingWindow.setVisible(true);
|
||||||
|
|
||||||
//
|
|
||||||
//the juicy server GENERATION part
|
|
||||||
//
|
|
||||||
//init save structure
|
|
||||||
SaveUtils.createOrOverwriteSave("random_sp_world");
|
|
||||||
//create terrain
|
|
||||||
Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,0.0f,0);
|
Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,0.0f,0);
|
||||||
Globals.serverTerrainManager.generate();
|
if(!SaveUtils.getSaves().contains("random_sp_world")){
|
||||||
Globals.serverTerrainManager.save(SaveUtils.deriveSaveDirectoryPath("random_sp_world"));
|
//
|
||||||
//create world.json
|
//the juicy server GENERATION part
|
||||||
Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
|
//
|
||||||
FileUtils.serializeObjectToSavePath("random_sp_world", "./world.json", Globals.serverWorldData);
|
//init save structure
|
||||||
|
SaveUtils.createOrOverwriteSave("random_sp_world");
|
||||||
|
//create terrain
|
||||||
|
Globals.serverTerrainManager.generate();
|
||||||
|
Globals.serverTerrainManager.save(SaveUtils.deriveSaveDirectoryPath("random_sp_world"));
|
||||||
|
//create world.json
|
||||||
|
Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
|
||||||
|
FileUtils.serializeObjectToSavePath("random_sp_world", "./world.json", Globals.serverWorldData);
|
||||||
|
}
|
||||||
//load just-created save
|
//load just-created save
|
||||||
SaveUtils.loadSave("random_sp_world");
|
SaveUtils.loadSave("random_sp_world");
|
||||||
//start initializing game datastructures
|
//start initializing game datastructures
|
||||||
@ -313,11 +317,12 @@ public class LoadingThread extends Thread {
|
|||||||
} catch (InterruptedException ex) {}
|
} catch (InterruptedException ex) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
initWorldBaseGraphicalEntities();
|
|
||||||
|
|
||||||
spawnLocalPlayerTestEntity();
|
spawnLocalPlayerTestEntity();
|
||||||
|
|
||||||
|
initWorldBaseGraphicalEntities();
|
||||||
|
|
||||||
|
// SeekTown.attachToCreature(Globals.playerEntity);
|
||||||
|
|
||||||
//hide cursor
|
//hide cursor
|
||||||
Globals.controlHandler.hideMouse();
|
Globals.controlHandler.hideMouse();
|
||||||
@ -430,8 +435,10 @@ public class LoadingThread extends Thread {
|
|||||||
if(Globals.macroSimulation != null){
|
if(Globals.macroSimulation != null){
|
||||||
Town startTown = Globals.macroData.getTowns().get(0);
|
Town startTown = Globals.macroData.getTowns().get(0);
|
||||||
Vector2i firstPos = startTown.getPositions().get(0);
|
Vector2i firstPos = startTown.getPositions().get(0);
|
||||||
double startX = firstPos.x * Globals.serverTerrainManager.getChunkWidth();
|
// double startX = firstPos.x * Globals.serverTerrainManager.getChunkWidth();
|
||||||
double startZ = firstPos.y * Globals.serverTerrainManager.getChunkWidth();
|
// double startZ = firstPos.y * Globals.serverTerrainManager.getChunkWidth();
|
||||||
|
double startX = Globals.commonWorldData.convertWorldToReal(firstPos.x);
|
||||||
|
double startZ = Globals.commonWorldData.convertWorldToReal(firstPos.y);
|
||||||
Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ);
|
Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -622,7 +629,8 @@ public class LoadingThread extends Thread {
|
|||||||
Player Camera
|
Player Camera
|
||||||
|
|
||||||
*/
|
*/
|
||||||
Globals.playerCamera = CameraEntityUtils.spawnPlayerEntityAirplaneTrackingCameraEntity(new Vector3f(1,0,1), new Vector3f(0,0,1));
|
Globals.playerCamera = CameraEntityUtils.spawnPlayerEntityTrackingCameraEntity(new Vector3f(1,0,1), new Vector3f(0,0,1));
|
||||||
|
// Globals.playerCamera = CameraEntityUtils.spawnPlayerEntityAirplaneTrackingCameraEntity(new Vector3f(1,0,1), new Vector3f(0,0,1));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -973,8 +981,10 @@ public class LoadingThread extends Thread {
|
|||||||
Player playerObject = Globals.playerManager.getPlayerFromId(0);
|
Player playerObject = Globals.playerManager.getPlayerFromId(0);
|
||||||
playerObject.setWorldX(Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x));
|
playerObject.setWorldX(Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x));
|
||||||
playerObject.setWorldY(Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z));
|
playerObject.setWorldY(Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z));
|
||||||
|
//set client entity data
|
||||||
|
Globals.clientPlayerData.setWorldPosition(playerObject.getWorldX(), playerObject.getWorldY());
|
||||||
//initially position entity
|
//initially position entity
|
||||||
EntityUtils.initiallyPositionEntity(newPlayerEntity, new Vector3d(Globals.spawnPoint.x,Globals.spawnPoint.y,Globals.spawnPoint.z));
|
EntityUtils.initiallyPositionEntity(newPlayerEntity, new Vector3d(Globals.spawnPoint.x + 1,Globals.spawnPoint.y + 5,Globals.spawnPoint.z + 1));
|
||||||
//add entity to correct cells
|
//add entity to correct cells
|
||||||
Globals.dataCellManager.addPlayerToGroundCells(playerObject);
|
Globals.dataCellManager.addPlayerToGroundCells(playerObject);
|
||||||
Globals.dataCellManager.movePlayerGroundCells(playerObject, Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x), Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z));
|
Globals.dataCellManager.movePlayerGroundCells(playerObject, Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x), Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z));
|
||||||
|
|||||||
20
src/main/java/electrosphere/entity/EntityTags.java
Normal file
20
src/main/java/electrosphere/entity/EntityTags.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package electrosphere.entity;
|
||||||
|
|
||||||
|
public class EntityTags {
|
||||||
|
|
||||||
|
public static final String BONE_ATTACHED = "boneAttached";
|
||||||
|
public static final String COLLIDABLE = "collidable";
|
||||||
|
public static final String SPRINTABLE = "sprintable";
|
||||||
|
public static final String MOVEABLE = "moveable";
|
||||||
|
public static final String ATTACKER = "attacker";
|
||||||
|
public static final String TARGETABLE = "targetable";
|
||||||
|
public static final String LIFE_STATE = "lifeState";
|
||||||
|
public static final String CREATURE = "creature";
|
||||||
|
public static final String UI = "ui";
|
||||||
|
public static final String DRAWABLE = "drawable";
|
||||||
|
public static final String LIGHT = "light";
|
||||||
|
public static final String ITEM = "item";
|
||||||
|
public static final String GRAVITY = "gravity";
|
||||||
|
public static final String PARTICLE = "particle";
|
||||||
|
|
||||||
|
}
|
||||||
@ -52,7 +52,7 @@ public class EntityUtils {
|
|||||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||||
rVal.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
rVal.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
||||||
Globals.entityManager.registerEntity(rVal);
|
Globals.entityManager.registerEntity(rVal);
|
||||||
Globals.entityManager.registerDrawableEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.DRAWABLE);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public class EntityUtils {
|
|||||||
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
rVal.putData(EntityDataStrings.DATA_STRING_DRAW, true);
|
||||||
rVal.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
rVal.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
|
||||||
Globals.entityManager.registerEntity(rVal);
|
Globals.entityManager.registerEntity(rVal);
|
||||||
Globals.entityManager.registerDrawableEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.DRAWABLE);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class EntityUtils {
|
|||||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_UI_ELEMENT, true);
|
rVal.putData(EntityDataStrings.DATA_STRING_UI_ELEMENT, true);
|
||||||
Globals.entityManager.registerEntity(rVal);
|
Globals.entityManager.registerEntity(rVal);
|
||||||
Globals.entityManager.registerUIEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.UI);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,6 +141,12 @@ public class EntityUtils {
|
|||||||
//initialize server datacell tracking of this entity
|
//initialize server datacell tracking of this entity
|
||||||
Globals.dataCellManager.initializeServerSideEntity(entity, newDataCell);
|
Globals.dataCellManager.initializeServerSideEntity(entity, newDataCell);
|
||||||
}
|
}
|
||||||
|
//if the server is also a client, update the drawcell manager to know to pull new chunks
|
||||||
|
if(Globals.RUN_CLIENT){
|
||||||
|
Globals.drawCellManager.invalidateAllCells();
|
||||||
|
Globals.drawCellManager.setCellX(Globals.clientPlayerData.getWorldPositionX());
|
||||||
|
Globals.drawCellManager.setCellY(Globals.clientPlayerData.getWorldPositionY());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//reposition entity
|
//reposition entity
|
||||||
CollisionObjUtils.positionCharacter(entity, position);
|
CollisionObjUtils.positionCharacter(entity, position);
|
||||||
@ -165,6 +171,12 @@ public class EntityUtils {
|
|||||||
ServerDataCell.moveEntityFromCellToCell(entity, oldDataCell, newDataCell);
|
ServerDataCell.moveEntityFromCellToCell(entity, oldDataCell, newDataCell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//if the server is also a client, update the drawcell manager to know to pull new chunks
|
||||||
|
if(Globals.RUN_CLIENT){
|
||||||
|
Globals.drawCellManager.invalidateAllCells();
|
||||||
|
Globals.drawCellManager.setCellX(Globals.clientPlayerData.getWorldPositionX());
|
||||||
|
Globals.drawCellManager.setCellY(Globals.clientPlayerData.getWorldPositionY());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//reposition entity
|
//reposition entity
|
||||||
CollisionObjUtils.positionCharacter(entity, Globals.spawnPoint);
|
CollisionObjUtils.positionCharacter(entity, Globals.spawnPoint);
|
||||||
|
|||||||
@ -5,7 +5,9 @@ import electrosphere.entity.state.BehaviorTree;
|
|||||||
import electrosphere.entity.types.attach.AttachUtils;
|
import electrosphere.entity.types.attach.AttachUtils;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -17,211 +19,79 @@ import org.joml.Vector3f;
|
|||||||
*
|
*
|
||||||
* @author satellite
|
* @author satellite
|
||||||
*/
|
*/
|
||||||
public class EntityManager {
|
public class Scene {
|
||||||
|
|
||||||
|
|
||||||
static Map<Integer,Entity> entityIdMap = new ConcurrentHashMap<Integer,Entity>();
|
Map<Integer,Entity> entityIdMap = new ConcurrentHashMap<Integer,Entity>();
|
||||||
static Map<Integer,Integer> clientToServerIdMap = new ConcurrentHashMap<Integer,Integer>();
|
Map<Integer,Integer> clientToServerIdMap = new ConcurrentHashMap<Integer,Integer>();
|
||||||
static Map<Integer,Integer> serverToClientIdMap = new ConcurrentHashMap<Integer,Integer>();
|
Map<Integer,Integer> serverToClientIdMap = new ConcurrentHashMap<Integer,Integer>();
|
||||||
static List<Entity> entityList = new CopyOnWriteArrayList<Entity>();
|
Map<String,List<Entity>> tagEntityMap = new ConcurrentHashMap<String,List<Entity>>();
|
||||||
static List<Entity> drawableList = new CopyOnWriteArrayList<Entity>();
|
List<Entity> entityList = new CopyOnWriteArrayList<Entity>();
|
||||||
static List<Entity> moveableList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> lightList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> uiList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> itemList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> boneAttachedList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> attackerList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> creatureList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> lifeStateList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> particleList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> gravityList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> collidableList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> targetableList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
static List<Entity> sprintableList = new CopyOnWriteArrayList<Entity>();
|
|
||||||
|
|
||||||
static List<BehaviorTree> behaviorTreeList = new CopyOnWriteArrayList<BehaviorTree>();
|
List<BehaviorTree> behaviorTreeList = new CopyOnWriteArrayList<BehaviorTree>();
|
||||||
|
|
||||||
public EntityManager(){
|
public Scene(){
|
||||||
|
tagEntityMap.put(EntityTags.BONE_ATTACHED, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.COLLIDABLE, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.SPRINTABLE, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.MOVEABLE, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.ATTACKER, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.TARGETABLE, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.LIFE_STATE, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.CREATURE, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.UI, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.DRAWABLE, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.LIGHT, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.ITEM, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.GRAVITY, new LinkedList<Entity>());
|
||||||
|
tagEntityMap.put(EntityTags.PARTICLE, new LinkedList<Entity>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerEntity(Entity e){
|
public void registerEntity(Entity e){
|
||||||
entityIdMap.put(e.getId(), e);
|
entityIdMap.put(e.getId(), e);
|
||||||
entityList.add(e);
|
entityList.add(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerDrawableEntity(Entity e){
|
|
||||||
drawableList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getDrawable(){
|
|
||||||
return drawableList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerMoveableEntity(Entity e){
|
|
||||||
moveableList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getMoveable(){
|
|
||||||
return moveableList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerLightEntity(Entity e){
|
|
||||||
lightList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getLights(){
|
|
||||||
return lightList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerUIEntity(Entity e){
|
|
||||||
uiList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getUIElements(){
|
|
||||||
return uiList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerItemEntity(Entity e){
|
|
||||||
itemList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getItemEntities(){
|
|
||||||
return itemList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerBoneAttachedEntity(Entity e){
|
|
||||||
boneAttachedList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getBoneAttachedEntities(){
|
|
||||||
return boneAttachedList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerAttackerEntity(Entity e){
|
|
||||||
attackerList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getAttackerEntities(){
|
|
||||||
return attackerList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerCreatureEntity(Entity e){
|
|
||||||
creatureList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getCreatureEntities(){
|
|
||||||
return creatureList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerLifeStateEntity(Entity e){
|
|
||||||
lifeStateList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getLifeStateEntities(){
|
|
||||||
return lifeStateList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerParticle(Entity e){
|
|
||||||
particleList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getParticles(){
|
|
||||||
return particleList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerGravityEntity(Entity e){
|
|
||||||
gravityList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getGravityEntities(){
|
|
||||||
return gravityList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerCollidableEntity(Entity e){
|
|
||||||
collidableList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getCollidables(){
|
|
||||||
return collidableList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deregisterCollidableEntity(Entity e){
|
/**
|
||||||
collidableList.remove(e);
|
* Registers an entity to a given tag
|
||||||
}
|
* @param e The entity
|
||||||
|
* @param tag The tag
|
||||||
public void registerTargetableEntity(Entity e){
|
*/
|
||||||
targetableList.add(e);
|
public void registerEntityToTag(Entity e, String tag){
|
||||||
}
|
if(tagEntityMap.containsKey(tag)){
|
||||||
|
tagEntityMap.get(tag).add(e);
|
||||||
public List<Entity> getTargetables(){
|
} else {
|
||||||
return targetableList;
|
List<Entity> newEntityList = new LinkedList<Entity>();
|
||||||
}
|
newEntityList.add(e);
|
||||||
|
tagEntityMap.put(tag,newEntityList);
|
||||||
public void registerSprintableEntity(Entity e){
|
|
||||||
sprintableList.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> getSprintables(){
|
|
||||||
return sprintableList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerBehaviorTree(BehaviorTree tree){
|
|
||||||
behaviorTreeList.add(tree);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeBehaviorTree(BehaviorTree tree){
|
|
||||||
behaviorTreeList.remove(tree);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void simulateBehaviorTrees(){
|
|
||||||
for(BehaviorTree tree : behaviorTreeList){
|
|
||||||
tree.simulate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all entities registered to a tag
|
||||||
|
* @param tag The tag
|
||||||
|
* @return A list of all entities with the tag, or null if no entities have been added to the tag yet
|
||||||
|
*/
|
||||||
|
public List<Entity> getEntitiesWithTag(String tag){
|
||||||
|
return tagEntityMap.get(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an entity from a tag
|
||||||
|
* @param e The entity
|
||||||
|
* @param tag The tag
|
||||||
|
*/
|
||||||
|
public void removeEntityFromTag(Entity e, String tag){
|
||||||
|
tagEntityMap.get(tag).remove(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deregisters an entity from an entity manager
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
public void deregisterEntity(Entity e){
|
public void deregisterEntity(Entity e){
|
||||||
if(lightList.contains(e)){
|
for(String key : tagEntityMap.keySet()){
|
||||||
lightList.remove(e);
|
tagEntityMap.get(key).remove(e);
|
||||||
}
|
|
||||||
if(moveableList.contains(e)){
|
|
||||||
moveableList.remove(e);
|
|
||||||
}
|
|
||||||
if(drawableList.contains(e)){
|
|
||||||
drawableList.remove(e);
|
|
||||||
}
|
|
||||||
if(entityList.contains(e)){
|
|
||||||
entityList.remove(e);
|
|
||||||
}
|
|
||||||
if(uiList.contains(e)){
|
|
||||||
uiList.remove(e);
|
|
||||||
}
|
|
||||||
if(itemList.contains(e)){
|
|
||||||
itemList.remove(e);
|
|
||||||
}
|
|
||||||
if(attackerList.contains(e)){
|
|
||||||
attackerList.remove(e);
|
|
||||||
}
|
|
||||||
if(creatureList.contains(e)){
|
|
||||||
creatureList.remove(e);
|
|
||||||
}
|
|
||||||
if(lifeStateList.contains(e)){
|
|
||||||
lifeStateList.remove(e);
|
|
||||||
}
|
|
||||||
if(particleList.contains(e)){
|
|
||||||
particleList.remove(e);
|
|
||||||
}
|
|
||||||
if(gravityList.contains(e)){
|
|
||||||
gravityList.remove(e);
|
|
||||||
}
|
|
||||||
if(collidableList.contains(e)){
|
|
||||||
collidableList.remove(e);
|
|
||||||
}
|
|
||||||
if(targetableList.contains(e)){
|
|
||||||
targetableList.remove(e);
|
|
||||||
}
|
|
||||||
if(sprintableList.contains(e)){
|
|
||||||
sprintableList.remove(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,13 +217,21 @@ public class EntityManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerBehaviorTree(BehaviorTree tree){
|
||||||
public void setTargetable(Entity target, boolean status){
|
behaviorTreeList.add(tree);
|
||||||
if(status){
|
}
|
||||||
targetableList.add(target);
|
|
||||||
} else {
|
public void deregisterBehaviorTree(BehaviorTree tree){
|
||||||
targetableList.remove(target);
|
behaviorTreeList.remove(tree);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulates all behavior trees stored in the entity manager
|
||||||
|
*/
|
||||||
|
public void simulateBehaviorTrees(float deltaTime){
|
||||||
|
for(BehaviorTree tree : behaviorTreeList){
|
||||||
|
tree.simulate(deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2,6 +2,6 @@ package electrosphere.entity.state;
|
|||||||
|
|
||||||
public interface BehaviorTree {
|
public interface BehaviorTree {
|
||||||
|
|
||||||
public void simulate();
|
public void simulate(float deltaTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,14 @@
|
|||||||
|
package electrosphere.entity.state;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
public @interface BehaviorTreeAnnotation {
|
||||||
|
|
||||||
|
public String name() default "";
|
||||||
|
|
||||||
|
}
|
||||||
@ -17,6 +17,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
@BehaviorTreeAnnotation(name="idle")
|
||||||
public class IdleTree {
|
public class IdleTree {
|
||||||
|
|
||||||
public static enum IdleTreeState {
|
public static enum IdleTreeState {
|
||||||
@ -57,7 +58,7 @@ public class IdleTree {
|
|||||||
state = IdleTreeState.NOT_IDLE;
|
state = IdleTreeState.NOT_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simulate(){
|
public void simulate(float deltaTime){
|
||||||
Actor entityActor = EntityUtils.getActor(parent);
|
Actor entityActor = EntityUtils.getActor(parent);
|
||||||
|
|
||||||
boolean movementTreeIsIdle = movementTreeIsIdle();
|
boolean movementTreeIsIdle = movementTreeIsIdle();
|
||||||
@ -94,6 +95,9 @@ public class IdleTree {
|
|||||||
case SETFACING:
|
case SETFACING:
|
||||||
case SETPOSITION:
|
case SETPOSITION:
|
||||||
case SETPROPERTY:
|
case SETPROPERTY:
|
||||||
|
case SPAWNCREATURE:
|
||||||
|
case SPAWNITEM:
|
||||||
|
case KILL:
|
||||||
//silently ignore
|
//silently ignore
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import org.joml.Vector3f;
|
|||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
*/
|
*/
|
||||||
public class ParticleTree {
|
public class ParticleTree implements BehaviorTree {
|
||||||
Entity parent;
|
Entity parent;
|
||||||
boolean hasLife = true;
|
boolean hasLife = true;
|
||||||
int maxLife;
|
int maxLife;
|
||||||
@ -50,7 +50,7 @@ public class ParticleTree {
|
|||||||
return acceleration;
|
return acceleration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simulate(){
|
public void simulate(float deltaTime){
|
||||||
Vector3d parentPosition = EntityUtils.getPosition(parent);
|
Vector3d parentPosition = EntityUtils.getPosition(parent);
|
||||||
parentPosition.add(new Vector3f(destination).mul(velocity));
|
parentPosition.add(new Vector3f(destination).mul(velocity));
|
||||||
velocity = velocity - acceleration;
|
velocity = velocity - acceleration;
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import org.joml.Quaternionfc;
|
|||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
public class AttackTree {
|
public class AttackTree implements BehaviorTree {
|
||||||
|
|
||||||
public static enum AttackTreeState {
|
public static enum AttackTreeState {
|
||||||
WINDUP,
|
WINDUP,
|
||||||
@ -147,7 +147,8 @@ public class AttackTree {
|
|||||||
state = AttackTreeState.COOLDOWN;
|
state = AttackTreeState.COOLDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simulate(){
|
@Override
|
||||||
|
public void simulate(float deltaTime){
|
||||||
frameCurrent = frameCurrent + Main.deltaFrames;
|
frameCurrent = frameCurrent + Main.deltaFrames;
|
||||||
float velocity = CreatureUtils.getVelocity(parent);
|
float velocity = CreatureUtils.getVelocity(parent);
|
||||||
Actor entityActor = EntityUtils.getActor(parent);
|
Actor entityActor = EntityUtils.getActor(parent);
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public class ShooterTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulate() {
|
public void simulate(float deltaTime) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
switch(state){
|
switch(state){
|
||||||
case ATTACK: {
|
case ATTACK: {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import electrosphere.engine.Globals;
|
|||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.state.BehaviorTree;
|
||||||
import electrosphere.entity.state.gravity.GravityTree;
|
import electrosphere.entity.state.gravity.GravityTree;
|
||||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
@ -26,7 +27,7 @@ import org.joml.Vector4f;
|
|||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
*/
|
*/
|
||||||
public class CollidableTree {
|
public class CollidableTree implements BehaviorTree {
|
||||||
|
|
||||||
Entity parent;
|
Entity parent;
|
||||||
CollisionObject body;
|
CollisionObject body;
|
||||||
@ -53,7 +54,7 @@ public class CollidableTree {
|
|||||||
|
|
||||||
static int incrementer = 0;
|
static int incrementer = 0;
|
||||||
|
|
||||||
public void simulate(){
|
public void simulate(float deltaTime){
|
||||||
Vector3d position = EntityUtils.getPosition(parent);
|
Vector3d position = EntityUtils.getPosition(parent);
|
||||||
Quaternionf rotation = EntityUtils.getRotation(parent);
|
Quaternionf rotation = EntityUtils.getRotation(parent);
|
||||||
Matrix4f inverseInertiaTensor = CollisionObjUtils.getInverseInertiaTensor(parent);
|
Matrix4f inverseInertiaTensor = CollisionObjUtils.getInverseInertiaTensor(parent);
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import electrosphere.dynamics.RigidBody;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.state.gravity.GravityUtils;
|
import electrosphere.entity.state.gravity.GravityUtils;
|
||||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||||
@ -118,7 +119,7 @@ public class EquipState {
|
|||||||
//hide toEquip actor
|
//hide toEquip actor
|
||||||
EntityUtils.setDraw(inWorldItem, false);
|
EntityUtils.setDraw(inWorldItem, false);
|
||||||
//make untargetable
|
//make untargetable
|
||||||
Globals.entityManager.setTargetable(inWorldItem, false);
|
Globals.entityManager.removeEntityFromTag(inWorldItem, EntityTags.TARGETABLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +131,7 @@ public class EquipState {
|
|||||||
CollisionObject rigidBody = (CollisionObject)inWorldItem.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
|
CollisionObject rigidBody = (CollisionObject)inWorldItem.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
|
||||||
Globals.collisionEngine.deregisterPhysicsObject(rigidBody);
|
Globals.collisionEngine.deregisterPhysicsObject(rigidBody);
|
||||||
}
|
}
|
||||||
Globals.entityManager.setTargetable(inWorldItem, false);
|
Globals.entityManager.removeEntityFromTag(inWorldItem, EntityTags.TARGETABLE);
|
||||||
GravityUtils.attemptDeactivateGravity(inWorldItem);
|
GravityUtils.attemptDeactivateGravity(inWorldItem);
|
||||||
}
|
}
|
||||||
//we need to send two packets
|
//we need to send two packets
|
||||||
@ -214,7 +215,7 @@ public class EquipState {
|
|||||||
//hide toEquip actor
|
//hide toEquip actor
|
||||||
EntityUtils.setDraw(toEquip, false);
|
EntityUtils.setDraw(toEquip, false);
|
||||||
//make untargetable
|
//make untargetable
|
||||||
Globals.entityManager.setTargetable(toEquip, false);
|
Globals.entityManager.removeEntityFromTag(toEquip, EntityTags.TARGETABLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,7 +227,7 @@ public class EquipState {
|
|||||||
CollisionObject rigidBody = (CollisionObject)toEquip.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
|
CollisionObject rigidBody = (CollisionObject)toEquip.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
|
||||||
Globals.collisionEngine.deregisterPhysicsObject(rigidBody);
|
Globals.collisionEngine.deregisterPhysicsObject(rigidBody);
|
||||||
}
|
}
|
||||||
Globals.entityManager.setTargetable(toEquip, false);
|
Globals.entityManager.removeEntityFromTag(toEquip, EntityTags.TARGETABLE);
|
||||||
GravityUtils.attemptDeactivateGravity(toEquip);
|
GravityUtils.attemptDeactivateGravity(toEquip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import electrosphere.collision.dispatch.CollisionObject;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.state.BehaviorTree;
|
||||||
import electrosphere.entity.state.collidable.CollidableTree;
|
import electrosphere.entity.state.collidable.CollidableTree;
|
||||||
import electrosphere.entity.state.collidable.Impulse;
|
import electrosphere.entity.state.collidable.Impulse;
|
||||||
import electrosphere.entity.state.movement.FallTree;
|
import electrosphere.entity.state.movement.FallTree;
|
||||||
@ -22,7 +23,7 @@ import electrosphere.net.parser.net.message.EntityMessage;
|
|||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
*/
|
*/
|
||||||
public class GravityTree {
|
public class GravityTree implements BehaviorTree {
|
||||||
|
|
||||||
public static enum GravityTreeState {
|
public static enum GravityTreeState {
|
||||||
ACTIVE,
|
ACTIVE,
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public class InventoryState implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulate() {
|
public void simulate(float deltaTime) {
|
||||||
if(Globals.RUN_SERVER){
|
if(Globals.RUN_SERVER){
|
||||||
for(InventoryMessage message : networkMessageQueue){
|
for(InventoryMessage message : networkMessageQueue){
|
||||||
networkMessageQueue.remove(message);
|
networkMessageQueue.remove(message);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class IronSightTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulate() {
|
public void simulate(float deltaTime) {
|
||||||
switch(state){
|
switch(state){
|
||||||
case ACTIVE:
|
case ACTIVE:
|
||||||
if(!cameraZoomedIn){
|
if(!cameraZoomedIn){
|
||||||
|
|||||||
@ -135,7 +135,7 @@ public class LifeState implements BehaviorTree {
|
|||||||
lifeCurrent = lifeMax;
|
lifeCurrent = lifeMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simulate(){
|
public void simulate(float deltaTime){
|
||||||
for(EntityMessage message : networkMessageQueue){
|
for(EntityMessage message : networkMessageQueue){
|
||||||
networkMessageQueue.remove(message);
|
networkMessageQueue.remove(message);
|
||||||
long updateTime = message.gettime();
|
long updateTime = message.gettime();
|
||||||
|
|||||||
@ -70,7 +70,7 @@ public class AirplaneMovementTree implements BehaviorTree {
|
|||||||
/**
|
/**
|
||||||
* Simulates a step of the behavior tree
|
* Simulates a step of the behavior tree
|
||||||
*/
|
*/
|
||||||
public void simulate(){
|
public void simulate(float deltaTime){
|
||||||
//
|
//
|
||||||
//Get important initial values
|
//Get important initial values
|
||||||
//
|
//
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public class ApplyRotationTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulate(){
|
public void simulate(float deltaTime){
|
||||||
switch(state){
|
switch(state){
|
||||||
case ROTATE:
|
case ROTATE:
|
||||||
EntityUtils.getRotation(parent).mul(rotationToApply).normalize();
|
EntityUtils.getRotation(parent).mul(rotationToApply).normalize();
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public class FallTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulate() {
|
public void simulate(float deltaTime) {
|
||||||
Actor entityActor = EntityUtils.getActor(parent);
|
Actor entityActor = EntityUtils.getActor(parent);
|
||||||
switch(state){
|
switch(state){
|
||||||
case ACTIVE:
|
case ACTIVE:
|
||||||
|
|||||||
@ -153,7 +153,7 @@ public class GroundMovementTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simulate(){
|
public void simulate(float deltaTime){
|
||||||
float velocity = CreatureUtils.getVelocity(parent);
|
float velocity = CreatureUtils.getVelocity(parent);
|
||||||
float acceleration = CreatureUtils.getAcceleration(parent);
|
float acceleration = CreatureUtils.getAcceleration(parent);
|
||||||
float maxNaturalVelocity = sprintTree != null && sprintTree.state == SprintTreeState.SPRINTING ? sprintTree.maxVelocity : CreatureUtils.getMaxNaturalVelocity(parent);
|
float maxNaturalVelocity = sprintTree != null && sprintTree.state == SprintTreeState.SPRINTING ? sprintTree.maxVelocity : CreatureUtils.getMaxNaturalVelocity(parent);
|
||||||
|
|||||||
@ -49,7 +49,7 @@ public class JumpTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulate() {
|
public void simulate(float deltaTime) {
|
||||||
Actor entityActor = EntityUtils.getActor(parent);
|
Actor entityActor = EntityUtils.getActor(parent);
|
||||||
switch(state){
|
switch(state){
|
||||||
case ACTIVE:
|
case ACTIVE:
|
||||||
|
|||||||
@ -40,12 +40,12 @@ public class ProjectileTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulate() {
|
public void simulate(float deltaTime) {
|
||||||
|
|
||||||
lifeCurrent++;
|
lifeCurrent++;
|
||||||
if(lifeCurrent >= maxLife){
|
if(lifeCurrent >= maxLife){
|
||||||
Globals.entityManager.deregisterEntity(parent);
|
Globals.entityManager.deregisterEntity(parent);
|
||||||
Globals.entityManager.removeBehaviorTree(this);
|
Globals.entityManager.deregisterBehaviorTree(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3d positionCurrent = EntityUtils.getPosition(parent);
|
Vector3d positionCurrent = EntityUtils.getPosition(parent);
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
package electrosphere.entity.state.movement;
|
package electrosphere.entity.state.movement;
|
||||||
|
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.state.BehaviorTree;
|
||||||
import electrosphere.entity.state.movement.GroundMovementTree.MovementTreeState;
|
import electrosphere.entity.state.movement.GroundMovementTree.MovementTreeState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
*/
|
*/
|
||||||
public class SprintTree {
|
public class SprintTree implements BehaviorTree {
|
||||||
|
|
||||||
public static enum SprintTreeState {
|
public static enum SprintTreeState {
|
||||||
SPRINTING,
|
SPRINTING,
|
||||||
@ -47,7 +48,8 @@ public class SprintTree {
|
|||||||
state = SprintTreeState.NOT_SPRINTING;
|
state = SprintTreeState.NOT_SPRINTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simulate(){
|
@Override
|
||||||
|
public void simulate(float deltaTime){
|
||||||
switch(state){
|
switch(state){
|
||||||
case SPRINTING:
|
case SPRINTING:
|
||||||
if(groundMovementTree != null && groundMovementTree.getState() != MovementTreeState.IDLE){
|
if(groundMovementTree != null && groundMovementTree.getState() != MovementTreeState.IDLE){
|
||||||
|
|||||||
@ -49,7 +49,7 @@ public class RotatorTree implements BehaviorTree{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simulate(){
|
public void simulate(float deltaTime){
|
||||||
if(entityActor.modelIsLoaded() && this.state == RotatorTreeState.ACTIVE){
|
if(entityActor.modelIsLoaded() && this.state == RotatorTreeState.ACTIVE){
|
||||||
for(RotatorHierarchyNode node : nodes){
|
for(RotatorHierarchyNode node : nodes){
|
||||||
applyRotatorNode(node);
|
applyRotatorNode(node);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package electrosphere.entity.types.attach;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import electrosphere.renderer.Model;
|
import electrosphere.renderer.Model;
|
||||||
@ -24,7 +25,7 @@ public class AttachUtils {
|
|||||||
|
|
||||||
|
|
||||||
public static void attachEntityToEntityAtBone(Entity parent, Entity toAttach, String boneName, Quaternionf rotation){
|
public static void attachEntityToEntityAtBone(Entity parent, Entity toAttach, String boneName, Quaternionf rotation){
|
||||||
Globals.entityManager.registerBoneAttachedEntity(toAttach);
|
Globals.entityManager.registerEntityToTag(toAttach, EntityTags.BONE_ATTACHED);
|
||||||
toAttach.putData(EntityDataStrings.ATTACH_ENTITY_IS_ATTACHED, true);
|
toAttach.putData(EntityDataStrings.ATTACH_ENTITY_IS_ATTACHED, true);
|
||||||
toAttach.putData(EntityDataStrings.ATTACH_PARENT, parent);
|
toAttach.putData(EntityDataStrings.ATTACH_PARENT, parent);
|
||||||
toAttach.putData(EntityDataStrings.ATTACH_TARGET_BONE, boneName);
|
toAttach.putData(EntityDataStrings.ATTACH_TARGET_BONE, boneName);
|
||||||
@ -39,7 +40,7 @@ public class AttachUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateAttachedEntityPositions(){
|
public static void updateAttachedEntityPositions(){
|
||||||
for(Entity currentEntity : Globals.entityManager.getBoneAttachedEntities()){
|
for(Entity currentEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.BONE_ATTACHED)){
|
||||||
Entity parent;
|
Entity parent;
|
||||||
if((parent = (Entity)currentEntity.getData(EntityDataStrings.ATTACH_PARENT))!=null){
|
if((parent = (Entity)currentEntity.getData(EntityDataStrings.ATTACH_PARENT))!=null){
|
||||||
String targetBone;
|
String targetBone;
|
||||||
@ -72,7 +73,7 @@ public class AttachUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void detatchEntityFromEntityAtBone(Entity parent, Entity toAttach){
|
public static void detatchEntityFromEntityAtBone(Entity parent, Entity toAttach){
|
||||||
Globals.entityManager.registerBoneAttachedEntity(toAttach);
|
Globals.entityManager.registerEntityToTag(toAttach, EntityTags.BONE_ATTACHED);
|
||||||
toAttach.removeData(EntityDataStrings.ATTACH_ENTITY_IS_ATTACHED);
|
toAttach.removeData(EntityDataStrings.ATTACH_ENTITY_IS_ATTACHED);
|
||||||
toAttach.removeData(EntityDataStrings.ATTACH_PARENT);
|
toAttach.removeData(EntityDataStrings.ATTACH_PARENT);
|
||||||
toAttach.removeData(EntityDataStrings.ATTACH_TARGET_BONE);
|
toAttach.removeData(EntityDataStrings.ATTACH_TARGET_BONE);
|
||||||
|
|||||||
@ -43,7 +43,7 @@ public class CameraEntityUtils {
|
|||||||
rVal.putData(EntityDataStrings.CAMERA_YAW, 0.0f);
|
rVal.putData(EntityDataStrings.CAMERA_YAW, 0.0f);
|
||||||
BehaviorTree entityTrackingTree = new BehaviorTree() {
|
BehaviorTree entityTrackingTree = new BehaviorTree() {
|
||||||
@Override
|
@Override
|
||||||
public void simulate() {
|
public void simulate(float deltaTime) {
|
||||||
if(toTrack != null){
|
if(toTrack != null){
|
||||||
Vector3d entityPos = EntityUtils.getPosition(toTrack);
|
Vector3d entityPos = EntityUtils.getPosition(toTrack);
|
||||||
CameraEntityUtils.setCameraCenter(rVal, new Vector3f((float)entityPos.x,(float)entityPos.y,(float)entityPos.z).add(getOrbitalCameraRadialOffset(rVal)));
|
CameraEntityUtils.setCameraCenter(rVal, new Vector3f((float)entityPos.x,(float)entityPos.y,(float)entityPos.z).add(getOrbitalCameraRadialOffset(rVal)));
|
||||||
@ -66,7 +66,7 @@ public class CameraEntityUtils {
|
|||||||
rVal.putData(EntityDataStrings.CAMERA_YAW, 0.0f);
|
rVal.putData(EntityDataStrings.CAMERA_YAW, 0.0f);
|
||||||
BehaviorTree entityTrackingTree = new BehaviorTree() {
|
BehaviorTree entityTrackingTree = new BehaviorTree() {
|
||||||
@Override
|
@Override
|
||||||
public void simulate() {
|
public void simulate(float deltaTime) {
|
||||||
if(Globals.playerEntity != null){
|
if(Globals.playerEntity != null){
|
||||||
Vector3d entityPos = EntityUtils.getPosition(Globals.playerEntity);
|
Vector3d entityPos = EntityUtils.getPosition(Globals.playerEntity);
|
||||||
CameraEntityUtils.setCameraCenter(rVal, new Vector3f((float)entityPos.x,(float)entityPos.y,(float)entityPos.z).add(getOrbitalCameraRadialOffset(rVal)));
|
CameraEntityUtils.setCameraCenter(rVal, new Vector3f((float)entityPos.x,(float)entityPos.y,(float)entityPos.z).add(getOrbitalCameraRadialOffset(rVal)));
|
||||||
@ -89,7 +89,7 @@ public class CameraEntityUtils {
|
|||||||
rVal.putData(EntityDataStrings.CAMERA_YAW, 0.0f);
|
rVal.putData(EntityDataStrings.CAMERA_YAW, 0.0f);
|
||||||
BehaviorTree entityTrackingTree = new BehaviorTree() {
|
BehaviorTree entityTrackingTree = new BehaviorTree() {
|
||||||
@Override
|
@Override
|
||||||
public void simulate() {
|
public void simulate(float deltaTime) {
|
||||||
if(Globals.playerEntity != null){
|
if(Globals.playerEntity != null){
|
||||||
Vector3d entityPos = EntityUtils.getPosition(Globals.playerEntity);
|
Vector3d entityPos = EntityUtils.getPosition(Globals.playerEntity);
|
||||||
CameraEntityUtils.setCameraCenter(rVal, new Vector3f((float)entityPos.x,(float)entityPos.y,(float)entityPos.z).add(getOrbitalCameraRadialOffset(rVal)));
|
CameraEntityUtils.setCameraCenter(rVal, new Vector3f((float)entityPos.x,(float)entityPos.y,(float)entityPos.z).add(getOrbitalCameraRadialOffset(rVal)));
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import electrosphere.engine.Globals;
|
|||||||
import electrosphere.engine.Main;
|
import electrosphere.engine.Main;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.state.movement.AirplaneMovementTree;
|
import electrosphere.entity.state.movement.AirplaneMovementTree;
|
||||||
import electrosphere.entity.state.movement.FallTree;
|
import electrosphere.entity.state.movement.FallTree;
|
||||||
@ -121,14 +122,15 @@ public class CreatureUtils {
|
|||||||
Matrix4f inertiaTensor;
|
Matrix4f inertiaTensor;
|
||||||
Vector3f scale;
|
Vector3f scale;
|
||||||
switch(physicsTemplate.getType()){
|
switch(physicsTemplate.getType()){
|
||||||
case "CYLINDER":
|
case "CYLINDER": {
|
||||||
rigidBody = PhysicsUtils.getCylinderObject(new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.getCylinderObject(new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE);
|
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE);
|
||||||
|
CollidableTree tree = new CollidableTree(rVal,collidable,rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate);
|
rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable);
|
||||||
rVal.putData(EntityDataStrings.COLLIDABLE_TREE, new CollidableTree(rVal,collidable,rigidBody));
|
rVal.putData(EntityDataStrings.COLLIDABLE_TREE, tree);
|
||||||
|
|
||||||
scale = new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3());
|
scale = new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3());
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||||
@ -143,16 +145,17 @@ public class CreatureUtils {
|
|||||||
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
||||||
Globals.collisionEngine.registerDynamicPhysicsEntity(rVal);
|
Globals.collisionEngine.registerDynamicPhysicsEntity(rVal);
|
||||||
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
||||||
Globals.entityManager.registerCollidableEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.COLLIDABLE);
|
||||||
break;
|
} break;
|
||||||
case "CUBE":
|
case "CUBE": {
|
||||||
rigidBody = PhysicsUtils.getCubeObject(new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.getCubeObject(new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE);
|
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE);
|
||||||
|
CollidableTree tree = new CollidableTree(rVal,collidable,rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate);
|
rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable);
|
||||||
rVal.putData(EntityDataStrings.COLLIDABLE_TREE, new CollidableTree(rVal,collidable,rigidBody));
|
rVal.putData(EntityDataStrings.COLLIDABLE_TREE, tree);
|
||||||
|
|
||||||
scale = new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3());
|
scale = new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3());
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||||
@ -164,8 +167,8 @@ public class CreatureUtils {
|
|||||||
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
||||||
Globals.collisionEngine.registerDynamicPhysicsEntity(rVal);
|
Globals.collisionEngine.registerDynamicPhysicsEntity(rVal);
|
||||||
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
||||||
Globals.entityManager.registerCollidableEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.COLLIDABLE);
|
||||||
break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -205,7 +208,8 @@ public class CreatureUtils {
|
|||||||
sprintTree.setGroundMovementTree(moveTree);
|
sprintTree.setGroundMovementTree(moveTree);
|
||||||
moveTree.setSprintTree(sprintTree);
|
moveTree.setSprintTree(sprintTree);
|
||||||
rVal.putData(EntityDataStrings.SPRINT_TREE,sprintTree);
|
rVal.putData(EntityDataStrings.SPRINT_TREE,sprintTree);
|
||||||
Globals.entityManager.registerSprintableEntity(rVal);
|
Globals.entityManager.registerBehaviorTree(sprintTree);
|
||||||
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.SPRINTABLE);
|
||||||
}
|
}
|
||||||
//round out end of move system
|
//round out end of move system
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_MOVEMENT_BT, moveTree);
|
rVal.putData(EntityDataStrings.DATA_STRING_MOVEMENT_BT, moveTree);
|
||||||
@ -213,7 +217,8 @@ public class CreatureUtils {
|
|||||||
rVal.putData(EntityDataStrings.DATA_STRING_MAX_NATURAL_VELOCITY, groundMovementSystem.getMaxVelocity());
|
rVal.putData(EntityDataStrings.DATA_STRING_MAX_NATURAL_VELOCITY, groundMovementSystem.getMaxVelocity());
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration());
|
rVal.putData(EntityDataStrings.DATA_STRING_ACCELERATION, groundMovementSystem.getAcceleration());
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f);
|
rVal.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f);
|
||||||
Globals.entityManager.registerMoveableEntity(rVal);
|
Globals.entityManager.registerBehaviorTree(moveTree);
|
||||||
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.MOVEABLE);
|
||||||
break;
|
break;
|
||||||
//
|
//
|
||||||
// Jump
|
// Jump
|
||||||
@ -267,7 +272,8 @@ public class CreatureUtils {
|
|||||||
//register misc stuff
|
//register misc stuff
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_MOVEMENT_BT, airplaneMovementTree);
|
rVal.putData(EntityDataStrings.DATA_STRING_MOVEMENT_BT, airplaneMovementTree);
|
||||||
CreatureUtils.setFacingVector(rVal, new Vector3d(0,0,0));
|
CreatureUtils.setFacingVector(rVal, new Vector3d(0,0,0));
|
||||||
Globals.entityManager.registerMoveableEntity(rVal);
|
Globals.entityManager.registerBehaviorTree(airplaneMovementTree);
|
||||||
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.MOVEABLE);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,7 +290,8 @@ public class CreatureUtils {
|
|||||||
AttackTree attackTree = new AttackTree(rVal);
|
AttackTree attackTree = new AttackTree(rVal);
|
||||||
rVal.putData(EntityDataStrings.ATTACK_TREE, attackTree);
|
rVal.putData(EntityDataStrings.ATTACK_TREE, attackTree);
|
||||||
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
|
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
|
||||||
Globals.entityManager.registerAttackerEntity(rVal);
|
Globals.entityManager.registerBehaviorTree(attackTree);
|
||||||
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.ATTACKER);
|
||||||
//add all attack moves
|
//add all attack moves
|
||||||
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
|
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
|
||||||
for(AttackMove attackMove : rawType.getAttackMoves()){
|
for(AttackMove attackMove : rawType.getAttackMoves()){
|
||||||
@ -312,10 +319,10 @@ public class CreatureUtils {
|
|||||||
// gravityTree.setCollisionObject(collisionObject, collidable);
|
// gravityTree.setCollisionObject(collisionObject, collidable);
|
||||||
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
||||||
rVal.putData(EntityDataStrings.GRAVITY_TREE, gravityTree);
|
rVal.putData(EntityDataStrings.GRAVITY_TREE, gravityTree);
|
||||||
Globals.entityManager.registerGravityEntity(rVal);
|
Globals.entityManager.registerBehaviorTree(gravityTree);
|
||||||
break;
|
break;
|
||||||
case "TARGETABLE":
|
case "TARGETABLE":
|
||||||
Globals.entityManager.registerTargetableEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.TARGETABLE);
|
||||||
break;
|
break;
|
||||||
case "INVENTORY":
|
case "INVENTORY":
|
||||||
rVal.putData(EntityDataStrings.NATURAL_INVENTORY,UnrelationalInventoryState.createUnrelationalInventory(10));
|
rVal.putData(EntityDataStrings.NATURAL_INVENTORY,UnrelationalInventoryState.createUnrelationalInventory(10));
|
||||||
@ -416,10 +423,10 @@ public class CreatureUtils {
|
|||||||
}
|
}
|
||||||
//add health system
|
//add health system
|
||||||
rVal.putData(EntityDataStrings.LIFE_STATE, new LifeState(rVal, rawType.getHealthSystem()));
|
rVal.putData(EntityDataStrings.LIFE_STATE, new LifeState(rVal, rawType.getHealthSystem()));
|
||||||
Globals.entityManager.registerLifeStateEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.LIFE_STATE);
|
||||||
//idle tree & generic stuff all creatures have
|
//idle tree & generic stuff all creatures have
|
||||||
rVal.putData(EntityDataStrings.IDLE_TREE, new IdleTree(rVal));
|
rVal.putData(EntityDataStrings.IDLE_TREE, new IdleTree(rVal));
|
||||||
Globals.entityManager.registerCreatureEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.CREATURE);
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE, true);
|
rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE, true);
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_TYPE, type);
|
rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_TYPE, type);
|
||||||
CreatureUtils.setFacingVector(rVal, new Vector3d(0,0,1));
|
CreatureUtils.setFacingVector(rVal, new Vector3d(0,0,1));
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import electrosphere.collision.dispatch.CollisionObject;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.state.collidable.CollidableTree;
|
import electrosphere.entity.state.collidable.CollidableTree;
|
||||||
import electrosphere.entity.state.gravity.GravityTree;
|
import electrosphere.entity.state.gravity.GravityTree;
|
||||||
@ -90,7 +91,7 @@ public class ItemUtils {
|
|||||||
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
||||||
Globals.collisionEngine.registerDynamicPhysicsEntity(rVal);
|
Globals.collisionEngine.registerDynamicPhysicsEntity(rVal);
|
||||||
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
||||||
Globals.entityManager.registerCollidableEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.COLLIDABLE);
|
||||||
break;
|
break;
|
||||||
case "CUBE":
|
case "CUBE":
|
||||||
rigidBody = PhysicsUtils.getCubeObject(new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.getCubeObject(new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
||||||
@ -111,7 +112,7 @@ public class ItemUtils {
|
|||||||
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
||||||
Globals.collisionEngine.registerDynamicPhysicsEntity(rVal);
|
Globals.collisionEngine.registerDynamicPhysicsEntity(rVal);
|
||||||
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
||||||
Globals.entityManager.registerCollidableEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.COLLIDABLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,10 +128,10 @@ public class ItemUtils {
|
|||||||
// gravityTree.setCollisionObject(collisionObject, collidable);
|
// gravityTree.setCollisionObject(collisionObject, collidable);
|
||||||
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
||||||
rVal.putData(EntityDataStrings.GRAVITY_TREE, gravityTree);
|
rVal.putData(EntityDataStrings.GRAVITY_TREE, gravityTree);
|
||||||
Globals.entityManager.registerGravityEntity(rVal);
|
Globals.entityManager.registerBehaviorTree(gravityTree);
|
||||||
break;
|
break;
|
||||||
case "TARGETABLE":
|
case "TARGETABLE":
|
||||||
Globals.entityManager.registerTargetableEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.TARGETABLE);
|
||||||
break;
|
break;
|
||||||
case "OUTLINE":
|
case "OUTLINE":
|
||||||
rVal.putData(EntityDataStrings.DRAW_OUTLINE, true);
|
rVal.putData(EntityDataStrings.DRAW_OUTLINE, true);
|
||||||
@ -157,7 +158,7 @@ public class ItemUtils {
|
|||||||
rVal.putData(EntityDataStrings.ITEM_TYPE, name);
|
rVal.putData(EntityDataStrings.ITEM_TYPE, name);
|
||||||
// rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(0.005f,0.005f,0.005f));
|
// 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)));
|
// rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaternionf().identity().rotateY((float)(-Math.PI/2)).rotateZ(-(float)(Math.PI/2)));
|
||||||
Globals.entityManager.registerItemEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.ITEM);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import electrosphere.collision.dispatch.CollisionObject;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.state.BehaviorTree;
|
import electrosphere.entity.state.BehaviorTree;
|
||||||
import electrosphere.entity.state.IdleTree;
|
import electrosphere.entity.state.IdleTree;
|
||||||
@ -39,20 +40,20 @@ public class ObjectUtils {
|
|||||||
} break;
|
} break;
|
||||||
case "GENERATE_COLLISION_OBJECT": {
|
case "GENERATE_COLLISION_OBJECT": {
|
||||||
Globals.assetManager.addCollisionMeshToQueue(rawType.getModelPath());
|
Globals.assetManager.addCollisionMeshToQueue(rawType.getModelPath());
|
||||||
Globals.entityManager.registerBehaviorTree(new BehaviorTree() {public void simulate() {
|
Globals.entityManager.registerBehaviorTree(new BehaviorTree() {public void simulate(float deltaTime) {
|
||||||
CollisionObject collisionObject = Globals.assetManager.fetchCollisionObject(rawType.getModelPath());
|
CollisionObject collisionObject = Globals.assetManager.fetchCollisionObject(rawType.getModelPath());
|
||||||
if(collisionObject != null){
|
if(collisionObject != null){
|
||||||
Globals.entityManager.removeBehaviorTree(this);
|
Globals.entityManager.deregisterBehaviorTree(this);
|
||||||
CollisionObjUtils.attachCollisionObjectToEntity(rVal, collisionObject, 0, Collidable.TYPE_OBJECT);
|
CollisionObjUtils.attachCollisionObjectToEntity(rVal, collisionObject, 0, Collidable.TYPE_OBJECT);
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
} break;
|
} break;
|
||||||
case "GENERATE_COLLISION_TERRAIN": {
|
case "GENERATE_COLLISION_TERRAIN": {
|
||||||
Globals.assetManager.addCollisionMeshToQueue(rawType.getModelPath());
|
Globals.assetManager.addCollisionMeshToQueue(rawType.getModelPath());
|
||||||
Globals.entityManager.registerBehaviorTree(new BehaviorTree() {public void simulate() {
|
Globals.entityManager.registerBehaviorTree(new BehaviorTree() {public void simulate(float deltaTime) {
|
||||||
CollisionObject collisionObject = Globals.assetManager.fetchCollisionObject(rawType.getModelPath());
|
CollisionObject collisionObject = Globals.assetManager.fetchCollisionObject(rawType.getModelPath());
|
||||||
if(collisionObject != null){
|
if(collisionObject != null){
|
||||||
Globals.entityManager.removeBehaviorTree(this);
|
Globals.entityManager.deregisterBehaviorTree(this);
|
||||||
CollisionObjUtils.attachCollisionObjectToEntity(rVal, collisionObject, 0, Collidable.TYPE_TERRAIN);
|
CollisionObjUtils.attachCollisionObjectToEntity(rVal, collisionObject, 0, Collidable.TYPE_TERRAIN);
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
@ -68,14 +69,15 @@ public class ObjectUtils {
|
|||||||
Matrix4f inertiaTensor;
|
Matrix4f inertiaTensor;
|
||||||
Vector3f scale;
|
Vector3f scale;
|
||||||
switch(physicsTemplate.getType()){
|
switch(physicsTemplate.getType()){
|
||||||
case "CYLINDER":
|
case "CYLINDER": {
|
||||||
rigidBody = PhysicsUtils.getCylinderObject(new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.getCylinderObject(new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_OBJECT);
|
collidable = new Collidable(rVal, Collidable.TYPE_OBJECT);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate);
|
rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable);
|
||||||
rVal.putData(EntityDataStrings.COLLIDABLE_TREE, new CollidableTree(rVal,collidable,rigidBody, collisionMakeDynamic));
|
CollidableTree tree = new CollidableTree(rVal,collidable,rigidBody, collisionMakeDynamic);
|
||||||
|
rVal.putData(EntityDataStrings.COLLIDABLE_TREE, tree);
|
||||||
|
|
||||||
scale = new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3());
|
scale = new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3());
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||||
@ -88,16 +90,18 @@ public class ObjectUtils {
|
|||||||
rVal.putData(EntityDataStrings.PHYSICS_INVERSE_INERTIA_TENSOR, inertiaTensor.invert());
|
rVal.putData(EntityDataStrings.PHYSICS_INVERSE_INERTIA_TENSOR, inertiaTensor.invert());
|
||||||
|
|
||||||
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
||||||
|
Globals.entityManager.registerBehaviorTree(tree);
|
||||||
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
||||||
break;
|
} break;
|
||||||
case "CUBE":
|
case "CUBE": {
|
||||||
rigidBody = PhysicsUtils.getCubeObject(new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
rigidBody = PhysicsUtils.getCubeObject(new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()));
|
||||||
collidable = new Collidable(rVal, Collidable.TYPE_OBJECT);
|
collidable = new Collidable(rVal, Collidable.TYPE_OBJECT);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_OFFSET, new Vector3f(physicsTemplate.getOffsetX(),physicsTemplate.getOffsetY(),physicsTemplate.getOffsetZ()));
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate);
|
rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate);
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable);
|
rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable);
|
||||||
rVal.putData(EntityDataStrings.COLLIDABLE_TREE, new CollidableTree(rVal,collidable,rigidBody, collisionMakeDynamic));
|
CollidableTree tree = new CollidableTree(rVal,collidable,rigidBody, collisionMakeDynamic);
|
||||||
|
rVal.putData(EntityDataStrings.COLLIDABLE_TREE, tree);
|
||||||
|
|
||||||
scale = new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3());
|
scale = new Vector3f(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3());
|
||||||
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
rVal.putData(EntityDataStrings.PHYSICS_MASS, mass);
|
||||||
@ -107,11 +111,12 @@ public class ObjectUtils {
|
|||||||
rVal.putData(EntityDataStrings.PHYSICS_INVERSE_INERTIA_TENSOR, inertiaTensor.invert());
|
rVal.putData(EntityDataStrings.PHYSICS_INVERSE_INERTIA_TENSOR, inertiaTensor.invert());
|
||||||
|
|
||||||
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
Globals.collisionEngine.registerPhysicsEntity(rVal);
|
||||||
|
Globals.entityManager.registerBehaviorTree(tree);
|
||||||
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
Globals.collisionEngine.registerCollisionObject(rigidBody, collidable);
|
||||||
break;
|
} break;
|
||||||
}
|
}
|
||||||
Globals.collisionEngine.registerDynamicPhysicsEntity(rVal);
|
Globals.collisionEngine.registerDynamicPhysicsEntity(rVal);
|
||||||
Globals.entityManager.registerCollidableEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.COLLIDABLE);
|
||||||
}
|
}
|
||||||
for(String token : rawType.getTokens()){
|
for(String token : rawType.getTokens()){
|
||||||
switch(token){
|
switch(token){
|
||||||
@ -125,10 +130,10 @@ public class ObjectUtils {
|
|||||||
// gravityTree.setCollisionObject(collisionObject, collidable);
|
// gravityTree.setCollisionObject(collisionObject, collidable);
|
||||||
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
rVal.putData(EntityDataStrings.GRAVITY_ENTITY, true);
|
||||||
rVal.putData(EntityDataStrings.GRAVITY_TREE, gravityTree);
|
rVal.putData(EntityDataStrings.GRAVITY_TREE, gravityTree);
|
||||||
Globals.entityManager.registerGravityEntity(rVal);
|
Globals.entityManager.registerBehaviorTree(gravityTree);
|
||||||
break;
|
break;
|
||||||
case "TARGETABLE":
|
case "TARGETABLE":
|
||||||
Globals.entityManager.registerTargetableEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.TARGETABLE);
|
||||||
break;
|
break;
|
||||||
case "INVENTORY":
|
case "INVENTORY":
|
||||||
rVal.putData(EntityDataStrings.NATURAL_INVENTORY,UnrelationalInventoryState.createUnrelationalInventory(10));
|
rVal.putData(EntityDataStrings.NATURAL_INVENTORY,UnrelationalInventoryState.createUnrelationalInventory(10));
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package electrosphere.entity.types.particle;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.state.ParticleTree;
|
import electrosphere.entity.state.ParticleTree;
|
||||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||||
@ -28,7 +29,7 @@ public class ParticleUtils {
|
|||||||
ParticleTree particleTree = new ParticleTree(rVal, maxLife, destination, velocity, acceleration, true);
|
ParticleTree particleTree = new ParticleTree(rVal, maxLife, destination, velocity, acceleration, true);
|
||||||
rVal.putData(EntityDataStrings.PARTICLE_TREE, particleTree);
|
rVal.putData(EntityDataStrings.PARTICLE_TREE, particleTree);
|
||||||
rVal.putData(EntityDataStrings.IS_PARTICLE, true);
|
rVal.putData(EntityDataStrings.IS_PARTICLE, true);
|
||||||
Globals.entityManager.registerParticle(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.PARTICLE);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ public class ParticleUtils {
|
|||||||
ParticleTree particleTree = new ParticleTree(rVal, 10, new Vector3f(0,0,0), 0, 0, false);
|
ParticleTree particleTree = new ParticleTree(rVal, 10, new Vector3f(0,0,0), 0, 0, false);
|
||||||
rVal.putData(EntityDataStrings.PARTICLE_TREE, particleTree);
|
rVal.putData(EntityDataStrings.PARTICLE_TREE, particleTree);
|
||||||
rVal.putData(EntityDataStrings.IS_PARTICLE, true);
|
rVal.putData(EntityDataStrings.IS_PARTICLE, true);
|
||||||
Globals.entityManager.registerParticle(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.PARTICLE);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,8 +44,8 @@ public class DrawCell {
|
|||||||
|
|
||||||
CollisionObject physicsObject;
|
CollisionObject physicsObject;
|
||||||
|
|
||||||
static Texture groundTextureOne = new Texture("/Textures/Ground/tileableSlabstone.png");
|
static Texture groundTextureOne = new Texture("/Textures/Ground/Dirt1.png");
|
||||||
static Texture groundTextureTwo = new Texture("/Textures/Ground/tileableSlabstone.png");
|
static Texture groundTextureTwo = new Texture("/Textures/Ground/Dirt1.png");
|
||||||
static Texture groundTextureThree = new Texture("/Textures/Ground/Dirt1.png");
|
static Texture groundTextureThree = new Texture("/Textures/Ground/Dirt1.png");
|
||||||
static Texture groundTextureFour = new Texture("/Textures/Ground/Dirt1.png");
|
static Texture groundTextureFour = new Texture("/Textures/Ground/Dirt1.png");
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import electrosphere.net.parser.net.message.TerrainMessage;
|
|||||||
import electrosphere.renderer.ShaderProgram;
|
import electrosphere.renderer.ShaderProgram;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.joml.Vector2i;
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
@ -127,6 +129,11 @@ public class DrawCellManager {
|
|||||||
public void setCellY(int y){
|
public void setCellY(int y){
|
||||||
cellY = y;
|
cellY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCell(Vector2i cellPos){
|
||||||
|
cellX = cellPos.x;
|
||||||
|
cellY = cellPos.y;
|
||||||
|
}
|
||||||
|
|
||||||
void updateInvalidCell(){
|
void updateInvalidCell(){
|
||||||
int targetX = 0;
|
int targetX = 0;
|
||||||
@ -170,6 +177,8 @@ public class DrawCellManager {
|
|||||||
drawable[targetX][targetY] = false;
|
drawable[targetX][targetY] = false;
|
||||||
updateable[targetX][targetY] = false;
|
updateable[targetX][targetY] = false;
|
||||||
hasRequested[targetX][targetY] = false;
|
hasRequested[targetX][targetY] = false;
|
||||||
|
hasPhysics[targetX][targetY] = false;
|
||||||
|
needsPhysics[targetX][targetY] = true;
|
||||||
// if(Math.abs(physicsRadius + 1 - targetX) < physicsRadius && Math.abs(physicsRadius + 1 - targetY) < physicsRadius){
|
// if(Math.abs(physicsRadius + 1 - targetX) < physicsRadius && Math.abs(physicsRadius + 1 - targetY) < physicsRadius){
|
||||||
// needsPhysics[targetX][targetY] = true;
|
// needsPhysics[targetX][targetY] = true;
|
||||||
// }
|
// }
|
||||||
@ -185,6 +194,8 @@ public class DrawCellManager {
|
|||||||
drawable[targetX][targetY] = false;
|
drawable[targetX][targetY] = false;
|
||||||
updateable[targetX][targetY] = false;
|
updateable[targetX][targetY] = false;
|
||||||
hasRequested[targetX][targetY] = false;
|
hasRequested[targetX][targetY] = false;
|
||||||
|
hasPhysics[targetX][targetY] = false;
|
||||||
|
needsPhysics[targetX][targetY] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,7 +372,7 @@ public class DrawCellManager {
|
|||||||
// stride = stride + 1;
|
// stride = stride + 1;
|
||||||
// }
|
// }
|
||||||
// if(cells[targetX][targetY + drawRadius] != null){
|
// if(cells[targetX][targetY + drawRadius] != null){
|
||||||
// System.out.println(targetX + " - " + targetY);
|
// System.out.println(targetX + " - " + targetY);
|
||||||
cells[targetX + drawRadius - physicsRadius][targetY + drawRadius - physicsRadius].generatePhysics();
|
cells[targetX + drawRadius - physicsRadius][targetY + drawRadius - physicsRadius].generatePhysics();
|
||||||
// } else {
|
// } else {
|
||||||
// System.out.println("Current cell is null: " + currentCellX + " - " + currentCellY);
|
// System.out.println("Current cell is null: " + currentCellX + " - " + currentCellY);
|
||||||
@ -396,7 +407,9 @@ public class DrawCellManager {
|
|||||||
//retire physics of cells
|
//retire physics of cells
|
||||||
for(int x = 0; x < physicsRadius * 2 + 1; x++){
|
for(int x = 0; x < physicsRadius * 2 + 1; x++){
|
||||||
if(hasPhysics[x][physicsRadius * 2]){
|
if(hasPhysics[x][physicsRadius * 2]){
|
||||||
cells[x + drawRadius - physicsRadius][physicsRadius * 2 + drawRadius - physicsRadius].destroyPhysics();
|
if(cells[x + drawRadius - physicsRadius][physicsRadius * 2 + drawRadius - physicsRadius] != null){
|
||||||
|
cells[x + drawRadius - physicsRadius][physicsRadius * 2 + drawRadius - physicsRadius].destroyPhysics();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//shift physics array
|
//shift physics array
|
||||||
@ -436,7 +449,9 @@ public class DrawCellManager {
|
|||||||
//retire physics of cells
|
//retire physics of cells
|
||||||
for(int x = 0; x < physicsRadius * 2 + 1; x++){
|
for(int x = 0; x < physicsRadius * 2 + 1; x++){
|
||||||
if(hasPhysics[x][physicsRadius * 2]){
|
if(hasPhysics[x][physicsRadius * 2]){
|
||||||
cells[x + drawRadius - physicsRadius][physicsRadius * 2 + drawRadius - physicsRadius].destroyPhysics();
|
if(cells[x + drawRadius - physicsRadius][physicsRadius * 2 + drawRadius - physicsRadius] != null){
|
||||||
|
cells[x + drawRadius - physicsRadius][physicsRadius * 2 + drawRadius - physicsRadius].destroyPhysics();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//shift physics array
|
//shift physics array
|
||||||
@ -476,7 +491,9 @@ public class DrawCellManager {
|
|||||||
//retire physics of cells
|
//retire physics of cells
|
||||||
for(int x = 0; x < physicsRadius * 2 + 1; x++){
|
for(int x = 0; x < physicsRadius * 2 + 1; x++){
|
||||||
if(hasPhysics[x][physicsRadius * 2]){
|
if(hasPhysics[x][physicsRadius * 2]){
|
||||||
cells[x + drawRadius - physicsRadius][physicsRadius * 2 + drawRadius - physicsRadius].destroyPhysics();
|
if(cells[x + drawRadius - physicsRadius][physicsRadius * 2 + drawRadius - physicsRadius] != null){
|
||||||
|
cells[x + drawRadius - physicsRadius][physicsRadius * 2 + drawRadius - physicsRadius].destroyPhysics();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//shift physics array
|
//shift physics array
|
||||||
@ -516,7 +533,9 @@ public class DrawCellManager {
|
|||||||
//retire physics of cells
|
//retire physics of cells
|
||||||
for(int x = 0; x < physicsRadius * 2 + 1; x++){
|
for(int x = 0; x < physicsRadius * 2 + 1; x++){
|
||||||
if(hasPhysics[x][0]){
|
if(hasPhysics[x][0]){
|
||||||
cells[x + drawRadius - physicsRadius][0 + drawRadius - physicsRadius].destroyPhysics();
|
if(cells[x + drawRadius - physicsRadius][0 + drawRadius - physicsRadius] != null){
|
||||||
|
cells[x + drawRadius - physicsRadius][0 + drawRadius - physicsRadius].destroyPhysics();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//shift physics array
|
//shift physics array
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package electrosphere.game.client.targeting.crosshair;
|
|||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ public class Crosshair {
|
|||||||
if(!crosshairActive){
|
if(!crosshairActive){
|
||||||
Entity target = null;
|
Entity target = null;
|
||||||
double dist = 100;
|
double dist = 100;
|
||||||
for(Entity entity : Globals.entityManager.getTargetables()){
|
for(Entity entity : Globals.entityManager.getEntitiesWithTag(EntityTags.TARGETABLE)){
|
||||||
Vector3d entityPos = EntityUtils.getPosition(entity);
|
Vector3d entityPos = EntityUtils.getPosition(entity);
|
||||||
double currentDist = parentPos.distance(entityPos);
|
double currentDist = parentPos.distance(entityPos);
|
||||||
double currentAngleDiff = new Vector3d(entityPos).sub(parentPos).normalize().dot(new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera)));
|
double currentAngleDiff = new Vector3d(entityPos).sub(parentPos).normalize().dot(new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera)));
|
||||||
|
|||||||
@ -80,4 +80,8 @@ public class ClientWorldData {
|
|||||||
return (int)Math.floor(real / dynamicInterpolationRatio);
|
return (int)Math.floor(real / dynamicInterpolationRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float convertChunkToRealSpace(int chunk){
|
||||||
|
return chunk * dynamicInterpolationRatio;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,6 +80,14 @@ public class CommonWorldData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double convertWorldToReal(int world){
|
||||||
|
if(clientWorldData != null){
|
||||||
|
return clientWorldData.convertChunkToRealSpace(world);
|
||||||
|
} else {
|
||||||
|
return serverWorldData.convertChunkToRealSpace(world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getDynamicInterpolationRatio(){
|
public int getDynamicInterpolationRatio(){
|
||||||
if(clientWorldData != null){
|
if(clientWorldData != null){
|
||||||
return clientWorldData.getDynamicInterpolationRatio();
|
return clientWorldData.getDynamicInterpolationRatio();
|
||||||
|
|||||||
@ -307,7 +307,7 @@ public class ServerTerrainManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deformTerrainAtLocationToValue(int worldX, int worldY, int locationX, int locationY, float value){
|
public void deformTerrainAtLocationToValue(int worldX, int worldY, int locationX, int locationY, float value){
|
||||||
// System.out.println("Add modification at " + worldX + "," + worldY + " subloc " + locationX + "," + locationY);
|
System.out.println("Add modification at " + worldX + "," + worldY + " subloc " + locationX + "," + locationY);
|
||||||
TerrainModification modification = new TerrainModification(worldX,worldY,locationX,locationY,value);
|
TerrainModification modification = new TerrainModification(worldX,worldY,locationX,locationY,value);
|
||||||
model.addModification(modification);
|
model.addModification(modification);
|
||||||
String key = getKey(worldX,worldY);
|
String key = getKey(worldX,worldY);
|
||||||
@ -316,6 +316,17 @@ public class ServerTerrainManager {
|
|||||||
chunk.addModification(modification);
|
chunk.addModification(modification);
|
||||||
chunk.heightMap = modification.applyToHeightfield(chunk.heightMap);
|
chunk.heightMap = modification.applyToHeightfield(chunk.heightMap);
|
||||||
}
|
}
|
||||||
|
if(locationX == 0){
|
||||||
|
if(locationY == 0){
|
||||||
|
deformTerrainAtLocationToValue(worldX - 1, worldY - 1, Globals.serverTerrainManager.dynamicInterpolationRatio, Globals.serverTerrainManager.dynamicInterpolationRatio, value);
|
||||||
|
deformTerrainAtLocationToValue(worldX - 1, worldY, Globals.serverTerrainManager.dynamicInterpolationRatio, locationY, value);
|
||||||
|
deformTerrainAtLocationToValue(worldX, worldY - 1, locationX, Globals.serverTerrainManager.dynamicInterpolationRatio, value);
|
||||||
|
} else {
|
||||||
|
deformTerrainAtLocationToValue(worldX - 1, worldY, Globals.serverTerrainManager.dynamicInterpolationRatio, locationY, value);
|
||||||
|
}
|
||||||
|
} else if(locationY == 0){
|
||||||
|
deformTerrainAtLocationToValue(worldX, worldY - 1, locationX, Globals.serverTerrainManager.dynamicInterpolationRatio, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getRandomizerAtPoint(int worldX, int worldY){
|
public long getRandomizerAtPoint(int worldX, int worldY){
|
||||||
|
|||||||
@ -96,6 +96,10 @@ public class ServerWorldData {
|
|||||||
public int convertRealToChunkSpace(double real){
|
public int convertRealToChunkSpace(double real){
|
||||||
return (int)Math.floor(real / dynamicInterpolationRatio);
|
return (int)Math.floor(real / dynamicInterpolationRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float convertChunkToRealSpace(int chunk){
|
||||||
|
return chunk * dynamicInterpolationRatio;
|
||||||
|
}
|
||||||
|
|
||||||
public double getRelativeLocation(double real, int world){
|
public double getRelativeLocation(double real, int world){
|
||||||
return real - (world * dynamicInterpolationRatio);
|
return real - (world * dynamicInterpolationRatio);
|
||||||
|
|||||||
@ -20,14 +20,14 @@ public class LoggerInterface {
|
|||||||
public static Logger loggerDB;
|
public static Logger loggerDB;
|
||||||
|
|
||||||
public static void initLoggers(){
|
public static void initLoggers(){
|
||||||
loggerStartup = new Logger(LogLevel.WARNING);
|
loggerStartup = new Logger(LogLevel.INFO);
|
||||||
loggerNetworking = new Logger(LogLevel.DEBUG);
|
loggerNetworking = new Logger(LogLevel.INFO);
|
||||||
loggerFileIO = new Logger(LogLevel.WARNING);
|
loggerFileIO = new Logger(LogLevel.INFO);
|
||||||
loggerGameLogic = new Logger(LogLevel.WARNING);
|
loggerGameLogic = new Logger(LogLevel.INFO);
|
||||||
loggerRenderer = new Logger(LogLevel.WARNING);
|
loggerRenderer = new Logger(LogLevel.WARNING);
|
||||||
loggerEngine = new Logger(LogLevel.WARNING);
|
loggerEngine = new Logger(LogLevel.INFO);
|
||||||
loggerAuth = new Logger(LogLevel.INFO);
|
loggerAuth = new Logger(LogLevel.INFO);
|
||||||
loggerDB = new Logger(LogLevel.WARNING);
|
loggerDB = new Logger(LogLevel.INFO);
|
||||||
loggerStartup.INFO("Initialized loggers");
|
loggerStartup.INFO("Initialized loggers");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import electrosphere.entity.types.camera.CameraEntityUtils;
|
|||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import electrosphere.game.data.creature.type.CreatureType;
|
import electrosphere.game.data.creature.type.CreatureType;
|
||||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||||
|
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
||||||
import electrosphere.net.NetUtils;
|
import electrosphere.net.NetUtils;
|
||||||
import electrosphere.renderer.Model;
|
import electrosphere.renderer.Model;
|
||||||
import electrosphere.renderer.RenderingEngine;
|
import electrosphere.renderer.RenderingEngine;
|
||||||
@ -46,97 +47,6 @@ import electrosphere.server.saves.SaveUtils;
|
|||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
*/
|
*/
|
||||||
public class MenuGenerators {
|
public class MenuGenerators {
|
||||||
|
|
||||||
|
|
||||||
public static Element createTitleMenu(){
|
|
||||||
FormElement rVal = new FormElement();
|
|
||||||
|
|
||||||
//label (title)
|
|
||||||
Label titleLabel = new Label(100,150,1.0f);
|
|
||||||
titleLabel.setText("ORPG");
|
|
||||||
rVal.addChild(titleLabel);
|
|
||||||
|
|
||||||
//button (multiplayer)
|
|
||||||
Button singleplayerButton = new Button();
|
|
||||||
Label singleplayerLabel = new Label(100,275,1.0f);
|
|
||||||
singleplayerLabel.setText("Singleplayer");
|
|
||||||
singleplayerButton.addChild(singleplayerLabel);
|
|
||||||
rVal.addChild(singleplayerButton);
|
|
||||||
singleplayerButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
|
||||||
Globals.loadingThreadsList.add(clientThread);
|
|
||||||
Globals.RUN_CLIENT = true;
|
|
||||||
Globals.RUN_SERVER = true;
|
|
||||||
clientThread.start();
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
|
|
||||||
//button (multiplayer)
|
|
||||||
Button multiplayerButton = new Button();
|
|
||||||
Label multiplayerLabel = new Label(100,350,1.0f);
|
|
||||||
multiplayerLabel.setText("Multiplayer");
|
|
||||||
multiplayerButton.addChild(multiplayerLabel);
|
|
||||||
rVal.addChild(multiplayerButton);
|
|
||||||
multiplayerButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createMultiplayerMenu());
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
|
|
||||||
//button (arena)
|
|
||||||
Button arenaButton = new Button();
|
|
||||||
Label arenaLabel = new Label(100,425,1.0f);
|
|
||||||
arenaLabel.setText("Arena");
|
|
||||||
arenaButton.addChild(arenaLabel);
|
|
||||||
rVal.addChild(arenaButton);
|
|
||||||
arenaButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
LoadingThread serverThread = new LoadingThread(LoadingThread.LOAD_ARENA);
|
|
||||||
Globals.loadingThreadsList.add(serverThread);
|
|
||||||
Globals.RUN_CLIENT = true;
|
|
||||||
Globals.RUN_SERVER = true;
|
|
||||||
serverThread.start();
|
|
||||||
WindowUtils.replaceMainMenuContents(MenuGeneratorsArena.createArenaHostLoginMenu());
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
|
|
||||||
//button (options)
|
|
||||||
Button optionsButton = new Button();
|
|
||||||
Label optionsLabel = new Label(100,500,1.0f);
|
|
||||||
optionsLabel.setText("Options");
|
|
||||||
optionsButton.addChild(optionsLabel);
|
|
||||||
rVal.addChild(optionsButton);
|
|
||||||
optionsButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createOptionsMainMenu());
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
|
|
||||||
//button (sp debug)
|
|
||||||
Button uiDebugSPQuickstartButton = new Button();
|
|
||||||
Label uiDebugSPQuickstartLabel = new Label(100,575,1.0f);
|
|
||||||
uiDebugSPQuickstartLabel.setText("Debug SP Quickstart");
|
|
||||||
uiDebugSPQuickstartButton.addChild(uiDebugSPQuickstartLabel);
|
|
||||||
rVal.addChild(uiDebugSPQuickstartButton);
|
|
||||||
uiDebugSPQuickstartButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
LoadingThread loadingThread = new LoadingThread(LoadingThread.LOAD_DEBUG_RANDOM_SP_WORLD);
|
|
||||||
Globals.loadingThreadsList.add(loadingThread);
|
|
||||||
Globals.RUN_CLIENT = true;
|
|
||||||
Globals.RUN_SERVER = true;
|
|
||||||
loadingThread.start();
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
|
|
||||||
//button (ui testing)
|
|
||||||
Button uiTestingButton = new Button();
|
|
||||||
Label uiTestingLabel = new Label(100,650,1.0f);
|
|
||||||
uiTestingLabel.setText("UI Testing");
|
|
||||||
uiTestingButton.addChild(uiTestingLabel);
|
|
||||||
rVal.addChild(uiTestingButton);
|
|
||||||
uiTestingButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createUITestMenu());
|
|
||||||
return false;
|
|
||||||
}});
|
|
||||||
|
|
||||||
return rVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Used when we're displaying loading window to make main menu invisible
|
//Used when we're displaying loading window to make main menu invisible
|
||||||
public static Element createEmptyMainMenu(){
|
public static Element createEmptyMainMenu(){
|
||||||
@ -160,14 +70,17 @@ public class MenuGenerators {
|
|||||||
rVal.addChild(selectButton);
|
rVal.addChild(selectButton);
|
||||||
selectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
selectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
if(SaveUtils.worldHasSave(saveName.toLowerCase())){
|
if(SaveUtils.worldHasSave(saveName.toLowerCase())){
|
||||||
|
//need to log client in
|
||||||
|
Globals.clientUsername = "username";
|
||||||
|
Globals.clientPassword = AuthenticationManager.getHashedString("password");
|
||||||
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_CHARACTER_SERVER);
|
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_CHARACTER_SERVER);
|
||||||
Globals.loadingThreadsList.add(clientThread);
|
Globals.loadingThreadsList.add(clientThread);
|
||||||
LoadingThread serverThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
LoadingThread serverThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
||||||
Globals.loadingThreadsList.add(serverThread);
|
Globals.loadingThreadsList.add(serverThread);
|
||||||
Globals.RUN_CLIENT = true;
|
Globals.RUN_CLIENT = true;
|
||||||
Globals.RUN_SERVER = true;
|
Globals.RUN_SERVER = true;
|
||||||
clientThread.start();
|
|
||||||
serverThread.start();
|
serverThread.start();
|
||||||
|
clientThread.start();
|
||||||
} else {
|
} else {
|
||||||
Globals.currentSaveName = saveName.toLowerCase();
|
Globals.currentSaveName = saveName.toLowerCase();
|
||||||
SaveUtils.loadTerrainAndCreateWorldData();
|
SaveUtils.loadTerrainAndCreateWorldData();
|
||||||
@ -201,15 +114,26 @@ public class MenuGenerators {
|
|||||||
int verticalPosition = 125;
|
int verticalPosition = 125;
|
||||||
|
|
||||||
//TODO: add text input to name world
|
//TODO: add text input to name world
|
||||||
|
//text entry (address)
|
||||||
|
TextInput worldNameInput = new TextInput(100,screenTop + 125,1.0f);
|
||||||
|
worldNameInput.setText("World name");
|
||||||
|
rVal.addChild(worldNameInput);
|
||||||
|
|
||||||
//button (create)
|
//button (create)
|
||||||
Button createButton = new Button();
|
Button createButton = new Button();
|
||||||
Label createLabel = new Label(100,screenTop + verticalPosition,1.0f);
|
Label createLabel = new Label(100,screenTop + verticalPosition,1.0f);
|
||||||
createLabel.setText("Not implemented");
|
createLabel.setText("Create");
|
||||||
createButton.addChild(createLabel);
|
createButton.addChild(createLabel);
|
||||||
rVal.addChild(createButton);
|
rVal.addChild(createButton);
|
||||||
createButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
createButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createWorldCreationMenu());
|
String saveName = worldNameInput.getText();
|
||||||
|
//create save dir
|
||||||
|
SaveUtils.createOrOverwriteSave(saveName);
|
||||||
|
//create and save terrain
|
||||||
|
ServerTerrainManager terrainManager = new ServerTerrainManager(2000,50,100,0.0f,0);
|
||||||
|
terrainManager.generate();
|
||||||
|
terrainManager.save(SaveUtils.deriveSaveDirectoryPath(saveName));
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createWorldSelectMenu());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@ -324,7 +248,7 @@ public class MenuGenerators {
|
|||||||
connectButton.addChild(connectLabel);
|
connectButton.addChild(connectLabel);
|
||||||
rVal.addChild(connectButton);
|
rVal.addChild(connectButton);
|
||||||
connectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
connectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createTitleMenu());
|
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@ -424,7 +348,7 @@ public class MenuGenerators {
|
|||||||
backButton.addChild(backLabel);
|
backButton.addChild(backLabel);
|
||||||
rVal.addChild(backButton);
|
rVal.addChild(backButton);
|
||||||
backButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
backButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createTitleMenu());
|
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@ -442,7 +366,7 @@ public class MenuGenerators {
|
|||||||
backButton.addChild(backLabel);
|
backButton.addChild(backLabel);
|
||||||
rVal.addChild(backButton);
|
rVal.addChild(backButton);
|
||||||
backButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
backButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createTitleMenu());
|
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@ -538,7 +462,7 @@ public class MenuGenerators {
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
//checking macro data is a poor man's check for whether we're arena or full gamemode
|
//checking macro data is a poor man's check for whether we're arena or full gamemode
|
||||||
if(Globals.server != null && Globals.macroData == null){
|
// if(Globals.server != null && Globals.macroData == null){
|
||||||
//label 3 (debug)
|
//label 3 (debug)
|
||||||
Button debugButton = new Button();
|
Button debugButton = new Button();
|
||||||
Label debugLabel = new Label(100,250,1.0f);
|
Label debugLabel = new Label(100,250,1.0f);
|
||||||
@ -549,7 +473,7 @@ public class MenuGenerators {
|
|||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameDebugMainMenu());
|
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameDebugMainMenu());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
}
|
// }
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|||||||
103
src/main/java/electrosphere/menu/MenuGeneratorsTitleMenu.java
Normal file
103
src/main/java/electrosphere/menu/MenuGeneratorsTitleMenu.java
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
package electrosphere.menu;
|
||||||
|
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.engine.LoadingThread;
|
||||||
|
import electrosphere.renderer.ui.ClickableElement;
|
||||||
|
import electrosphere.renderer.ui.Element;
|
||||||
|
import electrosphere.renderer.ui.elements.Button;
|
||||||
|
import electrosphere.renderer.ui.elements.Label;
|
||||||
|
import electrosphere.renderer.ui.events.ClickEvent;
|
||||||
|
import electrosphere.renderer.ui.form.FormElement;
|
||||||
|
|
||||||
|
public class MenuGeneratorsTitleMenu {
|
||||||
|
public static Element createTitleMenu(){
|
||||||
|
FormElement rVal = new FormElement();
|
||||||
|
|
||||||
|
//label (title)
|
||||||
|
Label titleLabel = new Label(100,150,1.0f);
|
||||||
|
titleLabel.setText("ORPG");
|
||||||
|
rVal.addChild(titleLabel);
|
||||||
|
|
||||||
|
//button (multiplayer)
|
||||||
|
Button singleplayerButton = new Button();
|
||||||
|
Label singleplayerLabel = new Label(100,275,1.0f);
|
||||||
|
singleplayerLabel.setText("Singleplayer");
|
||||||
|
singleplayerButton.addChild(singleplayerLabel);
|
||||||
|
rVal.addChild(singleplayerButton);
|
||||||
|
singleplayerButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createWorldSelectMenu());
|
||||||
|
// LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
||||||
|
// Globals.loadingThreadsList.add(clientThread);
|
||||||
|
// Globals.RUN_CLIENT = true;
|
||||||
|
// Globals.RUN_SERVER = true;
|
||||||
|
// clientThread.start();
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
//button (multiplayer)
|
||||||
|
Button multiplayerButton = new Button();
|
||||||
|
Label multiplayerLabel = new Label(100,350,1.0f);
|
||||||
|
multiplayerLabel.setText("Multiplayer");
|
||||||
|
multiplayerButton.addChild(multiplayerLabel);
|
||||||
|
rVal.addChild(multiplayerButton);
|
||||||
|
multiplayerButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createMultiplayerMenu());
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
//button (arena)
|
||||||
|
Button arenaButton = new Button();
|
||||||
|
Label arenaLabel = new Label(100,425,1.0f);
|
||||||
|
arenaLabel.setText("Arena");
|
||||||
|
arenaButton.addChild(arenaLabel);
|
||||||
|
rVal.addChild(arenaButton);
|
||||||
|
arenaButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
|
LoadingThread serverThread = new LoadingThread(LoadingThread.LOAD_ARENA);
|
||||||
|
Globals.loadingThreadsList.add(serverThread);
|
||||||
|
Globals.RUN_CLIENT = true;
|
||||||
|
Globals.RUN_SERVER = true;
|
||||||
|
serverThread.start();
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGeneratorsArena.createArenaHostLoginMenu());
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
//button (options)
|
||||||
|
Button optionsButton = new Button();
|
||||||
|
Label optionsLabel = new Label(100,500,1.0f);
|
||||||
|
optionsLabel.setText("Options");
|
||||||
|
optionsButton.addChild(optionsLabel);
|
||||||
|
rVal.addChild(optionsButton);
|
||||||
|
optionsButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createOptionsMainMenu());
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
//button (sp debug)
|
||||||
|
Button uiDebugSPQuickstartButton = new Button();
|
||||||
|
Label uiDebugSPQuickstartLabel = new Label(100,575,1.0f);
|
||||||
|
uiDebugSPQuickstartLabel.setText("Debug SP Quickstart");
|
||||||
|
uiDebugSPQuickstartButton.addChild(uiDebugSPQuickstartLabel);
|
||||||
|
rVal.addChild(uiDebugSPQuickstartButton);
|
||||||
|
uiDebugSPQuickstartButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
|
LoadingThread loadingThread = new LoadingThread(LoadingThread.LOAD_DEBUG_RANDOM_SP_WORLD);
|
||||||
|
Globals.loadingThreadsList.add(loadingThread);
|
||||||
|
Globals.RUN_CLIENT = true;
|
||||||
|
Globals.RUN_SERVER = true;
|
||||||
|
loadingThread.start();
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
//button (ui testing)
|
||||||
|
Button uiTestingButton = new Button();
|
||||||
|
Label uiTestingLabel = new Label(100,650,1.0f);
|
||||||
|
uiTestingLabel.setText("UI Testing");
|
||||||
|
uiTestingButton.addChild(uiTestingLabel);
|
||||||
|
rVal.addChild(uiTestingButton);
|
||||||
|
uiTestingButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createUITestMenu());
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -116,7 +116,7 @@ public class WindowUtils {
|
|||||||
static void initMainMenuWindow(){
|
static void initMainMenuWindow(){
|
||||||
Window mainMenuWindow = new Window(0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
Window mainMenuWindow = new Window(0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||||
Globals.elementManager.registerWindow(WindowStrings.WINDOW_MENU_MAIN, mainMenuWindow);
|
Globals.elementManager.registerWindow(WindowStrings.WINDOW_MENU_MAIN, mainMenuWindow);
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createTitleMenu());
|
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initItemDropWindow(){
|
static void initItemDropWindow(){
|
||||||
|
|||||||
@ -1077,7 +1077,7 @@ public class RenderUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static float MINIMIZATION_DIFF_MAX = 0.1f;
|
static float MINIMIZATION_DIFF_MAX = 0.001f;
|
||||||
|
|
||||||
public static Model createMinimizedTerrainModelPrecomputedShader(float[][] heightfield, float[][] texturemap, ShaderProgram program, int stride){
|
public static Model createMinimizedTerrainModelPrecomputedShader(float[][] heightfield, float[][] texturemap, ShaderProgram program, int stride){
|
||||||
|
|
||||||
@ -1189,7 +1189,7 @@ public class RenderUtils {
|
|||||||
}
|
}
|
||||||
boolean textureMatch = false;
|
boolean textureMatch = false;
|
||||||
float texture = -1;
|
float texture = -1;
|
||||||
if(x+stride < width - 1 && y+stride < height -1 &&
|
if(x+stride < width - 1 && y+stride < height - 1 &&
|
||||||
texturemap[x][y] == texturemap[x+stride][y] &&
|
texturemap[x][y] == texturemap[x+stride][y] &&
|
||||||
texturemap[x][y] == texturemap[x][y+stride] &&
|
texturemap[x][y] == texturemap[x][y+stride] &&
|
||||||
texturemap[x][y] == texturemap[x+stride][y+stride]){
|
texturemap[x][y] == texturemap[x+stride][y+stride]){
|
||||||
@ -1257,9 +1257,13 @@ public class RenderUtils {
|
|||||||
quadCurrent.min = newMax;
|
quadCurrent.min = newMax;
|
||||||
quadCurrent.max = newMax;
|
quadCurrent.max = newMax;
|
||||||
} else {
|
} else {
|
||||||
//push quad
|
//push quad that we were building
|
||||||
firstPhaseQuads.add(quadCurrent);
|
firstPhaseQuads.add(quadCurrent);
|
||||||
quadCurrent = null;
|
// quadCurrent = null;
|
||||||
|
//create new quad from what we were just analyzing
|
||||||
|
boolean textureMatch = false;
|
||||||
|
float texture = -1;
|
||||||
|
quadCurrent = new QuadToGenerate(x,y,x+stride,y+stride,maxVal - minVal,minVal,maxVal,textureMatch,texture);
|
||||||
// System.out.println("Push");
|
// System.out.println("Push");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1286,7 +1290,7 @@ public class RenderUtils {
|
|||||||
if(toSkip.contains(currentQuad)){
|
if(toSkip.contains(currentQuad)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for(QuadToGenerate currentPotentialMatch : firstPhaseQuads){
|
for(QuadToGenerate currentPotentialMatch : firstPhaseQuads){
|
||||||
if(currentPotentialMatch.startX <= currentQuad.startX){
|
if(currentPotentialMatch.startX <= currentQuad.startX){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1332,7 +1336,7 @@ public class RenderUtils {
|
|||||||
}
|
}
|
||||||
toSkip.add(currentPotentialMatch);
|
toSkip.add(currentPotentialMatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finalQuads.add(currentQuad);
|
finalQuads.add(currentQuad);
|
||||||
}
|
}
|
||||||
// for(QuadToGenerate currentIteration : firstPhaseQuads){
|
// for(QuadToGenerate currentIteration : firstPhaseQuads){
|
||||||
|
|||||||
@ -75,6 +75,7 @@ import electrosphere.controls.MouseCallback;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||||
import electrosphere.entity.types.hitbox.HitboxData;
|
import electrosphere.entity.types.hitbox.HitboxData;
|
||||||
@ -549,7 +550,7 @@ public class RenderingEngine {
|
|||||||
//
|
//
|
||||||
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
||||||
modelTransformMatrix = new Matrix4f();
|
modelTransformMatrix = new Matrix4f();
|
||||||
for(Entity currentEntity : Globals.entityManager.getDrawable()){
|
for(Entity currentEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
||||||
@ -614,7 +615,7 @@ public class RenderingEngine {
|
|||||||
//
|
//
|
||||||
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
||||||
modelTransformMatrix = new Matrix4f();
|
modelTransformMatrix = new Matrix4f();
|
||||||
for(Entity currentEntity : Globals.entityManager.getDrawable()){
|
for(Entity currentEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
||||||
@ -653,7 +654,7 @@ public class RenderingEngine {
|
|||||||
glClearBufferfv(GL_COLOR,1,transparencyRevealageClear);
|
glClearBufferfv(GL_COLOR,1,transparencyRevealageClear);
|
||||||
|
|
||||||
|
|
||||||
for(Entity currentEntity : Globals.entityManager.getDrawable()){
|
for(Entity currentEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
||||||
@ -709,7 +710,7 @@ public class RenderingEngine {
|
|||||||
//
|
//
|
||||||
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
||||||
modelTransformMatrix = new Matrix4f();
|
modelTransformMatrix = new Matrix4f();
|
||||||
for(Entity currentEntity : Globals.entityManager.getDrawable()){
|
for(Entity currentEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
||||||
@ -926,7 +927,7 @@ public class RenderingEngine {
|
|||||||
|
|
||||||
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
||||||
modelTransformMatrix = new Matrix4f();
|
modelTransformMatrix = new Matrix4f();
|
||||||
for(Entity currentEntity : Globals.entityManager.getDrawable()){
|
for(Entity currentEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
||||||
@ -1158,7 +1159,7 @@ public class RenderingEngine {
|
|||||||
// D R A W A L L E N T I T I E S
|
// D R A W A L L E N T I T I E S
|
||||||
//
|
//
|
||||||
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
||||||
for(Entity currentEntity : Globals.entityManager.getDrawable()){
|
for(Entity currentEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
||||||
@ -1196,7 +1197,7 @@ public class RenderingEngine {
|
|||||||
//Draw front faces of all non-volumetrics
|
//Draw front faces of all non-volumetrics
|
||||||
//
|
//
|
||||||
cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
||||||
for(Entity currentEntity : Globals.entityManager.getDrawable()){
|
for(Entity currentEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
||||||
@ -1245,7 +1246,7 @@ public class RenderingEngine {
|
|||||||
//
|
//
|
||||||
// D R A W A L L E N T I T I E S
|
// D R A W A L L E N T I T I E S
|
||||||
//
|
//
|
||||||
for(Entity currentEntity : Globals.entityManager.getDrawable()){
|
for(Entity currentEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package electrosphere.renderer.light;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
|
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
@ -16,7 +17,7 @@ public class LightEntityUtils {
|
|||||||
public static Entity createDirectionalLight(Vector3f position, Vector3f ambient, Vector3f diffuse, Vector3f specular){
|
public static Entity createDirectionalLight(Vector3f position, Vector3f ambient, Vector3f diffuse, Vector3f specular){
|
||||||
Entity rVal = new Entity();
|
Entity rVal = new Entity();
|
||||||
Globals.entityManager.registerEntity(rVal);
|
Globals.entityManager.registerEntity(rVal);
|
||||||
Globals.entityManager.registerLightEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.LIGHT);
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_TYPE, EntityDataStrings.DATA_STRING_LIGHT_TYPE_DIRECTIONAL);
|
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_TYPE, EntityDataStrings.DATA_STRING_LIGHT_TYPE_DIRECTIONAL);
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_AMBIENT, ambient);
|
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_AMBIENT, ambient);
|
||||||
@ -28,7 +29,7 @@ public class LightEntityUtils {
|
|||||||
public static Entity createPointLight(Vector3f position, Vector3f ambient, Vector3f diffuse, Vector3f specular, float constant, float linear, float quadratic){
|
public static Entity createPointLight(Vector3f position, Vector3f ambient, Vector3f diffuse, Vector3f specular, float constant, float linear, float quadratic){
|
||||||
Entity rVal = new Entity();
|
Entity rVal = new Entity();
|
||||||
Globals.entityManager.registerEntity(rVal);
|
Globals.entityManager.registerEntity(rVal);
|
||||||
Globals.entityManager.registerLightEntity(rVal);
|
Globals.entityManager.registerEntityToTag(rVal, EntityTags.LIGHT);
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_TYPE, EntityDataStrings.DATA_STRING_LIGHT_TYPE_POINT);
|
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_TYPE, EntityDataStrings.DATA_STRING_LIGHT_TYPE_POINT);
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_AMBIENT, ambient);
|
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_AMBIENT, ambient);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package electrosphere.server.ai.creature;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.state.attack.AttackTree;
|
import electrosphere.entity.state.attack.AttackTree;
|
||||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||||
@ -101,7 +102,7 @@ public class MindlessAttacker extends AI{
|
|||||||
|
|
||||||
void searchForTarget(){
|
void searchForTarget(){
|
||||||
Vector3d position = EntityUtils.getPosition(character);
|
Vector3d position = EntityUtils.getPosition(character);
|
||||||
for(Entity current : Globals.entityManager.getLifeStateEntities()){
|
for(Entity current : Globals.entityManager.getEntitiesWithTag(EntityTags.LIFE_STATE)){
|
||||||
if(current != character){
|
if(current != character){
|
||||||
Vector3d potentialTargetPosition = EntityUtils.getPosition(current);
|
Vector3d potentialTargetPosition = EntityUtils.getPosition(current);
|
||||||
if(position.distance(potentialTargetPosition) < aggroRange){
|
if(position.distance(potentialTargetPosition) < aggroRange){
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package electrosphere.server.ai.creature;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.state.attack.AttackTree;
|
import electrosphere.entity.state.attack.AttackTree;
|
||||||
import electrosphere.entity.state.equip.EquipState;
|
import electrosphere.entity.state.equip.EquipState;
|
||||||
@ -192,7 +193,7 @@ public class OpportunisticAttacker extends AI {
|
|||||||
|
|
||||||
void searchForTarget(){
|
void searchForTarget(){
|
||||||
Vector3d position = EntityUtils.getPosition(character);
|
Vector3d position = EntityUtils.getPosition(character);
|
||||||
for(Entity current : Globals.entityManager.getLifeStateEntities()){
|
for(Entity current : Globals.entityManager.getEntitiesWithTag(EntityTags.LIFE_STATE)){
|
||||||
if(current != character){
|
if(current != character){
|
||||||
Vector3d potentialTargetPosition = EntityUtils.getPosition(current);
|
Vector3d potentialTargetPosition = EntityUtils.getPosition(current);
|
||||||
if(position.distance(potentialTargetPosition) < aggroRange){
|
if(position.distance(potentialTargetPosition) < aggroRange){
|
||||||
@ -219,7 +220,7 @@ public class OpportunisticAttacker extends AI {
|
|||||||
boolean weaponInRange(){
|
boolean weaponInRange(){
|
||||||
boolean rVal = false;
|
boolean rVal = false;
|
||||||
Vector3d position = EntityUtils.getPosition(character);
|
Vector3d position = EntityUtils.getPosition(character);
|
||||||
for(Entity current : Globals.entityManager.getItemEntities()){
|
for(Entity current : Globals.entityManager.getEntitiesWithTag(EntityTags.ITEM)){
|
||||||
if(current != character && ItemUtils.isItem(current) && ItemUtils.isWeapon(current)){
|
if(current != character && ItemUtils.isItem(current) && ItemUtils.isWeapon(current)){
|
||||||
Vector3d potentialTargetPosition = EntityUtils.getPosition(current);
|
Vector3d potentialTargetPosition = EntityUtils.getPosition(current);
|
||||||
if(position.distance(potentialTargetPosition) < weaponSeekRange){
|
if(position.distance(potentialTargetPosition) < weaponSeekRange){
|
||||||
|
|||||||
@ -0,0 +1,58 @@
|
|||||||
|
package electrosphere.server.ai.creature.adventurer;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||||
|
import electrosphere.entity.state.movement.GroundMovementTree.MovementRelativeFacing;
|
||||||
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
|
import electrosphere.game.server.town.Town;
|
||||||
|
import electrosphere.server.ai.AI;
|
||||||
|
|
||||||
|
public class SeekTown extends AI {
|
||||||
|
|
||||||
|
Entity character;
|
||||||
|
|
||||||
|
Town target = null;
|
||||||
|
Vector3d targetPos = null;
|
||||||
|
|
||||||
|
public SeekTown(Entity character){
|
||||||
|
this.character = character;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void attachToCreature(Entity creature){
|
||||||
|
SeekTown ai = new SeekTown(creature);
|
||||||
|
Globals.aiManager.registerAI(ai);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void simulate() {
|
||||||
|
if(target == null){
|
||||||
|
if(Globals.macroData.getTowns().size() > 0){
|
||||||
|
target = Globals.macroData.getTowns().get(0);
|
||||||
|
targetPos = new Vector3d(
|
||||||
|
Globals.commonWorldData.convertWorldToReal(target.getPositions().get(0).x),
|
||||||
|
0,
|
||||||
|
Globals.commonWorldData.convertWorldToReal(target.getPositions().get(0).y)
|
||||||
|
);
|
||||||
|
targetPos.y = Globals.commonWorldData.getElevationAtPoint(targetPos);
|
||||||
|
System.out.println("Target pos: " + targetPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
moveToTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
void moveToTarget(){
|
||||||
|
Vector3d targetPosition = targetPos;
|
||||||
|
Vector3d characterPosition = EntityUtils.getPosition(character);
|
||||||
|
Vector3d moveVector = new Vector3d(targetPosition).sub(characterPosition).normalize();
|
||||||
|
CreatureUtils.setFacingVector(character, new Vector3d((float)moveVector.x,(float)moveVector.y,(float)moveVector.z));
|
||||||
|
GroundMovementTree characterMoveTree = (GroundMovementTree)CreatureUtils.getEntityMovementTree(character);
|
||||||
|
if(characterMoveTree.getState()==GroundMovementTree.MovementTreeState.IDLE || characterMoveTree.getState()==GroundMovementTree.MovementTreeState.SLOWDOWN){
|
||||||
|
characterMoveTree.start(MovementRelativeFacing.FORWARD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
package electrosphere.server.ai.creature.party;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||||
|
import electrosphere.entity.state.movement.GroundMovementTree.MovementRelativeFacing;
|
||||||
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
|
import electrosphere.server.ai.AI;
|
||||||
|
|
||||||
|
public class PartyFollower extends AI {
|
||||||
|
|
||||||
|
Entity character;
|
||||||
|
Entity target;
|
||||||
|
double threshold = 0;
|
||||||
|
|
||||||
|
public PartyFollower(Entity character, Entity target, double threshold){
|
||||||
|
this.character = character;
|
||||||
|
this.target = target;
|
||||||
|
this.threshold = threshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void attachToCreature(Entity creature, Entity target, double threshold){
|
||||||
|
PartyFollower ai = new PartyFollower(creature, target, threshold);
|
||||||
|
Globals.aiManager.registerAI(ai);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void simulate() {
|
||||||
|
if(target == null){
|
||||||
|
Vector3d characterPosition = EntityUtils.getPosition(character);
|
||||||
|
Vector3d targetPosition = EntityUtils.getPosition(target);
|
||||||
|
if(targetPosition.distance(characterPosition) > threshold){
|
||||||
|
moveToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void moveToTarget(){
|
||||||
|
Vector3d targetPosition = EntityUtils.getPosition(target);
|
||||||
|
Vector3d characterPosition = EntityUtils.getPosition(character);
|
||||||
|
Vector3d moveVector = new Vector3d(targetPosition).sub(characterPosition).normalize();
|
||||||
|
CreatureUtils.setFacingVector(character, new Vector3d((float)moveVector.x,(float)moveVector.y,(float)moveVector.z));
|
||||||
|
GroundMovementTree characterMoveTree = (GroundMovementTree)CreatureUtils.getEntityMovementTree(character);
|
||||||
|
if(characterMoveTree.getState()==GroundMovementTree.MovementTreeState.IDLE || characterMoveTree.getState()==GroundMovementTree.MovementTreeState.SLOWDOWN){
|
||||||
|
characterMoveTree.start(MovementRelativeFacing.FORWARD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,7 +19,9 @@ import java.util.List;
|
|||||||
* Container for entities loaded into memory. This isn't intended to be in charge
|
* Container for entities loaded into memory. This isn't intended to be in charge
|
||||||
* of simulation. It just acts as an object to relate players and entities by location.
|
* of simulation. It just acts as an object to relate players and entities by location.
|
||||||
* This SHOULD be used for networking purposes. This is the mechanism to scope
|
* This SHOULD be used for networking purposes. This is the mechanism to scope
|
||||||
* network messages by location.
|
* network messages by location. If you are looking for something closer to a scene from
|
||||||
|
* a traditional game engine, EntityManager is effectively a scene for all intents and
|
||||||
|
* purposes.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ServerDataCell {
|
public class ServerDataCell {
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
package electrosphere.server.entitygroup;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
|
||||||
|
public class EntityGroup {
|
||||||
|
|
||||||
|
List<Entity> members;
|
||||||
|
|
||||||
|
public EntityGroup(){
|
||||||
|
members = new LinkedList<Entity>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMember(Entity newMember){
|
||||||
|
members.add(newMember);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Entity> getMemebers(){
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.region;
|
package electrosphere.server.region;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.region;
|
package electrosphere.server.region;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -5,6 +5,7 @@ import electrosphere.engine.Globals;
|
|||||||
import electrosphere.engine.Main;
|
import electrosphere.engine.Main;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.state.BehaviorTree;
|
import electrosphere.entity.state.BehaviorTree;
|
||||||
import electrosphere.entity.state.IdleTree;
|
import electrosphere.entity.state.IdleTree;
|
||||||
@ -49,7 +50,7 @@ public class MicroSimulation {
|
|||||||
//simulate ai
|
//simulate ai
|
||||||
Globals.aiManager.simulate();
|
Globals.aiManager.simulate();
|
||||||
//update actor animations
|
//update actor animations
|
||||||
for(Entity currentEntity : Globals.entityManager.getDrawable()){
|
for(Entity currentEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//increment animations
|
//increment animations
|
||||||
@ -58,43 +59,43 @@ public class MicroSimulation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//make items play idle animation
|
//make items play idle animation
|
||||||
for(Entity item : Globals.entityManager.getItemEntities()){
|
for(Entity item : Globals.entityManager.getEntitiesWithTag(EntityTags.ITEM)){
|
||||||
ItemUtils.updateItemActorAnimation(item);
|
ItemUtils.updateItemActorAnimation(item);
|
||||||
}
|
}
|
||||||
//simulate creature behavior trees
|
//simulate creature behavior trees
|
||||||
for(Entity currentMoveable : Globals.entityManager.getMoveable()){
|
// for(Entity currentMoveable : Globals.entityManager.getEntitiesWithTag(EntityTags.MOVEABLE)){
|
||||||
BehaviorTree behaviorTree = CreatureUtils.getEntityMovementTree(currentMoveable);
|
// BehaviorTree behaviorTree = CreatureUtils.getEntityMovementTree(currentMoveable);
|
||||||
behaviorTree.simulate();
|
// behaviorTree.simulate(Main.deltaFrames);
|
||||||
}
|
// }
|
||||||
//sprint tree
|
// //sprint tree
|
||||||
for(Entity currentSprint : Globals.entityManager.getSprintables()){
|
// for(Entity currentSprint : Globals.entityManager.getEntitiesWithTag(EntityTags.SPRINTABLE)){
|
||||||
SprintTree sprintTree = CreatureUtils.getSprintTree(currentSprint);
|
// SprintTree sprintTree = CreatureUtils.getSprintTree(currentSprint);
|
||||||
sprintTree.simulate();
|
// sprintTree.simulate(Main.deltaFrames);
|
||||||
}
|
// }
|
||||||
//simulate creature gravity trees
|
// //simulate creature gravity trees
|
||||||
for(Entity currentGravity : Globals.entityManager.getGravityEntities()){
|
// for(Entity currentGravity : Globals.entityManager.getEntitiesWithTag(EntityTags.GRAVITY)){
|
||||||
GravityTree gravityTree = (GravityTree)currentGravity.getData(EntityDataStrings.GRAVITY_TREE);
|
// GravityTree gravityTree = (GravityTree)currentGravity.getData(EntityDataStrings.GRAVITY_TREE);
|
||||||
gravityTree.simulate(Main.deltaFrames);
|
// gravityTree.simulate(Main.deltaFrames);
|
||||||
}
|
// }
|
||||||
//attacker behavior tree
|
// //attacker behavior tree
|
||||||
for(Entity currentAttacker : Globals.entityManager.getAttackerEntities()){
|
// for(Entity currentAttacker : Globals.entityManager.getEntitiesWithTag(EntityTags.ATTACKER)){
|
||||||
AttackTree attackTree = CreatureUtils.getAttackTree(currentAttacker);
|
// AttackTree attackTree = CreatureUtils.getAttackTree(currentAttacker);
|
||||||
attackTree.simulate();
|
// attackTree.simulate(Main.deltaFrames);
|
||||||
}
|
// }
|
||||||
//idle behavior tree
|
// //idle behavior tree
|
||||||
for(Entity currentIdler : Globals.entityManager.getCreatureEntities()){
|
// for(Entity currentIdler : Globals.entityManager.getEntitiesWithTag(EntityTags.CREATURE)){
|
||||||
IdleTree idleTree = CreatureUtils.getIdleTree(currentIdler);
|
// IdleTree idleTree = CreatureUtils.getIdleTree(currentIdler);
|
||||||
idleTree.simulate();
|
// idleTree.simulate(Main.deltaFrames);
|
||||||
}
|
// }
|
||||||
//life state updates
|
// //life state updates
|
||||||
for(Entity lifeStateEntity : Globals.entityManager.getLifeStateEntities()){
|
// for(Entity lifeStateEntity : Globals.entityManager.getEntitiesWithTag(EntityTags.LIFE_STATE)){
|
||||||
LifeState lifeState = LifeUtils.getLifeState(lifeStateEntity);
|
// LifeState lifeState = LifeUtils.getLifeState(lifeStateEntity);
|
||||||
lifeState.simulate();
|
// lifeState.simulate(Main.deltaFrames);
|
||||||
}
|
// }
|
||||||
//particle state updates
|
//particle state updates
|
||||||
for(Entity particle : Globals.entityManager.getParticles()){
|
for(Entity particle : Globals.entityManager.getEntitiesWithTag(EntityTags.PARTICLE)){
|
||||||
ParticleTree tree = ParticleUtils.getParticleTree(particle);
|
// ParticleTree tree = ParticleUtils.getParticleTree(particle);
|
||||||
tree.simulate();
|
// tree.simulate(Main.deltaFrames);
|
||||||
ParticleUtils.makeParticleBillboardFaceCamera(particle);
|
ParticleUtils.makeParticleBillboardFaceCamera(particle);
|
||||||
}
|
}
|
||||||
//update attached entity positions
|
//update attached entity positions
|
||||||
@ -110,23 +111,27 @@ public class MicroSimulation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//tally collidables and offset position accordingly
|
//tally collidables and offset position accordingly
|
||||||
for(Entity currentCollidable : Globals.entityManager.getCollidables()){
|
// for(Entity currentCollidable : Globals.entityManager.getEntitiesWithTag(EntityTags.COLLIDABLE)){
|
||||||
CollidableTree tree = CollidableTree.getCollidableTree(currentCollidable);
|
// CollidableTree tree = CollidableTree.getCollidableTree(currentCollidable);
|
||||||
tree.simulate();
|
// tree.simulate(Main.deltaFrames);
|
||||||
}
|
// }
|
||||||
//targeting crosshair
|
//targeting crosshair
|
||||||
if(Globals.RUN_CLIENT){
|
if(Globals.RUN_CLIENT){
|
||||||
Crosshair.checkTargetable();
|
Crosshair.checkTargetable();
|
||||||
Crosshair.updateTargetCrosshairPosition();
|
Crosshair.updateTargetCrosshairPosition();
|
||||||
}
|
}
|
||||||
|
//simulate behavior trees
|
||||||
|
Globals.entityManager.simulateBehaviorTrees(Main.deltaFrames);
|
||||||
|
//sum collidable impulses
|
||||||
|
for(Entity collidable : Globals.entityManager.getEntitiesWithTag(EntityTags.COLLIDABLE)){
|
||||||
|
CollidableTree.getCollidableTree(collidable).simulate(Main.deltaFrames);
|
||||||
|
}
|
||||||
//clear collidable impulse lists
|
//clear collidable impulse lists
|
||||||
Globals.collisionEngine.clearCollidableImpulseLists();
|
Globals.collisionEngine.clearCollidableImpulseLists();
|
||||||
//delete all client side entities that aren't in visible chunks
|
//delete all client side entities that aren't in visible chunks
|
||||||
if(Globals.RUN_CLIENT){
|
if(Globals.RUN_CLIENT){
|
||||||
Globals.entityManager.clearOutOfBoundsEntities();
|
Globals.entityManager.clearOutOfBoundsEntities();
|
||||||
}
|
}
|
||||||
//simulate behavior trees
|
|
||||||
Globals.entityManager.simulateBehaviorTrees();
|
|
||||||
//data cell manager update
|
//data cell manager update
|
||||||
if(Globals.dataCellManager != null){
|
if(Globals.dataCellManager != null){
|
||||||
boolean playerHasChangedChunk = Globals.dataCellManager.updatePlayerGroundCellPositions();
|
boolean playerHasChangedChunk = Globals.dataCellManager.updatePlayerGroundCellPositions();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user