From 1cfeb5c1739e3a72bf4592a16b70981660ac9e2d Mon Sep 17 00:00:00 2001 From: austin Date: Sat, 6 Nov 2021 16:39:59 -0400 Subject: [PATCH] Targeting Crosshair --- assets/Data/creatures.json | 6 +- assets/Data/items.json | 3 +- assets/Models/lockoncrosshair1.fbx | Bin 14860 -> 14860 bytes assets/Textures/default_texture_map.json | 6 ++ .../electrosphere/engine/LoadingThread.java | 11 ++- .../electrosphere/entity/EntityManager.java | 12 +++ .../electrosphere/entity/EntityUtils.java | 4 + .../entity/state/AttackTree.java | 2 +- .../entity/types/creature/CreatureUtils.java | 11 ++- .../entity/types/foliage/FoliageUtils.java | 4 +- .../entity/types/item/ItemUtils.java | 9 ++- .../entity/types/life/LifeState.java | 2 +- .../types/structure/StructureUtils.java | 4 +- .../client/targeting/crosshair/Crosshair.java | 73 ++++++++++++++++++ .../game/{config => data}/Config.java | 10 +-- .../creature/type/AttackMove.java | 2 +- .../creature/type/BodyPart.java | 2 +- .../creature/type/CollidableTemplate.java | 2 +- .../creature/type/CreatureType.java | 2 +- .../creature/type/HealthSystem.java | 2 +- .../creature/type/MovementSystem.java | 2 +- .../creature/type/model/CreatureTypeMap.java | 4 +- .../foliage/type/FoliageType.java | 2 +- .../foliage/type/PhysicsObject.java | 4 +- .../foliage/type/model/FoliageTypeMap.java | 4 +- .../game/{config => data}/item/type/Item.java | 4 +- .../item/type/model/ItemTypeMap.java | 4 +- .../type/model/CollisionObjectTemplate.java | 2 +- .../structure/type/model/StructureType.java | 2 +- .../type/model/StructureTypeMap.java | 2 +- .../virtual/VirtualStructureUtils.java | 2 +- .../MacroSimulation.java | 6 +- .../MicroSimulation.java | 8 +- .../electrosphere/logger/LoggerInterface.java | 2 +- src/main/java/electrosphere/main/Globals.java | 20 ++--- src/main/java/electrosphere/main/Main.java | 4 +- .../renderer/RenderingEngine.java | 2 +- .../util/worldviewer/TerrainViewer.java | 2 +- 38 files changed, 179 insertions(+), 64 deletions(-) create mode 100644 src/main/java/electrosphere/game/client/targeting/crosshair/Crosshair.java rename src/main/java/electrosphere/game/{config => data}/Config.java (84%) rename src/main/java/electrosphere/game/{config => data}/creature/type/AttackMove.java (90%) rename src/main/java/electrosphere/game/{config => data}/creature/type/BodyPart.java (52%) rename src/main/java/electrosphere/game/{config => data}/creature/type/CollidableTemplate.java (93%) rename src/main/java/electrosphere/game/{config => data}/creature/type/CreatureType.java (95%) rename src/main/java/electrosphere/game/{config => data}/creature/type/HealthSystem.java (90%) rename src/main/java/electrosphere/game/{config => data}/creature/type/MovementSystem.java (86%) rename src/main/java/electrosphere/game/{config => data}/creature/type/model/CreatureTypeMap.java (76%) rename src/main/java/electrosphere/game/{config => data}/foliage/type/FoliageType.java (90%) rename src/main/java/electrosphere/game/{config => data}/foliage/type/PhysicsObject.java (87%) rename src/main/java/electrosphere/game/{config => data}/foliage/type/model/FoliageTypeMap.java (79%) rename src/main/java/electrosphere/game/{config => data}/item/type/Item.java (84%) rename src/main/java/electrosphere/game/{config => data}/item/type/model/ItemTypeMap.java (79%) rename src/main/java/electrosphere/game/{config => data}/structure/type/model/CollisionObjectTemplate.java (95%) rename src/main/java/electrosphere/game/{config => data}/structure/type/model/StructureType.java (89%) rename src/main/java/electrosphere/game/{config => data}/structure/type/model/StructureTypeMap.java (89%) rename src/main/java/electrosphere/game/{state => simulation}/MacroSimulation.java (97%) rename src/main/java/electrosphere/game/{state => simulation}/MicroSimulation.java (95%) diff --git a/assets/Data/creatures.json b/assets/Data/creatures.json index fcef4adb..865eacbe 100644 --- a/assets/Data/creatures.json +++ b/assets/Data/creatures.json @@ -83,7 +83,8 @@ "BLENDER_TRANSFORM", "SENTIENT", "ATTACKER", - "GRAVITY" + "GRAVITY", + "TARGETABLE" ], "movementSystems" : [ { @@ -207,7 +208,8 @@ "BLENDER_TRANSFORM", "SENTIENT", "ATTACKER", - "GRAVITY" + "GRAVITY", + "TARGETABLE" ], "movementSystems" : [ { diff --git a/assets/Data/items.json b/assets/Data/items.json index 5a4fd997..9fa9fe0e 100644 --- a/assets/Data/items.json +++ b/assets/Data/items.json @@ -35,7 +35,8 @@ "tokens" : [ "GRAVITY", "WEAPON", - "RANGED" + "RANGED", + "TARGETABLE" ], "collidable": { "type" : "CUBE", diff --git a/assets/Models/lockoncrosshair1.fbx b/assets/Models/lockoncrosshair1.fbx index 3349e74f3e24d333ccbd237f49ab9fa24e5c8eed..d824cc809f378f0b5f801ddc354f3e24c37b7850 100644 GIT binary patch delta 1195 zcmZ`&Z%9*76o2=*xoQTQhSt}-cZ~aK?9EAeZ(LYHJJB^hp%L0YH~7E#c5BEvAJ?5zYlQ zLZCwk2fOUjch?rebZKv7G<*G!1x<-Py6)<=n0|CCo4PaoBS%J3{c7@tsGjhT&gp;i zB=F=;`FE7XOXgtU``Yv55e$^wh>R%XU?Z|hoPl5m?+bafIz+~Zdin}$jNsIE_%U@TO9muw+d#; zIQF;-rqmqy2FFzGWIKFSbr3hSs*BhQYRa;lvfN70Cs|Nnrr@SpNeW?7Z6I|}pwTTG z$6Jb}fmX4d?-GJG>e!>9Oz9pJXEZRQk&*jwPE*Xj)qql4jNzs=xkL#IwS~x2rd>nE zV#pZ?XiLadiojs0oSW6hd!T@_I|3fTXHT1bDxncvw1usm%>qMW2A2qRhY)I0K&CF2 z-K&RRnKJgY4qg?kgF`ww`2_ts7tz6#u9|p3tKYEl6tX9BU*zcYg}r|ca2ZbO<+8Ck z4;Hy4t~TD|^|xBdd$^-l$@gQ=Ci~ODhlQY*_t}ko&k8}x<+GbOS^=oyL>R4_D_GUd z{Xbf}iDru_4scFV2~)TpgbIV1+=K&$DmKFipG)*GZIH8eBbXJHqH#-)5e_T#5H*U~ zheo)esEmm#Oz=Zd4ilV=-Dv`6sTsDJN+NmXnE%|6S_6JRzAtaUAG$ktgk@+WRu?^G zeSNaR_QWrf|8%1-k$NQkmtYiHkojy_5M|*!KdK~$J0&%71K%!$>OfuYglKv1Z=*yU An*aa+ delta 1176 zcmZ`&T}V@57(U;eu9`++Ha%(nWN2wS`=44l@uysDu2|E8EOssCs9 z8irxk6NbSblZ-2=mhZCW;Gd!dP+lJh2dx>1S`yF{yXX%~g0&R!rbOH+xC4HVwE}S| z0aw~ZuU8Dk$O$CSZl53~rToTYDf9Md>iS%DPgxX>ZVE?ByWo~WZ*^D}B3p5-+A9Qn zf)wns89DiO_+AppXr4McWg{l;kx-FQ9(-pJR{}THrnG?Tu8CU7cos|mLV42cp>Ir?@X)K;ut?n2Qh1VduL zZ~cU%WPm^GRI-bDcwbNf-FlYH!zI0wXkkHLM_R#PsFw8`pu@=OZerf}Bv#wQUP(O2 zcL>pGOfOP0jHqz7@gC9NT0=g1jv-?MselFCyI{Ael8nPCQx#bQ_e>7557NvQ(hGKT1$hGJ%+-X2 z=jH?C2;`Ktb>}2pA!SX#@5he`I}SZqtR)NUBsET2uEVi3JsY}F`}|KC{p={cq+f?w gXlE;X6*}rHnJb~RWIDi5J?P3C;B@(gzcBh3S^xk5 diff --git a/assets/Textures/default_texture_map.json b/assets/Textures/default_texture_map.json index c3142bba..584251a6 100644 --- a/assets/Textures/default_texture_map.json +++ b/assets/Textures/default_texture_map.json @@ -125,6 +125,12 @@ "/Textures/arrow1.png", "/Textures/arrow1.png" ] + }, + "Models/lockoncrosshair1.fbx" : { + "Cube" : [ + "/Textures/w1.png", + "/Textures/w1.png" + ] } } } \ No newline at end of file diff --git a/src/main/java/electrosphere/engine/LoadingThread.java b/src/main/java/electrosphere/engine/LoadingThread.java index f84f893c..ef057bc8 100644 --- a/src/main/java/electrosphere/engine/LoadingThread.java +++ b/src/main/java/electrosphere/engine/LoadingThread.java @@ -13,7 +13,7 @@ import electrosphere.game.client.player.ClientPlayerData; import electrosphere.game.client.terrain.manager.ClientTerrainManager; import electrosphere.game.client.world.ClientWorldData; import electrosphere.game.collision.CommonWorldData; -import electrosphere.game.state.MacroSimulation; +import electrosphere.game.simulation.MacroSimulation; import electrosphere.game.server.terrain.manager.ServerTerrainManager; import electrosphere.game.server.world.ServerWorldData; import electrosphere.entity.types.attach.AttachUtils; @@ -30,7 +30,7 @@ import electrosphere.game.server.terrain.models.TerrainModification; import electrosphere.game.server.town.Town; import electrosphere.game.server.world.MacroData; import electrosphere.game.server.datacell.DataCellManager; -import electrosphere.game.state.MicroSimulation; +import electrosphere.game.simulation.MicroSimulation; import electrosphere.logger.LoggerInterface; import electrosphere.main.Globals; import static electrosphere.main.Globals.loadingBox; @@ -42,6 +42,7 @@ import electrosphere.renderer.ActorUtils; import electrosphere.renderer.Model; import electrosphere.renderer.RenderUtils; import electrosphere.engine.assetmanager.AssetDataStrings; +import electrosphere.game.client.targeting.crosshair.Crosshair; import electrosphere.game.server.pathfinding.NavMeshPathfinder; import electrosphere.game.server.pathfinding.navmesh.NavCube; import electrosphere.game.server.pathfinding.navmesh.NavMesh; @@ -486,6 +487,12 @@ public class LoadingThread extends Thread { Globals.playerCamera = CameraEntityUtils.spawnBasicCameraEntity(new Vector3f(1,0,1), new Vector3f(0,0,0)); + + /* + Targeting crosshair + */ + Crosshair.initCrossHairEntity(); + } static void initMacroSimulation(){ diff --git a/src/main/java/electrosphere/entity/EntityManager.java b/src/main/java/electrosphere/entity/EntityManager.java index 79e7e301..5026f64c 100644 --- a/src/main/java/electrosphere/entity/EntityManager.java +++ b/src/main/java/electrosphere/entity/EntityManager.java @@ -31,6 +31,7 @@ public class EntityManager { static CopyOnWriteArrayList particleList = new CopyOnWriteArrayList(); static CopyOnWriteArrayList gravityList = new CopyOnWriteArrayList(); static CopyOnWriteArrayList collidableList = new CopyOnWriteArrayList(); + static CopyOnWriteArrayList targetableList = new CopyOnWriteArrayList(); public EntityManager(){ @@ -137,6 +138,14 @@ public class EntityManager { return collidableList; } + public void registerTargetableEntity(Entity e){ + targetableList.add(e); + } + + public CopyOnWriteArrayList getTargetables(){ + return targetableList; + } + public void deregisterEntity(Entity e){ if(lightList.contains(e)){ lightList.remove(e); @@ -175,6 +184,9 @@ public class EntityManager { if(collidableList.contains(e)){ collidableList.remove(e); } + if(targetableList.contains(e)){ + targetableList.remove(e); + } } public void recursiveDeregister(Entity target){ diff --git a/src/main/java/electrosphere/entity/EntityUtils.java b/src/main/java/electrosphere/entity/EntityUtils.java index 7d2e93ab..f515b7d2 100644 --- a/src/main/java/electrosphere/entity/EntityUtils.java +++ b/src/main/java/electrosphere/entity/EntityUtils.java @@ -95,4 +95,8 @@ public class EntityUtils { return (CollidableTree)e.getData(EntityDataStrings.COLLIDABLE_TREE); } + public static void setVisible(Entity entity, boolean visible){ + entity.putData(EntityDataStrings.DATA_STRING_DRAW, visible); + } + } diff --git a/src/main/java/electrosphere/entity/state/AttackTree.java b/src/main/java/electrosphere/entity/state/AttackTree.java index 2d29d4e9..afef4088 100644 --- a/src/main/java/electrosphere/entity/state/AttackTree.java +++ b/src/main/java/electrosphere/entity/state/AttackTree.java @@ -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.config.creature.type.AttackMove; +import electrosphere.game.data.creature.type.AttackMove; import electrosphere.main.Globals; import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.renderer.Actor; diff --git a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java index 52089e57..b125b84a 100644 --- a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java +++ b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java @@ -8,8 +8,8 @@ import electrosphere.entity.EntityUtils; import electrosphere.entity.state.movement.GroundMovementTree; import electrosphere.entity.types.hitbox.HitboxData; import electrosphere.entity.types.hitbox.HitboxUtils; -import electrosphere.game.config.creature.type.CreatureType; -import electrosphere.game.config.creature.type.MovementSystem; +import electrosphere.game.data.creature.type.CreatureType; +import electrosphere.game.data.creature.type.MovementSystem; import electrosphere.entity.state.AttackTree; import electrosphere.entity.state.GravityTree; import electrosphere.entity.state.IdleTree; @@ -18,8 +18,8 @@ import electrosphere.entity.types.collision.CollisionObjUtils; import electrosphere.entity.types.life.LifeState; import electrosphere.game.collision.PhysicsUtils; import electrosphere.game.collision.collidable.Collidable; -import electrosphere.game.config.creature.type.AttackMove; -import electrosphere.game.config.creature.type.CollidableTemplate; +import electrosphere.game.data.creature.type.AttackMove; +import electrosphere.game.data.creature.type.CollidableTemplate; import electrosphere.logger.LoggerInterface; import electrosphere.main.Globals; import electrosphere.main.Main; @@ -123,6 +123,9 @@ public class CreatureUtils { rVal.putData(EntityDataStrings.GRAVITY_TREE, gravityTree); Globals.entityManager.registerGravityEntity(rVal); break; + case "TARGETABLE": + Globals.entityManager.registerTargetableEntity(rVal); + break; } } //add all attack moves diff --git a/src/main/java/electrosphere/entity/types/foliage/FoliageUtils.java b/src/main/java/electrosphere/entity/types/foliage/FoliageUtils.java index 1e10158b..8a856881 100644 --- a/src/main/java/electrosphere/entity/types/foliage/FoliageUtils.java +++ b/src/main/java/electrosphere/entity/types/foliage/FoliageUtils.java @@ -8,8 +8,8 @@ import electrosphere.entity.state.IdleTree; import electrosphere.entity.types.collision.CollisionObjUtils; import electrosphere.game.collision.PhysicsUtils; import electrosphere.game.collision.collidable.Collidable; -import electrosphere.game.config.foliage.type.FoliageType; -import electrosphere.game.config.foliage.type.PhysicsObject; +import electrosphere.game.data.foliage.type.FoliageType; +import electrosphere.game.data.foliage.type.PhysicsObject; import electrosphere.main.Globals; import electrosphere.renderer.ActorUtils; import java.util.List; diff --git a/src/main/java/electrosphere/entity/types/item/ItemUtils.java b/src/main/java/electrosphere/entity/types/item/ItemUtils.java index 05b006a0..cb27f799 100644 --- a/src/main/java/electrosphere/entity/types/item/ItemUtils.java +++ b/src/main/java/electrosphere/entity/types/item/ItemUtils.java @@ -12,9 +12,9 @@ import electrosphere.entity.types.hitbox.HitboxData; import electrosphere.entity.types.hitbox.HitboxUtils; import electrosphere.game.collision.PhysicsUtils; import electrosphere.game.collision.collidable.Collidable; -import electrosphere.game.config.creature.type.CollidableTemplate; -import electrosphere.game.config.creature.type.CreatureType; -import electrosphere.game.config.item.type.Item; +import electrosphere.game.data.creature.type.CollidableTemplate; +import electrosphere.game.data.creature.type.CreatureType; +import electrosphere.game.data.item.type.Item; import electrosphere.main.Globals; import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.NetworkMessage; @@ -86,6 +86,9 @@ public class ItemUtils { rVal.putData(EntityDataStrings.GRAVITY_TREE, gravityTree); Globals.entityManager.registerGravityEntity(rVal); break; + case "TARGETABLE": + Globals.entityManager.registerTargetableEntity(rVal); + break; } } rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true); diff --git a/src/main/java/electrosphere/entity/types/life/LifeState.java b/src/main/java/electrosphere/entity/types/life/LifeState.java index 3af5bd07..2d3024d9 100644 --- a/src/main/java/electrosphere/entity/types/life/LifeState.java +++ b/src/main/java/electrosphere/entity/types/life/LifeState.java @@ -1,7 +1,7 @@ package electrosphere.entity.types.life; import electrosphere.entity.Entity; -import electrosphere.game.config.creature.type.HealthSystem; +import electrosphere.game.data.creature.type.HealthSystem; public class LifeState { diff --git a/src/main/java/electrosphere/entity/types/structure/StructureUtils.java b/src/main/java/electrosphere/entity/types/structure/StructureUtils.java index a42a27bd..e0ac1005 100644 --- a/src/main/java/electrosphere/entity/types/structure/StructureUtils.java +++ b/src/main/java/electrosphere/entity/types/structure/StructureUtils.java @@ -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.config.structure.type.model.CollisionObjectTemplate; -import electrosphere.game.config.structure.type.model.StructureType; +import electrosphere.game.data.structure.type.model.CollisionObjectTemplate; +import electrosphere.game.data.structure.type.model.StructureType; import electrosphere.main.Globals; import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.NetworkMessage; diff --git a/src/main/java/electrosphere/game/client/targeting/crosshair/Crosshair.java b/src/main/java/electrosphere/game/client/targeting/crosshair/Crosshair.java new file mode 100644 index 00000000..8838f8f4 --- /dev/null +++ b/src/main/java/electrosphere/game/client/targeting/crosshair/Crosshair.java @@ -0,0 +1,73 @@ +package electrosphere.game.client.targeting.crosshair; + +import electrosphere.entity.Entity; +import electrosphere.entity.EntityUtils; +import electrosphere.main.Globals; +import org.joml.Vector3d; + +/** + * + * @author amaterasu + */ +public class Crosshair { + + static Entity crossHairEntity; + static float rotationTheta = 0; + static float bobTheta = 0; + static float bobMagnitude = 0.1f; + static float offsetVertical = 1; + static Entity currentTarget = null; + + public static void initCrossHairEntity(){ + crossHairEntity = EntityUtils.spawnDrawableEntity("/Models/lockoncrosshair1.fbx"); + EntityUtils.setVisible(crossHairEntity, false); + } + + + static final float TARGET_MAX_DIST = 1; + public static void checkTargetable(){ + if(crossHairEntity != null && Globals.playerCharacter != null){ + Vector3d parentPos = EntityUtils.getPosition(Globals.playerCharacter); + if(currentTarget == null){ + Entity target = null; + double dist = 100; + for(Entity entity : Globals.entityManager.getTargetables()){ + double currentDist = parentPos.distance(EntityUtils.getPosition(entity)); + if(currentDist < dist && currentDist <= TARGET_MAX_DIST && entity != Globals.playerCharacter){ + target = entity; + dist = currentDist; + } + } + if(target != null){ +// System.out.println("Found target!"); + currentTarget = target; + EntityUtils.setVisible(crossHairEntity, true); + } + } else { + if(parentPos.distance(EntityUtils.getPosition(currentTarget)) > TARGET_MAX_DIST){ + currentTarget = null; + EntityUtils.setVisible(crossHairEntity, false); + } + } + } + } + + public static void updateTargetCrosshairPosition(){ + if(crossHairEntity != null && currentTarget != null){ + rotationTheta += 0.01; + if(rotationTheta > Math.PI * 2){ + rotationTheta = 0; + } + bobTheta += 0.01; + if(bobTheta > Math.PI * 2){ + bobTheta = 0; + } + Vector3d crosshairPos = EntityUtils.getPosition(crossHairEntity); + crosshairPos.set(new Vector3d(EntityUtils.getPosition(currentTarget)).add(0,offsetVertical + Math.sin(bobTheta) * bobMagnitude,0)); +// EntityUtils.getRotation(crossHairEntity).rotationZ(rotationTheta); + EntityUtils.getRotation(crossHairEntity).rotationXYZ((float)-Math.PI/2.0f, 0, rotationTheta); + } + } + + +} diff --git a/src/main/java/electrosphere/game/config/Config.java b/src/main/java/electrosphere/game/data/Config.java similarity index 84% rename from src/main/java/electrosphere/game/config/Config.java rename to src/main/java/electrosphere/game/data/Config.java index c2ab15c6..22d04efc 100644 --- a/src/main/java/electrosphere/game/config/Config.java +++ b/src/main/java/electrosphere/game/data/Config.java @@ -1,9 +1,9 @@ -package electrosphere.game.config; +package electrosphere.game.data; -import electrosphere.game.config.creature.type.model.CreatureTypeMap; -import electrosphere.game.config.foliage.type.model.FoliageTypeMap; -import electrosphere.game.config.item.type.model.ItemTypeMap; -import electrosphere.game.config.structure.type.model.StructureTypeMap; +import electrosphere.game.data.creature.type.model.CreatureTypeMap; +import electrosphere.game.data.foliage.type.model.FoliageTypeMap; +import electrosphere.game.data.item.type.model.ItemTypeMap; +import electrosphere.game.data.structure.type.model.StructureTypeMap; import electrosphere.game.server.race.model.RaceMap; import electrosphere.game.server.symbolism.model.SymbolMap; import electrosphere.util.FileUtils; diff --git a/src/main/java/electrosphere/game/config/creature/type/AttackMove.java b/src/main/java/electrosphere/game/data/creature/type/AttackMove.java similarity index 90% rename from src/main/java/electrosphere/game/config/creature/type/AttackMove.java rename to src/main/java/electrosphere/game/data/creature/type/AttackMove.java index fcf5e910..ae18bc98 100644 --- a/src/main/java/electrosphere/game/config/creature/type/AttackMove.java +++ b/src/main/java/electrosphere/game/data/creature/type/AttackMove.java @@ -1,4 +1,4 @@ -package electrosphere.game.config.creature.type; +package electrosphere.game.data.creature.type; /** * diff --git a/src/main/java/electrosphere/game/config/creature/type/BodyPart.java b/src/main/java/electrosphere/game/data/creature/type/BodyPart.java similarity index 52% rename from src/main/java/electrosphere/game/config/creature/type/BodyPart.java rename to src/main/java/electrosphere/game/data/creature/type/BodyPart.java index 34e36913..e1ba7277 100644 --- a/src/main/java/electrosphere/game/config/creature/type/BodyPart.java +++ b/src/main/java/electrosphere/game/data/creature/type/BodyPart.java @@ -1,4 +1,4 @@ -package electrosphere.game.config.creature.type; +package electrosphere.game.data.creature.type; public class BodyPart { int bodyPartClass; diff --git a/src/main/java/electrosphere/game/config/creature/type/CollidableTemplate.java b/src/main/java/electrosphere/game/data/creature/type/CollidableTemplate.java similarity index 93% rename from src/main/java/electrosphere/game/config/creature/type/CollidableTemplate.java rename to src/main/java/electrosphere/game/data/creature/type/CollidableTemplate.java index cd42632d..851a059d 100644 --- a/src/main/java/electrosphere/game/config/creature/type/CollidableTemplate.java +++ b/src/main/java/electrosphere/game/data/creature/type/CollidableTemplate.java @@ -1,4 +1,4 @@ -package electrosphere.game.config.creature.type; +package electrosphere.game.data.creature.type; /** * diff --git a/src/main/java/electrosphere/game/config/creature/type/CreatureType.java b/src/main/java/electrosphere/game/data/creature/type/CreatureType.java similarity index 95% rename from src/main/java/electrosphere/game/config/creature/type/CreatureType.java rename to src/main/java/electrosphere/game/data/creature/type/CreatureType.java index 2340d0bc..20f48d32 100644 --- a/src/main/java/electrosphere/game/config/creature/type/CreatureType.java +++ b/src/main/java/electrosphere/game/data/creature/type/CreatureType.java @@ -1,4 +1,4 @@ -package electrosphere.game.config.creature.type; +package electrosphere.game.data.creature.type; import electrosphere.entity.types.hitbox.HitboxData; import java.util.List; diff --git a/src/main/java/electrosphere/game/config/creature/type/HealthSystem.java b/src/main/java/electrosphere/game/data/creature/type/HealthSystem.java similarity index 90% rename from src/main/java/electrosphere/game/config/creature/type/HealthSystem.java rename to src/main/java/electrosphere/game/data/creature/type/HealthSystem.java index d0edb02f..53302b65 100644 --- a/src/main/java/electrosphere/game/config/creature/type/HealthSystem.java +++ b/src/main/java/electrosphere/game/data/creature/type/HealthSystem.java @@ -1,4 +1,4 @@ -package electrosphere.game.config.creature.type; +package electrosphere.game.data.creature.type; /** * diff --git a/src/main/java/electrosphere/game/config/creature/type/MovementSystem.java b/src/main/java/electrosphere/game/data/creature/type/MovementSystem.java similarity index 86% rename from src/main/java/electrosphere/game/config/creature/type/MovementSystem.java rename to src/main/java/electrosphere/game/data/creature/type/MovementSystem.java index 8f402a8c..ef3cc0b6 100644 --- a/src/main/java/electrosphere/game/config/creature/type/MovementSystem.java +++ b/src/main/java/electrosphere/game/data/creature/type/MovementSystem.java @@ -1,4 +1,4 @@ -package electrosphere.game.config.creature.type; +package electrosphere.game.data.creature.type; public class MovementSystem { String type; diff --git a/src/main/java/electrosphere/game/config/creature/type/model/CreatureTypeMap.java b/src/main/java/electrosphere/game/data/creature/type/model/CreatureTypeMap.java similarity index 76% rename from src/main/java/electrosphere/game/config/creature/type/model/CreatureTypeMap.java rename to src/main/java/electrosphere/game/data/creature/type/model/CreatureTypeMap.java index a8df57a3..5a196089 100644 --- a/src/main/java/electrosphere/game/config/creature/type/model/CreatureTypeMap.java +++ b/src/main/java/electrosphere/game/data/creature/type/model/CreatureTypeMap.java @@ -1,6 +1,6 @@ -package electrosphere.game.config.creature.type.model; +package electrosphere.game.data.creature.type.model; -import electrosphere.game.config.creature.type.CreatureType; +import electrosphere.game.data.creature.type.CreatureType; import java.util.List; public class CreatureTypeMap { diff --git a/src/main/java/electrosphere/game/config/foliage/type/FoliageType.java b/src/main/java/electrosphere/game/data/foliage/type/FoliageType.java similarity index 90% rename from src/main/java/electrosphere/game/config/foliage/type/FoliageType.java rename to src/main/java/electrosphere/game/data/foliage/type/FoliageType.java index 265f2158..4c04ee8c 100644 --- a/src/main/java/electrosphere/game/config/foliage/type/FoliageType.java +++ b/src/main/java/electrosphere/game/data/foliage/type/FoliageType.java @@ -1,4 +1,4 @@ -package electrosphere.game.config.foliage.type; +package electrosphere.game.data.foliage.type; import java.util.List; diff --git a/src/main/java/electrosphere/game/config/foliage/type/PhysicsObject.java b/src/main/java/electrosphere/game/data/foliage/type/PhysicsObject.java similarity index 87% rename from src/main/java/electrosphere/game/config/foliage/type/PhysicsObject.java rename to src/main/java/electrosphere/game/data/foliage/type/PhysicsObject.java index 50f1915b..05b22d34 100644 --- a/src/main/java/electrosphere/game/config/foliage/type/PhysicsObject.java +++ b/src/main/java/electrosphere/game/data/foliage/type/PhysicsObject.java @@ -1,6 +1,4 @@ -package electrosphere.game.config.foliage.type; - -import electrosphere.game.config.creature.type.*; +package electrosphere.game.data.foliage.type; /** * diff --git a/src/main/java/electrosphere/game/config/foliage/type/model/FoliageTypeMap.java b/src/main/java/electrosphere/game/data/foliage/type/model/FoliageTypeMap.java similarity index 79% rename from src/main/java/electrosphere/game/config/foliage/type/model/FoliageTypeMap.java rename to src/main/java/electrosphere/game/data/foliage/type/model/FoliageTypeMap.java index 0a564554..481b2b13 100644 --- a/src/main/java/electrosphere/game/config/foliage/type/model/FoliageTypeMap.java +++ b/src/main/java/electrosphere/game/data/foliage/type/model/FoliageTypeMap.java @@ -1,6 +1,6 @@ -package electrosphere.game.config.foliage.type.model; +package electrosphere.game.data.foliage.type.model; -import electrosphere.game.config.foliage.type.FoliageType; +import electrosphere.game.data.foliage.type.FoliageType; import java.util.List; /** diff --git a/src/main/java/electrosphere/game/config/item/type/Item.java b/src/main/java/electrosphere/game/data/item/type/Item.java similarity index 84% rename from src/main/java/electrosphere/game/config/item/type/Item.java rename to src/main/java/electrosphere/game/data/item/type/Item.java index f5658a7f..d86cbda8 100644 --- a/src/main/java/electrosphere/game/config/item/type/Item.java +++ b/src/main/java/electrosphere/game/data/item/type/Item.java @@ -1,7 +1,7 @@ -package electrosphere.game.config.item.type; +package electrosphere.game.data.item.type; import electrosphere.entity.types.hitbox.HitboxData; -import electrosphere.game.config.creature.type.CollidableTemplate; +import electrosphere.game.data.creature.type.CollidableTemplate; import java.util.List; public class Item { diff --git a/src/main/java/electrosphere/game/config/item/type/model/ItemTypeMap.java b/src/main/java/electrosphere/game/data/item/type/model/ItemTypeMap.java similarity index 79% rename from src/main/java/electrosphere/game/config/item/type/model/ItemTypeMap.java rename to src/main/java/electrosphere/game/data/item/type/model/ItemTypeMap.java index 59e9b4a6..3102db1d 100644 --- a/src/main/java/electrosphere/game/config/item/type/model/ItemTypeMap.java +++ b/src/main/java/electrosphere/game/data/item/type/model/ItemTypeMap.java @@ -1,6 +1,6 @@ -package electrosphere.game.config.item.type.model; +package electrosphere.game.data.item.type.model; -import electrosphere.game.config.item.type.Item; +import electrosphere.game.data.item.type.Item; import java.util.List; public class ItemTypeMap { diff --git a/src/main/java/electrosphere/game/config/structure/type/model/CollisionObjectTemplate.java b/src/main/java/electrosphere/game/data/structure/type/model/CollisionObjectTemplate.java similarity index 95% rename from src/main/java/electrosphere/game/config/structure/type/model/CollisionObjectTemplate.java rename to src/main/java/electrosphere/game/data/structure/type/model/CollisionObjectTemplate.java index 0e955246..7d68cc10 100644 --- a/src/main/java/electrosphere/game/config/structure/type/model/CollisionObjectTemplate.java +++ b/src/main/java/electrosphere/game/data/structure/type/model/CollisionObjectTemplate.java @@ -1,4 +1,4 @@ -package electrosphere.game.config.structure.type.model; +package electrosphere.game.data.structure.type.model; /** * diff --git a/src/main/java/electrosphere/game/config/structure/type/model/StructureType.java b/src/main/java/electrosphere/game/data/structure/type/model/StructureType.java similarity index 89% rename from src/main/java/electrosphere/game/config/structure/type/model/StructureType.java rename to src/main/java/electrosphere/game/data/structure/type/model/StructureType.java index 43d34f68..fca4dad1 100644 --- a/src/main/java/electrosphere/game/config/structure/type/model/StructureType.java +++ b/src/main/java/electrosphere/game/data/structure/type/model/StructureType.java @@ -1,4 +1,4 @@ -package electrosphere.game.config.structure.type.model; +package electrosphere.game.data.structure.type.model; import java.util.List; diff --git a/src/main/java/electrosphere/game/config/structure/type/model/StructureTypeMap.java b/src/main/java/electrosphere/game/data/structure/type/model/StructureTypeMap.java similarity index 89% rename from src/main/java/electrosphere/game/config/structure/type/model/StructureTypeMap.java rename to src/main/java/electrosphere/game/data/structure/type/model/StructureTypeMap.java index 48cc39f6..1f109842 100644 --- a/src/main/java/electrosphere/game/config/structure/type/model/StructureTypeMap.java +++ b/src/main/java/electrosphere/game/data/structure/type/model/StructureTypeMap.java @@ -1,4 +1,4 @@ -package electrosphere.game.config.structure.type.model; +package electrosphere.game.data.structure.type.model; import java.util.List; diff --git a/src/main/java/electrosphere/game/server/structure/virtual/VirtualStructureUtils.java b/src/main/java/electrosphere/game/server/structure/virtual/VirtualStructureUtils.java index dc24a1ab..02d227bc 100644 --- a/src/main/java/electrosphere/game/server/structure/virtual/VirtualStructureUtils.java +++ b/src/main/java/electrosphere/game/server/structure/virtual/VirtualStructureUtils.java @@ -1,7 +1,7 @@ package electrosphere.game.server.structure.virtual; import electrosphere.entity.types.structure.StructureUtils; -import electrosphere.game.config.structure.type.model.StructureType; +import electrosphere.game.data.structure.type.model.StructureType; import electrosphere.main.Globals; import electrosphere.game.server.character.Character; import java.util.LinkedList; diff --git a/src/main/java/electrosphere/game/state/MacroSimulation.java b/src/main/java/electrosphere/game/simulation/MacroSimulation.java similarity index 97% rename from src/main/java/electrosphere/game/state/MacroSimulation.java rename to src/main/java/electrosphere/game/simulation/MacroSimulation.java index 5308c0d2..46a28012 100644 --- a/src/main/java/electrosphere/game/state/MacroSimulation.java +++ b/src/main/java/electrosphere/game/simulation/MacroSimulation.java @@ -1,9 +1,9 @@ -package electrosphere.game.state; +package electrosphere.game.simulation; import electrosphere.game.server.civilization.Civilization; import electrosphere.game.server.civilization.model.CivilizationMap; -import electrosphere.game.config.creature.type.CreatureType; -import electrosphere.game.config.creature.type.model.CreatureTypeMap; +import electrosphere.game.data.creature.type.CreatureType; +import electrosphere.game.data.creature.type.model.CreatureTypeMap; import electrosphere.game.server.culture.Culture; import electrosphere.game.server.culture.religion.Religion; import electrosphere.game.server.structure.virtual.Structure; diff --git a/src/main/java/electrosphere/game/state/MicroSimulation.java b/src/main/java/electrosphere/game/simulation/MicroSimulation.java similarity index 95% rename from src/main/java/electrosphere/game/state/MicroSimulation.java rename to src/main/java/electrosphere/game/simulation/MicroSimulation.java index 226af865..733047f2 100644 --- a/src/main/java/electrosphere/game/state/MicroSimulation.java +++ b/src/main/java/electrosphere/game/simulation/MicroSimulation.java @@ -1,4 +1,4 @@ -package electrosphere.game.state; +package electrosphere.game.simulation; import electrosphere.entity.types.attach.AttachUtils; import electrosphere.entity.Entity; @@ -16,6 +16,7 @@ import electrosphere.entity.types.item.ItemUtils; import electrosphere.entity.types.life.LifeState; import electrosphere.entity.types.life.LifeUtils; import electrosphere.entity.types.particle.ParticleUtils; +import electrosphere.game.client.targeting.crosshair.Crosshair; import electrosphere.main.Globals; import static electrosphere.main.Main.deltaTime; import electrosphere.renderer.Actor; @@ -103,6 +104,11 @@ public class MicroSimulation { CollidableTree tree = EntityUtils.getCollidableTree(currentCollidable); tree.simulate(); } + //targeting crosshair + if(Globals.RUN_CLIENT){ + Crosshair.checkTargetable(); + Crosshair.updateTargetCrosshairPosition(); + } //clear collidable impulse lists Globals.collisionEngine.clearCollidableImpulseLists(); //delete all client side entities that aren't in visible chunks diff --git a/src/main/java/electrosphere/logger/LoggerInterface.java b/src/main/java/electrosphere/logger/LoggerInterface.java index 5a42efca..02a0353b 100644 --- a/src/main/java/electrosphere/logger/LoggerInterface.java +++ b/src/main/java/electrosphere/logger/LoggerInterface.java @@ -17,7 +17,7 @@ public class LoggerInterface { public static Logger loggerEngine; public static void initLoggers(){ - loggerNetworking = new Logger(LogLevel.DEBUG); + loggerNetworking = new Logger(LogLevel.WARNING); loggerFileIO = new Logger(LogLevel.WARNING); loggerGameLogic = new Logger(LogLevel.WARNING); loggerRenderer = new Logger(LogLevel.WARNING); diff --git a/src/main/java/electrosphere/main/Globals.java b/src/main/java/electrosphere/main/Globals.java index 3ffb7ae2..f9fb2c34 100644 --- a/src/main/java/electrosphere/main/Globals.java +++ b/src/main/java/electrosphere/main/Globals.java @@ -22,19 +22,19 @@ import electrosphere.engine.LoadingThread; import electrosphere.game.config.UserSettings; import electrosphere.game.server.ai.AIManager; 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.data.creature.type.model.CreatureTypeMap; +import electrosphere.game.data.item.type.model.ItemTypeMap; +import electrosphere.game.data.structure.type.model.StructureTypeMap; import electrosphere.game.server.db.DatabaseController; import electrosphere.game.server.structure.virtual.Structure; import electrosphere.game.server.structure.virtual.StructureManager; -import electrosphere.game.state.MacroSimulation; +import electrosphere.game.simulation.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.MacroData; import electrosphere.game.server.datacell.DataCellManager; -import electrosphere.game.state.MicroSimulation; +import electrosphere.game.simulation.MicroSimulation; import electrosphere.menu.Menu; import electrosphere.net.client.ClientNetworking; import electrosphere.net.server.Player; @@ -127,8 +127,8 @@ public class Globals { // // Game config // - public static electrosphere.game.config.Config gameConfigDefault; - public static electrosphere.game.config.Config gameConfigCurrent; + public static electrosphere.game.data.Config gameConfigDefault; + public static electrosphere.game.data.Config gameConfigCurrent; // // Database stuff @@ -300,8 +300,8 @@ public class Globals { 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; - public static boolean RENDER_FLAG_RENDER_BLACK_BACKGROUND = false; - public static boolean RENDER_FLAG_RENDER_WHITE_BACKGROUND = true; + public static boolean RENDER_FLAG_RENDER_BLACK_BACKGROUND = true; + public static boolean RENDER_FLAG_RENDER_WHITE_BACKGROUND = false; public static boolean RENDER_FLAG_RENDER_UI = true; @@ -333,7 +333,7 @@ public class Globals { //nav mesh manager navMeshManager = new NavMeshManager(); //game config - gameConfigDefault = electrosphere.game.config.Config.loadDefaultConfig(); + gameConfigDefault = electrosphere.game.data.Config.loadDefaultConfig(); gameConfigCurrent = gameConfigDefault; //player manager playerManager = new PlayerManager(); diff --git a/src/main/java/electrosphere/main/Main.java b/src/main/java/electrosphere/main/Main.java index 2efe7ffc..8339bf3b 100644 --- a/src/main/java/electrosphere/main/Main.java +++ b/src/main/java/electrosphere/main/Main.java @@ -23,8 +23,8 @@ import electrosphere.game.server.saves.SaveUtils; import electrosphere.game.server.terrain.manager.ServerTerrainManager; import electrosphere.game.server.world.MacroData; import electrosphere.game.server.world.ServerWorldData; -import electrosphere.game.state.MacroSimulation; -import electrosphere.game.state.MicroSimulation; +import electrosphere.game.simulation.MacroSimulation; +import electrosphere.game.simulation.MicroSimulation; import electrosphere.logger.LoggerInterface; import electrosphere.renderer.RenderingEngine; import electrosphere.util.FileUtils; diff --git a/src/main/java/electrosphere/renderer/RenderingEngine.java b/src/main/java/electrosphere/renderer/RenderingEngine.java index 6c46112f..9da3bbab 100644 --- a/src/main/java/electrosphere/renderer/RenderingEngine.java +++ b/src/main/java/electrosphere/renderer/RenderingEngine.java @@ -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.config.creature.type.CollidableTemplate; +import electrosphere.game.data.creature.type.CollidableTemplate; import electrosphere.game.server.pathfinding.navmesh.NavCube; import electrosphere.game.server.pathfinding.navmesh.NavMesh; import electrosphere.game.server.pathfinding.navmesh.NavShape; diff --git a/src/main/java/electrosphere/util/worldviewer/TerrainViewer.java b/src/main/java/electrosphere/util/worldviewer/TerrainViewer.java index 10a27bc8..6e716e7b 100644 --- a/src/main/java/electrosphere/util/worldviewer/TerrainViewer.java +++ b/src/main/java/electrosphere/util/worldviewer/TerrainViewer.java @@ -1,7 +1,7 @@ package electrosphere.util.worldviewer; import com.google.gson.Gson; -import electrosphere.game.state.MacroSimulation; +import electrosphere.game.simulation.MacroSimulation; import electrosphere.game.server.terrain.manager.ServerTerrainManager; import electrosphere.game.server.terrain.models.TerrainModel; import electrosphere.main.Globals;