Merge branch 'master' into threading-rework-1
This commit is contained in:
commit
ad556e3553
1
.gitignore
vendored
1
.gitignore
vendored
@ -26,3 +26,4 @@
|
||||
|
||||
#docs backup files
|
||||
/docs/~$NetworkFlow.drawio.bkp
|
||||
/docs/~$NetworkFlow.drawio.dtmp
|
||||
|
||||
@ -57,7 +57,8 @@
|
||||
"TARGETABLE",
|
||||
"CAN_EQUIP",
|
||||
"INVENTORY",
|
||||
"OUTLINE"
|
||||
"OUTLINE",
|
||||
"PLAYABLE"
|
||||
],
|
||||
"visualAttributes" : [
|
||||
{
|
||||
|
||||
@ -66,6 +66,12 @@ public class Config {
|
||||
type.setAttackMoveResolver(new AttackMoveResolver(type.getAttackMoves()));
|
||||
}
|
||||
loader.putCreature(type.getCreatureId(), type);
|
||||
//loop through all creatures and add ones with PLAYABLE token to list of playable races
|
||||
for(String token : type.getTokens()){
|
||||
if(token.contains("PLAYABLE")){
|
||||
loader.putPlayableRace(type.getCreatureId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return loader;
|
||||
}
|
||||
|
||||
@ -1,18 +1,31 @@
|
||||
package electrosphere.game.data.creature.type;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CreatureTypeLoader {
|
||||
|
||||
Map<String,CreatureType> creatureMap = new HashMap<String,CreatureType>();
|
||||
|
||||
List<String> playableRaceNames = new LinkedList<String>();
|
||||
|
||||
public void putCreature(String name, CreatureType type){
|
||||
creatureMap.put(name,type);
|
||||
}
|
||||
|
||||
public void putPlayableRace(String name){
|
||||
playableRaceNames.add(name);
|
||||
}
|
||||
|
||||
public CreatureType getCreature(String name){
|
||||
return creatureMap.get(name);
|
||||
}
|
||||
|
||||
public List<String> getPlayableRaces(){
|
||||
return playableRaceNames;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
package electrosphere.net.server.protocol;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.net.parser.net.message.LoreMessage;
|
||||
import electrosphere.net.server.ServerConnectionHandler;
|
||||
import electrosphere.util.Utilities;
|
||||
|
||||
public class LoreProtocol {
|
||||
|
||||
@ -14,7 +18,9 @@ public class LoreProtocol {
|
||||
//TODO
|
||||
break;
|
||||
case REQUESTRACES:
|
||||
//TODO
|
||||
List<String> playableRaces = Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces();
|
||||
String returnData = Utilities.stringify(playableRaces);
|
||||
connectionHandler.addMessagetoOutgoingQueue(LoreMessage.constructResponseRacesMessage(returnData));
|
||||
break;
|
||||
|
||||
case RESPONSEDATA:
|
||||
|
||||
@ -36,8 +36,12 @@ import static org.lwjgl.opengl.GL30.glGenVertexArrays;
|
||||
* @author awhoove
|
||||
*/
|
||||
public class Utilities {
|
||||
|
||||
static {
|
||||
gson = new Gson();
|
||||
}
|
||||
|
||||
|
||||
static Gson gson;
|
||||
|
||||
public static Matrix4f convertAIMatrix(AIMatrix4x4 mat){
|
||||
Matrix4f rVal = new Matrix4f();
|
||||
@ -120,4 +124,9 @@ public class Utilities {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static String stringify(Object object){
|
||||
return gson.toJson(object);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user