uninteractable menu
This commit is contained in:
parent
b446ff6398
commit
784279e13f
@ -55,7 +55,8 @@
|
||||
"ATTACKER",
|
||||
"GRAVITY",
|
||||
"TARGETABLE",
|
||||
"CAN_EQUIP"
|
||||
"CAN_EQUIP",
|
||||
"INVENTORY"
|
||||
],
|
||||
"visualAttributes" : [],
|
||||
"movementSystems" : [
|
||||
@ -131,6 +132,50 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"equipPoints" : [
|
||||
{
|
||||
"equipPointId" : "handLeft",
|
||||
"bone" : "MiddleLower.L",
|
||||
"offsetVector" : [],
|
||||
"offsetRotation" : [],
|
||||
"equipClassWhitelist" : [
|
||||
"tool",
|
||||
"shield",
|
||||
"item"
|
||||
]
|
||||
},
|
||||
{
|
||||
"equipPointId" : "handRight",
|
||||
"bone" : "MiddleLower.R",
|
||||
"offsetVector" : [],
|
||||
"offsetRotation" : [],
|
||||
"equipClassWhitelist" : [
|
||||
"tool",
|
||||
"weapon",
|
||||
"item"
|
||||
]
|
||||
},
|
||||
{
|
||||
"equipPointId" : "Torso",
|
||||
"bone" : "Bone",
|
||||
"offsetVector" : [],
|
||||
"offsetRotation" : [],
|
||||
"equipClassWhitelist" : [
|
||||
"armor",
|
||||
"clothing"
|
||||
]
|
||||
},
|
||||
{
|
||||
"equipPointId" : "Legs",
|
||||
"bone" : "Bone",
|
||||
"offsetVector" : [],
|
||||
"offsetRotation" : [],
|
||||
"equipClassWhitelist" : [
|
||||
"armor",
|
||||
"clothing"
|
||||
]
|
||||
}
|
||||
],
|
||||
"collidable" : {
|
||||
"type" : "CYLINDER",
|
||||
"dimension1" : 0.1,
|
||||
|
||||
@ -26,10 +26,10 @@
|
||||
"tokens" : [
|
||||
"GRAVITY",
|
||||
"BLENDER_TRANSFORM",
|
||||
"WEAPON",
|
||||
"MELEE",
|
||||
"TARGETABLE"
|
||||
],
|
||||
"equipClass" : "weapon",
|
||||
"idleAnim" : "Sword|Idle",
|
||||
"collidable": {
|
||||
"type" : "CUBE",
|
||||
@ -39,36 +39,18 @@
|
||||
"offsetX" : 0,
|
||||
"offsetY" : 0.05,
|
||||
"offsetZ" : 0
|
||||
}
|
||||
},
|
||||
"iconPath" : "Textures/icons/itemIconWeapon.png"
|
||||
},
|
||||
{
|
||||
"itemId" : "Bow",
|
||||
"modelPath": "Models/bow1.fbx",
|
||||
"tokens" : [
|
||||
"GRAVITY",
|
||||
"WEAPON",
|
||||
"RANGED",
|
||||
"TARGETABLE"
|
||||
],
|
||||
"collidable": {
|
||||
"type" : "CUBE",
|
||||
"dimension1" : 0.1,
|
||||
"dimension2" : 0.1,
|
||||
"dimension3" : 0.35,
|
||||
"offsetX" : 0,
|
||||
"offsetY" : 0.05,
|
||||
"offsetZ" : 0
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"itemId" : "shorts1",
|
||||
"modelPath": "Models/itemEntityShorts.fbx",
|
||||
"tokens" : [
|
||||
"GRAVITY",
|
||||
"ARMOR",
|
||||
"TARGETABLE"
|
||||
],
|
||||
"equipClass" : "weapon",
|
||||
"collidable": {
|
||||
"type" : "CUBE",
|
||||
"dimension1" : 0.1,
|
||||
@ -78,6 +60,27 @@
|
||||
"offsetY" : 0.05,
|
||||
"offsetZ" : 0
|
||||
},
|
||||
"iconPath" : "Textures/icons/itemIconWeapon.png"
|
||||
},
|
||||
|
||||
{
|
||||
"itemId" : "shorts1",
|
||||
"modelPath": "Models/itemEntityShorts.fbx",
|
||||
"tokens" : [
|
||||
"GRAVITY",
|
||||
"TARGETABLE"
|
||||
],
|
||||
"equipClass" : "clothing",
|
||||
"collidable": {
|
||||
"type" : "CUBE",
|
||||
"dimension1" : 0.1,
|
||||
"dimension2" : 0.1,
|
||||
"dimension3" : 0.35,
|
||||
"offsetX" : 0,
|
||||
"offsetY" : 0.05,
|
||||
"offsetZ" : 0
|
||||
},
|
||||
"iconPath" : "Textures/icons/itemIconItemGeneric.png",
|
||||
"equipWhitelist" : [
|
||||
{
|
||||
"creatureId" : "human",
|
||||
@ -100,6 +103,7 @@
|
||||
"ARMOR",
|
||||
"TARGETABLE"
|
||||
],
|
||||
"equipClass" : "trait",
|
||||
"collidable": {
|
||||
"type" : "CUBE",
|
||||
"dimension1" : 0.1,
|
||||
@ -109,6 +113,7 @@
|
||||
"offsetY" : 0.05,
|
||||
"offsetZ" : 0
|
||||
},
|
||||
"iconPath" : "Textures/icons/itemIconItemGeneric.png",
|
||||
"equipWhitelist" : [
|
||||
{
|
||||
"creatureId" : "human",
|
||||
@ -129,6 +134,7 @@
|
||||
"ARMOR",
|
||||
"TARGETABLE"
|
||||
],
|
||||
"equipClass" : "clothing",
|
||||
"collidable": {
|
||||
"type" : "CUBE",
|
||||
"dimension1" : 0.1,
|
||||
@ -138,6 +144,7 @@
|
||||
"offsetY" : 0.05,
|
||||
"offsetZ" : 0
|
||||
},
|
||||
"iconPath" : "Textures/icons/itemIconItemGeneric.png",
|
||||
"equipWhitelist" : [
|
||||
{
|
||||
"creatureId" : "human",
|
||||
@ -164,6 +171,7 @@
|
||||
"ARMOR",
|
||||
"TARGETABLE"
|
||||
],
|
||||
"equipClass" : "clothing",
|
||||
"collidable": {
|
||||
"type" : "CUBE",
|
||||
"dimension1" : 0.1,
|
||||
@ -173,6 +181,7 @@
|
||||
"offsetY" : 0.05,
|
||||
"offsetZ" : 0
|
||||
},
|
||||
"iconPath" : "Textures/icons/itemIconItemGeneric.png",
|
||||
"equipWhitelist" : [
|
||||
{
|
||||
"creatureId" : "human",
|
||||
|
||||
BIN
assets/Textures/icons/itemIconEmpty.png
Normal file
BIN
assets/Textures/icons/itemIconEmpty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
BIN
assets/Textures/icons/itemIconItemGeneric.png
Normal file
BIN
assets/Textures/icons/itemIconItemGeneric.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
assets/Textures/icons/itemIconWeapon.png
Normal file
BIN
assets/Textures/icons/itemIconWeapon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@ -8,6 +8,8 @@ import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.equip.EquipState;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree.MovementRelativeFacing;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree.MovementTreeState;
|
||||
@ -51,6 +53,7 @@ public class ControlHandler {
|
||||
public static final String INPUT_CODE_SPRINT = "sprint";
|
||||
public static final String INPUT_CODE_INTERACT = "interact";
|
||||
public static final String INPUT_CODE_DROP = "drop";
|
||||
public static final String INPUT_CODE_INVENTORY_OPEN = "inventoryOpen";
|
||||
|
||||
public static final String DATA_STRING_INPUT_CODE_MENU_INCREMENT = "menuIncrement";
|
||||
public static final String DATA_STRING_INPUT_CODE_MENU_DECREMENT = "menuDecrement";
|
||||
@ -97,6 +100,9 @@ public class ControlHandler {
|
||||
public static final String DATA_STRING_INPUT_CODE_MENU_TYPE_X = "menuTypeX";
|
||||
public static final String DATA_STRING_INPUT_CODE_MENU_TYPE_Y = "menuTypeY";
|
||||
public static final String DATA_STRING_INPUT_CODE_MENU_TYPE_Z = "menuTypeZ";
|
||||
|
||||
public static final String INPUT_CODE_INVENTORY_CLOSE = "inventoryClose";
|
||||
public static final String INPUT_CODE_INVENTORY_ITEM_MANIPULATE = "inventoryItemManipulate";
|
||||
|
||||
|
||||
public static enum ControlsState {
|
||||
@ -104,6 +110,7 @@ public class ControlHandler {
|
||||
TITLE_MENU,
|
||||
MAIN_GAME,
|
||||
IN_GAME_MAIN_MENU,
|
||||
INVENTORY,
|
||||
NO_INPUT,
|
||||
}
|
||||
|
||||
@ -117,6 +124,7 @@ public class ControlHandler {
|
||||
List<Control> mainGameDebugControlList = new LinkedList<Control>();
|
||||
List<Control> menuNavigationControlList = new LinkedList<Control>();
|
||||
List<Control> typingControlList = new LinkedList<Control>();
|
||||
List<Control> inventoryControlList = new LinkedList<Control>();
|
||||
|
||||
ControlHandler(){
|
||||
controls = new HashMap<String, Control>();
|
||||
@ -145,6 +153,7 @@ public class ControlHandler {
|
||||
handler.addControl(INPUT_CODE_SPRINT, new Control(true,false,GLFW_KEY_LEFT_SHIFT));
|
||||
handler.addControl(INPUT_CODE_INTERACT, new Control(true,false,GLFW_KEY_E));
|
||||
handler.addControl(INPUT_CODE_DROP, new Control(true,false,GLFW_KEY_Y));
|
||||
handler.addControl(INPUT_CODE_INVENTORY_OPEN, new Control(true,false,GLFW_KEY_I));
|
||||
|
||||
/*
|
||||
Map the menu navigation controls
|
||||
@ -195,6 +204,12 @@ public class ControlHandler {
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MENU_TYPE_X, new Control(true,false,GLFW_KEY_X));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MENU_TYPE_Y, new Control(true,false,GLFW_KEY_Y));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MENU_TYPE_Z, new Control(true,false,GLFW_KEY_Z));
|
||||
|
||||
/*
|
||||
Inventory controls
|
||||
*/
|
||||
handler.addControl(INPUT_CODE_INVENTORY_CLOSE, new Control(true,false,GLFW_KEY_I));
|
||||
handler.addControl(INPUT_CODE_INVENTORY_ITEM_MANIPULATE, new Control(false,true,GLFW_MOUSE_BUTTON_1));
|
||||
|
||||
/*
|
||||
set state
|
||||
@ -248,6 +263,10 @@ public class ControlHandler {
|
||||
runHandlers(menuNavigationControlList);
|
||||
// pollMenuNavigationControls();
|
||||
break;
|
||||
|
||||
case INVENTORY:
|
||||
runHandlers(inventoryControlList);
|
||||
break;
|
||||
|
||||
case NO_INPUT:
|
||||
break;
|
||||
@ -261,6 +280,7 @@ public class ControlHandler {
|
||||
setInGameDebugControls();
|
||||
setMenuNavigationControls();
|
||||
setTypingControls();
|
||||
setInventoryControls();
|
||||
}
|
||||
|
||||
void setMainGameControls(){
|
||||
@ -541,8 +561,13 @@ public class ControlHandler {
|
||||
controls.get(INPUT_CODE_INTERACT).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerCharacter != null){
|
||||
if(Globals.playerCharacter.getDataKeys().contains(EntityDataStrings.EQUIP_STATE) && Crosshair.hasTarget()){
|
||||
EquipState equipState = (EquipState)Globals.playerCharacter.getData(EntityDataStrings.EQUIP_STATE);
|
||||
equipState.attemptEquip(Crosshair.getTarget());
|
||||
if(InventoryUtils.hasNaturalInventory(Globals.playerCharacter)){
|
||||
InventoryUtils.attemptStoreItem(Globals.playerCharacter, Crosshair.getTarget());
|
||||
// UnrelationalInventoryState inventory = InventoryUtils.getNaturalInventory(Globals.playerCharacter);
|
||||
// inventory.addItem(Crosshair.getTarget());
|
||||
}
|
||||
// EquipState equipState = (EquipState)Globals.playerCharacter.getData(EntityDataStrings.EQUIP_STATE);
|
||||
// // equipState.attemptEquip(Crosshair.getTarget());
|
||||
}
|
||||
}
|
||||
}});
|
||||
@ -554,8 +579,13 @@ public class ControlHandler {
|
||||
controls.get(INPUT_CODE_DROP).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerCharacter != null){
|
||||
if(Globals.playerCharacter.getDataKeys().contains(EntityDataStrings.EQUIP_STATE)){
|
||||
EquipState equipState = (EquipState)Globals.playerCharacter.getData(EntityDataStrings.EQUIP_STATE);
|
||||
equipState.drop();
|
||||
// EquipState equipState = (EquipState)Globals.playerCharacter.getData(EntityDataStrings.EQUIP_STATE);
|
||||
// equipState.drop();
|
||||
UnrelationalInventoryState inventory = InventoryUtils.getNaturalInventory(Globals.playerCharacter);
|
||||
if(inventory.getItems().size() > 0){
|
||||
Entity itemToDrop = inventory.getItems().get(0);
|
||||
InventoryUtils.attemptEjectItem(Globals.playerCharacter,itemToDrop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
@ -602,6 +632,20 @@ public class ControlHandler {
|
||||
Globals.controlHandler.setHandlerState(ControlsState.IN_GAME_MAIN_MENU);
|
||||
}});
|
||||
|
||||
/*
|
||||
Open inventory
|
||||
*/
|
||||
mainGameControlList.add(controls.get(INPUT_CODE_INVENTORY_OPEN));
|
||||
controls.get(INPUT_CODE_INVENTORY_OPEN).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(InventoryUtils.hasNaturalInventory(Globals.playerCharacter)){
|
||||
UnrelationalInventoryState inventory = InventoryUtils.getNaturalInventory(Globals.playerCharacter);
|
||||
Globals.currentMenu = MenuUtils.createNaturalInventoryMenu(inventory);
|
||||
MenuUtils.makeMenuDrawable(Globals.currentMenu);
|
||||
Globals.controlHandler.setHandlerState(ControlsState.INVENTORY);
|
||||
Globals.controlHandler.showMouse();
|
||||
}
|
||||
}});
|
||||
|
||||
}
|
||||
|
||||
void setInGameDebugControls(){
|
||||
@ -734,6 +778,23 @@ public class ControlHandler {
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void setInventoryControls(){
|
||||
/*
|
||||
Close inventory
|
||||
*/
|
||||
inventoryControlList.add(controls.get(INPUT_CODE_INVENTORY_CLOSE));
|
||||
controls.get(INPUT_CODE_INVENTORY_CLOSE).setOnPress(new ControlMethod(){public void execute(){
|
||||
MenuTransition.backout(Globals.currentMenu);
|
||||
}});
|
||||
/*
|
||||
Item manipulation
|
||||
*/
|
||||
inventoryControlList.add(controls.get(INPUT_CODE_INVENTORY_ITEM_MANIPULATE));
|
||||
controls.get(INPUT_CODE_INVENTORY_ITEM_MANIPULATE).setOnPress(new ControlMethod(){public void execute(){
|
||||
|
||||
}});
|
||||
}
|
||||
|
||||
public Control getControl(String controlName){
|
||||
return controls.get(controlName);
|
||||
|
||||
@ -160,6 +160,10 @@ public class AssetManager {
|
||||
texturesLoadedIntoMemory.put(rVal,t);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public boolean hasLoadedTexture(String path){
|
||||
return texturesLoadedIntoMemory.containsKey(path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -125,6 +125,8 @@ public class EntityDataStrings {
|
||||
public static final String COLLIDABLE_TREE = "collidableTree";
|
||||
|
||||
public static final String HITBOX_DATA = "hitboxData";
|
||||
public static final String HITBOX_ASSOCIATED_LIST = "hitboxAssociatedList";
|
||||
public static final String HURTBOX_ASSOCIATED_LIST = "hurtboxAssociatedList";
|
||||
|
||||
|
||||
/*
|
||||
@ -143,6 +145,7 @@ public class EntityDataStrings {
|
||||
public static final String ITEM_IS_WEAPON = "itemIsWeapon";
|
||||
public static final String ITEM_IS_ARMOR = "itemIsArmor";
|
||||
public static final String ITEM_EQUIP_WHITELIST = "itemEquipWhitelist";
|
||||
public static final String ITEM_ICON = "itemIcon";
|
||||
|
||||
|
||||
/*
|
||||
@ -186,6 +189,12 @@ public class EntityDataStrings {
|
||||
Equip state
|
||||
*/
|
||||
public static final String EQUIP_STATE = "equipState";
|
||||
public static final String EQUIP_INVENTORY = "equipInventory";
|
||||
|
||||
/*
|
||||
Inventory in general
|
||||
*/
|
||||
public static final String NATURAL_INVENTORY = "inventoryNatural";
|
||||
|
||||
/*
|
||||
Entity categories
|
||||
|
||||
@ -190,11 +190,10 @@ public class AttackTree {
|
||||
if(parent.getDataKeys().contains(EntityDataStrings.ATTACH_CHILDREN_LIST)){
|
||||
List<Entity> attachedEntities = (List<Entity>)parent.getData(EntityDataStrings.ATTACH_CHILDREN_LIST);
|
||||
for(Entity currentAttached : attachedEntities){
|
||||
if(currentAttached.getDataKeys().contains(EntityDataStrings.ITEM_IS_ITEM)){
|
||||
for(Entity hitbox : Globals.hitboxManager.getAllHitboxes()){
|
||||
if(hitbox.getData(EntityDataStrings.COLLISION_ENTITY_DATA_PARENT) == currentAttached){
|
||||
HitboxUtils.getHitboxData(hitbox).setActive(true);
|
||||
}
|
||||
if(currentAttached.getDataKeys().contains(EntityDataStrings.HITBOX_ASSOCIATED_LIST)){
|
||||
List<Entity> hitboxes = HitboxUtils.getHitboxAssociatedList(currentAttached);
|
||||
for(Entity hitbox : hitboxes){
|
||||
HitboxUtils.getHitboxData(hitbox).setActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -239,11 +238,10 @@ public class AttackTree {
|
||||
if(parent.getDataKeys().contains(EntityDataStrings.ATTACH_CHILDREN_LIST)){
|
||||
List<Entity> attachedEntities = (List<Entity>)parent.getData(EntityDataStrings.ATTACH_CHILDREN_LIST);
|
||||
for(Entity currentAttached : attachedEntities){
|
||||
if(currentAttached.getDataKeys().contains(EntityDataStrings.ITEM_IS_ITEM)){
|
||||
for(Entity hitbox : Globals.hitboxManager.getAllHitboxes()){
|
||||
if(hitbox.getData(EntityDataStrings.COLLISION_ENTITY_DATA_PARENT) == currentAttached){
|
||||
HitboxUtils.getHitboxData(hitbox).setActive(false);
|
||||
}
|
||||
if(currentAttached.getDataKeys().contains(EntityDataStrings.HITBOX_ASSOCIATED_LIST)){
|
||||
List<Entity> hitboxes = HitboxUtils.getHitboxAssociatedList(currentAttached);
|
||||
for(Entity hitbox : hitboxes){
|
||||
HitboxUtils.getHitboxData(hitbox).setActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -305,24 +303,24 @@ public class AttackTree {
|
||||
} else {
|
||||
if(parent.getDataKeys().contains(EntityDataStrings.EQUIP_STATE)){
|
||||
EquipState equipState = (EquipState)parent.getData(EntityDataStrings.EQUIP_STATE);
|
||||
if(equipState.hasEquipPrimary()){
|
||||
switch(attackType){
|
||||
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||
break;
|
||||
default:
|
||||
rVal = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch(attackType){
|
||||
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||
rVal = false;
|
||||
break;
|
||||
default:
|
||||
rVal = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if(equipState.hasEquipPrimary()){
|
||||
// switch(attackType){
|
||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||
// break;
|
||||
// default:
|
||||
// rVal = false;
|
||||
// break;
|
||||
// }
|
||||
// } else {
|
||||
// switch(attackType){
|
||||
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||
// rVal = false;
|
||||
// break;
|
||||
// default:
|
||||
// rVal = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
return rVal;
|
||||
|
||||
@ -4,7 +4,7 @@ import electrosphere.collision.dispatch.CollisionObject;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.GravityTree;
|
||||
import electrosphere.entity.state.gravity.GravityTree;
|
||||
import electrosphere.game.collision.PhysicsUtils;
|
||||
import electrosphere.game.collision.collidable.Collidable;
|
||||
import electrosphere.game.data.creature.type.CollidableTemplate;
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package electrosphere.entity.state.equip;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import electrosphere.collision.dispatch.CollisionObject;
|
||||
import electrosphere.dynamics.RigidBody;
|
||||
@ -12,6 +15,7 @@ import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.game.client.targeting.crosshair.Crosshair;
|
||||
import electrosphere.game.collision.collidable.Collidable;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.game.data.item.type.EquipWhitelist;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
@ -24,36 +28,38 @@ import electrosphere.renderer.actor.ActorMeshMask;
|
||||
public class EquipState {
|
||||
|
||||
Entity parent;
|
||||
|
||||
List<EquipPoint> equipPoints = new LinkedList<EquipPoint>();
|
||||
Map<String,Entity> equipMap = new HashMap<String,Entity>();
|
||||
|
||||
Entity equipPrimary;
|
||||
|
||||
String equipPrimaryBoneName;
|
||||
|
||||
public EquipState(Entity parent, String equipPrimaryBoneName){
|
||||
public EquipState(Entity parent, List<EquipPoint> equipPoints){
|
||||
this.parent = parent;
|
||||
this.equipPrimaryBoneName = equipPrimaryBoneName;
|
||||
}
|
||||
|
||||
public boolean hasEquipPrimary(){
|
||||
return equipPrimary != null;
|
||||
for(EquipPoint point : equipPoints){
|
||||
this.equipPoints.add(point);
|
||||
}
|
||||
}
|
||||
|
||||
public Entity getEquipPrimary() {
|
||||
return equipPrimary;
|
||||
}
|
||||
|
||||
public void setEquipPrimary(Entity equipPrimary) {
|
||||
this.equipPrimary = equipPrimary;
|
||||
public List<String> equippedPoints(){
|
||||
return new LinkedList<String>(equipMap.keySet());
|
||||
}
|
||||
|
||||
public void attemptEquip(Entity toEquip){
|
||||
if(!hasEquipPrimary() && ItemUtils.isItem(toEquip) && !AttachUtils.isAttached(toEquip)){
|
||||
if(ItemUtils.hasEquipList(toEquip)){
|
||||
public void attemptEquip(Entity toEquip, EquipPoint point){
|
||||
boolean hasEquipped = equipMap.containsKey(point.getEquipPointId());
|
||||
boolean targetIsItem = ItemUtils.isItem(toEquip);
|
||||
boolean targetIsAttached = AttachUtils.isAttached(toEquip);
|
||||
boolean targetHasWhitelist = ItemUtils.hasEquipList(toEquip);
|
||||
String equipItemClass = "";//somehow resolve from 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)){
|
||||
equipPrimary = toEquip;
|
||||
//put in map
|
||||
equipMap.put(point.getEquipPointId(),toEquip);
|
||||
String modelName = whitelistItem.getModel();
|
||||
Globals.assetManager.addModelPathToQueue(modelName);
|
||||
Actor parentActor = EntityUtils.getActor(parent);
|
||||
@ -66,7 +72,7 @@ public class EquipState {
|
||||
meshMask.queueMesh(modelName, toDraw);
|
||||
}
|
||||
//attach to parent bone
|
||||
AttachUtils.attachEntityToEntityAtBone(parent, toEquip, equipPrimaryBoneName);
|
||||
AttachUtils.attachEntityToEntityAtBone(parent, toEquip, point.getBone());
|
||||
//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);
|
||||
@ -75,32 +81,79 @@ public class EquipState {
|
||||
//hide toEquip actor
|
||||
EntityUtils.setDraw(toEquip, false);
|
||||
//make untargetable
|
||||
Globals.entityManager.setTargetable(equipPrimary, false);
|
||||
Globals.entityManager.setTargetable(toEquip, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
equipPrimary = toEquip;
|
||||
AttachUtils.attachEntityToEntityAtBone(parent, toEquip, equipPrimaryBoneName);
|
||||
//since we're not replacing meshes we must be attaching to a bone
|
||||
equipMap.put(point.getEquipPointId(),toEquip);
|
||||
AttachUtils.attachEntityToEntityAtBone(parent, toEquip, point.getBone());
|
||||
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);
|
||||
Globals.entityManager.setTargetable(toEquip, false);
|
||||
}
|
||||
}
|
||||
// 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 void drop(){
|
||||
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 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 unequipPoint(String pointId){
|
||||
equipMap.remove(pointId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package electrosphere.entity.state;
|
||||
package electrosphere.entity.state.gravity;
|
||||
|
||||
import electrosphere.collision.dispatch.CollisionObject;
|
||||
import electrosphere.entity.Entity;
|
||||
@ -0,0 +1,15 @@
|
||||
package electrosphere.entity.state.gravity;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
|
||||
public class GravityUtils {
|
||||
|
||||
public static void attemptActivateGravity(Entity target){
|
||||
if(target.getDataKeys().contains(EntityDataStrings.GRAVITY_ENTITY)){
|
||||
GravityTree tree = (GravityTree)target.getData(EntityDataStrings.GRAVITY_TREE);
|
||||
tree.start();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package electrosphere.entity.state.inventory;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.gravity.GravityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
|
||||
public class InventoryUtils {
|
||||
|
||||
|
||||
public static boolean hasNaturalInventory(Entity target){
|
||||
return target.getDataKeys().contains(EntityDataStrings.NATURAL_INVENTORY);
|
||||
}
|
||||
|
||||
public static UnrelationalInventoryState getNaturalInventory(Entity target){
|
||||
return (UnrelationalInventoryState)target.getData(EntityDataStrings.NATURAL_INVENTORY);
|
||||
}
|
||||
|
||||
public static void attemptStoreItem(Entity creature, Entity item){
|
||||
boolean creatureIsCreature = CreatureUtils.isCreature(creature);
|
||||
boolean itemIsItem = ItemUtils.isItem(item);
|
||||
boolean hasInventory = hasNaturalInventory(creature);
|
||||
if(creatureIsCreature && itemIsItem && hasInventory){
|
||||
//get inventory
|
||||
//for the moment we're just gonna get natural inventory
|
||||
//later we'll need to search through all creature inventories to find the item
|
||||
UnrelationalInventoryState inventory = getNaturalInventory(creature);
|
||||
//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
|
||||
Entity inventoryItem = ItemUtils.recreateContainerItem(item);
|
||||
//destroy the item that was left over
|
||||
ItemUtils.destroyInWorldItem(item);
|
||||
//store item in inventory
|
||||
inventory.addItem(inventoryItem);
|
||||
}
|
||||
}
|
||||
|
||||
//need creature so we can figure out where to drop the item
|
||||
public static void attemptEjectItem(Entity creature, Entity item){
|
||||
//verify creature is creature, item is item, inventory exists, and item is in inventory
|
||||
boolean creatureIsCreature = CreatureUtils.isCreature(creature);
|
||||
boolean itemIsItem = ItemUtils.isItem(item);
|
||||
boolean hasInventory = hasNaturalInventory(creature);
|
||||
if(creatureIsCreature && itemIsItem && hasInventory){
|
||||
//get inventory
|
||||
UnrelationalInventoryState inventory = getNaturalInventory(creature);
|
||||
//remove item from inventory
|
||||
inventory.removeItem(item);
|
||||
//compose item into in-world entity
|
||||
Entity inWorldItem = ItemUtils.spawnBasicItem(ItemUtils.getType(item));
|
||||
//delete in container item
|
||||
ItemUtils.destroyInInventoryItem(item);
|
||||
//find "in front of creature"
|
||||
Vector3d dropSpot = new Vector3d(EntityUtils.getPosition(creature)).add(CreatureUtils.getFacingVector(creature));
|
||||
//move in-world entity to in front of creature
|
||||
EntityUtils.getPosition(inWorldItem).set(dropSpot);
|
||||
//activate gravity
|
||||
GravityUtils.attemptActivateGravity(inWorldItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,22 +1,31 @@
|
||||
package electrosphere.entity.state.inventory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
|
||||
public class RelationalInventoryState {
|
||||
|
||||
int capacity;
|
||||
|
||||
Map<String,Entity> items = new HashMap<String,Entity>();
|
||||
|
||||
public RelationalInventoryState(List<String> slots){
|
||||
public static RelationalInventoryState buildRelationalInventoryStateFromStringList(List<String> slots){
|
||||
RelationalInventoryState rVal = new RelationalInventoryState();
|
||||
for(String slot : slots){
|
||||
items.put(slot,null);
|
||||
rVal.items.put(slot,null);
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static RelationalInventoryState buildRelationalInventoryStateFromEquipList(List<EquipPoint> points){
|
||||
RelationalInventoryState rVal = new RelationalInventoryState();
|
||||
for(EquipPoint point : points){
|
||||
rVal.items.put(point.getEquipPointId(),null);
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public void addItem(String slot, Entity item){
|
||||
@ -38,8 +47,8 @@ public class RelationalInventoryState {
|
||||
return items.containsKey(slot) ? items.get(slot) != null : false;
|
||||
}
|
||||
|
||||
public Set<String> getSlots(){
|
||||
return items.keySet();
|
||||
public List<String> getSlots(){
|
||||
return new LinkedList<String>(items.keySet());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -11,6 +11,10 @@ public class UnrelationalInventoryState {
|
||||
|
||||
List<Entity> items = new LinkedList<Entity>();
|
||||
|
||||
public UnrelationalInventoryState(int capacity){
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public void addItem(Entity item){
|
||||
items.add(item);
|
||||
}
|
||||
@ -23,7 +27,9 @@ public class UnrelationalInventoryState {
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
public int getCapacity(){
|
||||
return capacity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package electrosphere.entity.state.movement;
|
||||
|
||||
import electrosphere.entity.state.collidable.Impulse;
|
||||
import electrosphere.entity.state.gravity.GravityTree;
|
||||
import electrosphere.entity.state.gravity.GravityUtils;
|
||||
import electrosphere.collision.dispatch.CollisionObject;
|
||||
import electrosphere.dynamics.RigidBody;
|
||||
import electrosphere.entity.CameraEntityUtils;
|
||||
@ -10,8 +12,6 @@ import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.AttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.GravityTree;
|
||||
import electrosphere.entity.state.GravityTree;
|
||||
import electrosphere.entity.state.movement.SprintTree.SprintTreeState;
|
||||
import electrosphere.game.collision.CollisionEngine;
|
||||
import electrosphere.game.collision.PhysicsUtils;
|
||||
@ -179,17 +179,17 @@ public class GroundMovementTree {
|
||||
case 0:
|
||||
state = MovementTreeState.STARTUP;
|
||||
// System.out.println("Set state STARTUP");
|
||||
activateGravityTree();
|
||||
GravityUtils.attemptActivateGravity(parent);
|
||||
break;
|
||||
case 1:
|
||||
state = MovementTreeState.MOVE;
|
||||
// System.out.println("Set state MOVE");
|
||||
activateGravityTree();
|
||||
GravityUtils.attemptActivateGravity(parent);
|
||||
break;
|
||||
case 2:
|
||||
state = MovementTreeState.SLOWDOWN;
|
||||
// System.out.println("Set state SLOWDOWN");
|
||||
activateGravityTree();
|
||||
GravityUtils.attemptActivateGravity(parent);
|
||||
break;
|
||||
case 3:
|
||||
state = MovementTreeState.IDLE;
|
||||
@ -247,7 +247,7 @@ public class GroundMovementTree {
|
||||
// position.set(newPosition);
|
||||
rotation.set(movementQuaternion);
|
||||
|
||||
activateGravityTree();
|
||||
GravityUtils.attemptActivateGravity(parent);
|
||||
|
||||
if(Globals.RUN_SERVER){
|
||||
// Globals.server.broadcastMessage(
|
||||
@ -323,7 +323,7 @@ public class GroundMovementTree {
|
||||
// position.set(newPosition);
|
||||
rotation.set(movementQuaternion);
|
||||
|
||||
activateGravityTree();
|
||||
GravityUtils.attemptActivateGravity(parent);
|
||||
|
||||
if(Globals.RUN_SERVER){
|
||||
// Globals.server.broadcastMessage(
|
||||
@ -407,7 +407,7 @@ public class GroundMovementTree {
|
||||
// position.set(newPosition);
|
||||
rotation.set(movementQuaternion);
|
||||
|
||||
activateGravityTree();
|
||||
GravityUtils.attemptActivateGravity(parent);
|
||||
|
||||
if(Globals.RUN_SERVER){
|
||||
// Globals.server.broadcastMessage(
|
||||
@ -474,13 +474,6 @@ public class GroundMovementTree {
|
||||
networkMessageQueue.add(networkMessage);
|
||||
}
|
||||
|
||||
public void activateGravityTree(){
|
||||
if(parent.getDataKeys().contains(EntityDataStrings.GRAVITY_ENTITY)){
|
||||
GravityTree tree = (GravityTree)parent.getData(EntityDataStrings.GRAVITY_TREE);
|
||||
tree.start();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canStartMoving(){
|
||||
boolean rVal = true;
|
||||
if(parent.getDataKeys().contains(EntityDataStrings.ATTACK_TREE) && ((AttackTree)parent.getData(EntityDataStrings.ATTACK_TREE)).getState() != AttackTreeState.IDLE){
|
||||
|
||||
@ -11,10 +11,12 @@ import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||
import electrosphere.game.data.creature.type.CreatureType;
|
||||
import electrosphere.game.data.creature.type.MovementSystem;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.GravityTree;
|
||||
import electrosphere.entity.state.IdleTree;
|
||||
import electrosphere.entity.state.collidable.CollidableTree;
|
||||
import electrosphere.entity.state.equip.EquipState;
|
||||
import electrosphere.entity.state.gravity.GravityTree;
|
||||
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.entity.state.life.LifeState;
|
||||
import electrosphere.entity.state.movement.SprintTree;
|
||||
@ -23,6 +25,7 @@ import electrosphere.game.collision.collidable.Collidable;
|
||||
import electrosphere.game.data.creature.type.CollidableTemplate;
|
||||
import electrosphere.game.data.creature.type.SprintSystem;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.game.data.creature.type.visualattribute.AttributeVariant;
|
||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
@ -36,6 +39,10 @@ import electrosphere.renderer.Model;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.ActorUtils;
|
||||
import electrosphere.util.ModelLoader;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
@ -70,11 +77,19 @@ public class CreatureUtils {
|
||||
Entity rVal = EntityUtils.spawnDrawableEntity(rawType.getModelPath());
|
||||
Actor creatureActor = EntityUtils.getActor(rVal);
|
||||
for(HitboxData hitboxdata : rawType.getHitboxes()){
|
||||
List<Entity> hitboxList = new LinkedList<Entity>();
|
||||
List<Entity> hurtboxList = new LinkedList<Entity>();
|
||||
if(hitboxdata.getType().equals("hit")){
|
||||
Globals.hitboxManager.registerHitbox(HitboxUtils.spawnRegularHitbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius()));
|
||||
Entity hitbox = HitboxUtils.spawnRegularHitbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius());
|
||||
Globals.hitboxManager.registerHitbox(hitbox);
|
||||
hitboxList.add(hitbox);
|
||||
} else if(hitboxdata.getType().equals("hurt")){
|
||||
Globals.hitboxManager.registerHitbox(HitboxUtils.spawnRegularHurtbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius()));
|
||||
Entity hurtbox = HitboxUtils.spawnRegularHurtbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius());
|
||||
Globals.hitboxManager.registerHitbox(hurtbox);
|
||||
hurtboxList.add(hurtbox);
|
||||
}
|
||||
rVal.putData(EntityDataStrings.HITBOX_ASSOCIATED_LIST, hitboxList);
|
||||
rVal.putData(EntityDataStrings.HURTBOX_ASSOCIATED_LIST, hurtboxList);
|
||||
}
|
||||
if(rawType.getCollidable() != null){
|
||||
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
||||
@ -136,6 +151,10 @@ public class CreatureUtils {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){
|
||||
rVal.putData(EntityDataStrings.EQUIP_STATE, new EquipState(rVal,rawType.getEquipPoints()));
|
||||
rVal.putData(EntityDataStrings.EQUIP_INVENTORY, RelationalInventoryState.buildRelationalInventoryStateFromEquipList(rawType.getEquipPoints()));
|
||||
}
|
||||
for(String token : rawType.getTokens()){
|
||||
switch(token){
|
||||
case "BLENDER_TRANSFORM":
|
||||
@ -170,8 +189,11 @@ public class CreatureUtils {
|
||||
Globals.entityManager.registerTargetableEntity(rVal);
|
||||
break;
|
||||
case "CAN_EQUIP":
|
||||
rVal.putData(EntityDataStrings.EQUIP_STATE, new EquipState(rVal,"MiddleLower.R"));
|
||||
// rVal.putData(EntityDataStrings.EQUIP_STATE, new EquipState(rVal,"MiddleLower.R"));
|
||||
break;
|
||||
case "INVENTORY":
|
||||
rVal.putData(EntityDataStrings.NATURAL_INVENTORY,new UnrelationalInventoryState(10));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//variants
|
||||
|
||||
@ -12,7 +12,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
*/
|
||||
public class HitboxManager {
|
||||
|
||||
CopyOnWriteArrayList<Entity> hitboxes = new CopyOnWriteArrayList();
|
||||
CopyOnWriteArrayList<Entity> hitboxes = new CopyOnWriteArrayList<Entity>();
|
||||
long idIncrementer = 0;
|
||||
|
||||
public HitboxManager(){
|
||||
@ -28,4 +28,8 @@ public class HitboxManager {
|
||||
public CopyOnWriteArrayList<Entity> getAllHitboxes(){
|
||||
return hitboxes;
|
||||
}
|
||||
|
||||
public void deregisterHitbox(Entity hitbox){
|
||||
hitboxes.remove(hitbox);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,9 @@ import electrosphere.entity.state.life.LifeState;
|
||||
import electrosphere.entity.state.life.LifeUtils;
|
||||
import electrosphere.game.server.effects.ParticleEffects;
|
||||
import electrosphere.main.Globals;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3d;
|
||||
@ -148,5 +151,13 @@ public class HitboxUtils {
|
||||
public static HitboxData getHitboxData(Entity e){
|
||||
return (HitboxData)e.getData(EntityDataStrings.HITBOX_DATA);
|
||||
}
|
||||
|
||||
public static List<Entity> getHitboxAssociatedList(Entity e){
|
||||
return (List<Entity>)e.getData(EntityDataStrings.HITBOX_ASSOCIATED_LIST);
|
||||
}
|
||||
|
||||
public static List<Entity> getHurtboxAssociatedList(Entity e){
|
||||
return (List<Entity>)e.getData(EntityDataStrings.HURTBOX_ASSOCIATED_LIST);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,10 +4,11 @@ import electrosphere.collision.dispatch.CollisionObject;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.GravityTree;
|
||||
import electrosphere.entity.state.collidable.CollidableTree;
|
||||
import electrosphere.entity.state.gravity.GravityTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.entity.types.hitbox.HitboxData;
|
||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||
import electrosphere.game.collision.PhysicsUtils;
|
||||
@ -24,6 +25,7 @@ import electrosphere.renderer.Model;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.ActorUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
@ -35,13 +37,20 @@ import org.joml.Vector3f;
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class ItemUtils {
|
||||
|
||||
static final String genericItemIconPath = "Textures/icons/itemIconItemGeneric.png";
|
||||
|
||||
public static Entity spawnBasicItem(String name){
|
||||
Item item = Globals.gameConfigCurrent.getItemMap().getItem(name);
|
||||
Entity rVal = EntityUtils.spawnDrawableEntity(item.getModelPath());
|
||||
if(item.getHitboxes() != null){
|
||||
List<Entity> hitboxList = new LinkedList<Entity>();
|
||||
for(HitboxData hitboxdata : item.getHitboxes()){
|
||||
Globals.hitboxManager.registerHitbox(HitboxUtils.spawnRegularHitbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius()));
|
||||
Entity hitbox = HitboxUtils.spawnRegularHitbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius());
|
||||
Globals.hitboxManager.registerHitbox(hitbox);
|
||||
hitboxList.add(hitbox);
|
||||
}
|
||||
rVal.putData(EntityDataStrings.HITBOX_ASSOCIATED_LIST,hitboxList);
|
||||
}
|
||||
if(item.getCollidable() != null){
|
||||
CollidableTemplate physicsTemplate = item.getCollidable();
|
||||
@ -93,12 +102,6 @@ public class ItemUtils {
|
||||
case "TARGETABLE":
|
||||
Globals.entityManager.registerTargetableEntity(rVal);
|
||||
break;
|
||||
case "WEAPON":
|
||||
rVal.putData(EntityDataStrings.ITEM_IS_WEAPON, true);
|
||||
break;
|
||||
case "ARMOR":
|
||||
rVal.putData(EntityDataStrings.ITEM_IS_ARMOR, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(item.getEquipWhitelist() != null){
|
||||
@ -107,6 +110,11 @@ public class ItemUtils {
|
||||
if(item.getIdleAnim() != null){
|
||||
rVal.putData(EntityDataStrings.ANIM_IDLE,item.getIdleAnim());
|
||||
}
|
||||
if(item.getIconPath() != null && !item.getIconPath().equals("")){
|
||||
rVal.putData(EntityDataStrings.ITEM_ICON,item.getIconPath());
|
||||
} else {
|
||||
rVal.putData(EntityDataStrings.ITEM_ICON,genericItemIconPath);
|
||||
}
|
||||
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
|
||||
rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true);
|
||||
rVal.putData(EntityDataStrings.ITEM_TYPE, name);
|
||||
@ -192,4 +200,52 @@ public class ItemUtils {
|
||||
return (List<EquipWhitelist>)item.getData(EntityDataStrings.ITEM_EQUIP_WHITELIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits an entity which represents the item inside a container
|
||||
*/
|
||||
public static Entity recreateContainerItem(Entity item){
|
||||
if(isItem(item)){
|
||||
Entity rVal = new Entity();
|
||||
if(getEquipWhitelist(item) != null){
|
||||
rVal.putData(EntityDataStrings.ITEM_EQUIP_WHITELIST, getEquipWhitelist(item));
|
||||
}
|
||||
rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item));
|
||||
rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true);
|
||||
rVal.putData(EntityDataStrings.ITEM_TYPE, item.getData(EntityDataStrings.ITEM_TYPE));
|
||||
Globals.entityManager.registerEntity(rVal);
|
||||
return rVal;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyInWorldItem(Entity item){
|
||||
if(isItem(item)){
|
||||
//destroy physics
|
||||
if(item.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLISION_BODY) && item.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLIDABLE)){
|
||||
//destroy physics
|
||||
//this deregisters from all four & unhooks rigid bodies from the physics runtime
|
||||
Globals.collisionEngine.destroyEntityThatHasPhysics(item);
|
||||
//destroy hitboxes
|
||||
List<Entity> hitboxes = HitboxUtils.getHitboxAssociatedList(item);
|
||||
if(hitboxes != null){
|
||||
for(Entity hitbox : hitboxes){
|
||||
Globals.hitboxManager.deregisterHitbox(hitbox);
|
||||
HitboxUtils.getHitboxData(hitbox).setActive(false);
|
||||
}
|
||||
}
|
||||
//destroy graphics
|
||||
EntityUtils.cleanUpDrawableEntity(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyInInventoryItem(Entity item){
|
||||
Globals.entityManager.deregisterEntity(item);
|
||||
}
|
||||
|
||||
public static String getItemIcon(Entity item){
|
||||
return (String)item.getData(EntityDataStrings.ITEM_ICON);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.collidable.Impulse;
|
||||
import electrosphere.entity.types.hitbox.HitboxData;
|
||||
import electrosphere.game.collision.collidable.Collidable;
|
||||
|
||||
import static electrosphere.main.Main.deltaTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -278,6 +279,10 @@ public class CollisionEngine {
|
||||
public List<Entity> getPhysicsEntities(){
|
||||
return physicsEntities;
|
||||
}
|
||||
|
||||
public void deregisterPhysicsEntity(Entity physicsEntity){
|
||||
physicsEntities.remove(physicsEntity);
|
||||
}
|
||||
|
||||
public void registerDynamicPhysicsEntity(Entity dynamicEntity){
|
||||
dynamicPhysicsEntities.add(dynamicEntity);
|
||||
@ -466,5 +471,14 @@ public class CollisionEngine {
|
||||
structurePhysicsEntities.remove(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyEntityThatHasPhysics(Entity e){
|
||||
//make uncollidable
|
||||
if(e.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLISION_BODY) && e.getDataKeys().contains(EntityDataStrings.PHYSICS_COLLIDABLE)){
|
||||
CollisionObject rigidBody = (CollisionObject)e.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
|
||||
deregisterPhysicsObject(rigidBody);
|
||||
}
|
||||
deregisterCollidableEntity(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package electrosphere.game.data.creature.type;
|
||||
import electrosphere.entity.types.hitbox.HitboxData;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMoveResolver;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.game.data.creature.type.rotator.RotatorSystem;
|
||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||
|
||||
@ -15,6 +16,7 @@ public class CreatureType {
|
||||
List<VisualAttribute> visualAttributes;
|
||||
List<MovementSystem> movementSystems;
|
||||
RotatorSystem rotatorSystem;
|
||||
List<EquipPoint> equipPoints;
|
||||
CollidableTemplate collidable;
|
||||
List<AttackMove> attackMoves;
|
||||
HealthSystem healthSystem;
|
||||
@ -67,6 +69,10 @@ public class CreatureType {
|
||||
return rotatorSystem;
|
||||
}
|
||||
|
||||
public List<EquipPoint> getEquipPoints(){
|
||||
return equipPoints;
|
||||
}
|
||||
|
||||
public void setAttackMoveResolver(AttackMoveResolver resolver){
|
||||
attackMoveResolver = resolver;
|
||||
}
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
package electrosphere.game.data.creature.type.equip;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EquipPoint {
|
||||
|
||||
String equipPointId;
|
||||
String bone;
|
||||
List<Float> offsetVector;
|
||||
List<Float> offsetRotation;
|
||||
List<String> equipClassWhitelist;
|
||||
|
||||
public String getEquipPointId(){
|
||||
return equipPointId;
|
||||
}
|
||||
|
||||
public String getBone(){
|
||||
return bone;
|
||||
}
|
||||
|
||||
public List<Float> getOffsetVector(){
|
||||
return offsetVector;
|
||||
}
|
||||
|
||||
public List<Float> getOffsetRotation(){
|
||||
return offsetRotation;
|
||||
}
|
||||
|
||||
public List<String> getEquipClassWhitelist(){
|
||||
return equipClassWhitelist;
|
||||
}
|
||||
|
||||
}
|
||||
@ -13,6 +13,7 @@ public class Item {
|
||||
CollidableTemplate collidable;
|
||||
List<EquipWhitelist> equipWhitelist;
|
||||
String idleAnim;
|
||||
String iconPath;
|
||||
|
||||
public String getItemId() {
|
||||
return itemId;
|
||||
@ -42,5 +43,8 @@ public class Item {
|
||||
return idleAnim;
|
||||
}
|
||||
|
||||
public String getIconPath(){
|
||||
return iconPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -208,9 +208,9 @@ public class OpportunisticAttacker extends AI {
|
||||
boolean rVal = false;
|
||||
if(character.getDataKeys().contains(EntityDataStrings.EQUIP_STATE)){
|
||||
EquipState equipState = (EquipState)character.getData(EntityDataStrings.EQUIP_STATE);
|
||||
if(equipState.hasEquipPrimary()){
|
||||
rVal = true;
|
||||
}
|
||||
// if(equipState.hasEquipPrimary()){
|
||||
// rVal = true;
|
||||
// }
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
@ -244,9 +244,9 @@ public class OpportunisticAttacker extends AI {
|
||||
void pickupWeapon(){
|
||||
if(character.getDataKeys().contains(EntityDataStrings.EQUIP_STATE)){
|
||||
EquipState equipState = (EquipState)character.getData(EntityDataStrings.EQUIP_STATE);
|
||||
if(!equipState.hasEquipPrimary()){
|
||||
equipState.attemptEquip(target);
|
||||
}
|
||||
// if(!equipState.hasEquipPrimary()){
|
||||
// equipState.attemptEquip(target);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,11 +5,11 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.GravityTree;
|
||||
import electrosphere.entity.state.IdleTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||
import electrosphere.entity.state.ParticleTree;
|
||||
import electrosphere.entity.state.collidable.CollidableTree;
|
||||
import electrosphere.entity.state.gravity.GravityTree;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
|
||||
@ -53,6 +53,7 @@ import electrosphere.game.server.pathfinding.NavMeshManager;
|
||||
import electrosphere.renderer.ui.Widget;
|
||||
import electrosphere.renderer.ui.WidgetManager;
|
||||
import electrosphere.renderer.ui.WidgetUtils;
|
||||
import electrosphere.renderer.ui.WindowManager;
|
||||
import electrosphere.renderer.ui.font.FontUtils;
|
||||
import electrosphere.renderer.ui.font.RawFontMap;
|
||||
import electrosphere.renderer.ui.font.TextBox;
|
||||
@ -275,6 +276,9 @@ public class Globals {
|
||||
//thread for loading different game states
|
||||
public static LoadingThread loadingThread;
|
||||
|
||||
//manages all windows to be drawn to the screen
|
||||
public static WindowManager windowManager;
|
||||
|
||||
//manager for all widgets currently being drawn to screen
|
||||
public static WidgetManager widgetManager;
|
||||
|
||||
|
||||
@ -435,15 +435,17 @@ public class Main {
|
||||
mouse_lastX = (float) xpos;
|
||||
mouse_lastY = (float) ypos;
|
||||
|
||||
yaw = yaw + xoffset;
|
||||
pitch = pitch - yoffset;
|
||||
if(Globals.controlHandler != null && !Globals.controlHandler.isMouseVisible()){
|
||||
yaw = yaw + xoffset;
|
||||
pitch = pitch - yoffset;
|
||||
|
||||
if (pitch > 100.0f) {
|
||||
pitch = 100.0f;
|
||||
if (pitch > 100.0f) {
|
||||
pitch = 100.0f;
|
||||
}
|
||||
if (pitch < -99.0f) {
|
||||
pitch = -99.0f;
|
||||
}
|
||||
}
|
||||
if (pitch < -99.0f) {
|
||||
pitch = -99.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ public class Menu {
|
||||
OPTIONS_MAIN_MENU,
|
||||
IN_GAME_MAIN_MENU,
|
||||
TEST,
|
||||
INVENTORY_NATURAL,
|
||||
}
|
||||
|
||||
MenuType type;
|
||||
@ -34,8 +35,8 @@ public class Menu {
|
||||
int option = 0;
|
||||
int optionMax = 0;
|
||||
|
||||
List<Widget> widgetList = new ArrayList();
|
||||
List<Widget> optionList = new ArrayList();
|
||||
List<Widget> widgetList = new ArrayList<Widget>();
|
||||
List<Widget> optionList = new ArrayList<Widget>();
|
||||
|
||||
public Menu(MenuType type){
|
||||
this.type = type;
|
||||
|
||||
@ -206,6 +206,12 @@ public class MenuTransition {
|
||||
Globals.currentMenu.dispose();
|
||||
Globals.controlHandler.setHandlerState(ControlsState.MAIN_GAME);
|
||||
break;
|
||||
case INVENTORY_NATURAL:
|
||||
MenuUtils.makeMenuUndrawable(Globals.currentMenu);
|
||||
Globals.currentMenu.dispose();
|
||||
Globals.controlHandler.setHandlerState(ControlsState.MAIN_GAME);
|
||||
Globals.controlHandler.hideMouse();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package electrosphere.menu;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.game.server.saves.SaveUtils;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.menu.Menu.MenuType;
|
||||
@ -128,10 +131,10 @@ public class MenuUtils {
|
||||
Window menuWindow = new Window(100, 100, 500, 500);
|
||||
|
||||
//black texture background
|
||||
ImagePanel imagePanel = new ImagePanel(0,0,width,height);
|
||||
imagePanel.setWidth(width);
|
||||
imagePanel.setHeight(height);
|
||||
imagePanel.setTexture(Globals.assetManager.fetchTexture(Globals.blackTexture));
|
||||
ImagePanel imagePanel = new ImagePanel(0,0,width,height,Globals.blackTexture);
|
||||
// imagePanel.setWidth(width);
|
||||
// imagePanel.setHeight(height);
|
||||
// imagePanel.setTexture(Globals.assetManager.fetchTexture(Globals.blackTexture));
|
||||
menuWindow.addWidget(imagePanel);
|
||||
|
||||
//label 1 (back)
|
||||
@ -160,6 +163,55 @@ public class MenuUtils {
|
||||
rVal.addElement(WidgetUtils.createWindowTEST());
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Menu createNaturalInventoryMenu(UnrelationalInventoryState inventory){
|
||||
Menu rVal = new Menu(MenuType.INVENTORY_NATURAL);
|
||||
int screenTop = Globals.WINDOW_HEIGHT - 150;
|
||||
int width = 500;
|
||||
int height = 500;
|
||||
int screenLeft = (Globals.WINDOW_WIDTH - width)/2;
|
||||
Window menuWindow = new Window(100, 100, 500, 500);
|
||||
|
||||
//black texture background
|
||||
ImagePanel imagePanel = new ImagePanel(0,0,width,height,Globals.blackTexture);
|
||||
// imagePanel.setWidth(width);
|
||||
// imagePanel.setHeight(height);
|
||||
// imagePanel.setTexture(Globals.assetManager.fetchTexture(Globals.blackTexture));
|
||||
menuWindow.addWidget(imagePanel);
|
||||
|
||||
//label 1 (inventory)
|
||||
Label inventoryLabel = new Label(10,10,1.0f);
|
||||
inventoryLabel.setText("INVENTORY");
|
||||
menuWindow.addWidget(inventoryLabel);
|
||||
rVal.addOption(inventoryLabel);
|
||||
|
||||
int columns = 8;
|
||||
int columnWidth = 60;
|
||||
int rowHeight = 60;
|
||||
for(int i = 0; i < inventory.getCapacity(); i++){
|
||||
String texturePath = "Textures/icons/itemIconEmpty.png";
|
||||
if(i < inventory.getItems().size()){
|
||||
Entity currentItem = inventory.getItems().get(i);
|
||||
//get texture path from item
|
||||
texturePath = ItemUtils.getItemIcon(currentItem);
|
||||
}
|
||||
if(!Globals.assetManager.hasLoadedTexture(texturePath)){
|
||||
Globals.assetManager.addTexturePathtoQueue(texturePath);
|
||||
}
|
||||
ImagePanel panel = new ImagePanel((10 + i % columns * columnWidth),height - (110 + i / columns * rowHeight),50,50,texturePath);
|
||||
// imagePanel.setWidth(width);
|
||||
// imagePanel.setHeight(height);
|
||||
// imagePanel.setTexture(Globals.assetManager.fetchTexture(Globals.blackTexture));
|
||||
menuWindow.addWidget(panel);
|
||||
}
|
||||
|
||||
|
||||
rVal.addElement(menuWindow);
|
||||
Globals.widgetManager.registerWidget(menuWindow);
|
||||
// rVal.addElement(WidgetUtils.createVerticallyAlignedMinSizeTextBoxFromCharCount(40, 40, screenTop - 50, "BACK", true));
|
||||
// rVal.addOption( WidgetUtils.createVerticallyAlignedMinSizeTextBoxFromCharCount(40, 40, screenTop - 275, "QUIT", true));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static void makeMenuDrawable(Menu m){
|
||||
for(Widget w : m.widgetList){
|
||||
|
||||
38
src/main/java/electrosphere/renderer/ui/WindowManager.java
Normal file
38
src/main/java/electrosphere/renderer/ui/WindowManager.java
Normal file
@ -0,0 +1,38 @@
|
||||
package electrosphere.renderer.ui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WindowManager {
|
||||
|
||||
|
||||
Map<String,Window> windowManager = new HashMap<String,Window>();
|
||||
List<Window> windowPriorityList = new LinkedList<Window>();
|
||||
|
||||
public void registerWindow(String windowName, Window window){
|
||||
windowManager.put(windowName,window);
|
||||
windowPriorityList.add(window);
|
||||
}
|
||||
|
||||
public Window getWindow(String windowName){
|
||||
return windowManager.get(windowName);
|
||||
}
|
||||
|
||||
public void unregisterWindow(String windowName){
|
||||
Window toRemove = windowManager.remove(windowName);
|
||||
if(toRemove != null){
|
||||
windowPriorityList.remove(toRemove);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* windows should be drawn in this order
|
||||
* @return
|
||||
*/
|
||||
public List<Window> getWindowPriorityList(){
|
||||
return windowPriorityList;
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,16 +21,24 @@ import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
||||
*/
|
||||
public class ImagePanel extends Widget {
|
||||
|
||||
String texturePath;
|
||||
Material customMat = new Material();
|
||||
boolean hasLoadedTexture = false;
|
||||
Texture texture = null;
|
||||
|
||||
|
||||
Vector3f texPosition = new Vector3f(0,0,0);
|
||||
Vector3f texScale = new Vector3f(1,1,0);
|
||||
|
||||
public ImagePanel(int x, int y, int width, int height){
|
||||
texture = Globals.assetManager.fetchTexture("Textures/default_diffuse.png");
|
||||
customMat.setTexturePointer(texture.getTexturePointer());
|
||||
public ImagePanel(int x, int y, int width, int height, String texturePath){
|
||||
this.texturePath = texturePath;
|
||||
texture = Globals.assetManager.fetchTexture(this.texturePath);
|
||||
if(texture != null){
|
||||
customMat.setTexturePointer(texture.getTexturePointer());
|
||||
hasLoadedTexture = true;
|
||||
} else {
|
||||
customMat.setTexturePointer(Globals.assetManager.fetchTexture(Globals.blackTexture).getTexturePointer());
|
||||
}
|
||||
this.positionX = x;
|
||||
this.positionY = y;
|
||||
this.width = width;
|
||||
@ -49,6 +57,13 @@ public class ImagePanel extends Widget {
|
||||
|
||||
@Override
|
||||
public void draw(int parentFramebufferPointer, int parentWidth, int parentHeight) {
|
||||
if(!hasLoadedTexture){
|
||||
texture = Globals.assetManager.fetchTexture(this.texturePath);
|
||||
if(texture != null){
|
||||
customMat.setTexturePointer(texture.getTexturePointer());
|
||||
hasLoadedTexture = true;
|
||||
}
|
||||
}
|
||||
//this call binds the screen as the "texture" we're rendering to
|
||||
//have to call before actually rendering
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, parentFramebufferPointer);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user