From c7cc11e7a17589210fe7849ed90d7dead4b40405 Mon Sep 17 00:00:00 2001 From: "Theunis J. Botha" Date: Fri, 24 Sep 2021 07:05:52 +0200 Subject: [PATCH] fix other components --- src/r3/r3-component/r3-component-code.js | 333 +++++++++++++++++++++++ 1 file changed, 333 insertions(+) create mode 100644 src/r3/r3-component/r3-component-code.js diff --git a/src/r3/r3-component/r3-component-code.js b/src/r3/r3-component/r3-component-code.js new file mode 100644 index 0000000..86d4845 --- /dev/null +++ b/src/r3/r3-component/r3-component-code.js @@ -0,0 +1,333 @@ +const Event = require('.././r3-event'); +const Utils = require('.././r3-utils'); +const Component = require('.././r3-component.js'); + +/** + + GENERATED_INHERITED_START + + Class R3.Event.Object.Component.Code + [Inherited from Event] + + Inherited Properties: + + + + Inherited Static Properties: + + + + Inherited Methods: + + - async(eventId, data, clientCallback, clientErrorCallback) + Simply calls 'Async()' passing it the arguments + + - emit(eventId, data, clientCallback, clientErrorCallback) + Simply calls 'Emit()' passing it the arguments + + - subscribe(eventId, callback) + Simply calls 'Subscribe()' passing it the arguments + + Inherited Static Methods: + + - Async(eventId, data, clientCallback, clientErrorCallback) + Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as + arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the + error as argument. + + - Emit(eventId, data, clientCallback, clientErrorCallback) + Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after + the event result is obtained, passing it the result. If an exception occurs during execution, the + clientErrorCallback is called with the error as argument. + + - Subscribe(eventId, callback) + Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised + + [Inherited from R3Object] + + Inherited Properties: + + - id (Default value Utils.RandomId(15) - Each Object receives an 15 digit random ID which uniquely + identifies it everywhere (client and server side)) + - name (Default value 'Object ' + options.id - Each Object has a name) + - parent (Default value null - All objects could have a parent) + - children (Default value [] - All objects could have some children) + + Inherited Static Properties: + + + + Inherited Methods: + + + + Inherited Static Methods: + + + + [Inherited from Component] + + Inherited Properties: + + + + Inherited Static Properties: + + + + Inherited Methods: + + + + Inherited Static Methods: + + + + [Belonging to ComponentCode] + + Properties: + + + + Static Properties: + + + + Methods: + + + + Static Methods: + + + + GENERATED_INHERITED_END + + TEMPLATE_OPTIONS_START + initialized=false - A boolean which indicates whether or not this component has initialized + instance=null - Holds the current instance of this object as determined (built) by the runtime object. + initializeDepth=0 - The amount of times this component passed through initialize() functions + TEMPLATE_OPTIONS_END + + CUSTOM_OPTIONS_START + CUSTOM_OPTIONS_END + + TEMPLATE_STATIC_OPTIONS_START + TEMPLATE_STATIC_OPTIONS_END + + CUSTOM_STATIC_OPTIONS_START + CUSTOM_STATIC_OPTIONS_END + + TEMPLATE_INSTANCE_OPTIONS_MAPPING_START + TEMPLATE_INSTANCE_OPTIONS_MAPPING_END + + CUSTOM_INSTANCE_OPTIONS_MAPPING_START + CUSTOM_INSTANCE_OPTIONS_MAPPING_END + + TEMPLATE_EXCLUDED_FROM_INSTANCE_OPTIONS_START + instance + initializeDepth + initialized + TEMPLATE_EXCLUDED_FROM_INSTANCE_OPTIONS_END + + CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_START + CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_END + + TEMPLATE_METHODS_START + initialize() - Notifies all systems listening that this component initialized. + updateInstance(property) - Updates this object by copying the values of the current object into it's instance object. + updateFromInstance(property) - Updates this object by copying the values of its instance into the current object. + TEMPLATE_METHODS_END + + CUSTOM_METHODS_START + CUSTOM_METHODS_END + + TEMPLATE_STATIC_METHODS_START + TEMPLATE_STATIC_METHODS_END + + CUSTOM_STATIC_METHODS_START + CUSTOM_STATIC_METHODS_END + + **/ + +class ComponentCode extends Component { + + //GENERATED_CONSTRUCTOR_START + constructor(options) { + + if (typeof options === 'undefined') { + options = {}; + } + + if (typeof options.maxDepth === 'undefined') { + options.maxDepth = 0; + } + + if (typeof options.callDepth === 'undefined') { + options.callDepth = 0; + } else { + options.callDepth++; + } + + options.maxDepth = options.callDepth; + + //GENERATED_TEMPLATE_OPTIONS_INIT_START + /** + * initialized - A boolean which indicates whether or not this component has initialized + */ + if (typeof options.initialized === 'undefined') { + options.initialized = false; + } + /** + * instance - Holds the current instance of this object as determined (built) by the runtime object. + */ + if (typeof options.instance === 'undefined') { + options.instance = null; + } + /** + * initializeDepth - The amount of times this component passed through initialize() functions + */ + if (typeof options.initializeDepth === 'undefined') { + options.initializeDepth = 0; + } + //GENERATED_TEMPLATE_OPTIONS_INIT_END + + super(options); + + //GENERATED_OPTIONS_INIT_START + //GENERATED_OPTIONS_INIT_END + + //CUSTOM_OPTIONS_INIT_START + //CUSTOM_OPTIONS_INIT_END + + Object.assign(this, options); + + //CUSTOM_BEFORE_INIT_START + //CUSTOM_BEFORE_INIT_END + + if (options.callDepth === 0) { + this.initialize(); + } else { + options.callDepth--; + } + + //CUSTOM_AFTER_INIT_START + //CUSTOM_AFTER_INIT_END + } + //GENERATED_CONSTRUCTOR_END + + //GENERATED_TEMPLATE_METHODS_START + + /** + * initialize() + * - Notifies all systems listening that this component initialized. + */ + initialize() { + + //GENERATED_INITIALIZE_METHOD_START + super.initialize(); + //GENERATED_INITIALIZE_METHOD_END + + //CUSTOM_INITIALIZE_METHOD_START + //CUSTOM_INITIALIZE_METHOD_END + + //GENERATED_INITIALIZE_METHOD_AFTER_START + if (this.initializeDepth === this.maxDepth) { + + if (this instanceof R3.Component) { + this.createInstance(); + } + + if (this instanceof R3.Entity && this.initialized && !this.started) { + this.start(); + } + + } else { + this.initializeDepth++; + } + //GENERATED_INITIALIZE_METHOD_AFTER_END + + } + + /** + * updateInstance() + * - Updates this object by copying the values of the current object into it's instance object. + * @param property + */ + updateInstance(property) { + + //GENERATED_UPDATE_INSTANCE_METHOD_START + this.emit(Event.UPDATE_INSTANCE_BEFORE, this); + + //GENERATED_UPDATE_INSTANCE_OPTIONS_START + //GENERATED_UPDATE_INSTANCE_OPTIONS_END + + //GENERATED_TEMPLATE_UPDATE_INSTANCE_OPTIONS_START + //GENERATED_TEMPLATE_UPDATE_INSTANCE_OPTIONS_END + + this.emit(Event.UPDATE_INSTANCE_AFTER, this); + //GENERATED_UPDATE_INSTANCE_METHOD_END + + //CUSTOM_UPDATE_INSTANCE_METHOD_START + //CUSTOM_UPDATE_INSTANCE_METHOD_END + + //GENERATED_UPDATE_INSTANCE_METHOD_AFTER_START + //GENERATED_UPDATE_INSTANCE_METHOD_AFTER_END + + } + + /** + * updateFromInstance() + * - Updates this object by copying the values of its instance into the current object. + * @param property + */ + updateFromInstance(property) { + + //GENERATED_UPDATE_FROM_INSTANCE_METHOD_START + this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this); + + //GENERATED_UPDATE_FROM_INSTANCE_OPTIONS_START + //GENERATED_UPDATE_FROM_INSTANCE_OPTIONS_END + + //GENERATED_TEMPLATE_UPDATE_FROM_INSTANCE_OPTIONS_START + //GENERATED_TEMPLATE_UPDATE_FROM_INSTANCE_OPTIONS_END + + this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this); + + //GENERATED_UPDATE_FROM_INSTANCE_METHOD_END + + //CUSTOM_UPDATE_FROM_INSTANCE_METHOD_START + //CUSTOM_UPDATE_FROM_INSTANCE_METHOD_END + + //GENERATED_UPDATE_FROM_INSTANCE_METHOD_AFTER_START + //GENERATED_UPDATE_FROM_INSTANCE_METHOD_AFTER_END + + } + //GENERATED_TEMPLATE_METHODS_END + + //GENERATED_METHODS_START + //GENERATED_METHODS_END + + //GENERATED_TEMPLATE_STATIC_METHODS_START + //GENERATED_TEMPLATE_STATIC_METHODS_END + + //GENERATED_STATIC_METHODS_START + //GENERATED_STATIC_METHODS_END + + //CUSTOM_IMPLEMENTATION_START + //CUSTOM_IMPLEMENTATION_END +} + +//GENERATED_TEMPLATE_STATIC_OPTIONS_INIT_START +//GENERATED_TEMPLATE_STATIC_OPTIONS_INIT_END + +//GENERATED_STATIC_OPTIONS_INIT_START +//GENERATED_STATIC_OPTIONS_INIT_END + +//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_START +//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_END + +//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START +//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END + +module.exports = ComponentCode;