From 39ba611af47322d164abc3f666a716bb25967678 Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 7 Nov 2021 16:48:35 -0500 Subject: [PATCH] Refactor life stuff --- .../electrosphere/engine/LoadingThread.java | 19 +++++++++++++------ .../{types => state}/life/LifeState.java | 2 +- .../{types => state}/life/LifeUtils.java | 2 +- .../entity/types/creature/CreatureUtils.java | 2 +- .../entity/types/hitbox/HitboxUtils.java | 4 ++-- .../game/simulation/MicroSimulation.java | 4 ++-- 6 files changed, 20 insertions(+), 13 deletions(-) rename src/main/java/electrosphere/entity/{types => state}/life/LifeState.java (98%) rename src/main/java/electrosphere/entity/{types => state}/life/LifeUtils.java (87%) diff --git a/src/main/java/electrosphere/engine/LoadingThread.java b/src/main/java/electrosphere/engine/LoadingThread.java index 1fddd415..719d31c6 100644 --- a/src/main/java/electrosphere/engine/LoadingThread.java +++ b/src/main/java/electrosphere/engine/LoadingThread.java @@ -385,6 +385,13 @@ public class LoadingThread extends Thread { static void initCommonWorldData(boolean FLAG_INIT_SERVER){ if(FLAG_INIT_SERVER){ Globals.commonWorldData = new CommonWorldData(Globals.serverWorldData, Globals.serverTerrainManager); + if(Globals.macroSimulation != null){ + Town startTown = Globals.macroData.getTowns().get(0); + Vector2i firstPos = startTown.getPositions().get(0); + double startX = firstPos.x * Globals.serverTerrainManager.getChunkWidth(); + double startZ = firstPos.y * Globals.serverTerrainManager.getChunkWidth(); + Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ); + } } else { Globals.commonWorldData = new CommonWorldData(Globals.clientWorldData, Globals.clientTerrainManager); } @@ -508,12 +515,12 @@ public class LoadingThread extends Thread { // Globals.macroData.describeWorld(); Globals.macroSimulation = new MacroSimulation(); Globals.macroSimulation.simulate(); - Town startTown = Globals.macroData.getTowns().get(0); - Vector2i firstPos = startTown.getPositions().get(0); - double startX = firstPos.x * Globals.serverTerrainManager.getChunkWidth(); - double startZ = firstPos.y * Globals.serverTerrainManager.getChunkWidth(); - Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ); - Globals.macroSimulation.setReady(true); +// Town startTown = Globals.macroData.getTowns().get(0); +// Vector2i firstPos = startTown.getPositions().get(0); +// double startX = firstPos.x * Globals.serverTerrainManager.getChunkWidth(); +// double startZ = firstPos.y * Globals.serverTerrainManager.getChunkWidth(); +// Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ); +// Globals.macroSimulation.setReady(true); } diff --git a/src/main/java/electrosphere/entity/types/life/LifeState.java b/src/main/java/electrosphere/entity/state/life/LifeState.java similarity index 98% rename from src/main/java/electrosphere/entity/types/life/LifeState.java rename to src/main/java/electrosphere/entity/state/life/LifeState.java index 2d3024d9..e2d1d777 100644 --- a/src/main/java/electrosphere/entity/types/life/LifeState.java +++ b/src/main/java/electrosphere/entity/state/life/LifeState.java @@ -1,4 +1,4 @@ -package electrosphere.entity.types.life; +package electrosphere.entity.state.life; import electrosphere.entity.Entity; import electrosphere.game.data.creature.type.HealthSystem; diff --git a/src/main/java/electrosphere/entity/types/life/LifeUtils.java b/src/main/java/electrosphere/entity/state/life/LifeUtils.java similarity index 87% rename from src/main/java/electrosphere/entity/types/life/LifeUtils.java rename to src/main/java/electrosphere/entity/state/life/LifeUtils.java index a8c8e23b..d42a0c08 100644 --- a/src/main/java/electrosphere/entity/types/life/LifeUtils.java +++ b/src/main/java/electrosphere/entity/state/life/LifeUtils.java @@ -1,4 +1,4 @@ -package electrosphere.entity.types.life; +package electrosphere.entity.state.life; import electrosphere.entity.Entity; import electrosphere.entity.EntityDataStrings; diff --git a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java index 729c9bfa..4a6e2516 100644 --- a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java +++ b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java @@ -15,7 +15,7 @@ import electrosphere.entity.state.GravityTree; import electrosphere.entity.state.IdleTree; import electrosphere.entity.state.collidable.CollidableTree; import electrosphere.entity.types.collision.CollisionObjUtils; -import electrosphere.entity.types.life.LifeState; +import electrosphere.entity.state.life.LifeState; import electrosphere.game.collision.PhysicsUtils; import electrosphere.game.collision.collidable.Collidable; import electrosphere.game.data.creature.type.AttackMove; diff --git a/src/main/java/electrosphere/entity/types/hitbox/HitboxUtils.java b/src/main/java/electrosphere/entity/types/hitbox/HitboxUtils.java index eff836c5..bf580c6f 100644 --- a/src/main/java/electrosphere/entity/types/hitbox/HitboxUtils.java +++ b/src/main/java/electrosphere/entity/types/hitbox/HitboxUtils.java @@ -5,8 +5,8 @@ import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityUtils; import electrosphere.entity.types.attach.AttachUtils; import electrosphere.entity.types.item.ItemUtils; -import electrosphere.entity.types.life.LifeState; -import electrosphere.entity.types.life.LifeUtils; +import electrosphere.entity.state.life.LifeState; +import electrosphere.entity.state.life.LifeUtils; import electrosphere.game.server.effects.ParticleEffects; import electrosphere.main.Globals; import org.joml.Matrix4f; diff --git a/src/main/java/electrosphere/game/simulation/MicroSimulation.java b/src/main/java/electrosphere/game/simulation/MicroSimulation.java index 733047f2..decec7a1 100644 --- a/src/main/java/electrosphere/game/simulation/MicroSimulation.java +++ b/src/main/java/electrosphere/game/simulation/MicroSimulation.java @@ -13,8 +13,8 @@ import electrosphere.entity.state.collidable.CollidableTree; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.hitbox.HitboxUtils; import electrosphere.entity.types.item.ItemUtils; -import electrosphere.entity.types.life.LifeState; -import electrosphere.entity.types.life.LifeUtils; +import electrosphere.entity.state.life.LifeState; +import electrosphere.entity.state.life.LifeUtils; import electrosphere.entity.types.particle.ParticleUtils; import electrosphere.game.client.targeting.crosshair.Crosshair; import electrosphere.main.Globals;