AMAZING bug with attaching collidable items
This commit is contained in:
parent
992ef0d159
commit
d1c0791e48
@ -126,6 +126,11 @@
|
||||
"isKey": true,
|
||||
"isMouse": false,
|
||||
"keyValue": 340
|
||||
},
|
||||
"interact" : {
|
||||
"isKey": true,
|
||||
"isMouse": false,
|
||||
"keyValue": 69
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,7 +84,8 @@
|
||||
"SENTIENT",
|
||||
"ATTACKER",
|
||||
"GRAVITY",
|
||||
"TARGETABLE"
|
||||
"TARGETABLE",
|
||||
"CAN_EQUIP"
|
||||
],
|
||||
"movementSystems" : [
|
||||
{
|
||||
@ -238,7 +239,8 @@
|
||||
"SENTIENT",
|
||||
"ATTACKER",
|
||||
"GRAVITY",
|
||||
"TARGETABLE"
|
||||
"TARGETABLE",
|
||||
"CAN_EQUIP"
|
||||
],
|
||||
"movementSystems" : [
|
||||
{
|
||||
|
||||
@ -6,6 +6,7 @@ import electrosphere.entity.EntityDataStrings;
|
||||
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.movement.GroundMovementTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree.MovementTreeState;
|
||||
import electrosphere.entity.state.movement.SprintTree;
|
||||
@ -46,6 +47,7 @@ public class ControlHandler {
|
||||
public static final String DATA_STRING_INPUT_CODE_IN_GAME_MAIN_MENU = "inGameMainMenu";
|
||||
public static final String DATA_STRING_INPUT_CODE_LOCK_CROSSHAIR = "crosshairLock";
|
||||
public static final String INPUT_CODE_SPRINT = "sprint";
|
||||
public static final String INPUT_CODE_INTERACT = "interact";
|
||||
|
||||
public static final String DATA_STRING_INPUT_CODE_MENU_INCREMENT = "menuIncrement";
|
||||
public static final String DATA_STRING_INPUT_CODE_MENU_DECREMENT = "menuDecrement";
|
||||
@ -131,6 +133,7 @@ public class ControlHandler {
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_IN_GAME_MAIN_MENU, new Control(true,false,GLFW_KEY_ESCAPE));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_LOCK_CROSSHAIR, new Control(false,true,GLFW_MOUSE_BUTTON_RIGHT));
|
||||
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));
|
||||
|
||||
/*
|
||||
Map the menu navigation controls
|
||||
@ -386,6 +389,28 @@ public class ControlHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Interact
|
||||
*/
|
||||
/*
|
||||
Sprint
|
||||
*/
|
||||
if(controls.containsKey(INPUT_CODE_INTERACT)){
|
||||
if(controls.get(INPUT_CODE_INTERACT).isIsKey() && glfwGetKey(Globals.window, controls.get(INPUT_CODE_INTERACT).getKeyValue()) == GLFW_PRESS){
|
||||
if(controls.get(INPUT_CODE_INTERACT).isState() == false){
|
||||
if(Globals.playerCharacter.getDataKeys().contains(EntityDataStrings.EQUIP_STATE) && Crosshair.hasTarget()){
|
||||
EquipState equipState = (EquipState)Globals.playerCharacter.getData(EntityDataStrings.EQUIP_STATE);
|
||||
equipState.attemptEquip(Crosshair.getTarget());
|
||||
}
|
||||
}
|
||||
controls.get(INPUT_CODE_INTERACT).setState(true);
|
||||
} else {
|
||||
if(controls.get(INPUT_CODE_INTERACT).isState() == true){
|
||||
}
|
||||
controls.get(INPUT_CODE_INTERACT).setState(false);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Attack
|
||||
*/
|
||||
|
||||
@ -173,6 +173,11 @@ public class EntityDataStrings {
|
||||
public static final String FOLIAGE_IS_FOLIAGE = "foliageIsFoliage";
|
||||
public static final String FOLIAGE_TYPE = "foliageType";
|
||||
|
||||
/*
|
||||
Equip state
|
||||
*/
|
||||
public static final String EQUIP_STATE = "equipState";
|
||||
|
||||
/*
|
||||
Entity categories
|
||||
*/
|
||||
|
||||
@ -3,6 +3,7 @@ package electrosphere.entity.state;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.equip.EquipState;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||
import electrosphere.game.data.creature.type.AttackMove;
|
||||
@ -51,7 +52,7 @@ public class AttackTree {
|
||||
}
|
||||
|
||||
public void start(String attackType){
|
||||
if(canAttack()){
|
||||
if(canAttack(attackType)){
|
||||
parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType);
|
||||
AttackMove currentMove;
|
||||
switch(attackType){
|
||||
@ -277,11 +278,32 @@ public class AttackTree {
|
||||
networkMessageQueue.add(networkMessage);
|
||||
}
|
||||
|
||||
boolean canAttack(){
|
||||
boolean canAttack(String attackType){
|
||||
boolean rVal = true;
|
||||
if(state != AttackTreeState.IDLE){
|
||||
rVal = false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package electrosphere.entity.state.equip;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -12,12 +14,15 @@ public class EquipState {
|
||||
|
||||
Entity equipPrimary;
|
||||
|
||||
public EquipState(Entity parent){
|
||||
String equipPrimaryBoneName;
|
||||
|
||||
public EquipState(Entity parent, String equipPrimaryBoneName){
|
||||
this.parent = parent;
|
||||
this.equipPrimaryBoneName = equipPrimaryBoneName;
|
||||
}
|
||||
|
||||
public boolean hasEquipPrimary(){
|
||||
return equipPrimary == null;
|
||||
return equipPrimary != null;
|
||||
}
|
||||
|
||||
public Entity getEquipPrimary() {
|
||||
@ -28,5 +33,12 @@ public class EquipState {
|
||||
this.equipPrimary = equipPrimary;
|
||||
}
|
||||
|
||||
public void attemptEquip(Entity toEquip){
|
||||
if(!hasEquipPrimary() && ItemUtils.isItem(toEquip) && !AttachUtils.isAttached(toEquip)){
|
||||
equipPrimary = toEquip;
|
||||
AttachUtils.attachEntityToEntityAtBone(parent, toEquip, equipPrimaryBoneName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
package electrosphere.entity.state.equip;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class EquipTree {
|
||||
|
||||
}
|
||||
@ -14,6 +14,7 @@ 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.types.collision.CollisionObjUtils;
|
||||
import electrosphere.entity.state.life.LifeState;
|
||||
import electrosphere.entity.state.movement.SprintTree;
|
||||
@ -155,6 +156,9 @@ public class CreatureUtils {
|
||||
case "TARGETABLE":
|
||||
Globals.entityManager.registerTargetableEntity(rVal);
|
||||
break;
|
||||
case "CAN_EQUIP":
|
||||
rVal.putData(EntityDataStrings.EQUIP_STATE, new EquipState(rVal,"Bone.031"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//add all attack moves
|
||||
|
||||
@ -94,5 +94,9 @@ public class Crosshair {
|
||||
return EntityUtils.getPosition(currentTarget);
|
||||
}
|
||||
|
||||
public static Entity getTarget(){
|
||||
return currentTarget;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -106,9 +106,9 @@ public class ServerConnectionHandler implements Runnable {
|
||||
newPlayerObject.setWorldY(Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z));
|
||||
Globals.dataCellManager.addPlayer(newPlayerObject);
|
||||
Globals.dataCellManager.movePlayer(newPlayerObject, Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x), Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z));
|
||||
//spawn player sword
|
||||
Entity sword = ItemUtils.spawnBasicItem("Katana");
|
||||
AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031");
|
||||
// //spawn player sword
|
||||
// Entity sword = ItemUtils.spawnBasicItem("Katana");
|
||||
// AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031");
|
||||
//set controller id
|
||||
CreatureUtils.setControllerPlayerId(newPlayerCharacter, playerID);
|
||||
if(Globals.RUN_SERVER && Main.playerId == -1){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user