From 570086c2cc41bf5aff16418b3c3b51641851c30a Mon Sep 17 00:00:00 2001 From: austin Date: Wed, 24 Jul 2024 12:49:44 -0400 Subject: [PATCH] 2h katana --- assets/Data/creatures/human.json | 24 +++ assets/Data/items.json | 175 ++++++++++++------ docs/src/progress/renderertodo.md | 4 + .../controls/ControlHandler.java | 2 +- src/main/java/electrosphere/engine/Main.java | 6 +- .../entity/EntityDataStrings.java | 1 + .../entity/state/attack/ClientAttackTree.java | 23 ++- .../entity/state/attack/ServerAttackTree.java | 3 + .../client/firstPerson/FirstPersonTree.java | 8 + .../entity/types/item/ItemUtils.java | 38 +++- .../type/attack/AttackMoveResolver.java | 33 +++- .../game/data/item/type/EquipData.java | 43 +++++ .../game/data/item/type/Item.java | 30 +-- .../net/client/protocol/EntityProtocol.java | 1 - .../pipelines/MainContentPipeline.java | 63 +++++-- .../character/PlayerCharacterCreation.java | 4 +- 16 files changed, 337 insertions(+), 121 deletions(-) create mode 100644 src/main/java/electrosphere/game/data/item/type/EquipData.java diff --git a/assets/Data/creatures/human.json b/assets/Data/creatures/human.json index 60193cd1..fa3dfcfa 100644 --- a/assets/Data/creatures/human.json +++ b/assets/Data/creatures/human.json @@ -367,6 +367,30 @@ "name" : "Jump" } }, + { + "attackMoveId" : "Sword2HSlash1", + "type" : "MELEE_WEAPON_SWING_TWO_HAND", + "attackAnimationName" : "SwordR2HSlash", + "windupFrames" : 2, + "attackFrames" : 5, + "cooldownFrames" : 28, + "firesProjectile" : false, + "nextAttackMoveWindowStart" : 10, + "nextAttackMoveWindowEnd" : 18, + "driftGoal" : 0.03, + "driftFrameStart" : 1, + "driftFrameEnd" : 10, + "initialMove" : true, + "animationFirstPersonWindup" : { + "name" : "HoldItemR2H" + }, + "animationFirstPersonHold" : { + "name" : "HoldItemR2H" + }, + "animationFirstPersonAttack" : { + "name" : "SwordR2HSlash" + } + }, { "attackMoveId" : "Bow2HFire", "type" : "RANGED_WEAPON_BOW_TWO_HAND", diff --git a/assets/Data/items.json b/assets/Data/items.json index d6e3ea84..5caffa93 100644 --- a/assets/Data/items.json +++ b/assets/Data/items.json @@ -27,6 +27,59 @@ } ] }, + "equipData": { + "equipClass" : "weapon" + }, + "tokens" : [ + "GRAVITY", + "BLENDER_TRANSFORM", + "MELEE", + "TARGETABLE", + "OUTLINE" + ], + "idleAnim" : "Sword|Idle", + "collidable": { + "type" : "CUBE", + "dimension1" : 0.03, + "dimension2" : 0.03, + "dimension3" : 0.2, + "rotX": 0, + "rotY": 0, + "rotZ": 0, + "rotW": 1, + "offsetX" : 0.0, + "offsetY" : 0.05, + "offsetZ" : 0.0 + }, + "iconPath" : "Textures/icons/itemIconWeapon.png" + }, + { + "itemId" : "Katana2H", + "modelPath" : "Models/items/weapons/katana1alt.fbx", + "weaponData" : { + "weaponClass" : "sword2h", + "damage" : 10, + "hitboxes" : [ + { + "type": "hit_connected", + "bone": "Blade1", + "radius": 0.04 + }, + { + "type": "hit_connected", + "bone": "Blade2", + "radius": 0.04 + }, + { + "type": "hit_connected", + "bone": "Blade3", + "radius": 0.04 + } + ] + }, + "equipData": { + "equipClass" : "weapon" + }, "tokens" : [ "GRAVITY", "BLENDER_TRANSFORM", @@ -34,7 +87,6 @@ "TARGETABLE", "OUTLINE" ], - "equipClass" : "weapon", "idleAnim" : "Sword|Idle", "collidable": { "type" : "CUBE", @@ -59,13 +111,15 @@ "damage" : 10, "projectileModel" : "Models/arrow1.fbx" }, + "equipData": { + "equipClass" : "weapon" + }, "tokens" : [ "GRAVITY", "RANGED", "TARGETABLE", "OUTLINE" ], - "equipClass" : "weapon", "collidable": { "type" : "CUBE", "dimension1" : 0.1, @@ -85,11 +139,25 @@ { "itemId" : "shorts1", "modelPath": "Models/items/itemEntityShorts.fbx", + "equipData": { + "equipClass" : "clothing", + "equipWhitelist" : [ + { + "creatureId" : "human", + "model" : "Models/creatures/person2/clothing/shorts1.fbx", + "meshList" : [ + "ClothingItem" + ], + "meshMaskList" : [ + "Shorts" + ] + } + ] + }, "tokens" : [ "GRAVITY", "TARGETABLE" ], - "equipClass" : "clothing", "collidable": { "type" : "CUBE", "dimension1" : 0.1, @@ -103,24 +171,25 @@ "offsetY" : 0.05, "offsetZ" : 0 }, - "iconPath" : "Textures/icons/itemIconItemGeneric.png", - "equipWhitelist" : [ - { - "creatureId" : "human", - "model" : "Models/creatures/person2/clothing/shorts1.fbx", - "meshList" : [ - "ClothingItem" - ], - "meshMaskList" : [ - "Shorts" - ] - } - ] + "iconPath" : "Textures/icons/itemIconItemGeneric.png" }, { "itemId" : "hairshort1", "modelPath": "Models/itemEntityShorts.fbx", + "equipData": { + "equipClass" : "trait", + "equipWhitelist" : [ + { + "creatureId" : "human", + "model" : "Models/hairshort1.fbx", + "meshList" : [ + "Hair" + ], + "meshMaskList" : [] + } + ] + }, "tokens" : [ "GRAVITY", "ARMOR", @@ -140,17 +209,7 @@ "offsetY" : 0.05, "offsetZ" : 0 }, - "iconPath" : "Textures/icons/itemIconItemGeneric.png", - "equipWhitelist" : [ - { - "creatureId" : "human", - "model" : "Models/hairshort1.fbx", - "meshList" : [ - "Hair" - ], - "meshMaskList" : [] - } - ] + "iconPath" : "Textures/icons/itemIconItemGeneric.png" }, { @@ -161,7 +220,21 @@ "ARMOR", "TARGETABLE" ], - "equipClass" : "clothing", + "equipData": { + "equipClass" : "clothing", + "equipWhitelist" : [ + { + "creatureId" : "human", + "model" : "Models/boots1.glb", + "meshList" : [ + "BootLeft", + "BootRight" + ], + "meshMaskList" : [ + ] + } + ] + }, "collidable": { "type" : "CUBE", "dimension1" : 0.1, @@ -175,19 +248,7 @@ "offsetY" : 0.05, "offsetZ" : 0 }, - "iconPath" : "Textures/icons/itemIconItemGeneric.png", - "equipWhitelist" : [ - { - "creatureId" : "human", - "model" : "Models/boots1.glb", - "meshList" : [ - "BootLeft", - "BootRight" - ], - "meshMaskList" : [ - ] - } - ] + "iconPath" : "Textures/icons/itemIconItemGeneric.png" }, { @@ -198,7 +259,22 @@ "ARMOR", "TARGETABLE" ], - "equipClass" : "clothing", + "equipData": { + "equipClass" : "clothing", + "equipWhitelist" : [ + { + "creatureId" : "human", + "model" : "Models/shirt1.fbx", + "meshList" : [ + "ClothingItem" + ], + "meshMaskList" : [ + "ShoulderLeft", + "ShoulderRight" + ] + } + ] + }, "collidable": { "type" : "CUBE", "dimension1" : 0.1, @@ -212,20 +288,7 @@ "offsetY" : 0.05, "offsetZ" : 0 }, - "iconPath" : "Textures/icons/itemIconItemGeneric.png", - "equipWhitelist" : [ - { - "creatureId" : "human", - "model" : "Models/shirt1.fbx", - "meshList" : [ - "ClothingItem" - ], - "meshMaskList" : [ - "ShoulderLeft", - "ShoulderRight" - ] - } - ] + "iconPath" : "Textures/icons/itemIconItemGeneric.png" } diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index cb03dba3..0c78e59d 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -443,6 +443,10 @@ Word element Text Wrap handling Overflow handling +(07/21/2024) +AI scaffolding +Attacker ai tree + # TODO diff --git a/src/main/java/electrosphere/controls/ControlHandler.java b/src/main/java/electrosphere/controls/ControlHandler.java index 0c977791..aa670734 100644 --- a/src/main/java/electrosphere/controls/ControlHandler.java +++ b/src/main/java/electrosphere/controls/ControlHandler.java @@ -249,7 +249,7 @@ public class ControlHandler { boolean shouldRecaptureScreen = false; //controls whether the camera is first or third person - boolean cameraIsThirdPerson = true; + boolean cameraIsThirdPerson = false; //The list of window strings that would block main game controls static String[] controlBlockingWindows = new String[]{ diff --git a/src/main/java/electrosphere/engine/Main.java b/src/main/java/electrosphere/engine/Main.java index 3b9d9ccc..b249b285 100644 --- a/src/main/java/electrosphere/engine/Main.java +++ b/src/main/java/electrosphere/engine/Main.java @@ -164,10 +164,10 @@ public class Main { //uncomment to test loading a model into engine // if(1==1){ - // Globals.assetManager.addModelPathToQueue("/Models/baseman9.glb"); + // Globals.assetManager.addModelPathToQueue("/Models/creatures/viewmodel.glb"); // Globals.assetManager.loadAssetsInQueue(); - // Model model = Globals.assetManager.fetchModel("/Models/baseman9.glb"); - // // for(electrosphere.renderer.anim.Animation anim : model.animations){ + // electrosphere.renderer.model.Model model = Globals.assetManager.fetchModel("/Models/creatures/viewmodel.glb"); + // // for(electrosphere.renderer.anim.Animation anim : model.getAnimations()){ // // if(anim.name.equals("Armature|Idle1")){ // // System.out.println(anim.duration); // // for(electrosphere.renderer.anim.AnimChannel channel : anim.channels){ diff --git a/src/main/java/electrosphere/entity/EntityDataStrings.java b/src/main/java/electrosphere/entity/EntityDataStrings.java index 84c479c6..51c50a7f 100644 --- a/src/main/java/electrosphere/entity/EntityDataStrings.java +++ b/src/main/java/electrosphere/entity/EntityDataStrings.java @@ -202,6 +202,7 @@ public class EntityDataStrings { public static final String ATTACK_MOVE_TYPE_ACTIVE = "attackMoveTypeActive"; public static final String ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND = "MELEE_WEAPON_SWING_ONE_HAND"; + public static final String ATTACK_MOVE_TYPE_MELEE_SWING_TWO_HAND = "MELEE_WEAPON_SWING_TWO_HAND"; public static final String ATTACK_MOVE_TYPE_BOW_TWO_HAND = "RANGED_WEAPON_BOW_TWO_HAND"; /** diff --git a/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java b/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java index 140fbe76..392413b0 100644 --- a/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java +++ b/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java @@ -266,20 +266,24 @@ public class ClientAttackTree implements BehaviorTree { } //activate hitboxes List attachedEntities = AttachUtils.getChildrenList(parent); - for(Entity currentAttached : attachedEntities){ - if(HitboxCollectionState.hasHitboxState(currentAttached)){ - HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached); - currentState.setActive(true); + if(attachedEntities != null){ + for(Entity currentAttached : attachedEntities){ + if(HitboxCollectionState.hasHitboxState(currentAttached)){ + HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached); + currentState.setActive(true); + } } } } break; case COOLDOWN: { //deactive hitboxes List attachedEntities = AttachUtils.getChildrenList(parent); - for(Entity currentAttached : attachedEntities){ - if(HitboxCollectionState.hasHitboxState(currentAttached)){ - HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached); - currentState.setActive(false); + if(attachedEntities != null){ + for(Entity currentAttached : attachedEntities){ + if(HitboxCollectionState.hasHitboxState(currentAttached)){ + HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached); + currentState.setActive(false); + } } } if(currentMove != null && frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames() + currentMove.getCooldownFrames()){ @@ -317,6 +321,9 @@ public class ClientAttackTree implements BehaviorTree { case "sword1h": rVal = EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND; break; + case "sword2h": + rVal = EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_TWO_HAND; + break; case "bow2h": rVal = EntityDataStrings.ATTACK_MOVE_TYPE_BOW_TWO_HAND; break; diff --git a/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java b/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java index 9d35b077..d6c5caae 100644 --- a/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java +++ b/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java @@ -381,6 +381,9 @@ public class ServerAttackTree implements BehaviorTree { case "sword1h": rVal = EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND; break; + case "sword2h": + rVal = EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_TWO_HAND; + break; case "bow2h": rVal = EntityDataStrings.ATTACK_MOVE_TYPE_BOW_TWO_HAND; break; diff --git a/src/main/java/electrosphere/entity/state/client/firstPerson/FirstPersonTree.java b/src/main/java/electrosphere/entity/state/client/firstPerson/FirstPersonTree.java index c9b5bcfd..42db18fb 100644 --- a/src/main/java/electrosphere/entity/state/client/firstPerson/FirstPersonTree.java +++ b/src/main/java/electrosphere/entity/state/client/firstPerson/FirstPersonTree.java @@ -109,6 +109,14 @@ public class FirstPersonTree implements BehaviorTree { this.currentAnimation = animationName; } + /** + * Gets the animation currently playing + * @return The name of the animation + */ + public String getCurrentAnimation(){ + return currentAnimation; + } + /** * If the entity has a first person tree, plays the provided animation * @param entity The entity diff --git a/src/main/java/electrosphere/entity/types/item/ItemUtils.java b/src/main/java/electrosphere/entity/types/item/ItemUtils.java index 70a9d809..0fcccb50 100644 --- a/src/main/java/electrosphere/entity/types/item/ItemUtils.java +++ b/src/main/java/electrosphere/entity/types/item/ItemUtils.java @@ -18,6 +18,7 @@ import electrosphere.entity.state.gravity.ClientGravityTree; import electrosphere.entity.state.gravity.ServerGravityTree; import electrosphere.entity.state.hitbox.HitboxCollectionState; import electrosphere.game.data.collidable.CollidableTemplate; +import electrosphere.game.data.item.type.EquipData; import electrosphere.game.data.item.type.EquipWhitelist; import electrosphere.game.data.item.type.Item; import electrosphere.game.data.item.type.WeaponData; @@ -79,9 +80,6 @@ public class ItemUtils { break; } } - if(item.getEquipWhitelist() != null){ - rVal.putData(EntityDataStrings.ITEM_EQUIP_WHITELIST, item.getEquipWhitelist()); - } if(item.getIdleAnim() != null){ rVal.putData(EntityDataStrings.ANIM_IDLE,item.getIdleAnim()); } @@ -90,8 +88,20 @@ public class ItemUtils { } else { rVal.putData(EntityDataStrings.ITEM_ICON,genericItemIconPath); } - if(item.getEquipClass() != null){ - rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS,item.getEquipClass()); + + // + // + // Equip data + // + // + if(item.getEquipData() != null){ + EquipData equipData = item.getEquipData(); + if(equipData.getEquipWhitelist() != null){ + rVal.putData(EntityDataStrings.ITEM_EQUIP_WHITELIST, equipData.getEquipWhitelist()); + } + if(equipData.getEquipClass() != null){ + rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS,equipData.getEquipClass()); + } } rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true); EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM); @@ -152,9 +162,6 @@ public class ItemUtils { break; } } - if(item.getEquipWhitelist() != null){ - rVal.putData(EntityDataStrings.ITEM_EQUIP_WHITELIST, item.getEquipWhitelist()); - } if(item.getIdleAnim() != null){ rVal.putData(EntityDataStrings.ANIM_IDLE,item.getIdleAnim()); } @@ -163,8 +170,19 @@ public class ItemUtils { } else { rVal.putData(EntityDataStrings.ITEM_ICON,genericItemIconPath); } - if(item.getEquipClass() != null){ - rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS,item.getEquipClass()); + // + // + // Equip data + // + // + if(item.getEquipData() != null){ + EquipData equipData = item.getEquipData(); + if(equipData.getEquipWhitelist() != null){ + rVal.putData(EntityDataStrings.ITEM_EQUIP_WHITELIST, equipData.getEquipWhitelist()); + } + if(equipData.getEquipClass() != null){ + rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS,equipData.getEquipClass()); + } } rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true); EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM); diff --git a/src/main/java/electrosphere/game/data/creature/type/attack/AttackMoveResolver.java b/src/main/java/electrosphere/game/data/creature/type/attack/AttackMoveResolver.java index 67d25391..31c85994 100644 --- a/src/main/java/electrosphere/game/data/creature/type/attack/AttackMoveResolver.java +++ b/src/main/java/electrosphere/game/data/creature/type/attack/AttackMoveResolver.java @@ -7,10 +7,20 @@ import java.util.Map; import electrosphere.logger.LoggerInterface; +/** + * Resolves attack move ids to lists of chains of attacks + */ public class AttackMoveResolver { + /** + * The map of attack move id -> attack move object chain + */ Map> attackMovesetMap = new HashMap>(); + /** + * Constructor + * @param movelist The raw list of attack moves + */ public AttackMoveResolver(List movelist){ //get all moves for(AttackMove move : movelist){ @@ -24,16 +34,27 @@ public class AttackMoveResolver { } } //reorder - for(List toOrder : attackMovesetMap.values()){ - reorderMoveset(toOrder); + for(String attackTypeKey : attackMovesetMap.keySet()){ + List currentKeyList = attackMovesetMap.get(attackTypeKey); + reorderMoveset(attackTypeKey, currentKeyList); } } + /** + * Gets a chain of attack moves based on the attack type + * @param attackType The type of attack (IE "Sword2HSlash1") + * @return The chain of attack moves if it exists, null otherwise + */ public List getMoveset(String attackType){ return attackMovesetMap.get(attackType); } - void reorderMoveset(List finalMovelist){ + /** + * Reorders the attack moveset list + * @param attackTypeKey The current attack type key (IE "Sword2HSlash1") + * @param finalMovelist The moveset list + */ + void reorderMoveset(String attackTypeKey, List finalMovelist){ AttackMove currentMove = null; //solve for initial move for(AttackMove move : finalMovelist){ @@ -67,7 +88,11 @@ public class AttackMoveResolver { finalMovelist.add(move); } } else { - LoggerInterface.loggerEngine.WARNING("FAILED TO LOAD INITIAL MOVE IN AttackMoveResolver"); + String message = "FAILED TO LOAD INITIAL MOVE IN AttackMoveResolver\n" + + "The attack move type is: " + attackTypeKey + "\n" + + "This is commonly caused by having your initial move in the attack chain in data not having the field \"initialMove\" set to true!" + ; + LoggerInterface.loggerEngine.ERROR(new IllegalArgumentException(message)); } } diff --git a/src/main/java/electrosphere/game/data/item/type/EquipData.java b/src/main/java/electrosphere/game/data/item/type/EquipData.java new file mode 100644 index 00000000..37e7c722 --- /dev/null +++ b/src/main/java/electrosphere/game/data/item/type/EquipData.java @@ -0,0 +1,43 @@ +package electrosphere.game.data.item.type; + +import java.util.List; + +/** + * Data about how this item is equipped (ie, where is it equipped, what slots does it take, who can equip it, etc) + */ +public class EquipData { + + //the equip whitelist for this item (what creatures can equip this item?) + List equipWhitelist; + + //the class of item + String equipClass; + + //The list of slots that this item takes up when it is equipped + List equipSlots; + + /** + * the equip whitelist for this item (what creatures can equip this item?) + * @return + */ + public List getEquipWhitelist(){ + return equipWhitelist; + } + + /** + * the class of item + * @return + */ + public String getEquipClass(){ + return equipClass; + } + + /** + * Gets the list of equip slot ids that are taken up when equipping this item + * @return The list of equip slot ids + */ + public List getEquipSlots(){ + return equipSlots; + } + +} diff --git a/src/main/java/electrosphere/game/data/item/type/Item.java b/src/main/java/electrosphere/game/data/item/type/Item.java index c9b44ee5..3117ac5d 100644 --- a/src/main/java/electrosphere/game/data/item/type/Item.java +++ b/src/main/java/electrosphere/game/data/item/type/Item.java @@ -17,16 +17,14 @@ public class Item { List tokens; //the collidable data for the item CollidableTemplate collidable; - //the equip whitelist for this item (what creatures can equip this item?) - List equipWhitelist; //the idle animation for the item String idleAnim; //the path for the icon texture for this item String iconPath; - //the class of item - String equipClass; //weapon data for this item if it is an item WeaponData weaponData; + //The data defining how this item is equipped + EquipData equipData; /** * the id of the item @@ -59,14 +57,6 @@ public class Item { return collidable; } - /** - * the equip whitelist for this item (what creatures can equip this item?) - * @return - */ - public List getEquipWhitelist(){ - return equipWhitelist; - } - /** * the idle animation for the item * @return @@ -83,14 +73,6 @@ public class Item { return iconPath; } - /** - * the class of item - * @return - */ - public String getEquipClass(){ - return equipClass; - } - /** * weapon data for this item if it is an item * @return @@ -98,5 +80,13 @@ public class Item { public WeaponData getWeaponData(){ return weaponData; } + + /** + * Gets the equip data for the item type + * @return The equip data + */ + public EquipData getEquipData(){ + return equipData; + } } diff --git a/src/main/java/electrosphere/net/client/protocol/EntityProtocol.java b/src/main/java/electrosphere/net/client/protocol/EntityProtocol.java index 14656fcd..ba05b7d1 100644 --- a/src/main/java/electrosphere/net/client/protocol/EntityProtocol.java +++ b/src/main/java/electrosphere/net/client/protocol/EntityProtocol.java @@ -168,7 +168,6 @@ public class EntityProtocol { Globals.firstPersonEntity = EntityCreationUtils.createClientSpatialEntity(); EntityCreationUtils.makeEntityDrawable(Globals.firstPersonEntity, viewModelData.getFirstPersonModelPath()); FirstPersonTree.attachTree(Globals.firstPersonEntity, viewModelData.getHeightFromOrigin(), viewModelData.getCameraViewDirOffsetY(), viewModelData.getCameraViewDirOffsetZ()); - Globals.clientSceneWrapper.getScene().removeEntityFromTag(Globals.firstPersonEntity,EntityTags.DRAWABLE); } } } diff --git a/src/main/java/electrosphere/renderer/pipelines/MainContentPipeline.java b/src/main/java/electrosphere/renderer/pipelines/MainContentPipeline.java index 7407090f..b83257e0 100644 --- a/src/main/java/electrosphere/renderer/pipelines/MainContentPipeline.java +++ b/src/main/java/electrosphere/renderer/pipelines/MainContentPipeline.java @@ -70,10 +70,7 @@ public class MainContentPipeline implements RenderPipeline { // for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAWABLE)){ Vector3d position = EntityUtils.getPosition(currentEntity); - if( - (boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) && - currentEntity.getData(EntityDataStrings.DRAW_SOLID_PASS) != null - ){ + if(shouldDrawSolidPass(currentEntity)){ //fetch actor Actor currentActor = EntityUtils.getActor(currentEntity); //calculate camera-modified vector3f @@ -91,10 +88,7 @@ public class MainContentPipeline implements RenderPipeline { Globals.clientFoliageManager.draw(); for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_INSTANCED)){ Vector3d position = EntityUtils.getPosition(currentEntity); - if( - currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) != null && - currentEntity.getData(EntityDataStrings.DRAW_SOLID_PASS) != null - ){ + if(shouldDrawSolidPass(currentEntity)){ //fetch actor InstancedActor currentActor = InstancedActor.getInstancedActor(currentEntity); //if the shader attribute for model matrix exists, calculate the model matrix and apply @@ -156,10 +150,7 @@ public class MainContentPipeline implements RenderPipeline { for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAWABLE)){ Vector3d position = EntityUtils.getPosition(currentEntity); - if( - (boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) && - currentEntity.getData(EntityDataStrings.DRAW_TRANSPARENT_PASS) != null - ){ + if(shouldDrawTransparentPass(currentEntity)){ //fetch actor Actor currentActor = EntityUtils.getActor(currentEntity); //calculate camera-modified vector3f @@ -176,10 +167,7 @@ public class MainContentPipeline implements RenderPipeline { } for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_INSTANCED)){ Vector3d position = EntityUtils.getPosition(currentEntity); - if( - currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) != null && - currentEntity.getData(EntityDataStrings.DRAW_TRANSPARENT_PASS) != null - ){ + if(shouldDrawTransparentPass(currentEntity)){ //fetch actor InstancedActor currentActor = InstancedActor.getInstancedActor(currentEntity); //if the shader attribute for model matrix exists, calculate the model matrix and apply @@ -218,5 +206,48 @@ public class MainContentPipeline implements RenderPipeline { Globals.profiler.endCpuSample(); } + + /** + * Checks if the entity should be drawn + * @param entity The entity + * @return true if should draw, false otherwise + */ + static boolean shouldDrawSolidPass(Entity entity){ + return + ( + (boolean)entity.getData(EntityDataStrings.DATA_STRING_DRAW) && + entity.getData(EntityDataStrings.DRAW_SOLID_PASS) != null + ) && + ( + !entityBlacklist(entity) + ) + ; + } + + /** + * Checks if the entity should be drawn + * @param entity The entity + * @return true if should draw, false otherwise + */ + static boolean shouldDrawTransparentPass(Entity entity){ + return + ( + (boolean)entity.getData(EntityDataStrings.DATA_STRING_DRAW) && + entity.getData(EntityDataStrings.DRAW_TRANSPARENT_PASS) != null + ) && + ( + !entityBlacklist(entity) + ) + ; + } + + /** + * Checks whether the entity is on the blacklist for drawing in main pipeline or not + * @param entity The entity + * @return True if in blacklist, false otherwise + */ + static boolean entityBlacklist(Entity entity){ + return entity == Globals.firstPersonEntity; + } } diff --git a/src/main/java/electrosphere/server/character/PlayerCharacterCreation.java b/src/main/java/electrosphere/server/character/PlayerCharacterCreation.java index 0d00d1c1..532ce92b 100644 --- a/src/main/java/electrosphere/server/character/PlayerCharacterCreation.java +++ b/src/main/java/electrosphere/server/character/PlayerCharacterCreation.java @@ -42,9 +42,9 @@ public class PlayerCharacterCreation { realm.getServerWorldData().convertRealToChunkSpace(Globals.spawnPoint.z) )); realm.getDataCellManager().addPlayerToRealm(playerObject); - //set controller id + //parse network messages on client if running if(playerObject == Globals.clientPlayer){ - Globals.playerEntity = newPlayerEntity; + Globals.clientConnection.parseMessages(); } }