diff --git a/dist/index.html b/dist/index.html index 44042fe..9d90f2d 100644 --- a/dist/index.html +++ b/dist/index.html @@ -40,6 +40,7 @@ slider.images = [image]; slider.canvas = null; slider.canvas = canvas; + slider.images = []; }); diff --git a/dist/r3.js b/dist/r3.js index 63a9eba..7967763 100644 --- a/dist/r3.js +++ b/dist/r3.js @@ -1,6 +1,6 @@ class R3 { - static version = '3.0.67'; - static compileDate = '2021 Sep 23 - 14:00:26 pm'; + static version = '3.0.68'; + static compileDate = '2021 Sep 23 - 20:16:29 pm'; } class Runtime { @@ -1505,6 +1505,52 @@ class SystemLinking extends System { console.log('Entity object update of property ' + object.property); + /** + * Set the parent relationships + */ + if (object.value instanceof Array) { + + /** + * This entity could have its property set to an empty array. + * In this case - we should check its existing components and have their relationships + * severed + */ + if (object.value.length === 0) { + + if (object.entity[object.property] instanceof Array) { + for (let i = 0; i < object.entity[object.property].length; i++) { + if (object.entity[object.property][i] instanceof R3.Component) { + object.entity.dirty = true; + object.entity[object.property][i].parent = null; + } + } + } + + } else { + for (let i = 0; i < object.value.length; i++) { + if (object.value[i] instanceof R3.Component) { + object.value[i].parent = object.entity; + } + } + } + + } + + if (object.value instanceof R3.Component) { + object.value.parent = object.entity; + } + + /** + * The value was unassigned - remove the parent relationships of the existing + * components (if available) + */ + if (object.value === null || typeof object.value === 'undefined') { + if (object.entity[object.property] instanceof R3.Component) { + object.entity.dirty = true; + object.entity[object.property].parent = null; + } + } + if (!object.entity.underConstruction) { if (object.entity.initialized) { @@ -1530,6 +1576,18 @@ class SystemLinking extends System { static OnEntityPropertyUpdated(object) { if (!object.entity.underConstruction) { + + /** + * At this point - the object entity would have been brought to a stop + * if it had been transitioned into an uninitialized state by setting one of + * its required properties. + * We can safely clear the dirty state + */ + + if (object.entity.dirty) { + object.entity.dirty = false; + } + object.entity.initializeDepth = 0; object.entity.initialize(); } @@ -2953,6 +3011,14 @@ class EntitySlider extends Entity { if (typeof options.subscriptions === 'undefined') { options.subscriptions = {}; } + /** + * dirty - When dirty is true, it means that this entity is in transition from having a Component to not + * having this Component, and will probably end up in an uninitialized state. During the next few + * clock cycles this child Component will have its parent reference to this entity removed. + */ + if (typeof options.dirty === 'undefined') { + options.dirty = false; + } super(options); diff --git a/package.json b/package.json index afa2e21..8c9c2a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "r3", - "version" : "3.0.67", + "version" : "3.0.68", "description": "", "private": true, "dependencies": { diff --git a/src/r3/r3-entity/r3-entity-slider.js b/src/r3/r3-entity/r3-entity-slider.js index 5e5c660..81f389a 100644 --- a/src/r3/r3-entity/r3-entity-slider.js +++ b/src/r3/r3-entity/r3-entity-slider.js @@ -113,6 +113,7 @@ const Entity = require('.././r3-entity.js'); components=[] - A list of components that this entity is composed of started=false - Indicates whether or not this entity is active (subscribing to events) or not subscriptions={} - An association object which hold the subscription handles for Events this system is listening to. The system can stop receiving events by calling remove() on a handle. + dirty=false - When dirty is true, it means that this entity is in transition from having a Component to not having this Component, and will probably end up in an uninitialized state. During the next few clock cycles this child Component will have its parent reference to this entity removed. TEMPLATE_OPTIONS_END CUSTOM_OPTIONS_START @@ -219,6 +220,14 @@ class EntitySlider extends Entity { if (typeof options.subscriptions === 'undefined') { options.subscriptions = {}; } + /** + * dirty - When dirty is true, it means that this entity is in transition from having a Component to not + * having this Component, and will probably end up in an uninitialized state. During the next few + * clock cycles this child Component will have its parent reference to this entity removed. + */ + if (typeof options.dirty === 'undefined') { + options.dirty = false; + } //GENERATED_TEMPLATE_OPTIONS_INIT_END super(options); diff --git a/src/r3/r3-r3.js b/src/r3/r3-r3.js index baf2a84..d9c3b90 100644 --- a/src/r3/r3-r3.js +++ b/src/r3/r3-r3.js @@ -1,6 +1,6 @@ class R3 { - static version = '3.0.67'; - static compileDate = '2021 Sep 23 - 14:00:26 pm'; + static version = '3.0.68'; + static compileDate = '2021 Sep 23 - 20:16:29 pm'; } //GENERATED_IMPORTS_START diff --git a/src/r3/r3-system/r3-system-linking.js b/src/r3/r3-system/r3-system-linking.js index 0646da1..d229e94 100644 --- a/src/r3/r3-system/r3-system-linking.js +++ b/src/r3/r3-system/r3-system-linking.js @@ -368,6 +368,52 @@ class SystemLinking extends System { //CUSTOM_STATIC_ON_ENTITY_PROPERTY_UPDATE_METHOD_START console.log('Entity object update of property ' + object.property); + /** + * Set the parent relationships + */ + if (object.value instanceof Array) { + + /** + * This entity could have its property set to an empty array. + * In this case - we should check its existing components and have their relationships + * severed + */ + if (object.value.length === 0) { + + if (object.entity[object.property] instanceof Array) { + for (let i = 0; i < object.entity[object.property].length; i++) { + if (object.entity[object.property][i] instanceof R3.Component) { + object.entity.dirty = true; + object.entity[object.property][i].parent = null; + } + } + } + + } else { + for (let i = 0; i < object.value.length; i++) { + if (object.value[i] instanceof R3.Component) { + object.value[i].parent = object.entity; + } + } + } + + } + + if (object.value instanceof R3.Component) { + object.value.parent = object.entity; + } + + /** + * The value was unassigned - remove the parent relationships of the existing + * components (if available) + */ + if (object.value === null || typeof object.value === 'undefined') { + if (object.entity[object.property] instanceof R3.Component) { + object.entity.dirty = true; + object.entity[object.property].parent = null; + } + } + if (!object.entity.underConstruction) { if (object.entity.initialized) { @@ -399,6 +445,18 @@ class SystemLinking extends System { //CUSTOM_STATIC_ON_ENTITY_PROPERTY_UPDATED_METHOD_START if (!object.entity.underConstruction) { + + /** + * At this point - the object entity would have been brought to a stop + * if it had been transitioned into an uninitialized state by setting one of + * its required properties. + * We can safely clear the dirty state + */ + + if (object.entity.dirty) { + object.entity.dirty = false; + } + object.entity.initializeDepth = 0; object.entity.initialize(); } diff --git a/src/templates/entity_extends.template b/src/templates/entity_extends.template index 070918b..08faa0f 100644 --- a/src/templates/entity_extends.template +++ b/src/templates/entity_extends.template @@ -15,6 +15,7 @@ const EXTEND_CLASS = require('INCLUDE_PATH/EXTEND_CLASS_FILE_NAME'); components=[] - A list of components that this entity is composed of started=false - Indicates whether or not this entity is active (subscribing to events) or not subscriptions={} - An association object which hold the subscription handles for Events this system is listening to. The system can stop receiving events by calling remove() on a handle. + dirty=false - When dirty is true, it means that this entity is in transition from having a Component to not having this Component, and will probably end up in an uninitialized state. During the next few clock cycles this child Component will have its parent reference to this entity removed. TEMPLATE_OPTIONS_END CUSTOM_OPTIONS_START diff --git a/version b/version index 6cdf9d2..f1eb5bc 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.0.67 \ No newline at end of file +3.0.68 \ No newline at end of file