templating
parent
394fcd6a45
commit
7499b82596
|
|
@ -18,8 +18,20 @@ public class SceneManager {
|
|||
*/
|
||||
public static boolean loadScene(String scene) {
|
||||
synchronized(entities) {
|
||||
entities = getScene(scene + ".scene");
|
||||
System.out.println("Loaded Scene File...");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static Entity getTemplate(String name) {
|
||||
return getScene(name + ".template").get(0);
|
||||
}
|
||||
|
||||
private static ArrayList<Entity> getScene(String scene) {
|
||||
ArrayList<Entity> entities = new ArrayList<Entity>();
|
||||
try{
|
||||
List<String> lines = Files.readAllLines(Paths.get(Engine.gameFolder, scene + ".scene"), Charset.forName("UTF-8"));
|
||||
List<String> lines = Files.readAllLines(Paths.get(Engine.gameFolder, scene), Charset.forName("UTF-8"));
|
||||
Stack<Object> scopeObject = new Stack<Object>();
|
||||
for (String line : lines) {
|
||||
//System.out.println(line);
|
||||
|
|
@ -137,6 +149,11 @@ public class SceneManager {
|
|||
scopeObject.push(component);
|
||||
}else if (line.equals("End Component")) {
|
||||
scopeObject.pop();
|
||||
}else if (line.startsWith("Template")) {
|
||||
String[] parts = line.split(" ");
|
||||
String template = parts[1].trim();
|
||||
Entity entity = getTemplate(template);
|
||||
entities.add(entity);
|
||||
}
|
||||
}
|
||||
for(Entity e : entities) {
|
||||
|
|
@ -146,11 +163,10 @@ public class SceneManager {
|
|||
}
|
||||
}catch(Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
System.out.println("Loaded Scene File...");
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
public static void entityDump() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue