templating
parent
394fcd6a45
commit
7499b82596
|
|
@ -18,8 +18,20 @@ public class SceneManager {
|
||||||
*/
|
*/
|
||||||
public static boolean loadScene(String scene) {
|
public static boolean loadScene(String scene) {
|
||||||
synchronized(entities) {
|
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{
|
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>();
|
Stack<Object> scopeObject = new Stack<Object>();
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
//System.out.println(line);
|
//System.out.println(line);
|
||||||
|
|
@ -137,6 +149,11 @@ public class SceneManager {
|
||||||
scopeObject.push(component);
|
scopeObject.push(component);
|
||||||
}else if (line.equals("End Component")) {
|
}else if (line.equals("End Component")) {
|
||||||
scopeObject.pop();
|
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) {
|
for(Entity e : entities) {
|
||||||
|
|
@ -146,11 +163,10 @@ public class SceneManager {
|
||||||
}
|
}
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
return false;
|
return null;
|
||||||
}
|
|
||||||
System.out.println("Loaded Scene File...");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void entityDump() {
|
public static void entityDump() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue