Added some comments

This commit is contained in:
7u83 2020-10-23 09:45:44 +02:00
parent b084e0a156
commit 2e1a53789f
1 changed files with 19 additions and 6 deletions

View File

@ -109,7 +109,14 @@ public class GodWorld implements GetJson, World {
} }
init(cfg,false); init(cfg,false);
} }
private void init(JSONObject cfg, boolean mt) {
// this.scheduler = new Scheduler();
// this.scheduler.start();
putJson(cfg);
}
public Scheduler getScheduler() { public Scheduler getScheduler() {
return scheduler; return scheduler;
} }
@ -122,11 +129,6 @@ public class GodWorld implements GetJson, World {
this(new JSONObject("{}")); this(new JSONObject("{}"));
} }
private void init(JSONObject cfg, boolean mt) {
this.scheduler = new Scheduler();
this.scheduler.start();
putJson(cfg);
}
private void putJson(JSONObject cfg) { private void putJson(JSONObject cfg) {
// Read assets // Read assets
@ -186,11 +188,19 @@ public class GodWorld implements GetJson, World {
return cfg; return cfg;
} }
/**
* Create an asset from a JSON object
*
* @param cfg the JSON object to create the asset from
* @return the created asset
* @throws SeSimException
*/
public AbstractAsset createAsset(JSONObject cfg) throws SeSimException { public AbstractAsset createAsset(JSONObject cfg) throws SeSimException {
AbstractAsset a; AbstractAsset a;
String class_name; String class_name;
Class<AbstractAsset> cls; Class<AbstractAsset> cls;
// get asset name
try { try {
class_name = cfg.getString(JKEYS.ASSET_TYPE); class_name = cfg.getString(JKEYS.ASSET_TYPE);
} catch (JSONException jex) { } catch (JSONException jex) {
@ -198,10 +208,13 @@ public class GodWorld implements GetJson, World {
return null; return null;
} }
// create class from name
try { try {
cls = (Class<AbstractAsset>) Class.forName(class_name); cls = (Class<AbstractAsset>) Class.forName(class_name);
a = cls.getConstructor(GodWorld.class, JSONObject.class).newInstance(this, cfg); a = cls.getConstructor(GodWorld.class, JSONObject.class).newInstance(this, cfg);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { } catch (ClassNotFoundException | NoSuchMethodException | SecurityException
| InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException ex) {
Logger.getLogger(GodWorld.class.getName()).log(Level.SEVERE, class_name, ex); Logger.getLogger(GodWorld.class.getName()).log(Level.SEVERE, class_name, ex);
return null; return null;
} }