Added some comments
This commit is contained in:
parent
b084e0a156
commit
2e1a53789f
@ -109,7 +109,14 @@ public class GodWorld implements GetJson, World {
|
||||
}
|
||||
init(cfg,false);
|
||||
}
|
||||
|
||||
private void init(JSONObject cfg, boolean mt) {
|
||||
// this.scheduler = new Scheduler();
|
||||
// this.scheduler.start();
|
||||
putJson(cfg);
|
||||
}
|
||||
|
||||
|
||||
public Scheduler getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
@ -122,11 +129,6 @@ public class GodWorld implements GetJson, World {
|
||||
this(new JSONObject("{}"));
|
||||
}
|
||||
|
||||
private void init(JSONObject cfg, boolean mt) {
|
||||
this.scheduler = new Scheduler();
|
||||
this.scheduler.start();
|
||||
putJson(cfg);
|
||||
}
|
||||
|
||||
private void putJson(JSONObject cfg) {
|
||||
// Read assets
|
||||
@ -186,11 +188,19 @@ public class GodWorld implements GetJson, World {
|
||||
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 {
|
||||
AbstractAsset a;
|
||||
String class_name;
|
||||
Class<AbstractAsset> cls;
|
||||
|
||||
// get asset name
|
||||
try {
|
||||
class_name = cfg.getString(JKEYS.ASSET_TYPE);
|
||||
} catch (JSONException jex) {
|
||||
@ -198,10 +208,13 @@ public class GodWorld implements GetJson, World {
|
||||
return null;
|
||||
}
|
||||
|
||||
// create class from name
|
||||
try {
|
||||
cls = (Class<AbstractAsset>) Class.forName(class_name);
|
||||
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);
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user