Fix items networking
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-04-21 17:41:50 -04:00
parent 597a969151
commit a1d03ef59e
125 changed files with 936 additions and 453 deletions

View File

@ -116,7 +116,7 @@
"variants" : [ "variants" : [
{ {
"id" : "hairshort1", "id" : "hairshort1",
"model" : "Models/hairshort1meshed.fbx", "model" : "Models/creatures/person2/hair/hairshort1meshed.fbx",
"meshes" : [ "meshes" : [
"Hair" "Hair"
] ]

View File

@ -116,7 +116,7 @@
"variants" : [ "variants" : [
{ {
"id" : "hairshort1", "id" : "hairshort1",
"model" : "Models/hairshort1meshed.fbx", "model" : "Models/creatures/person2/hair/hairshort1meshed.fbx",
"meshes" : [ "meshes" : [
"Hair" "Hair"
] ]
@ -334,7 +334,7 @@
"maxHealth" : 100, "maxHealth" : 100,
"onDamageIFrames" : 30 "onDamageIFrames" : 30
}, },
"modelPath" : "Models/person2_1.glb" "modelPath" : "Models/creatures/person2/person2_1.glb"
} }
], ],
"files" : [] "files" : []

View File

@ -29,7 +29,7 @@
"growthModel": { "growthModel": {
"growthRate" : 0.001 "growthRate" : 0.001
}, },
"modelPath" : "Models/grass2.fbx" "modelPath" : "Models/foliage/grass2.fbx"
}, },
{ {
"name" : "oak", "name" : "oak",

View File

@ -84,7 +84,7 @@
{ {
"itemId" : "shorts1", "itemId" : "shorts1",
"modelPath": "Models/itemEntityShorts.fbx", "modelPath": "Models/items/itemEntityShorts.fbx",
"tokens" : [ "tokens" : [
"GRAVITY", "GRAVITY",
"TARGETABLE" "TARGETABLE"
@ -107,7 +107,7 @@
"equipWhitelist" : [ "equipWhitelist" : [
{ {
"creatureId" : "human", "creatureId" : "human",
"model" : "Models/shorts1.fbx", "model" : "Models/creatures/person2/clothing/shorts1.fbx",
"meshList" : [ "meshList" : [
"ClothingItem" "ClothingItem"
], ],
@ -155,7 +155,7 @@
{ {
"itemId" : "boots1", "itemId" : "boots1",
"modelPath": "Models/itemEntityShorts.fbx", "modelPath": "Models/boots1.glb",
"tokens" : [ "tokens" : [
"GRAVITY", "GRAVITY",
"ARMOR", "ARMOR",
@ -179,16 +179,12 @@
"equipWhitelist" : [ "equipWhitelist" : [
{ {
"creatureId" : "human", "creatureId" : "human",
"model" : "Models/boots1.fbx", "model" : "Models/boots1.glb",
"meshList" : [ "meshList" : [
"BootLeft", "BootLeft",
"BootRight" "BootRight"
], ],
"meshMaskList" : [ "meshMaskList" : [
"FootLeft",
"FootRight",
"LowerLegLeft",
"LowerLegRight"
] ]
} }
] ]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

@ -67,7 +67,7 @@
] ]
}, },
{ {
"path" : "Models/person2_1.glb", "path" : "Models/creatures/person2/person2_1.glb",
"globalTransform": { "globalTransform": {
"rotation" : [0,0,0,1], "rotation" : [0,0,0,1],
"offset" : [0.0, 0.0, 0.0], "offset" : [0.0, 0.0, 0.0],
@ -77,7 +77,7 @@
] ]
}, },
{ {
"path" : "Models/grass2.fbx", "path" : "Models/foliage/grass2.fbx",
"globalTransform": { "globalTransform": {
"rotation" : [0.0, 0.0, 0.0, 1.0], "rotation" : [0.0, 0.0, 0.0, 1.0],
"offset" : [0.0, 0.0, 0.0], "offset" : [0.0, 0.0, 0.0],

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -30,7 +30,7 @@
"/Textures/transparent_blue.png" "/Textures/transparent_blue.png"
] ]
}, },
"Models/unitsphere_1.fbx": { "Models/basic/geometry/unitsphere_1.fbx": {
"Sphere": [ "Sphere": [
"/Textures/transparent_red.png", "/Textures/transparent_red.png",
"/Textures/transparent_red.png" "/Textures/transparent_red.png"
@ -324,19 +324,19 @@
"/Textures/arrow1.png" "/Textures/arrow1.png"
] ]
}, },
"Models/lockoncrosshair1.fbx" : { "Models/engine/lockoncrosshair1.fbx" : {
"Cube" : [ "Cube" : [
"/Textures/w1.png", "/Textures/w1.png",
"/Textures/w1.png" "/Textures/w1.png"
] ]
}, },
"Models/shorts1.fbx" : { "Models/creatures/person2/clothing/shorts1.fbx" : {
"ClothingItem" : [ "ClothingItem" : [
"/Textures/shorts1.png", "/Textures/shorts1.png",
"/Textures/shorts1.png" "/Textures/shorts1.png"
] ]
}, },
"Models/hairshort1meshed.fbx" : { "Models/creatures/person2/hair/hairshort1meshed.fbx" : {
"Hair" : [ "Hair" : [
"/Textures/b1.png", "/Textures/b1.png",
"/Textures/b1.png" "/Textures/b1.png"
@ -358,13 +358,13 @@
"/Textures/shirt1.png" "/Textures/shirt1.png"
] ]
}, },
"Models/cloudRing.fbx" : { "Models/environment/cloudRing.fbx" : {
"Sphere" : [ "Sphere" : [
"/Textures/cloudRing.png", "/Textures/cloudRing.png",
"/Textures/cloudRing.png" "/Textures/cloudRing.png"
] ]
}, },
"Models/skyboxSphere.fbx" : { "Models/environment/skyboxSphere.fbx" : {
"Sphere" : [ "Sphere" : [
"/Textures/starrySky.png", "/Textures/starrySky.png",
"/Textures/starrySky.png" "/Textures/starrySky.png"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 440 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 380 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

View File

@ -0,0 +1,32 @@
@page equipstate Equip State
# Relevant Classes
# Data Explanation
## Item-side definitions
Items must define a property `equipClass`. This determines what type of item it is.
The equip points on the creature then whitelist equipClass variants.
IE, I would define a sword as a "weapon", then assign the item type "weapon" to a given equippoint (ie the person's hand).
Furthermore, a creature can define a `equipWhitelist` array. This allows you to define per-item what creatures can equip it.
The goal with this is to limit item equipping when we haven't modeled out a variant for a given creature.
IE, if you make a cool helmet for a human and don't bother to make one for dwarves, you could equipWhitelist it to just humans.
## Creature-side definitions
Creatures define an array `equipPoints`. This contains a list of points that the creature can equip items at.
A given equipPoint controls the bone the item is attached to, offsets/rotations from that bone, and the types of equipment that can be attached at that point.
## Equip Classes
They're basically category strings. There isn't any data intrinsic to an equipClass yet.
Potentially these will eventually be broken out into a dedicated data object to support things like tooltips.

View File

@ -12,6 +12,7 @@ Discussion of, at a high game-design level, how everything should work and conne
- @subpage macrosimtimeline - @subpage macrosimtimeline
- @subpage narrativemanager - @subpage narrativemanager
- @subpage itemsindex - @subpage itemsindex
- @subpage equipstate
- @subpage puzzleindex - @subpage puzzleindex
- @subpage fluidindex - @subpage fluidindex
- @subpage locomotion - @subpage locomotion

View File

@ -220,8 +220,18 @@ UI Work
- Level editor ability to destroy an entity on server, have it also destroy on client, AND not persist on save - Level editor ability to destroy an entity on server, have it also destroy on client, AND not persist on save
- Environment controls (not persisting in save yet) - Environment controls (not persisting in save yet)
Fix Movement Bug where player keeps running after releasing control
# TODO # TODO
UI Fixes
- Refactor ui toolkit elements to separate absolute and relative position
- Fix inventory menus
Touch Up working with items
- Make sure the models are appropriately scaled
- Remove all logic from before client-server separation
More Debug menus More Debug menus
- Screen that shows the overall status of client scene - Screen that shows the overall status of client scene
- Number of entities - Number of entities

View File

@ -25,7 +25,7 @@ public class Crosshair {
public static void initCrossHairEntity(){ public static void initCrossHairEntity(){
crossHairEntity = EntityCreationUtils.createClientSpatialEntity(); crossHairEntity = EntityCreationUtils.createClientSpatialEntity();
EntityCreationUtils.makeEntityDrawable(crossHairEntity, "/Models/lockoncrosshair1.fbx"); EntityCreationUtils.makeEntityDrawable(crossHairEntity, "/Models/engine/lockoncrosshair1.fbx");
EntityUtils.setVisible(crossHairEntity, false); EntityUtils.setVisible(crossHairEntity, false);
} }

View File

@ -81,7 +81,7 @@ import electrosphere.entity.Entity;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.attack.AttackTree; import electrosphere.entity.state.attack.AttackTree;
import electrosphere.entity.state.attack.ShooterTree; import electrosphere.entity.state.attack.ShooterTree;
import electrosphere.entity.state.equip.EquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.inventory.InventoryUtils; import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.state.inventory.UnrelationalInventoryState; import electrosphere.entity.state.inventory.UnrelationalInventoryState;
import electrosphere.entity.state.ironsight.IronSightTree; import electrosphere.entity.state.ironsight.IronSightTree;
@ -821,9 +821,9 @@ public class ControlHandler {
mainGameControlList.add(controls.get(INPUT_CODE_INTERACT)); mainGameControlList.add(controls.get(INPUT_CODE_INTERACT));
controls.get(INPUT_CODE_INTERACT).setOnPress(new ControlMethod(){public void execute(){ controls.get(INPUT_CODE_INTERACT).setOnPress(new ControlMethod(){public void execute(){
if(Globals.playerEntity != null){ if(Globals.playerEntity != null){
if(EquipState.hasEquipState(Globals.playerEntity) && Crosshair.hasTarget()){ if(ClientEquipState.hasEquipState(Globals.playerEntity) && Crosshair.hasTarget()){
if(InventoryUtils.hasNaturalInventory(Globals.playerEntity)){ if(InventoryUtils.hasNaturalInventory(Globals.playerEntity)){
InventoryUtils.attemptStoreItem(Globals.playerEntity, Crosshair.getTarget()); InventoryUtils.clientAttemptStoreItem(Globals.playerEntity, Crosshair.getTarget());
} }
} }
} }
@ -835,11 +835,11 @@ public class ControlHandler {
mainGameControlList.add(controls.get(INPUT_CODE_DROP)); mainGameControlList.add(controls.get(INPUT_CODE_DROP));
controls.get(INPUT_CODE_DROP).setOnPress(new ControlMethod(){public void execute(){ controls.get(INPUT_CODE_DROP).setOnPress(new ControlMethod(){public void execute(){
if(Globals.playerEntity != null){ if(Globals.playerEntity != null){
if(EquipState.hasEquipState(Globals.playerEntity)){ if(ClientEquipState.hasEquipState(Globals.playerEntity)){
UnrelationalInventoryState inventory = InventoryUtils.getNaturalInventory(Globals.playerEntity); UnrelationalInventoryState inventory = InventoryUtils.getNaturalInventory(Globals.playerEntity);
if(inventory.getItems().size() > 0){ if(inventory.getItems().size() > 0){
Entity itemToDrop = inventory.getItems().get(0); Entity itemToDrop = inventory.getItems().get(0);
InventoryUtils.attemptEjectItem(Globals.playerEntity,itemToDrop); InventoryUtils.clientAttemptEjectItem(Globals.playerEntity,itemToDrop);
} }
} }
} }
@ -1081,15 +1081,15 @@ public class ControlHandler {
controls.get(DATA_STRING_INPUT_CODE_MENU_INCREMENT).setOnPress(new ControlMethod(){public void execute(){ controls.get(DATA_STRING_INPUT_CODE_MENU_INCREMENT).setOnPress(new ControlMethod(){public void execute(){
Globals.elementManager.fireEvent( Globals.elementManager.fireEvent(
new MenuEvent(MenuEventType.INCREMENT), new MenuEvent(MenuEventType.INCREMENT),
Globals.elementManager.getFocusedElement().getPositionX(), Globals.elementManager.getFocusedElement().getAbsoluteX(),
Globals.elementManager.getFocusedElement().getPositionY() Globals.elementManager.getFocusedElement().getAbsoluteY()
); );
}}); }});
controls.get(DATA_STRING_INPUT_CODE_MENU_INCREMENT).setOnRepeat(new ControlMethod(){public void execute(){ controls.get(DATA_STRING_INPUT_CODE_MENU_INCREMENT).setOnRepeat(new ControlMethod(){public void execute(){
Globals.elementManager.fireEvent( Globals.elementManager.fireEvent(
new MenuEvent(MenuEventType.INCREMENT), new MenuEvent(MenuEventType.INCREMENT),
Globals.elementManager.getFocusedElement().getPositionX(), Globals.elementManager.getFocusedElement().getAbsoluteX(),
Globals.elementManager.getFocusedElement().getPositionY() Globals.elementManager.getFocusedElement().getAbsoluteY()
); );
}}); }});
controls.get(DATA_STRING_INPUT_CODE_MENU_INCREMENT).setRepeatTimeout(0.5f * Main.targetFrameRate); controls.get(DATA_STRING_INPUT_CODE_MENU_INCREMENT).setRepeatTimeout(0.5f * Main.targetFrameRate);
@ -1141,15 +1141,15 @@ public class ControlHandler {
controls.get(DATA_STRING_INPUT_CODE_MENU_DECREMENT).setOnPress(new ControlMethod(){public void execute(){ controls.get(DATA_STRING_INPUT_CODE_MENU_DECREMENT).setOnPress(new ControlMethod(){public void execute(){
Globals.elementManager.fireEvent( Globals.elementManager.fireEvent(
new MenuEvent(MenuEventType.DECREMENT), new MenuEvent(MenuEventType.DECREMENT),
Globals.elementManager.getFocusedElement().getPositionX(), Globals.elementManager.getFocusedElement().getAbsoluteX(),
Globals.elementManager.getFocusedElement().getPositionY() Globals.elementManager.getFocusedElement().getAbsoluteY()
); );
}}); }});
controls.get(DATA_STRING_INPUT_CODE_MENU_DECREMENT).setOnRepeat(new ControlMethod(){public void execute(){ controls.get(DATA_STRING_INPUT_CODE_MENU_DECREMENT).setOnRepeat(new ControlMethod(){public void execute(){
Globals.elementManager.fireEvent( Globals.elementManager.fireEvent(
new MenuEvent(MenuEventType.DECREMENT), new MenuEvent(MenuEventType.DECREMENT),
Globals.elementManager.getFocusedElement().getPositionX(), Globals.elementManager.getFocusedElement().getAbsoluteX(),
Globals.elementManager.getFocusedElement().getPositionY() Globals.elementManager.getFocusedElement().getAbsoluteY()
); );
}}); }});
controls.get(DATA_STRING_INPUT_CODE_MENU_DECREMENT).setRepeatTimeout(0.5f * Main.targetFrameRate); controls.get(DATA_STRING_INPUT_CODE_MENU_DECREMENT).setRepeatTimeout(0.5f * Main.targetFrameRate);

View File

@ -513,13 +513,13 @@ public class Globals {
//init fluid shader program //init fluid shader program
FluidChunkModelGeneration.fluidChunkShaderProgram = ShaderProgram.loadSpecificShader("/Shaders/fluid2/fluid2.vs", "/Shaders/fluid2/fluid2.fs"); FluidChunkModelGeneration.fluidChunkShaderProgram = ShaderProgram.loadSpecificShader("/Shaders/fluid2/fluid2.vs", "/Shaders/fluid2/fluid2.fs");
//init models //init models
assetManager.addModelPathToQueue("Models/unitsphere.fbx"); assetManager.addModelPathToQueue("Models/basic/geometry/unitsphere.fbx");
assetManager.addModelPathToQueue("Models/unitsphere_1.fbx"); assetManager.addModelPathToQueue("Models/basic/geometry/unitsphere_1.fbx");
assetManager.addModelPathToQueue("Models/unitsphere_grey.fbx"); assetManager.addModelPathToQueue("Models/basic/geometry/unitsphere_grey.fbx");
assetManager.addModelPathToQueue("Models/SmallCube.fbx"); assetManager.addModelPathToQueue("Models/basic/geometry/SmallCube.fbx");
assetManager.addModelPathToQueue("Models/unitcylinder.fbx"); assetManager.addModelPathToQueue("Models/basic/geometry/unitcylinder.fbx");
assetManager.addModelPathToQueue("Models/unitplane.fbx"); assetManager.addModelPathToQueue("Models/basic/geometry/unitplane.fbx");
assetManager.addModelPathToQueue("Models/unitcube.fbx"); assetManager.addModelPathToQueue("Models/basic/geometry/unitcube.fbx");
imagePlaneModelID = assetManager.registerModel(RenderUtils.createPlaneModel("Shaders/plane/plane.vs", "Shaders/plane/plane.fs")); imagePlaneModelID = assetManager.registerModel(RenderUtils.createPlaneModel("Shaders/plane/plane.vs", "Shaders/plane/plane.fs"));
assetManager.addShaderToQueue("Shaders/plane/plane.vs", null, "Shaders/plane/plane.fs"); assetManager.addShaderToQueue("Shaders/plane/plane.vs", null, "Shaders/plane/plane.fs");
solidPlaneModelID = assetManager.registerModel(RenderUtils.createInWindowPanel("Shaders/ui/plainBox/plainBox.vs", "Shaders/ui/plainBox/plainBox.fs")); solidPlaneModelID = assetManager.registerModel(RenderUtils.createInWindowPanel("Shaders/ui/plainBox/plainBox.vs", "Shaders/ui/plainBox/plainBox.fs"));

View File

@ -209,23 +209,23 @@ public class ClientLoading {
//starry sky true skybox //starry sky true skybox
Entity skybox = EntityCreationUtils.createClientSpatialEntity(); Entity skybox = EntityCreationUtils.createClientSpatialEntity();
EntityCreationUtils.makeEntityDrawable(skybox, "Models/skyboxSphere.fbx"); EntityCreationUtils.makeEntityDrawable(skybox, "Models/environment/skyboxSphere.fbx");
DrawableUtils.disableCulling(skybox); DrawableUtils.disableCulling(skybox);
EntityUtils.getRotation(skybox).rotateX((float)(-Math.PI/2.0f)); EntityUtils.getRotation(skybox).rotateX((float)(-Math.PI/2.0f));
EntityUtils.getScale(skybox).mul(200000.0f); EntityUtils.getScale(skybox).mul(200000.0f);
Globals.assetManager.queueOverrideMeshShader("Models/skyboxSphere.fbx", "Sphere", "Shaders/skysphere/skysphere.vs", "Shaders/skysphere/skysphere.fs"); Globals.assetManager.queueOverrideMeshShader("Models/environment/skyboxSphere.fbx", "Sphere", "Shaders/skysphere/skysphere.vs", "Shaders/skysphere/skysphere.fs");
//cloud ring pseudo skybox //cloud ring pseudo skybox
Entity cloudRing = EntityCreationUtils.createClientSpatialEntity(); Entity cloudRing = EntityCreationUtils.createClientSpatialEntity();
EntityCreationUtils.makeEntityDrawable(cloudRing, "Models/cloudRing.fbx"); EntityCreationUtils.makeEntityDrawable(cloudRing, "Models/environment/cloudRing.fbx");
DrawableUtils.disableCulling(cloudRing); DrawableUtils.disableCulling(cloudRing);
EntityUtils.getRotation(cloudRing).rotateX((float)(-Math.PI/2.0f)); EntityUtils.getRotation(cloudRing).rotateX((float)(-Math.PI/2.0f));
EntityUtils.getScale(cloudRing).mul(100000.0f); EntityUtils.getScale(cloudRing).mul(100000.0f);
Globals.clientScene.registerBehaviorTree(new ApplyRotationTree(cloudRing,new Quaterniond().rotationZ(0.0001))); Globals.clientScene.registerBehaviorTree(new ApplyRotationTree(cloudRing,new Quaterniond().rotationZ(0.0001)));
Globals.assetManager.queueOverrideMeshShader("Models/cloudRing.fbx", "Sphere", "Shaders/skysphere/skysphere.vs", "Shaders/skysphere/skysphere.fs"); Globals.assetManager.queueOverrideMeshShader("Models/environment/cloudRing.fbx", "Sphere", "Shaders/skysphere/skysphere.vs", "Shaders/skysphere/skysphere.fs");
Entity cursorTracker = EntityCreationUtils.createClientSpatialEntity(); Entity cursorTracker = EntityCreationUtils.createClientSpatialEntity();
EntityCreationUtils.makeEntityDrawable(cursorTracker, "Models/unitsphere_1.fbx"); EntityCreationUtils.makeEntityDrawable(cursorTracker, "Models/basic/geometry/unitsphere_1.fbx");
EntityUtils.getScale(cursorTracker).set(30f); EntityUtils.getScale(cursorTracker).set(30f);
Globals.clientSceneWrapper.getScene().registerBehaviorTree(new BehaviorTree() { Globals.clientSceneWrapper.getScene().registerBehaviorTree(new BehaviorTree() {
@Override @Override

View File

@ -54,8 +54,10 @@ public class Scene {
* @param e The entity to register * @param e The entity to register
*/ */
public void registerEntity(Entity e){ public void registerEntity(Entity e){
if(!entityIdMap.containsKey(e.getId())){
entityList.add(e);
}
entityIdMap.put(e.getId(), e); entityIdMap.put(e.getId(), e);
entityList.add(e);
} }
/** /**

View File

@ -9,7 +9,7 @@ import electrosphere.entity.EntityUtils;
import electrosphere.entity.ServerEntityUtils; import electrosphere.entity.ServerEntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.collidable.Impulse; import electrosphere.entity.state.collidable.Impulse;
import electrosphere.entity.state.equip.EquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.movement.groundmove.GroundMovementTree; import electrosphere.entity.state.movement.groundmove.GroundMovementTree;
import electrosphere.entity.state.rotator.RotatorTree; import electrosphere.entity.state.rotator.RotatorTree;
import electrosphere.entity.types.attach.AttachUtils; import electrosphere.entity.types.attach.AttachUtils;
@ -299,7 +299,7 @@ public class AttackTree implements BehaviorTree {
Vector3d spawnPosition = new Vector3d(0,0,0); Vector3d spawnPosition = new Vector3d(0,0,0);
Quaterniond arrowRotation = new Quaterniond(); Quaterniond arrowRotation = new Quaterniond();
String targetBone = null; String targetBone = null;
EquipState equipState = EquipState.getEquipState(parent); ClientEquipState equipState = ClientEquipState.getEquipState(parent);
EquipPoint weaponPoint = null; EquipPoint weaponPoint = null;
if((weaponPoint = equipState.getEquipPoint(attackingPoint)) != null){ if((weaponPoint = equipState.getEquipPoint(attackingPoint)) != null){
targetBone = weaponPoint.getBone(); targetBone = weaponPoint.getBone();
@ -395,8 +395,8 @@ public class AttackTree implements BehaviorTree {
String getAttackType(){ String getAttackType(){
String rVal = null; String rVal = null;
if(EquipState.hasEquipState(parent)){ if(ClientEquipState.hasEquipState(parent)){
EquipState equipState = EquipState.getEquipState(parent); ClientEquipState equipState = ClientEquipState.getEquipState(parent);
for(String point : equipState.equippedPoints()){ for(String point : equipState.equippedPoints()){
Entity item = equipState.getEquippedItemAtPoint(point); Entity item = equipState.getEquippedItemAtPoint(point);
if(ItemUtils.isWeapon(item)){ if(ItemUtils.isWeapon(item)){
@ -430,8 +430,8 @@ public class AttackTree implements BehaviorTree {
rVal = true; rVal = true;
} }
} else { } else {
if(EquipState.hasEquipState(parent)){ if(ClientEquipState.hasEquipState(parent)){
EquipState equipState = EquipState.getEquipState(parent); ClientEquipState equipState = ClientEquipState.getEquipState(parent);
// if(equipState.hasEquipPrimary()){ // if(equipState.hasEquipPrimary()){
// switch(attackType){ // switch(attackType){
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND: // case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:

View File

@ -9,7 +9,7 @@ import electrosphere.entity.EntityUtils;
import electrosphere.entity.ServerEntityUtils; import electrosphere.entity.ServerEntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.collidable.Impulse; import electrosphere.entity.state.collidable.Impulse;
import electrosphere.entity.state.equip.EquipState; import electrosphere.entity.state.equip.ServerEquipState;
import electrosphere.entity.state.movement.groundmove.GroundMovementTree; import electrosphere.entity.state.movement.groundmove.GroundMovementTree;
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree; import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
import electrosphere.entity.state.rotator.RotatorTree; import electrosphere.entity.state.rotator.RotatorTree;
@ -300,7 +300,7 @@ public class ServerAttackTree implements BehaviorTree {
Vector3d spawnPosition = new Vector3d(0,0,0); Vector3d spawnPosition = new Vector3d(0,0,0);
Quaterniond arrowRotation = new Quaterniond(); Quaterniond arrowRotation = new Quaterniond();
String targetBone = null; String targetBone = null;
EquipState equipState = EquipState.getEquipState(parent); ServerEquipState equipState = ServerEquipState.getEquipState(parent);
EquipPoint weaponPoint = null; EquipPoint weaponPoint = null;
if((weaponPoint = equipState.getEquipPoint(attackingPoint)) != null){ if((weaponPoint = equipState.getEquipPoint(attackingPoint)) != null){
targetBone = weaponPoint.getBone(); targetBone = weaponPoint.getBone();
@ -393,8 +393,8 @@ public class ServerAttackTree implements BehaviorTree {
String getAttackType(){ String getAttackType(){
String rVal = null; String rVal = null;
if(EquipState.hasEquipState(parent)){ if(ServerEquipState.hasEquipState(parent)){
EquipState equipState = EquipState.getEquipState(parent); ServerEquipState equipState = ServerEquipState.getEquipState(parent);
for(String point : equipState.equippedPoints()){ for(String point : equipState.equippedPoints()){
Entity item = equipState.getEquippedItemAtPoint(point); Entity item = equipState.getEquippedItemAtPoint(point);
if(ItemUtils.isWeapon(item)){ if(ItemUtils.isWeapon(item)){
@ -428,8 +428,8 @@ public class ServerAttackTree implements BehaviorTree {
rVal = true; rVal = true;
} }
} else { } else {
if(EquipState.hasEquipState(parent)){ if(ServerEquipState.hasEquipState(parent)){
EquipState equipState = EquipState.getEquipState(parent); ServerEquipState equipState = ServerEquipState.getEquipState(parent);
// if(equipState.hasEquipPrimary()){ // if(equipState.hasEquipPrimary()){
// switch(attackType){ // switch(attackType){
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND: // case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:

View File

@ -0,0 +1,262 @@
package electrosphere.entity.state.equip;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.ode4j.ode.DBody;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityTags;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.gravity.GravityUtils;
import electrosphere.entity.types.attach.AttachUtils;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.game.data.creature.type.equip.EquipPoint;
import electrosphere.game.data.item.type.EquipWhitelist;
import electrosphere.net.parser.net.message.InventoryMessage;
import electrosphere.net.parser.net.message.NetworkMessage;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
import electrosphere.renderer.actor.Actor;
import electrosphere.renderer.actor.ActorMeshMask;
@SynchronizedBehaviorTree(name = "clientEquipState", isServer = false, correspondingTree="serverEquipState")
/**
* Client view of items equipped to a given entity
*/
public class ClientEquipState {
Entity parent;
List<EquipPoint> equipPoints = new LinkedList<EquipPoint>();
Map<String,Entity> equipMap = new HashMap<String,Entity>();
public ClientEquipState(Entity parent, List<EquipPoint> equipPoints){
this.parent = parent;
for(EquipPoint point : equipPoints){
this.equipPoints.add(point);
}
}
public List<String> equippedPoints(){
return new LinkedList<String>(equipMap.keySet());
}
public void commandAttemptEquip(Entity toEquip, EquipPoint point){
boolean hasEquipped = hasEquippedAtPoint(point.getEquipPointId());
boolean targetIsItem = ItemUtils.isItem(toEquip);
boolean targetIsAttached = AttachUtils.isAttached(toEquip);
boolean targetHasWhitelist = ItemUtils.hasEquipList(toEquip);
String equipItemClass = ItemUtils.getEquipClass(toEquip);
List<String> pointEquipClassList = point.getEquipClassWhitelist();
boolean itemIsInPointWhitelist = pointEquipClassList.contains(equipItemClass);
if(!hasEquipped && targetIsItem && !targetIsAttached && itemIsInPointWhitelist){
//send packet to server requesting to equip
String pointName = point.getEquipPointId();
int serverSideID = Globals.clientSceneWrapper.mapClientToServerId(toEquip.getId());
NetworkMessage requestPickupMessage = InventoryMessage.constructclientRequestEquipItemMessage(pointName, serverSideID);
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage);
}
}
public void clientAttemptEquip(Entity toEquip, EquipPoint point){
boolean hasEquipped = hasEquippedAtPoint(point.getEquipPointId());
boolean targetIsItem = ItemUtils.isItem(toEquip);
boolean targetIsAttached = AttachUtils.isAttached(toEquip);
boolean targetHasWhitelist = ItemUtils.hasEquipList(toEquip);
String equipItemClass = ItemUtils.getEquipClass(toEquip);
List<String> pointEquipClassList = point.getEquipClassWhitelist();
boolean itemIsInPointWhitelist = pointEquipClassList.contains(equipItemClass);
if(!hasEquipped && targetIsItem && !targetIsAttached && itemIsInPointWhitelist){
if(targetHasWhitelist){
//by attaching are we going to be replacing meshes?
String parentCreatureId = CreatureUtils.getType(parent);
List<EquipWhitelist> whitelist = ItemUtils.getEquipWhitelist(toEquip);
for(EquipWhitelist whitelistItem : whitelist){
if(whitelistItem.getCreatureId().equals(parentCreatureId)){
//put in map
equipMap.put(point.getEquipPointId(),toEquip);
String modelName = whitelistItem.getModel();
Globals.assetManager.addModelPathToQueue(modelName);
Actor parentActor = EntityUtils.getActor(parent);
//queue meshes from display model to parent actor
ActorMeshMask meshMask = parentActor.getMeshMask();
for(String toBlock : whitelistItem.getMeshMaskList()){
meshMask.blockMesh(modelName, toBlock);
}
for(String toDraw : whitelistItem.getMeshList()){
meshMask.queueMesh(modelName, toDraw);
}
//attach to parent bone
AttachUtils.clientAttachEntityToEntityAtBone(parent, toEquip, point.getBone(), AttachUtils.getEquipPointRotationOffset(point.getOffsetRotation()));
//make uncollidable
if(toEquip.containsKey(EntityDataStrings.PHYSICS_COLLISION_BODY) && toEquip.containsKey(EntityDataStrings.PHYSICS_COLLIDABLE)){
DBody rigidBody = (DBody)toEquip.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
Globals.clientSceneWrapper.getCollisionEngine().deregisterPhysicsObject(rigidBody);
}
//hide toEquip actor
EntityUtils.setDraw(toEquip, false);
//make untargetable
Globals.clientSceneWrapper.getScene().removeEntityFromTag(toEquip, EntityTags.TARGETABLE);
break;
}
}
} else {
//since we're not replacing meshes we must be attaching to a bone
equipMap.put(point.getEquipPointId(),toEquip);
AttachUtils.clientAttachEntityToEntityAtBone(parent, toEquip, point.getBone(), AttachUtils.getEquipPointRotationOffset(point.getOffsetRotation()));
if(toEquip.containsKey(EntityDataStrings.PHYSICS_COLLISION_BODY) && toEquip.containsKey(EntityDataStrings.PHYSICS_COLLIDABLE)){
DBody rigidBody = (DBody)toEquip.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
Globals.clientSceneWrapper.getCollisionEngine().deregisterPhysicsObject(rigidBody);
}
Globals.clientSceneWrapper.getScene().removeEntityFromTag(toEquip, EntityTags.TARGETABLE);
GravityUtils.clientAttemptDeactivateGravity(toEquip);
}
}
// if(!hasEquipPrimary() && ItemUtils.isItem(toEquip) && !AttachUtils.isAttached(toEquip)){
// if(ItemUtils.hasEquipList(toEquip)){
// String parentCreatureId = CreatureUtils.getType(parent);
// List<EquipWhitelist> whitelist = ItemUtils.getEquipWhitelist(toEquip);
// for(EquipWhitelist whitelistItem : whitelist){
// if(whitelistItem.getCreatureId().equals(parentCreatureId)){
// equipPrimary = toEquip;
// String modelName = whitelistItem.getModel();
// Globals.assetManager.addModelPathToQueue(modelName);
// Actor parentActor = EntityUtils.getActor(parent);
// //queue meshes from display model to parent actor
// ActorMeshMask meshMask = parentActor.getMeshMask();
// for(String toBlock : whitelistItem.getMeshMaskList()){
// meshMask.blockMesh(modelName, toBlock);
// }
// for(String toDraw : whitelistItem.getMeshList()){
// meshMask.queueMesh(modelName, toDraw);
// }
// //attach to parent bone
// AttachUtils.attachEntityToEntityAtBone(parent, toEquip, equipPrimaryBoneName);
// //make uncollidable
// if(toEquip.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLISION_BODY) && toEquip.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLIDABLE)){
// CollisionObject rigidBody = (CollisionObject)toEquip.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
// Globals.collisionEngine.deregisterPhysicsObject(rigidBody);
// }
// //hide toEquip actor
// EntityUtils.setDraw(toEquip, false);
// //make untargetable
// Globals.entityManager.setTargetable(equipPrimary, false);
// break;
// }
// }
// } else {
// equipPrimary = toEquip;
// AttachUtils.attachEntityToEntityAtBone(parent, toEquip, equipPrimaryBoneName);
// if(toEquip.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLISION_BODY) && toEquip.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLIDABLE)){
// CollisionObject rigidBody = (CollisionObject)toEquip.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
// Globals.collisionEngine.deregisterPhysicsObject(rigidBody);
// }
// Globals.entityManager.setTargetable(equipPrimary, false);
// }
// }
}
public EquipPoint getEquipPoint(String name){
for(EquipPoint point : equipPoints){
if(point.getEquipPointId().equals(name)){
return point;
}
}
return null;
}
public Entity getEquippedItemAtPoint(String point){
return equipMap.get(point);
}
/**
* Returns whether the entity has an equip state
* @param entity The entity to check
* @return True if the entity contains an equip state, false otherwise
*/
public static boolean hasEquipState(Entity entity){
return entity.containsKey(EntityDataStrings.EQUIP_STATE);
}
/**
* Gets the equip state on the entity
* @param entity The entity to retrieve equip state from
* @return The equip state on the entity
*/
public static ClientEquipState getEquipState(Entity entity){
return (ClientEquipState)entity.getData(EntityDataStrings.EQUIP_STATE);
}
/**
* Sets the equip state on the entity
* @param entity The entity to attach the equip state to
* @param equipState The equip state to attach
*/
public static void setEquipState(Entity entity, ClientEquipState equipState){
entity.putData(EntityDataStrings.EQUIP_STATE, equipState);
}
// public void drop(Entity entity){
// if(hasEquipPrimary()){
// AttachUtils.detatchEntityFromEntityAtBone(parent,equipPrimary);
// if(equipPrimary.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLISION_BODY) && equipPrimary.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLIDABLE)){
// CollisionObject rigidBody = (CollisionObject)equipPrimary.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
// Globals.collisionEngine.registerPhysicsObject(rigidBody);
// }
// Globals.entityManager.setTargetable(equipPrimary, true);
// equipPrimary = null;
// }
// }
public void commandAttemptUnequip(String pointId){
boolean hasEquipped = hasEquippedAtPoint(pointId);
if(hasEquipped){
//send packet to server requesting to equip
NetworkMessage requestUnequipMessage = InventoryMessage.constructclientRequestUnequipItemMessage(pointId);
Globals.clientConnection.queueOutgoingMessage(requestUnequipMessage);
}
}
public void clientTransformUnequipPoint(String pointId){
Entity equipped = equipMap.remove(pointId);
if(equipped != null){
boolean targetHasWhitelist = ItemUtils.hasEquipList(equipped);
if(targetHasWhitelist){
//by attaching are we going to be replacing meshes?
String parentCreatureId = CreatureUtils.getType(parent);
List<EquipWhitelist> whitelist = ItemUtils.getEquipWhitelist(equipped);
for(EquipWhitelist whitelistItem : whitelist){
if(whitelistItem.getCreatureId().equals(parentCreatureId)){
//put in map
String modelName = whitelistItem.getModel();
Actor parentActor = EntityUtils.getActor(parent);
//queue meshes from display model to parent actor
ActorMeshMask meshMask = parentActor.getMeshMask();
for(String toUnblock : whitelistItem.getMeshMaskList()){
meshMask.unblockMesh(toUnblock);
}
for(String toDraw : whitelistItem.getMeshList()){
meshMask.removeAdditionalMesh(toDraw);
}
break;
}
}
} else {
AttachUtils.clientDetatchEntityFromEntityAtBone(parent, equipped);
EntityUtils.cleanUpEntity(equipped);
}
}
}
public boolean hasEquippedAtPoint(String point){
return equipMap.containsKey(point);
}
}

View File

@ -8,8 +8,6 @@ import java.util.Map;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.ode4j.ode.DBody; import org.ode4j.ode.DBody;
import electrosphere.client.targeting.crosshair.Crosshair;
import electrosphere.collision.collidable.Collidable;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
@ -28,25 +26,24 @@ import electrosphere.net.parser.net.message.InventoryMessage;
import electrosphere.net.parser.net.message.NetworkMessage; import electrosphere.net.parser.net.message.NetworkMessage;
import electrosphere.net.server.player.Player; import electrosphere.net.server.player.Player;
import electrosphere.net.server.protocol.InventoryProtocol; import electrosphere.net.server.protocol.InventoryProtocol;
import electrosphere.renderer.actor.Actor; import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
import electrosphere.renderer.actor.ActorMeshMask;
import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.ServerDataCell; import electrosphere.server.datacell.ServerDataCell;
import electrosphere.server.datacell.utils.DataCellSearchUtils; import electrosphere.server.datacell.utils.DataCellSearchUtils;
import electrosphere.server.datacell.utils.ServerEntityTagUtils; import electrosphere.server.datacell.utils.ServerEntityTagUtils;
@SynchronizedBehaviorTree(name = "serverEquipState", isServer = true, correspondingTree="clientEquipState")
/** /**
* * Server view of items equipped onto an entity
* @author amaterasu
*/ */
public class EquipState { public class ServerEquipState {
Entity parent; Entity parent;
List<EquipPoint> equipPoints = new LinkedList<EquipPoint>(); List<EquipPoint> equipPoints = new LinkedList<EquipPoint>();
Map<String,Entity> equipMap = new HashMap<String,Entity>(); Map<String,Entity> equipMap = new HashMap<String,Entity>();
public EquipState(Entity parent, List<EquipPoint> equipPoints){ public ServerEquipState(Entity parent, List<EquipPoint> equipPoints){
this.parent = parent; this.parent = parent;
for(EquipPoint point : equipPoints){ for(EquipPoint point : equipPoints){
this.equipPoints.add(point); this.equipPoints.add(point);
@ -67,14 +64,7 @@ public class EquipState {
boolean itemIsInPointWhitelist = pointEquipClassList.contains(equipItemClass); boolean itemIsInPointWhitelist = pointEquipClassList.contains(equipItemClass);
if(!hasEquipped && targetIsItem && !targetIsAttached && itemIsInPointWhitelist){ if(!hasEquipped && targetIsItem && !targetIsAttached && itemIsInPointWhitelist){
//if we're the server, perform the attempt, otherwise send packet to server requesting to equip //if we're the server, perform the attempt, otherwise send packet to server requesting to equip
if(Globals.RUN_SERVER){ serverAttemptEquip(toEquip, point);
serverAttemptEquip(toEquip, point);
} else {
String pointName = point.getEquipPointId();
int serverSideID = Globals.clientSceneWrapper.mapClientToServerId(toEquip.getId());
NetworkMessage requestPickupMessage = InventoryMessage.constructclientRequestEquipItemMessage(pointName, serverSideID);
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage);
}
} }
} }
@ -103,15 +93,6 @@ public class EquipState {
equipMap.put(point.getEquipPointId(),inWorldItem); equipMap.put(point.getEquipPointId(),inWorldItem);
String modelName = whitelistItem.getModel(); String modelName = whitelistItem.getModel();
Globals.assetManager.addModelPathToQueue(modelName); Globals.assetManager.addModelPathToQueue(modelName);
Actor parentActor = EntityUtils.getActor(parent);
//queue meshes from display model to parent actor
ActorMeshMask meshMask = parentActor.getMeshMask();
for(String toBlock : whitelistItem.getMeshMaskList()){
meshMask.blockMesh(modelName, toBlock);
}
for(String toDraw : whitelistItem.getMeshList()){
meshMask.queueMesh(modelName, toDraw);
}
//attach to parent bone //attach to parent bone
AttachUtils.serverAttachEntityToEntityAtBone(parent, inWorldItem, point.getBone(), AttachUtils.getEquipPointRotationOffset(point.getOffsetRotation())); AttachUtils.serverAttachEntityToEntityAtBone(parent, inWorldItem, point.getBone(), AttachUtils.getEquipPointRotationOffset(point.getOffsetRotation()));
//make uncollidable //make uncollidable
@ -142,7 +123,7 @@ public class EquipState {
//we need to send two packets //we need to send two packets
//1) Remove item from original inventory //1) Remove item from original inventory
//2) Add item with ID to "equipped" inventory //2) Add item with ID to "equipped" inventory
//let clients know of the updates if we're the server //let clients know of the updates
//get the parent (typically creature) that contains the in-inventory item //get the parent (typically creature) that contains the in-inventory item
Entity containingEntity = ItemUtils.getContainingParent(inInventoryEntity); Entity containingEntity = ItemUtils.getContainingParent(inInventoryEntity);
//actually switch containers //actually switch containers
@ -182,105 +163,6 @@ public class EquipState {
} }
} }
public void clientAttemptEquip(Entity toEquip, EquipPoint point){
boolean hasEquipped = hasEquippedAtPoint(point.getEquipPointId());
boolean targetIsItem = ItemUtils.isItem(toEquip);
boolean targetIsAttached = AttachUtils.isAttached(toEquip);
boolean targetHasWhitelist = ItemUtils.hasEquipList(toEquip);
String equipItemClass = ItemUtils.getEquipClass(toEquip);
List<String> pointEquipClassList = point.getEquipClassWhitelist();
boolean itemIsInPointWhitelist = pointEquipClassList.contains(equipItemClass);
if(!hasEquipped && targetIsItem && !targetIsAttached && itemIsInPointWhitelist){
if(targetHasWhitelist){
//by attaching are we going to be replacing meshes?
String parentCreatureId = CreatureUtils.getType(parent);
List<EquipWhitelist> whitelist = ItemUtils.getEquipWhitelist(toEquip);
for(EquipWhitelist whitelistItem : whitelist){
if(whitelistItem.getCreatureId().equals(parentCreatureId)){
//put in map
equipMap.put(point.getEquipPointId(),toEquip);
String modelName = whitelistItem.getModel();
Globals.assetManager.addModelPathToQueue(modelName);
Actor parentActor = EntityUtils.getActor(parent);
//queue meshes from display model to parent actor
ActorMeshMask meshMask = parentActor.getMeshMask();
for(String toBlock : whitelistItem.getMeshMaskList()){
meshMask.blockMesh(modelName, toBlock);
}
for(String toDraw : whitelistItem.getMeshList()){
meshMask.queueMesh(modelName, toDraw);
}
//attach to parent bone
AttachUtils.clientAttachEntityToEntityAtBone(parent, toEquip, point.getBone(), AttachUtils.getEquipPointRotationOffset(point.getOffsetRotation()));
//make uncollidable
if(toEquip.containsKey(EntityDataStrings.PHYSICS_COLLISION_BODY) && toEquip.containsKey(EntityDataStrings.PHYSICS_COLLIDABLE)){
DBody rigidBody = (DBody)toEquip.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
Globals.clientSceneWrapper.getCollisionEngine().deregisterPhysicsObject(rigidBody);
}
//hide toEquip actor
EntityUtils.setDraw(toEquip, false);
//make untargetable
Globals.clientSceneWrapper.getScene().removeEntityFromTag(toEquip, EntityTags.TARGETABLE);
break;
}
}
} else {
//since we're not replacing meshes we must be attaching to a bone
equipMap.put(point.getEquipPointId(),toEquip);
AttachUtils.clientAttachEntityToEntityAtBone(parent, toEquip, point.getBone(), AttachUtils.getEquipPointRotationOffset(point.getOffsetRotation()));
if(toEquip.containsKey(EntityDataStrings.PHYSICS_COLLISION_BODY) && toEquip.containsKey(EntityDataStrings.PHYSICS_COLLIDABLE)){
DBody rigidBody = (DBody)toEquip.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
Globals.clientSceneWrapper.getCollisionEngine().deregisterPhysicsObject(rigidBody);
}
Globals.clientSceneWrapper.getScene().removeEntityFromTag(toEquip, EntityTags.TARGETABLE);
GravityUtils.clientAttemptDeactivateGravity(toEquip);
}
}
// if(!hasEquipPrimary() && ItemUtils.isItem(toEquip) && !AttachUtils.isAttached(toEquip)){
// if(ItemUtils.hasEquipList(toEquip)){
// String parentCreatureId = CreatureUtils.getType(parent);
// List<EquipWhitelist> whitelist = ItemUtils.getEquipWhitelist(toEquip);
// for(EquipWhitelist whitelistItem : whitelist){
// if(whitelistItem.getCreatureId().equals(parentCreatureId)){
// equipPrimary = toEquip;
// String modelName = whitelistItem.getModel();
// Globals.assetManager.addModelPathToQueue(modelName);
// Actor parentActor = EntityUtils.getActor(parent);
// //queue meshes from display model to parent actor
// ActorMeshMask meshMask = parentActor.getMeshMask();
// for(String toBlock : whitelistItem.getMeshMaskList()){
// meshMask.blockMesh(modelName, toBlock);
// }
// for(String toDraw : whitelistItem.getMeshList()){
// meshMask.queueMesh(modelName, toDraw);
// }
// //attach to parent bone
// AttachUtils.attachEntityToEntityAtBone(parent, toEquip, equipPrimaryBoneName);
// //make uncollidable
// if(toEquip.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLISION_BODY) && toEquip.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLIDABLE)){
// CollisionObject rigidBody = (CollisionObject)toEquip.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
// Globals.collisionEngine.deregisterPhysicsObject(rigidBody);
// }
// //hide toEquip actor
// EntityUtils.setDraw(toEquip, false);
// //make untargetable
// Globals.entityManager.setTargetable(equipPrimary, false);
// break;
// }
// }
// } else {
// equipPrimary = toEquip;
// AttachUtils.attachEntityToEntityAtBone(parent, toEquip, equipPrimaryBoneName);
// if(toEquip.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLISION_BODY) && toEquip.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLIDABLE)){
// CollisionObject rigidBody = (CollisionObject)toEquip.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
// Globals.collisionEngine.deregisterPhysicsObject(rigidBody);
// }
// Globals.entityManager.setTargetable(equipPrimary, false);
// }
// }
}
public EquipPoint getEquipPoint(String name){ public EquipPoint getEquipPoint(String name){
for(EquipPoint point : equipPoints){ for(EquipPoint point : equipPoints){
if(point.getEquipPointId().equals(name)){ if(point.getEquipPointId().equals(name)){
@ -308,8 +190,8 @@ public class EquipState {
* @param entity The entity to retrieve equip state from * @param entity The entity to retrieve equip state from
* @return The equip state on the entity * @return The equip state on the entity
*/ */
public static EquipState getEquipState(Entity entity){ public static ServerEquipState getEquipState(Entity entity){
return (EquipState)entity.getData(EntityDataStrings.EQUIP_STATE); return (ServerEquipState)entity.getData(EntityDataStrings.EQUIP_STATE);
} }
/** /**
@ -317,7 +199,7 @@ public class EquipState {
* @param entity The entity to attach the equip state to * @param entity The entity to attach the equip state to
* @param equipState The equip state to attach * @param equipState The equip state to attach
*/ */
public static void setEquipState(Entity entity, EquipState equipState){ public static void setEquipState(Entity entity, ServerEquipState equipState){
entity.putData(EntityDataStrings.EQUIP_STATE, equipState); entity.putData(EntityDataStrings.EQUIP_STATE, equipState);
} }
@ -336,13 +218,8 @@ public class EquipState {
public void commandAttemptUnequip(String pointId){ public void commandAttemptUnequip(String pointId){
boolean hasEquipped = hasEquippedAtPoint(pointId); boolean hasEquipped = hasEquippedAtPoint(pointId);
if(hasEquipped){ if(hasEquipped){
//if we're the server, perform the attempt, otherwise send packet to server requesting to equip //perform the attempt
if(Globals.RUN_SERVER){ serverAttemptUnequip(pointId);
serverAttemptUnequip(pointId);
} else {
NetworkMessage requestUnequipMessage = InventoryMessage.constructclientRequestUnequipItemMessage(pointId);
Globals.clientConnection.queueOutgoingMessage(requestUnequipMessage);
}
} }
} }
@ -393,18 +270,6 @@ public class EquipState {
// inventory.addItem(item); // inventory.addItem(item);
} }
public void clientTransformUnequipPoint(String pointId){
Entity equipped = equipMap.remove(pointId);
if(equipped != null){
boolean targetHasWhitelist = ItemUtils.hasEquipList(equipped);
if(targetHasWhitelist){
} else {
AttachUtils.clientDetatchEntityFromEntityAtBone(parent, equipped);
EntityUtils.cleanUpEntity(equipped);
}
}
}
public void serverTransformUnequipPoint(String pointId){ public void serverTransformUnequipPoint(String pointId){
Entity equipped = equipMap.remove(pointId); Entity equipped = equipMap.remove(pointId);
if(equipped != null){ if(equipped != null){
@ -452,6 +317,4 @@ public class EquipState {
public boolean hasEquippedAtPoint(String point){ public boolean hasEquippedAtPoint(String point){
return equipMap.containsKey(point); return equipMap.containsKey(point);
} }
} }

View File

@ -6,7 +6,7 @@ import electrosphere.engine.Globals;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.equip.EquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.types.item.ItemUtils; import electrosphere.entity.types.item.ItemUtils;
import electrosphere.game.data.creature.type.equip.EquipPoint; import electrosphere.game.data.creature.type.equip.EquipPoint;
import electrosphere.menu.WindowStrings; import electrosphere.menu.WindowStrings;
@ -95,9 +95,9 @@ public class InventoryState implements BehaviorTree {
} }
break; break;
case SERVERCOMMANDUNEQUIPITEM: { case SERVERCOMMANDUNEQUIPITEM: {
if(Globals.playerEntity != null && EquipState.hasEquipState(Globals.playerEntity)){ if(Globals.playerEntity != null && ClientEquipState.hasEquipState(Globals.playerEntity)){
//unequip the item //unequip the item
EquipState equipState = EquipState.getEquipState(Globals.playerEntity); ClientEquipState equipState = ClientEquipState.getEquipState(Globals.playerEntity);
Entity entityInSlot = equipState.getEquippedItemAtPoint(message.getequipPointId()); Entity entityInSlot = equipState.getEquippedItemAtPoint(message.getequipPointId());
equipState.clientTransformUnequipPoint(message.getequipPointId()); equipState.clientTransformUnequipPoint(message.getequipPointId());
//destroy the in-world manifestation of said item //destroy the in-world manifestation of said item

View File

@ -7,7 +7,8 @@ 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.equip.EquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.equip.ServerEquipState;
import electrosphere.entity.state.gravity.GravityUtils; import electrosphere.entity.state.gravity.GravityUtils;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils; import electrosphere.entity.types.item.ItemUtils;
@ -96,28 +97,26 @@ public class InventoryUtils {
//destroy in-world entity and create in-inventory item //destroy in-world entity and create in-inventory item
//we're doing this so that we're not constantly sending networking messages for invisible entities attached to the player //we're doing this so that we're not constantly sending networking messages for invisible entities attached to the player
Entity inventoryItem = ItemUtils.serverRecreateContainerItem(item, creature); Entity inventoryItem = ItemUtils.serverRecreateContainerItem(item, creature);
//destroy the item that was left over
ItemUtils.serverDestroyInWorldItem(item);
//store item in inventory //store item in inventory
inventory.addItem(inventoryItem); inventory.addItem(inventoryItem);
//set item containing parent //set item containing parent
ItemUtils.setContainingParent(inventoryItem, creature); ItemUtils.setContainingParent(inventoryItem, creature);
//if we are the server, immediately send required packets //if we are the server, immediately send required packets
if(Globals.RUN_SERVER){ ServerDataCell dataCell = DataCellSearchUtils.getEntityDataCell(item);
ServerDataCell dataCell = Globals.realmManager.getEntityRealm(item).getEntityDataCellMapper().getEntityDataCell(item); // ServerDataCell dataCell = Globals.dataCellLocationResolver.getDataCellAtPoint(EntityUtils.getPosition(item),item);
// ServerDataCell dataCell = Globals.dataCellLocationResolver.getDataCellAtPoint(EntityUtils.getPosition(item),item); dataCell.getScene().deregisterEntity(item);
dataCell.getScene().deregisterEntity(item); //broadcast destroy entity
//broadcast destroy entity dataCell.broadcastNetworkMessage(EntityMessage.constructDestroyMessage(item.getId()));
dataCell.broadcastNetworkMessage(EntityMessage.constructDestroyMessage(item.getId())); //tell controlling player that they have an item in their inventory
//tell controlling player that they have an item in their inventory if(CreatureUtils.hasControllerPlayerId(creature)){
if(CreatureUtils.hasControllerPlayerId(creature)){ //get the player
//get the player int controllerPlayerID = CreatureUtils.getControllerPlayerId(creature);
int controllerPlayerID = CreatureUtils.getControllerPlayerId(creature); Player controllerPlayer = Globals.playerManager.getPlayerFromId(controllerPlayerID);
Player controllerPlayer = Globals.playerManager.getPlayerFromId(controllerPlayerID); //send message
//send message controllerPlayer.addMessage(InventoryMessage.constructaddItemToInventoryMessage(inventoryItem.getId(), ItemUtils.getType(inventoryItem)));
controllerPlayer.addMessage(InventoryMessage.constructaddItemToInventoryMessage(inventoryItem.getId(), ItemUtils.getType(inventoryItem)));
}
} }
//destroy the item that was left over
ItemUtils.serverDestroyInWorldItem(item);
} }
} }
@ -126,18 +125,23 @@ public class InventoryUtils {
* @param creature the creature which has a natural inventory * @param creature the creature which has a natural inventory
* @param item the in-world item entity to store * @param item the in-world item entity to store
*/ */
public static void attemptStoreItem(Entity creature, Entity item){ public static void clientAttemptStoreItem(Entity creature, Entity item){
if(Globals.RUN_SERVER){ //tell the server we want to try the transform
//if we're the server, immediately attempt the transform NetworkMessage requestPickupMessage = InventoryMessage.constructaddItemToInventoryMessage(
serverAttemptStoreItemTransform(creature,item); Globals.clientSceneWrapper.mapClientToServerId(item.getId()),
} else { ItemUtils.getType(item)
//if we're the client, tell the server we want to try the transform );
NetworkMessage requestPickupMessage = InventoryMessage.constructaddItemToInventoryMessage( Globals.clientConnection.queueOutgoingMessage(requestPickupMessage);
Globals.clientSceneWrapper.mapClientToServerId(item.getId()), }
ItemUtils.getType(item)
); /**
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage); * Attempts to store the in-world item entity in a creature inventory container
} * @param creature the creature which has a natural inventory
* @param item the in-world item entity to store
*/
public static void serverAttemptStoreItem(Entity creature, Entity item){
//immediately attempt the transform
serverAttemptStoreItemTransform(creature,item);
} }
/** /**
@ -206,7 +210,7 @@ public class InventoryUtils {
Entity realWorldItem = ItemUtils.getRealWorldEntity(item); Entity realWorldItem = ItemUtils.getRealWorldEntity(item);
if(realWorldItem != null){ if(realWorldItem != null){
//drop item //drop item
EquipState equipState = EquipState.getEquipState(creature); ServerEquipState equipState = ServerEquipState.getEquipState(creature);
equipState.serverTransformUnequipPoint(inventorySlot); equipState.serverTransformUnequipPoint(inventorySlot);
// equipState.serverAttemptUnequip(inventory.getItemSlot(item)); // equipState.serverAttemptUnequip(inventory.getItemSlot(item));
// //
@ -245,15 +249,16 @@ public class InventoryUtils {
} }
//need creature so we can figure out where to drop the item //need creature so we can figure out where to drop the item
public static void attemptEjectItem(Entity creature, Entity item){ public static void serverAttemptEjectItem(Entity creature, Entity item){
if(Globals.RUN_SERVER){ //if we're the server, immediately attempt the transform
//if we're the server, immediately attempt the transform serverAttemptEjectItemTransform(creature,item);
serverAttemptEjectItemTransform(creature,item); }
} else {
//if we're the client, tell the server we want to try the transform //need creature so we can figure out where to drop the item
NetworkMessage requestPickupMessage = InventoryMessage.constructremoveItemFromInventoryMessage(Globals.clientSceneWrapper.mapClientToServerId(item.getId())); public static void clientAttemptEjectItem(Entity creature, Entity item){
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage); //if we're the client, tell the server we want to try the transform
} NetworkMessage requestPickupMessage = InventoryMessage.constructremoveItemFromInventoryMessage(Globals.clientSceneWrapper.mapClientToServerId(item.getId()));
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage);
} }
/** /**
@ -284,7 +289,7 @@ public class InventoryUtils {
Entity realWorldItem = ItemUtils.getRealWorldEntity(item); Entity realWorldItem = ItemUtils.getRealWorldEntity(item);
if(realWorldItem != null){ if(realWorldItem != null){
//drop item //drop item
EquipState equipState = EquipState.getEquipState(creature); ClientEquipState equipState = ClientEquipState.getEquipState(creature);
equipState.clientTransformUnequipPoint(inventory.getItemSlot(item)); equipState.clientTransformUnequipPoint(inventory.getItemSlot(item));
} }
//remove item from inventory //remove item from inventory

View File

@ -6,7 +6,7 @@ import electrosphere.engine.Globals;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.equip.EquipState; import electrosphere.entity.state.equip.ServerEquipState;
import electrosphere.entity.types.item.ItemUtils; import electrosphere.entity.types.item.ItemUtils;
import electrosphere.game.data.creature.type.equip.EquipPoint; import electrosphere.game.data.creature.type.equip.EquipPoint;
import electrosphere.menu.WindowStrings; import electrosphere.menu.WindowStrings;
@ -42,17 +42,17 @@ public class ServerInventoryState implements BehaviorTree {
networkMessageQueue.remove(message); networkMessageQueue.remove(message);
switch(message.getMessageSubtype()){ switch(message.getMessageSubtype()){
case ADDITEMTOINVENTORY: case ADDITEMTOINVENTORY:
InventoryUtils.attemptStoreItem(parent, EntityLookupUtils.getEntityById(message.getentityId())); InventoryUtils.serverAttemptStoreItem(parent, EntityLookupUtils.getEntityById(message.getentityId()));
break; break;
case REMOVEITEMFROMINVENTORY: case REMOVEITEMFROMINVENTORY:
InventoryUtils.attemptEjectItem(parent, EntityLookupUtils.getEntityById(message.getentityId())); InventoryUtils.serverAttemptEjectItem(parent, EntityLookupUtils.getEntityById(message.getentityId()));
break; break;
case CLIENTREQUESTEQUIPITEM:{ case CLIENTREQUESTEQUIPITEM:{
//item to equip //item to equip
Entity target = EntityLookupUtils.getEntityById(message.getentityId()); Entity target = EntityLookupUtils.getEntityById(message.getentityId());
//perform transform if it makes sense //perform transform if it makes sense
if(InventoryUtils.hasEquipInventory(parent) && InventoryUtils.hasNaturalInventory(parent) && EquipState.hasEquipState(parent)){ if(InventoryUtils.hasEquipInventory(parent) && InventoryUtils.hasNaturalInventory(parent) && ServerEquipState.hasEquipState(parent)){
EquipState equipState = EquipState.getEquipState(parent); ServerEquipState equipState = ServerEquipState.getEquipState(parent);
EquipPoint point = equipState.getEquipPoint(message.getequipPointId()); EquipPoint point = equipState.getEquipPoint(message.getequipPointId());
equipState.commandAttemptEquip(target, point); equipState.commandAttemptEquip(target, point);
} }
@ -60,8 +60,8 @@ public class ServerInventoryState implements BehaviorTree {
break; break;
case CLIENTREQUESTUNEQUIPITEM:{ case CLIENTREQUESTUNEQUIPITEM:{
//make sure can unequip //make sure can unequip
if(InventoryUtils.hasEquipInventory(parent) && InventoryUtils.hasNaturalInventory(parent) && EquipState.hasEquipState(parent)){ if(InventoryUtils.hasEquipInventory(parent) && InventoryUtils.hasNaturalInventory(parent) && ServerEquipState.hasEquipState(parent)){
EquipState equipState = EquipState.getEquipState(parent); ServerEquipState equipState = ServerEquipState.getEquipState(parent);
EquipPoint point = equipState.getEquipPoint(message.getequipPointId()); EquipPoint point = equipState.getEquipPoint(message.getequipPointId());
if(equipState.hasEquippedAtPoint(message.getequipPointId())){ if(equipState.hasEquippedAtPoint(message.getequipPointId())){
equipState.commandAttemptUnequip(message.getequipPointId()); equipState.commandAttemptUnequip(message.getequipPointId());

View File

@ -10,6 +10,7 @@ import electrosphere.renderer.actor.Actor;
import electrosphere.renderer.model.Model; import electrosphere.renderer.model.Model;
import electrosphere.server.datacell.ServerDataCell; import electrosphere.server.datacell.ServerDataCell;
import electrosphere.server.datacell.utils.ServerEntityTagUtils; import electrosphere.server.datacell.utils.ServerEntityTagUtils;
import electrosphere.server.poseactor.PoseActor;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -45,7 +46,7 @@ public class AttachUtils {
if((parent = (Entity)currentEntity.getData(EntityDataStrings.ATTACH_PARENT))!=null){ if((parent = (Entity)currentEntity.getData(EntityDataStrings.ATTACH_PARENT))!=null){
String targetBone; String targetBone;
if((targetBone = (String)currentEntity.getData(EntityDataStrings.ATTACH_TARGET_BONE))!=null){ if((targetBone = (String)currentEntity.getData(EntityDataStrings.ATTACH_TARGET_BONE))!=null){
Actor parentActor = EntityUtils.getActor(parent); PoseActor parentActor = EntityUtils.getPoseActor(parent);
//get offset rotation //get offset rotation
Quaterniond offsetRotation = getRotationOffset(currentEntity); Quaterniond offsetRotation = getRotationOffset(currentEntity);
//transform bone space //transform bone space
@ -420,7 +421,11 @@ public class AttachUtils {
} }
public static Quaterniond getEquipPointRotationOffset(List<Float> values){ public static Quaterniond getEquipPointRotationOffset(List<Float> values){
return new Quaterniond(values.get(0),values.get(1),values.get(2),values.get(3)); if(values.size() > 0){
return new Quaterniond(values.get(0),values.get(1),values.get(2),values.get(3));
} else {
return new Quaterniond();
}
} }
} }

View File

@ -25,7 +25,8 @@ import electrosphere.entity.state.attack.ServerAttackTree;
import electrosphere.entity.state.attack.ShooterTree; import electrosphere.entity.state.attack.ShooterTree;
import electrosphere.entity.state.collidable.ClientCollidableTree; import electrosphere.entity.state.collidable.ClientCollidableTree;
import electrosphere.entity.state.collidable.ServerCollidableTree; import electrosphere.entity.state.collidable.ServerCollidableTree;
import electrosphere.entity.state.equip.EquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.equip.ServerEquipState;
import electrosphere.entity.state.gravity.ClientGravityTree; import electrosphere.entity.state.gravity.ClientGravityTree;
import electrosphere.entity.state.gravity.ServerGravityTree; import electrosphere.entity.state.gravity.ServerGravityTree;
import electrosphere.entity.state.idle.IdleTree; import electrosphere.entity.state.idle.IdleTree;
@ -227,7 +228,7 @@ public class CreatureUtils {
} }
} }
if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){ if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){
EquipState.setEquipState(rVal, new EquipState(rVal,rawType.getEquipPoints())); ClientEquipState.setEquipState(rVal, new ClientEquipState(rVal,rawType.getEquipPoints()));
rVal.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints())); rVal.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints()));
} }
for(String token : rawType.getTokens()){ for(String token : rawType.getTokens()){
@ -523,7 +524,7 @@ public class CreatureUtils {
} }
} }
if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){ if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){
EquipState.setEquipState(rVal, new EquipState(rVal,rawType.getEquipPoints())); ServerEquipState.setEquipState(rVal, new ServerEquipState(rVal,rawType.getEquipPoints()));
rVal.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints())); rVal.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints()));
} }
for(String token : rawType.getTokens()){ for(String token : rawType.getTokens()){

View File

@ -389,13 +389,15 @@ public class ItemUtils {
Realm itemRealm = Globals.realmManager.getEntityRealm(item); Realm itemRealm = Globals.realmManager.getEntityRealm(item);
//destroy physics //destroy physics
//this deregisters from all four & unhooks rigid bodies from the physics runtime //this deregisters from all four & unhooks rigid bodies from the physics runtime
itemRealm.getCollisionEngine().destroyEntityThatHasPhysics(item); if(itemRealm != null){
//destroy hitboxes itemRealm.getCollisionEngine().destroyEntityThatHasPhysics(item);
List<Entity> hitboxes = HitboxUtils.getHitboxAssociatedList(item); //destroy hitboxes
if(hitboxes != null){ List<Entity> hitboxes = HitboxUtils.getHitboxAssociatedList(item);
for(Entity hitbox : hitboxes){ if(hitboxes != null){
itemRealm.getHitboxManager().deregisterHitbox(hitbox); for(Entity hitbox : hitboxes){
HitboxUtils.getHitboxData(hitbox).setActive(false); itemRealm.getHitboxManager().deregisterHitbox(hitbox);
HitboxUtils.getHitboxData(hitbox).setActive(false);
}
} }
} }
//destroy graphics //destroy graphics

View File

@ -1,6 +1,5 @@
package electrosphere.game.data.item.type; package electrosphere.game.data.item.type;
import electrosphere.entity.types.hitbox.HitboxData;
import electrosphere.game.data.collidable.CollidableTemplate; import electrosphere.game.data.collidable.CollidableTemplate;
import java.util.List; import java.util.List;

View File

@ -21,7 +21,7 @@ public class WindowUtils {
//todo: destroy elements as well //todo: destroy elements as well
mainMenu.clear(); mainMenu.clear();
mainMenu.addChild(newMenu); mainMenu.addChild(newMenu);
mainMenu.applyYoga(); mainMenu.applyYoga(0,0);
Globals.elementManager.focusFirstElement(); Globals.elementManager.focusFirstElement();
} }
} }
@ -35,6 +35,9 @@ public class WindowUtils {
recursiveSetVisible(child, visible); recursiveSetVisible(child, visible);
} }
} }
if(visible){
topLevelMenu.applyYoga(0, 0);
}
} }
public static String getInventoryWindowID(int id){ public static String getInventoryWindowID(int id){
@ -122,7 +125,7 @@ public class WindowUtils {
Label loadingLabel = new Label(1.0f); Label loadingLabel = new Label(1.0f);
loadingLabel.setText("LOADING"); loadingLabel.setText("LOADING");
loadingWindow.addChild(loadingLabel); loadingWindow.addChild(loadingLabel);
loadingWindow.applyYoga(); loadingWindow.applyYoga(0,0);
Globals.elementManager.registerWindow(WindowStrings.WINDOW_LOADING, loadingWindow); Globals.elementManager.registerWindow(WindowStrings.WINDOW_LOADING, loadingWindow);
WindowUtils.recursiveSetVisible(loadingWindow, true); WindowUtils.recursiveSetVisible(loadingWindow, true);
} }
@ -138,7 +141,7 @@ public class WindowUtils {
} }
static void initItemDragContainerWindow(){ static void initItemDragContainerWindow(){
Window itemDragContainerWindow = new Window(0,0,Globals.WINDOW_WIDTH,Globals.WINDOW_HEIGHT,true); Window itemDragContainerWindow = new Window(0,0,Globals.WINDOW_WIDTH,Globals.WINDOW_HEIGHT,false);
Globals.elementManager.registerWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER, itemDragContainerWindow); Globals.elementManager.registerWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER, itemDragContainerWindow);
} }

View File

@ -0,0 +1,118 @@
package electrosphere.menu.debug;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.foliage.FoliageUtils;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.renderer.RenderingEngine;
import electrosphere.renderer.actor.Actor;
import electrosphere.renderer.actor.ActorMeshMask;
import electrosphere.renderer.model.Mesh;
import electrosphere.renderer.ui.imgui.ImGuiWindow;
import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback;
import imgui.ImGui;
/**
* Macros for creating imgui windows relating to entity debugging
*/
public class ImGuiEntityMacros {
protected static ImGuiWindow clientEntityWindow;
private static boolean filterToCreatures = false;
protected static ImGuiWindow actorView;
static Entity actorViewEntity;
/**
* Creates the windows in this file
*/
protected static void createClientEntityWindows(){
createClientEntityDebugWindow();
createActorViewDebugWindow();
}
/**
* Client scene entity view
*/
protected static void createClientEntityDebugWindow(){
clientEntityWindow = new ImGuiWindow("Client Entities");
clientEntityWindow.setCallback(new ImGuiWindowCallback() {
@Override
public void exec() {
//audio engine details
ImGui.text("Client Entities");
if(ImGui.checkbox("Filter to Creatures", filterToCreatures)){
filterToCreatures = !filterToCreatures;
}
for(Entity entity : Globals.clientSceneWrapper.getScene().getEntityList()){
//filters
if(filterToCreatures && !CreatureUtils.isCreature(entity)){
continue;
}
ImGui.beginGroup();
ImGui.text("Id: " + entity.getId() + " (" + getEntityName(entity) + ")");
if(CreatureUtils.isCreature(entity)){
if(ImGui.button("Actor View")){
actorViewEntity = entity;
actorView.setOpen(true);
}
}
ImGui.endGroup();
}
}
});
clientEntityWindow.setOpen(false);
RenderingEngine.addImGuiWindow(clientEntityWindow);
}
/**
* Client scene entity view
*/
protected static void createActorViewDebugWindow(){
actorView = new ImGuiWindow("Actor View");
actorView.setCallback(new ImGuiWindowCallback() {
@Override
public void exec() {
if(actorViewEntity != null && EntityUtils.getActor(actorViewEntity) != null){
Actor actor = EntityUtils.getActor(actorViewEntity);
//mesh mask
if(ImGui.collapsingHeader("Mesh Mask")){
ActorMeshMask meshMask = actor.getMeshMask();
ImGui.text("To Draw Meshes:");
for(Mesh mesh : meshMask.getToDrawMeshes()){
ImGui.text(mesh.getMeshName());
}
ImGui.text("Blocked Meshes:");
for(String blocked : meshMask.getBlockedMeshes()){
ImGui.text(blocked);
}
}
}
}
});
actorView.setOpen(false);
RenderingEngine.addImGuiWindow(actorView);
}
/**
* Gets the displayed name of an entity (ie creature type, foliage type, terrain, etc)
* @param entity
* @return
*/
private static String getEntityName(Entity entity){
if(CreatureUtils.isCreature(entity)){
return CreatureUtils.getType(entity);
}
if(ItemUtils.isItem(entity)){
return ItemUtils.getType(entity);
}
if(FoliageUtils.isFoliage(entity)){
return FoliageUtils.getFoliageType(entity).getName();
}
return "Entity";
}
}

Some files were not shown because too many files have changed in this diff Show More