menu refactoring
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-03-24 13:19:02 -04:00
parent dffd02853d
commit 6f8e44f325
26 changed files with 229 additions and 70 deletions

View File

@ -8,6 +8,7 @@
- @subpage audioengine
- @subpage timekeeper
- @subpage archimprovementtargets
- @subpage savesindex
# What is this section

View File

@ -0,0 +1 @@
@page savesindex Saves

View File

@ -0,0 +1,21 @@
@page entitySerialization Entity Serialization
How are entities load from disk/sent to player
Entities have a top level 'type', ie 'creature', 'object', 'foliage', etc
Beneath that is the specific subtype, ie 'human', 'elf', 'woodenCrate'
Lets say when the client receives the request 'spawn human' it runs the full human-creation macro. What then needs to be updated from the default for the macro?
Visual attributes
Equip state
current animation
movement state
idle state
gravity state
jump state
attack state
Specifically when loading files, also need to store server data
Which entity is the player's entity

View File

@ -1,3 +1,6 @@
@page serverSceneManagement Server Scene Management
TODO
TODO
[TOC]
- @subpage entitySerialization

View File

@ -195,6 +195,15 @@ Level loading/saving + Basic Editor
- Menu of types of entities to spawn
- Button to spawn them at cursor
More Debug menus
- Screen that shows the overall status of client scene
- Number of entities
- Maybe a listing of each one?
- Screen that shows the overall status of draw cell manager
- Screen that shows the overall status of fluid cell manager
- Screen that shows the overall status of realm 0
- Screen that shows the overall status of realm manager
Revisit first attempt at instancing (its really laggy lol)
- Maybe have draw call happen on top level entity and immediately queue all children recursively

View File

@ -97,11 +97,11 @@ import electrosphere.entity.types.camera.CameraEntityUtils;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.logger.LoggerInterface;
import electrosphere.menu.MenuGenerators;
import electrosphere.menu.MenuGeneratorsDebug;
import electrosphere.menu.MenuGeneratorsInGame;
import electrosphere.menu.MenuGeneratorsInventory;
import electrosphere.menu.WindowStrings;
import electrosphere.menu.WindowUtils;
import electrosphere.menu.ingame.MenuGeneratorsInGame;
import electrosphere.menu.ingame.MenuGeneratorsInventory;
import electrosphere.menu.mainmenu.MenuGeneratorsDebug;
import electrosphere.renderer.ui.Window;
import electrosphere.renderer.ui.events.ClickEvent;
import electrosphere.renderer.ui.events.KeyboardEvent;

View File

@ -17,7 +17,7 @@ import electrosphere.engine.time.Timekeeper;
import electrosphere.game.config.UserSettings;
import electrosphere.game.server.world.MacroData;
import electrosphere.logger.LoggerInterface;
import electrosphere.menu.ImGuiWindowMacros;
import electrosphere.menu.debug.ImGuiWindowMacros;
import electrosphere.renderer.RenderingEngine;
import electrosphere.server.simulation.MacroSimulation;

View File

@ -31,9 +31,9 @@ import electrosphere.entity.types.camera.CameraEntityUtils;
import electrosphere.entity.types.tree.ProceduralTree;
import electrosphere.logger.LoggerInterface;
import electrosphere.menu.MenuGenerators;
import electrosphere.menu.MenuGeneratorsMultiplayer;
import electrosphere.menu.WindowStrings;
import electrosphere.menu.WindowUtils;
import electrosphere.menu.mainmenu.MenuGeneratorsMultiplayer;
import electrosphere.net.NetUtils;
import electrosphere.net.client.ClientNetworking;
import electrosphere.renderer.ui.Window;

View File

@ -49,10 +49,6 @@ import electrosphere.server.terrain.manager.ServerTerrainManager;
*/
public class LoadingUtils {
// static void initTerrainDataCellManager(){
// Globals.griddedDataCellManager.init(Globals.serverWorldData);
// }
static void initServerGameTerrainManager(){
@ -62,13 +58,11 @@ public class LoadingUtils {
*/
float randomDampener = 0.0f; //0.25f;
Globals.serverTerrainManager = new ServerTerrainManager(2000,50,randomDampener,0,new OverworldChunkGenerator());
if(Globals.RUN_SERVER){
if(Globals.userSettings.gameplayGenerateWorld()){
Globals.serverTerrainManager.generate();
Globals.serverTerrainManager.save("./terrain.json");
} else {
SaveUtils.loadSave(Globals.currentSaveName);
}
if(Globals.userSettings.gameplayGenerateWorld()){
Globals.serverTerrainManager.generate();
Globals.serverTerrainManager.save("./terrain.json");
} else {
SaveUtils.loadSave(Globals.currentSaveName);
}
/*

View File

@ -32,6 +32,12 @@ public class EntityDataStrings {
public static final String INSTANCED_MODEL_ATTRIBUTE = "instancedModelAttribute";
/**
* Entity type
*/
public static final String ENTITY_TYPE = "entityType"; //ie "creature", "foliage", "terrain", etc
public static final String ENTITY_SUBTYPE = "entitySubtype"; //ie "human", "woodenCrate", etc
/*
Terrain Entity
*/
@ -46,8 +52,6 @@ public class EntityDataStrings {
/*
Creature Entity
*/
public static final String DATA_STRING_CREATURE_IS_CREATURE = "isCreature";
public static final String DATA_STRING_CREATURE_TYPE = "creatureType";
public static final String DATA_STRING_CREATURE_CONTROLLER_PLAYER_ID = "creaturePlayerId";
public static final String CLIENT_MOVEMENT_BT = "clientMovementBT";
public static final String SERVER_MOVEMENT_BT = "serverMovementBT";
@ -176,8 +180,6 @@ public class EntityDataStrings {
/*
Item Entity
*/
public static final String ITEM_IS_ITEM = "itemIsItem";
public static final String ITEM_TYPE = "itemType";
public static final String ITEM_IS_WEAPON = "itemIsWeapon";
public static final String ITEM_IS_ARMOR = "itemIsArmor";
public static final String ITEM_EQUIP_WHITELIST = "itemEquipWhitelist";

View File

@ -1,5 +1,8 @@
package electrosphere.entity;
/**
* Tags used in scenes to delineate groups of entities
*/
public class EntityTags {
public static final String BONE_ATTACHED = "boneAttached";
@ -12,8 +15,8 @@ public class EntityTags {
public static final String LIFE_STATE = "lifeState";
public static final String CREATURE = "creature";
public static final String FOLIAGE = "foliage";
public static final String UI = "ui";
public static final String DRAWABLE = "drawable";
public static final String UI = "ui"; //is it a ui entity
public static final String DRAWABLE = "drawable"; //is it drawable
public static final String DRAW_INSTANCED = "drawInstanced"; //if it's instanced, but not necessarily managed by a service (ie a tree branch)
public static final String DRAW_INSTANCED_MANAGED = "drawInstancedManaged"; //if it's managed by a service (ie foliage manager)
public static final String LIGHT = "light";

View File

@ -118,11 +118,9 @@ public class EntityUtils {
*/
protected static Entity spawnSpatialEntity(){
Entity rVal = new Entity();
// rVal.putData(EntityDataStrings.DATA_STRING_MODEL_PATH, modelPath);
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(0,0,0));
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaterniond().identity());
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
EntityLookupUtils.registerServerEntity(rVal);
return rVal;
}
@ -149,14 +147,20 @@ public class EntityUtils {
EntityLookupUtils.removeEntity(e);
}
// public static void setEntityID(Entity e, int id){
// Globals.entityManager.mapIdToId(e.getId(), id);
// }
/**
* Gets the actor on the entity
* @param e The entity
* @return The actor
*/
public static Actor getActor(Entity e){
return (Actor)e.getData(EntityDataStrings.DATA_STRING_ACTOR);
}
/**
* Gets the pose actor on the entity
* @param e The entity
* @return the pose actor
*/
public static PoseActor getPoseActor(Entity e){
return (PoseActor)e.getData(EntityDataStrings.POSE_ACTOR);
}
@ -172,5 +176,41 @@ public class EntityUtils {
public static boolean getDraw(Entity entity){
return (boolean)entity.getData(EntityDataStrings.DATA_STRING_DRAW);
}
/**
* Gets the type of the entity
* @param entity The entity
* @return The type
*/
public static int getEntityType(Entity entity){
return (int)entity.getData(EntityDataStrings.ENTITY_TYPE);
}
/**
* Sets the entity type
* @param entity the entity
* @param type the type
*/
public static void setEntityType(Entity entity, int type){
entity.putData(EntityDataStrings.ENTITY_TYPE, type);
}
/**
* Gets the subtype of this entity
* @param entity The entity
* @return The subtype
*/
public static String getEntitySubtype(Entity entity){
return (String)entity.getData(EntityDataStrings.ENTITY_SUBTYPE);
}
/**
* Sets the subtype of this entity
* @param entity The entity
* @param subtype The subtype
*/
public static void setEntitySubtype(Entity entity, String subtype){
entity.putData(EntityDataStrings.ENTITY_SUBTYPE, subtype);
}
}

View File

@ -84,6 +84,9 @@ import electrosphere.util.Utilities;
* Utilities for creating creatures on the client and server
*/
public class CreatureUtils {
//The entity type int for creatures
public static final int ENTITY_TYPE_CREATURE = 0;
/**
* Spawns a client-side creature entity
@ -371,8 +374,8 @@ public class CreatureUtils {
rVal.putData(EntityDataStrings.TREE_IDLE, idleTree);
Globals.clientScene.registerBehaviorTree(idleTree);
Globals.clientScene.registerEntityToTag(rVal, EntityTags.CREATURE);
rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE, true);
rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_TYPE, type);
EntityUtils.setEntityType(rVal, ENTITY_TYPE_CREATURE);
EntityUtils.setEntitySubtype(rVal, type);
CreatureUtils.setFacingVector(rVal, new Vector3d(0,0,1));
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
return rVal;
@ -667,8 +670,8 @@ public class CreatureUtils {
ServerIdleTree.attachTree(rVal);
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.CREATURE);
rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE, true);
rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_TYPE, type);
EntityUtils.setEntityType(rVal, ENTITY_TYPE_CREATURE);
EntityUtils.setEntitySubtype(rVal, type);
CreatureUtils.setFacingVector(rVal, new Vector3d(0,0,1));
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
return rVal;
@ -755,8 +758,13 @@ public class CreatureUtils {
clientGetAttackTree(e).addNetworkMessage(em);
}
/**
* Gets the type of creature
* @param e the entity
* @return the type
*/
public static String getType(Entity e){
return (String)e.getData(EntityDataStrings.DATA_STRING_CREATURE_TYPE);
return (String)EntityUtils.getEntitySubtype(e);
}
public static int getControllerPlayerId(Entity e){
@ -771,8 +779,16 @@ public class CreatureUtils {
return e.containsKey(EntityDataStrings.DATA_STRING_CREATURE_CONTROLLER_PLAYER_ID);
}
/**
* Checks if this entity is a creature
* @param e The entity
* @return true if it is a creature, false otherwise
*/
public static boolean isCreature(Entity e){
return e.containsKey(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE);
if(!e.containsKey(EntityDataStrings.ENTITY_TYPE)){
return false;
}
return (int)e.getData(EntityDataStrings.ENTITY_TYPE) == ENTITY_TYPE_CREATURE;
}
public static AttackTree clientGetAttackTree(Entity e){

View File

@ -40,11 +40,14 @@ import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
/**
*
* @author amaterasu
* Utilities for working with items
*/
public class ItemUtils {
//The item creature type
public static final int ENTITY_TYPE_ITEM = 1;
//generic item icon filepath
static final String genericItemIconPath = "Textures/icons/itemIconItemGeneric.png";
public static Entity clientSpawnBasicItem(String name){
@ -106,9 +109,9 @@ public class ItemUtils {
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS,item.getEquipClass());
}
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true);
EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM);
rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, false);
rVal.putData(EntityDataStrings.ITEM_TYPE, name);
EntityUtils.setEntitySubtype(rVal, name);
// rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(0.005f,0.005f,0.005f));
// rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaternionf().identity().rotateY((float)(-Math.PI/2)).rotateZ(-(float)(Math.PI/2)));
Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.ITEM);
@ -176,9 +179,9 @@ public class ItemUtils {
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS,item.getEquipClass());
}
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true);
EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM);
rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, false);
rVal.putData(EntityDataStrings.ITEM_TYPE, name);
EntityUtils.setEntitySubtype(rVal, name);
// rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(0.005f,0.005f,0.005f));
// rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaternionf().identity().rotateY((float)(-Math.PI/2)).rotateZ(-(float)(Math.PI/2)));
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.ITEM);
@ -234,12 +237,26 @@ public class ItemUtils {
player.addMessage(message);
}
public static boolean isItem(Entity item){
return item.containsKey(EntityDataStrings.ITEM_IS_ITEM);
/**
* Checks if this entity is an item
* @param e the entity
* @return true if it is an item, false otherwise
*/
public static boolean isItem(Entity e){
if(!e.containsKey(EntityDataStrings.ENTITY_TYPE)){
return false;
}
return (int)e.getData(EntityDataStrings.ENTITY_TYPE) == ENTITY_TYPE_ITEM;
}
/**
* Gets the type of item
* @param item The entity
* @return The type
*/
public static String getType(Entity item){
return (String)item.getData(EntityDataStrings.ITEM_TYPE);
return EntityUtils.getEntitySubtype(item);
}
public static boolean isWeapon(Entity item){
@ -298,10 +315,10 @@ public class ItemUtils {
}
rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item));
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS, item.getData(EntityDataStrings.ITEM_EQUIP_CLASS));
rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true);
EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM);
rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, true);
ItemUtils.setContainingParent(rVal, containingParent);
rVal.putData(EntityDataStrings.ITEM_TYPE, item.getData(EntityDataStrings.ITEM_TYPE));
EntityUtils.setEntitySubtype(rVal, EntityUtils.getEntitySubtype(item));
Globals.clientSceneWrapper.getScene().registerEntity(rVal);
return rVal;
} else {
@ -323,10 +340,10 @@ public class ItemUtils {
}
rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item));
rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS, item.getData(EntityDataStrings.ITEM_EQUIP_CLASS));
rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true);
EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM);
rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, true);
ItemUtils.setContainingParent(rVal, containingParent);
rVal.putData(EntityDataStrings.ITEM_TYPE, item.getData(EntityDataStrings.ITEM_TYPE));
EntityUtils.setEntitySubtype(rVal, EntityUtils.getEntitySubtype(item));
return rVal;
} else {
return null;

View File

@ -16,6 +16,7 @@ import electrosphere.entity.types.camera.CameraEntityUtils;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.game.data.creature.type.CreatureType;
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
import electrosphere.menu.mainmenu.MenuGeneratorsTitleMenu;
import electrosphere.net.NetUtils;
import electrosphere.renderer.RenderingEngine;
import electrosphere.renderer.actor.Actor;
@ -70,7 +71,7 @@ public class MenuGenerators {
selectButton.addChild(selectLabel);
rVal.addChild(selectButton);
selectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
if(SaveUtils.worldHasSave(saveName.toLowerCase())){
if(SaveUtils.saveHasWorldFile(saveName.toLowerCase())){
//need to log client in
Globals.clientUsername = "username";
Globals.clientPassword = AuthenticationManager.getHashedString("password");
@ -152,7 +153,7 @@ public class MenuGenerators {
saveButton.addChild(saveLabel);
rVal.addChild(saveButton);
saveButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
SaveUtils.saveWorldDataToSave(Globals.currentSaveName);
SaveUtils.saveWorldData(Globals.currentSaveName);
WindowUtils.replaceMainMenuContents(MenuGenerators.createWorldSelectMenu());
return false;
}});

View File

@ -4,6 +4,8 @@ import electrosphere.engine.Globals;
import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.state.inventory.RelationalInventoryState;
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
import electrosphere.menu.ingame.MenuGeneratorsInventory;
import electrosphere.menu.mainmenu.MenuGeneratorsTitleMenu;
import electrosphere.renderer.ui.ContainerElement;
import electrosphere.renderer.ui.DrawableElement;
import electrosphere.renderer.ui.Element;

View File

@ -1,4 +1,4 @@
package electrosphere.menu;
package electrosphere.menu.debug;
import java.util.HashMap;
import java.util.Map;
@ -71,6 +71,7 @@ public class ImGuiWindowMacros {
initFramerateGraphSeries("clientNetwork");
initFramerateGraphSeries("controls");
globalFrametimeWindow.addElement(globalFrametimePlot);
globalFrametimeWindow.setOpen(false);
RenderingEngine.addImGuiWindow(globalFrametimeWindow);
}

View File

@ -1,4 +1,4 @@
package electrosphere.menu;
package electrosphere.menu.ingame;
import org.joml.Vector3f;
@ -11,6 +11,8 @@ import electrosphere.entity.EntityUtils;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.game.data.creature.type.CreatureType;
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
import electrosphere.menu.WindowStrings;
import electrosphere.menu.WindowUtils;
import electrosphere.renderer.RenderingEngine;
import electrosphere.renderer.actor.Actor;
import electrosphere.renderer.actor.ActorStaticMorph;

View File

@ -1,4 +1,4 @@
package electrosphere.menu;
package electrosphere.menu.ingame;
import java.util.List;
@ -14,6 +14,8 @@ import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.state.inventory.RelationalInventoryState;
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.menu.WindowStrings;
import electrosphere.menu.WindowUtils;
import electrosphere.renderer.ui.DraggableElement.DragEventCallback;
import electrosphere.renderer.ui.elements.Div;
import electrosphere.renderer.ui.elements.ImagePanel;

View File

@ -1,4 +1,4 @@
package electrosphere.menu;
package electrosphere.menu.mainmenu;
import electrosphere.auth.AuthenticationManager;
import electrosphere.engine.Globals;

View File

@ -1,9 +1,11 @@
package electrosphere.menu;
package electrosphere.menu.mainmenu;
import java.util.LinkedList;
import java.util.List;
import electrosphere.engine.Globals;
import electrosphere.menu.WindowStrings;
import electrosphere.menu.WindowUtils;
import electrosphere.renderer.debug.DebugRendering;
import electrosphere.renderer.ui.ClickableElement;
import electrosphere.renderer.ui.ContainerElement;

View File

@ -1,4 +1,4 @@
package electrosphere.menu;
package electrosphere.menu.mainmenu;
import java.util.LinkedList;
import java.util.List;
@ -12,6 +12,8 @@ import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.game.data.creature.type.CreatureType;
import electrosphere.game.data.creature.type.visualattribute.AttributeVariant;
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
import electrosphere.menu.MenuGenerators;
import electrosphere.menu.WindowUtils;
import electrosphere.net.parser.net.message.CharacterMessage;
import electrosphere.renderer.RenderingEngine;
import electrosphere.renderer.actor.Actor;

View File

@ -1,7 +1,9 @@
package electrosphere.menu;
package electrosphere.menu.mainmenu;
import electrosphere.engine.Globals;
import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.menu.MenuGenerators;
import electrosphere.menu.WindowUtils;
import electrosphere.renderer.ui.ClickableElement;
import electrosphere.renderer.ui.Element;
import electrosphere.renderer.ui.elements.Button;

View File

@ -6,7 +6,7 @@ import electrosphere.engine.Main;
import electrosphere.entity.Entity;
import electrosphere.entity.Scene;
import electrosphere.entity.types.hitbox.HitboxManager;
import electrosphere.menu.ImGuiWindowMacros;
import electrosphere.menu.debug.ImGuiWindowMacros;
import electrosphere.net.parser.net.message.NetworkMessage;
import electrosphere.server.datacell.interfaces.DataCellManager;

View File

@ -1,8 +1,11 @@
package electrosphere.server.saves;
import java.util.List;
import electrosphere.entity.Scene;
/**
*
* @author satellite
* Top level save object that stores information about the save
*/
public class Save {
/*
@ -11,4 +14,21 @@ public class Save {
we can put them all in here then serialize this instead
or smthn
*/
//the version of the game
String versionString;
//the time the save was created
String timeCreated;
//The scenes
List<Scene> scenes;
/**
* Constructor
*/
public Save(){
versionString = "0.0.1";
timeCreated = System.currentTimeMillis() + "";
}
}

View File

@ -15,8 +15,7 @@ import electrosphere.server.terrain.manager.ServerTerrainManager;
import electrosphere.util.FileUtils;
/**
*
* @author satellite
* Utilities for dealing with saves (init, loading, storing, etc)
*/
public class SaveUtils {
@ -75,12 +74,7 @@ public class SaveUtils {
}
public static boolean overwriteSave(String saveName){
boolean rVal = false;
return rVal;
}
@Deprecated
public static boolean loadTerrainAndDB(String saveName){
String dirPath = deriveSaveDirectoryPath(saveName);
String dbFilePath = FileUtils.sanitizeFilePath(dirPath) + "/central.db";
@ -89,6 +83,11 @@ public class SaveUtils {
return true;
}
/**
* Loads a save into the server
* @param saveName The name of the save
* @return true always
*/
public static boolean loadSave(String saveName){
String dirPath = deriveSaveDirectoryPath(saveName);
String dbFilePath = FileUtils.sanitizeFilePath(dirPath) + "/central.db";
@ -101,16 +100,30 @@ public class SaveUtils {
return true;
}
/**
* Gets the list of all saves by name
* @return The list of all saves
*/
public static List<String> getSaves(){
return FileUtils.listDirectory("./saves");
}
public static boolean worldHasSave(String saveName){
/**
* Checks if the save has a world file
* @param saveName The name of the save
* @return true if the world file exists, false otherwise
*/
public static boolean saveHasWorldFile(String saveName){
String dirPath = deriveSaveDirectoryPath(saveName) + "/world.json";
LoggerInterface.loggerEngine.DEBUG("Exists? " + dirPath);
return FileUtils.checkFileExists(dirPath);
}
/**
* Loads terrain and creates world data object
* @param currentSaveName The save name
* @return true always
*/
public static boolean loadTerrainAndCreateWorldData(String currentSaveName){
Globals.serverTerrainManager = new ServerTerrainManager(2000,50,0.0f,0,new OverworldChunkGenerator());
Globals.serverFluidManager = new ServerFluidManager(Globals.serverTerrainManager, 2000, 50, 0.0f, 0, new ArenaFluidGenerator());
@ -121,7 +134,12 @@ public class SaveUtils {
return true;
}
public static boolean saveWorldDataToSave(String saveName){
/**
* Saves world data file
* @param saveName The name of the save
* @return true always
*/
public static boolean saveWorldData(String saveName){
/*
Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
//TODO: Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);