Can place structures
This commit is contained in:
parent
45e28e5568
commit
1e1117f9e1
@ -3,6 +3,7 @@
|
||||
{
|
||||
"name" : "building1",
|
||||
"modelPath" : "Models/building1.fbx",
|
||||
"radius" : 10,
|
||||
"collision" : [
|
||||
{
|
||||
"type" : "CUBE",
|
||||
|
||||
@ -24,6 +24,7 @@ import electrosphere.game.collision.PhysicsUtils;
|
||||
import electrosphere.game.collision.collidable.Collidable;
|
||||
import electrosphere.game.server.ai.creature.MindlessAttacker;
|
||||
import electrosphere.game.server.terrain.models.TerrainModification;
|
||||
import electrosphere.game.server.town.Town;
|
||||
import electrosphere.game.state.MicroSimulation;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.main.Globals;
|
||||
@ -42,6 +43,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector2i;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
@ -110,6 +112,7 @@ public class LoadingThread extends Thread {
|
||||
//init the data of the world
|
||||
if(Globals.RUN_SERVER){
|
||||
initServerGameWorldData();
|
||||
createServerWorld();
|
||||
}
|
||||
|
||||
//initialize the server thread (server only)
|
||||
@ -331,6 +334,15 @@ public class LoadingThread extends Thread {
|
||||
Globals.serverTerrainManager.getChunk(0, 0).addModification(new TerrainModification(0,0,5,5,5));
|
||||
}
|
||||
|
||||
static void createServerWorld(){
|
||||
Vector2i townLoc = Town.findValidTownLocation();
|
||||
if(townLoc != null){
|
||||
int chunkSize = Globals.serverTerrainManager.getChunkWidth();
|
||||
Globals.spawnPoint = new Vector3f(townLoc.x * chunkSize, Globals.serverTerrainManager.getHeightAtPosition(townLoc.x * chunkSize,townLoc.y * chunkSize), townLoc.y * chunkSize);
|
||||
Town.createTown(townLoc.x,townLoc.y);
|
||||
}
|
||||
}
|
||||
|
||||
static void initServerGameWorldData(){
|
||||
Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||
import electrosphere.game.server.creature.type.AttackMove;
|
||||
import electrosphere.game.config.creature.type.AttackMove;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.renderer.Actor;
|
||||
|
||||
@ -8,16 +8,16 @@ import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.movement.MovementTree;
|
||||
import electrosphere.entity.types.hitbox.HitboxData;
|
||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||
import electrosphere.game.server.creature.type.CreatureType;
|
||||
import electrosphere.game.server.creature.type.MovementSystem;
|
||||
import electrosphere.game.config.creature.type.CreatureType;
|
||||
import electrosphere.game.config.creature.type.MovementSystem;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.GravityTree;
|
||||
import electrosphere.entity.state.IdleTree;
|
||||
import electrosphere.entity.types.life.LifeState;
|
||||
import electrosphere.game.collision.PhysicsUtils;
|
||||
import electrosphere.game.collision.collidable.Collidable;
|
||||
import electrosphere.game.server.creature.type.AttackMove;
|
||||
import electrosphere.game.server.creature.type.PhysicsObject;
|
||||
import electrosphere.game.config.creature.type.AttackMove;
|
||||
import electrosphere.game.config.creature.type.PhysicsObject;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.main.Main;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
@ -54,7 +54,7 @@ public class CreatureUtils {
|
||||
// }
|
||||
|
||||
public static Entity spawnBasicCreature(String type){
|
||||
CreatureType rawType = Globals.creatureMap.getCreature(type);
|
||||
CreatureType rawType = Globals.gameConfigCurrent.getCreatureMap().getCreature(type);
|
||||
Entity rVal = EntityUtils.spawnDrawableEntity(rawType.getModelPath());
|
||||
for(HitboxData hitboxdata : rawType.getHitboxes()){
|
||||
if(hitboxdata.getType().equals("hit")){
|
||||
|
||||
@ -6,8 +6,8 @@ import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.movement.MovementTree;
|
||||
import electrosphere.entity.types.hitbox.HitboxData;
|
||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||
import electrosphere.game.server.creature.type.CreatureType;
|
||||
import electrosphere.game.server.item.type.Item;
|
||||
import electrosphere.game.config.creature.type.CreatureType;
|
||||
import electrosphere.game.config.item.type.Item;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.renderer.Actor;
|
||||
import electrosphere.renderer.ActorUtils;
|
||||
@ -21,7 +21,7 @@ import org.joml.Vector3f;
|
||||
*/
|
||||
public class ItemUtils {
|
||||
public static Entity spawnBasicItem(String name){
|
||||
Item item = Globals.itemMap.getItem(name);
|
||||
Item item = Globals.gameConfigCurrent.getItemMap().getItem(name);
|
||||
Entity rVal = EntityUtils.spawnDrawableEntity(item.getModelPath());
|
||||
for(HitboxData hitboxdata : item.getHitboxes()){
|
||||
Globals.hitboxManager.registerHitbox(HitboxUtils.spawnRegularHitbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius()));
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package electrosphere.entity.types.life;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.game.server.creature.type.HealthSystem;
|
||||
import electrosphere.game.config.creature.type.HealthSystem;
|
||||
|
||||
public class LifeState {
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@ import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.game.collision.collidable.Collidable;
|
||||
import electrosphere.game.server.structure.model.CollisionObjectTemplate;
|
||||
import electrosphere.game.server.structure.model.StructureType;
|
||||
import electrosphere.game.config.structure.type.model.CollisionObjectTemplate;
|
||||
import electrosphere.game.config.structure.type.model.StructureType;
|
||||
import electrosphere.main.Globals;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
@ -21,7 +21,7 @@ public class StructureUtils {
|
||||
|
||||
|
||||
public static Entity spawnBasicStructure(String type, Vector3f position, Quaternionf rotation){
|
||||
StructureType rawType = Globals.structureTypeMap.getType(type);
|
||||
StructureType rawType = Globals.gameConfigCurrent.getStructureTypeMap().getType(type);
|
||||
Entity rVal = EntityUtils.spawnDrawableEntity(rawType.getModelPath());
|
||||
EntityUtils.getPosition(rVal).set(position);
|
||||
EntityUtils.getRotation(rVal).set(rotation);
|
||||
|
||||
@ -37,6 +37,7 @@ public class LoadingChunk {
|
||||
}
|
||||
|
||||
public void addModification(int worldX, int worldY, int locationX, int locationY, float value){
|
||||
// System.out.println("Client add modification");
|
||||
ChunkModification newModification = new ChunkModification(worldX, worldY, locationX, locationY, value);
|
||||
modification.add(newModification);
|
||||
}
|
||||
@ -58,7 +59,8 @@ public class LoadingChunk {
|
||||
);
|
||||
if(modification != null){
|
||||
for(ChunkModification modification : modification){
|
||||
modification.applyModification(heightmap);
|
||||
// System.out.println("Apply modification");
|
||||
heightmap = modification.applyModification(heightmap);
|
||||
}
|
||||
}
|
||||
return heightmap;
|
||||
|
||||
38
src/main/java/electrosphere/game/config/Config.java
Normal file
38
src/main/java/electrosphere/game/config/Config.java
Normal file
@ -0,0 +1,38 @@
|
||||
package electrosphere.game.config;
|
||||
|
||||
import electrosphere.game.config.creature.type.model.CreatureTypeMap;
|
||||
import electrosphere.game.config.item.type.model.ItemTypeMap;
|
||||
import electrosphere.game.config.structure.type.model.StructureTypeMap;
|
||||
import electrosphere.util.FileLoadingUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Config {
|
||||
|
||||
CreatureTypeMap creatureMap;
|
||||
StructureTypeMap structureTypeMap;
|
||||
ItemTypeMap itemMap;
|
||||
|
||||
public static Config loadDefaultConfig(){
|
||||
Config config = new Config();
|
||||
config.creatureMap = FileLoadingUtils.loadObjectFromAssetPath("Data/creatures.json", CreatureTypeMap.class);
|
||||
config.itemMap = FileLoadingUtils.loadObjectFromAssetPath("Data/items.json", ItemTypeMap.class);
|
||||
config.structureTypeMap = FileLoadingUtils.loadObjectFromAssetPath("Data/structures.json", StructureTypeMap.class);
|
||||
return config;
|
||||
}
|
||||
|
||||
public CreatureTypeMap getCreatureMap() {
|
||||
return creatureMap;
|
||||
}
|
||||
|
||||
public StructureTypeMap getStructureTypeMap() {
|
||||
return structureTypeMap;
|
||||
}
|
||||
|
||||
public ItemTypeMap getItemMap() {
|
||||
return itemMap;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.server.creature.type;
|
||||
package electrosphere.game.config.creature.type;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.server.creature.type;
|
||||
package electrosphere.game.config.creature.type;
|
||||
|
||||
public class BodyPart {
|
||||
int bodyPartClass;
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.server.creature.type;
|
||||
package electrosphere.game.config.creature.type;
|
||||
|
||||
import electrosphere.entity.types.hitbox.HitboxData;
|
||||
import java.util.List;
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.server.creature.type;
|
||||
package electrosphere.game.config.creature.type;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.server.creature.type;
|
||||
package electrosphere.game.config.creature.type;
|
||||
|
||||
public class MovementSystem {
|
||||
String type;
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.server.creature.type;
|
||||
package electrosphere.game.config.creature.type;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -1,6 +1,6 @@
|
||||
package electrosphere.game.server.creature.type.model;
|
||||
package electrosphere.game.config.creature.type.model;
|
||||
|
||||
import electrosphere.game.server.creature.type.CreatureType;
|
||||
import electrosphere.game.config.creature.type.CreatureType;
|
||||
import java.util.List;
|
||||
|
||||
public class CreatureTypeMap {
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.server.item.type;
|
||||
package electrosphere.game.config.item.type;
|
||||
|
||||
import electrosphere.entity.types.hitbox.HitboxData;
|
||||
import java.util.List;
|
||||
@ -1,6 +1,6 @@
|
||||
package electrosphere.game.server.item.type.model;
|
||||
package electrosphere.game.config.item.type.model;
|
||||
|
||||
import electrosphere.game.server.item.type.Item;
|
||||
import electrosphere.game.config.item.type.Item;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemTypeMap {
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.server.structure.model;
|
||||
package electrosphere.game.config.structure.type.model;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.server.structure.model;
|
||||
package electrosphere.game.config.structure.type.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -10,6 +10,7 @@ public class StructureType {
|
||||
|
||||
String modelPath;
|
||||
String name;
|
||||
float radius;
|
||||
|
||||
List<CollisionObjectTemplate> collision;
|
||||
|
||||
@ -24,6 +25,10 @@ public class StructureType {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public float getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.game.server.structure.model;
|
||||
package electrosphere.game.config.structure.type.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -2,7 +2,7 @@ package electrosphere.game.server.character;
|
||||
|
||||
import electrosphere.game.server.culture.Culture;
|
||||
import electrosphere.game.server.character.Character;
|
||||
import electrosphere.game.server.creature.type.CreatureType;
|
||||
import electrosphere.game.config.creature.type.CreatureType;
|
||||
|
||||
public class CharacterGenerator {
|
||||
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package electrosphere.game.server.structure.virtual;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Structure {
|
||||
float locationX;
|
||||
float locationY;
|
||||
String type;
|
||||
|
||||
public Structure(float locationX, float locationY, String type) {
|
||||
this.locationX = locationX;
|
||||
this.locationY = locationY;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public float getLocationX() {
|
||||
return locationX;
|
||||
}
|
||||
|
||||
public float getLocationY() {
|
||||
return locationY;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package electrosphere.game.server.structure.virtual;
|
||||
|
||||
import electrosphere.entity.types.structure.StructureUtils;
|
||||
import electrosphere.game.config.structure.type.model.StructureType;
|
||||
import electrosphere.main.Globals;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class StructurePlacer {
|
||||
|
||||
|
||||
public static Structure placeStructureAtPoint(float posX, float posY, String type){
|
||||
Structure rVal = new Structure(posX,posY,type);
|
||||
|
||||
float centerHeight = Globals.serverTerrainManager.getHeightAtPosition(posX, posY);
|
||||
StructureType currentTypeObject = Globals.gameConfigCurrent.getStructureTypeMap().getType(type);
|
||||
float radius = currentTypeObject.getRadius();
|
||||
for(int x = -(int)radius; x < radius; x++){
|
||||
for(int y = -(int)radius; y < radius; y++){
|
||||
int newWorldX = Globals.serverWorldData.convertRealToChunkSpace(posX + x);
|
||||
int newWorldY = Globals.serverWorldData.convertRealToChunkSpace(posY + y);
|
||||
float newLocationX = Globals.serverWorldData.getRelativeLocation(posX + x, newWorldX);
|
||||
float newLocationY = Globals.serverWorldData.getRelativeLocation(posY + y, newWorldY);
|
||||
// System.out.println("Set height: " + centerHeight);
|
||||
// System.out.println("Deform in chunk: " + newWorldX + "," + newWorldY);
|
||||
Globals.serverTerrainManager.deformTerrainAtLocationToValue(newWorldX, newWorldY, (int)(newLocationX), (int)(newLocationY), centerHeight);
|
||||
}
|
||||
}
|
||||
StructureUtils.spawnBasicStructure(type, new Vector3f(posX,centerHeight + 2.4f,posY), new Quaternionf());
|
||||
return rVal;
|
||||
}
|
||||
}
|
||||
@ -275,7 +275,7 @@ public class ServerTerrainManager {
|
||||
ModificationList modificationList = model.getModifications(x, y);
|
||||
if(modificationList != null){
|
||||
for(TerrainModification modification : modificationList.getModifications()){
|
||||
modification.applyToHeightfield(heightmap);
|
||||
heightmap = modification.applyToHeightfield(heightmap);
|
||||
}
|
||||
}
|
||||
if(elevationMapCacheContents.size() > cacheSize){
|
||||
@ -306,7 +306,15 @@ public class ServerTerrainManager {
|
||||
}
|
||||
|
||||
public void deformTerrainAtLocationToValue(int worldX, int worldY, int locationX, int locationY, float value){
|
||||
|
||||
// System.out.println("Add modification at " + worldX + "," + worldY + " subloc " + locationX + "," + locationY);
|
||||
TerrainModification modification = new TerrainModification(worldX,worldY,locationX,locationY,value);
|
||||
model.addModification(modification);
|
||||
String key = getKey(worldX,worldY);
|
||||
if(elevationMapCache.containsKey(key)){
|
||||
ServerTerrainChunk chunk = elevationMapCache.get(key);
|
||||
chunk.addModification(modification);
|
||||
chunk.heightMap = modification.applyToHeightfield(chunk.heightMap);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ public class TerrainModel {
|
||||
float[][] rVal = new float[5][5];
|
||||
for(int i = -2; i < 3; i++){
|
||||
for(int j = -2; j < 3; j++){
|
||||
if(x + i >= 0 && x + i < discreteArrayDimension){
|
||||
if(x + i >= 0 && x + i < discreteArrayDimension && y + j >= 0 && y + j < discreteArrayDimension){
|
||||
rVal[i+2][j+2] = elevation[x+i][y+j];
|
||||
} else {
|
||||
rVal[i+2][j+2] = 0;
|
||||
@ -343,7 +343,7 @@ public class TerrainModel {
|
||||
long[][] rVal = new long[5][5];
|
||||
for(int i = -2; i < 3; i++){
|
||||
for(int j = -2; j < 3; j++){
|
||||
if(x + i >= 0 && x + i < discreteArrayDimension){
|
||||
if(x + i >= 0 && x + i < discreteArrayDimension && y + j >= 0 && y + j < discreteArrayDimension){
|
||||
rVal[i+2][j+2] = chunkRandomizer[x+i][y+j];
|
||||
} else {
|
||||
rVal[i+2][j+2] = 0;
|
||||
@ -392,6 +392,7 @@ public class TerrainModel {
|
||||
}
|
||||
|
||||
public ModificationList getModifications(int worldX, int worldY){
|
||||
// System.out.println("Got modifications at " + worldX + " " + worldY);
|
||||
return modifications.get(getModificationKey(worldX, worldY));
|
||||
}
|
||||
|
||||
|
||||
66
src/main/java/electrosphere/game/server/town/Town.java
Normal file
66
src/main/java/electrosphere/game/server/town/Town.java
Normal file
@ -0,0 +1,66 @@
|
||||
package electrosphere.game.server.town;
|
||||
|
||||
import electrosphere.game.server.structure.virtual.StructurePlacer;
|
||||
import electrosphere.game.server.terrain.manager.ServerTerrainChunk;
|
||||
import electrosphere.main.Globals;
|
||||
import java.util.Random;
|
||||
import org.joml.Vector2i;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Town {
|
||||
|
||||
int id;
|
||||
static int idIncrementer = 0;
|
||||
|
||||
final static int avgDiffThreshold = 10;
|
||||
public static Vector2i findValidTownLocation(){
|
||||
for(int x = 0; x < Globals.serverTerrainManager.getWorldDiscreteSize(); x++){
|
||||
for(int y = 0; y < Globals.serverTerrainManager.getWorldDiscreteSize(); y++){
|
||||
ServerTerrainChunk chunk = Globals.serverTerrainManager.getChunk(x, y);
|
||||
float[][] macroValues = chunk.getMacroValues();
|
||||
float sum = 0;
|
||||
int count = 0;
|
||||
for(int i = 0; i < 5; i++){
|
||||
for(int j = 0; j < 5; j++){
|
||||
sum = sum + macroValues[i][j];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
float average = sum / (float)count;
|
||||
if(average > 1000){
|
||||
float diffSum = 0;
|
||||
for(int i = 0; i < 5; i++){
|
||||
for(int j = 0; j < 5; j++){
|
||||
diffSum = diffSum + (float)Math.abs(average - macroValues[i][j]);
|
||||
}
|
||||
}
|
||||
float averageDiff = diffSum / (float)count;
|
||||
if(averageDiff < avgDiffThreshold){
|
||||
return new Vector2i(x,y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Town(){
|
||||
this.id = idIncrementer;
|
||||
idIncrementer++;
|
||||
}
|
||||
|
||||
public static Town createTown(int x, int y){
|
||||
Town rVal = new Town();
|
||||
Random rand = new Random();
|
||||
int structCount = (rand.nextInt(3) + 2);
|
||||
int chunkSize = Globals.serverTerrainManager.getChunkWidth();
|
||||
for(int i = 0; i < structCount; i++){
|
||||
StructurePlacer.placeStructureAtPoint(x * chunkSize + rand.nextFloat() * 100, y * chunkSize + rand.nextFloat() * 100, "building1");
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
}
|
||||
@ -94,6 +94,10 @@ public class ServerWorldData {
|
||||
return (int)Math.floor(real / dynamicInterpolationRatio);
|
||||
}
|
||||
|
||||
public float getRelativeLocation(float real, int world){
|
||||
return real - (world * dynamicInterpolationRatio);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,10 +2,12 @@ package electrosphere.game.state;
|
||||
|
||||
import electrosphere.game.server.civilization.Civilization;
|
||||
import electrosphere.game.server.civilization.model.CivilizationMap;
|
||||
import electrosphere.game.server.creature.type.CreatureType;
|
||||
import electrosphere.game.server.creature.type.model.CreatureTypeMap;
|
||||
import electrosphere.game.config.creature.type.CreatureType;
|
||||
import electrosphere.game.config.creature.type.model.CreatureTypeMap;
|
||||
import electrosphere.game.server.culture.Culture;
|
||||
import electrosphere.game.server.culture.religion.Religion;
|
||||
import electrosphere.game.server.structure.virtual.Structure;
|
||||
import electrosphere.game.server.town.Town;
|
||||
import electrosphere.util.FileLoadingUtils;
|
||||
import electrosphere.util.Utilities;
|
||||
import java.util.LinkedList;
|
||||
@ -18,6 +20,8 @@ public class MacroSimulation {
|
||||
List<Religion> religionList = new LinkedList();
|
||||
List<CreatureType> creatureList = new LinkedList();
|
||||
List<Character> characterList = new LinkedList();
|
||||
List<Town> townList = new LinkedList();
|
||||
List<Structure> structureList = new LinkedList();
|
||||
|
||||
public MacroSimulation(){
|
||||
init();
|
||||
|
||||
@ -19,11 +19,14 @@ import electrosphere.game.client.world.ClientWorldData;
|
||||
import electrosphere.game.collision.CommonWorldData;
|
||||
import electrosphere.engine.LoadingThread;
|
||||
import electrosphere.game.server.ai.AIManager;
|
||||
import electrosphere.game.server.creature.type.model.CreatureTypeMap;
|
||||
import electrosphere.game.server.item.type.model.ItemTypeMap;
|
||||
import electrosphere.game.server.structure.model.StructureTypeMap;
|
||||
import electrosphere.game.server.character.Character;
|
||||
import electrosphere.game.config.creature.type.model.CreatureTypeMap;
|
||||
import electrosphere.game.config.item.type.model.ItemTypeMap;
|
||||
import electrosphere.game.config.structure.type.model.StructureTypeMap;
|
||||
import electrosphere.game.server.structure.virtual.Structure;
|
||||
import electrosphere.game.state.MacroSimulation;
|
||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
||||
import electrosphere.game.server.town.Town;
|
||||
import electrosphere.game.server.world.ServerWorldData;
|
||||
import electrosphere.game.server.world.datacell.DataCellManager;
|
||||
import electrosphere.game.server.world.virtualcell.VirtualCellManager;
|
||||
@ -54,6 +57,7 @@ import org.joml.Vector3f;
|
||||
import electrosphere.util.ModelLoader;
|
||||
import electrosphere.util.Utilities;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||
|
||||
@ -98,13 +102,16 @@ public class Globals {
|
||||
public static CollisionEngine collisionEngine;
|
||||
|
||||
|
||||
//
|
||||
// Game config
|
||||
//
|
||||
public static electrosphere.game.config.Config gameConfigDefault;
|
||||
public static electrosphere.game.config.Config gameConfigCurrent;
|
||||
|
||||
//
|
||||
//current world
|
||||
//
|
||||
public static ServerWorldData serverWorldData;
|
||||
public static CreatureTypeMap creatureMap;
|
||||
public static StructureTypeMap structureTypeMap;
|
||||
public static ItemTypeMap itemMap;
|
||||
VirtualCellManager virtualCellManager;
|
||||
DataCellManager dataCellManager;
|
||||
|
||||
@ -168,7 +175,6 @@ public class Globals {
|
||||
//
|
||||
//keeps track of all entities in game
|
||||
public static EntityManager entityManager;
|
||||
public static EntityManager serverEntityManager;
|
||||
|
||||
//terrain manager
|
||||
public static boolean LOAD_TERRAIN = false;
|
||||
@ -235,6 +241,15 @@ public class Globals {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// Renderer flags
|
||||
//
|
||||
//
|
||||
public static boolean RENDER_FLAG_RENDER_SHADOW_MAP = false;
|
||||
public static boolean RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = false;
|
||||
public static boolean RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER = false;
|
||||
@ -253,12 +268,6 @@ public class Globals {
|
||||
textureMapDefault = FileLoadingUtils.loadObjectFromAssetPath("Textures/default_texture_map.json", TextureMap.class);
|
||||
// textureMapDefault = gson.fromJson(Files.newBufferedReader(new File(Thread.currentThread().getContextClassLoader().getResource("Textures/default_texture_map.json").getFile()).toPath()), TextureMap.class); //only the best of coding practices :)
|
||||
// } catch (IOException ex) { ex.printStackTrace(); } //TODO: handle better :tm:
|
||||
//init creature type map
|
||||
initCreatureTypeMap();
|
||||
//init structure type map
|
||||
initStructureTypeMap();
|
||||
//init item type map
|
||||
initItemTypeMap();
|
||||
//create entity manager
|
||||
entityManager = new EntityManager();
|
||||
//temporary hold for skybox colors
|
||||
@ -273,6 +282,9 @@ public class Globals {
|
||||
aiManager = new AIManager();
|
||||
//collision engine
|
||||
collisionEngine = new CollisionEngine();
|
||||
//game config
|
||||
gameConfigDefault = electrosphere.game.config.Config.loadDefaultConfig();
|
||||
gameConfigCurrent = gameConfigDefault;
|
||||
}
|
||||
|
||||
public static void initDefaultGraphicalResources(){
|
||||
@ -298,35 +310,17 @@ public class Globals {
|
||||
defaultMeshShader = ShaderProgram.smart_assemble_shader(false,true);
|
||||
//init skybox
|
||||
assetManager.registerModelToSpecificString(RenderUtils.createSkyboxModel(null), AssetDataStrings.ASSET_STRING_SKYBOX_BASIC);
|
||||
//init hurtbox
|
||||
//init models
|
||||
assetManager.addModelPathToQueue("Models/unitsphere.fbx");
|
||||
//init hitbox
|
||||
assetManager.addModelPathToQueue("Models/unitsphere_1.fbx");
|
||||
//init disabled hitbox
|
||||
assetManager.addModelPathToQueue("Models/unitsphere_grey.fbx");
|
||||
//init smallcube
|
||||
assetManager.addModelPathToQueue("Models/SmallCube.fbx");
|
||||
//init unit cylinder
|
||||
assetManager.addModelPathToQueue("Models/unitcylinder.fbx");
|
||||
//init unit plane
|
||||
assetManager.addModelPathToQueue("Models/unitplane.fbx");
|
||||
//init unit plane
|
||||
assetManager.addModelPathToQueue("Models/unitcube.fbx");
|
||||
|
||||
//as these assets are required for the renderer to work, we go ahead and
|
||||
//load them into memory now. The loading time penalty is worth it I think.
|
||||
Globals.assetManager.loadAssetsInQueue();
|
||||
}
|
||||
|
||||
static void initCreatureTypeMap(){
|
||||
creatureMap = FileLoadingUtils.loadObjectFromAssetPath("Data/creatures.json", CreatureTypeMap.class);
|
||||
}
|
||||
|
||||
static void initItemTypeMap(){
|
||||
itemMap = FileLoadingUtils.loadObjectFromAssetPath("Data/items.json", ItemTypeMap.class);
|
||||
}
|
||||
|
||||
static void initStructureTypeMap(){
|
||||
structureTypeMap = FileLoadingUtils.loadObjectFromAssetPath("Data/structures.json", StructureTypeMap.class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +84,8 @@ public class ServerProtocol {
|
||||
long randomizerValue22
|
||||
*/
|
||||
|
||||
// System.out.println("Received request for chunk " + message.getworldX() + " " + message.getworldY());
|
||||
|
||||
ServerTerrainChunk chunk = Globals.serverTerrainManager.getChunk(message.getworldX(), message.getworldY());
|
||||
|
||||
float[][] macroValues = chunk.getMacroValues();//Globals.serverTerrainManager.getRad5MacroValues(message.getworldX(), message.getworldY());
|
||||
|
||||
@ -6,7 +6,7 @@ import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.hitbox.HitboxData;
|
||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||
import electrosphere.game.server.creature.type.PhysicsObject;
|
||||
import electrosphere.game.config.creature.type.PhysicsObject;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.main.Globals;
|
||||
import static electrosphere.main.Main.deltaTime;
|
||||
@ -82,7 +82,7 @@ public class RenderingEngine {
|
||||
static Framebuffer lightDepthBuffer;
|
||||
|
||||
public static boolean renderHitboxes = false;
|
||||
public static boolean renderPhysics = true;
|
||||
public static boolean renderPhysics = false;
|
||||
|
||||
ShaderProgram activeProgram;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user