From 2e1a53789fe102606293c18da6fbf1fa4f8b0b09 Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@mail.ru> Date: Fri, 23 Oct 2020 09:45:44 +0200 Subject: [PATCH] Added some comments --- src/opensesim/world/GodWorld.java | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/opensesim/world/GodWorld.java b/src/opensesim/world/GodWorld.java index d15d7b2..10657de 100644 --- a/src/opensesim/world/GodWorld.java +++ b/src/opensesim/world/GodWorld.java @@ -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 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) 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; }