diff --git a/client/index.js b/client/index.js index 12032d0..5b5a1b9 100644 --- a/client/index.js +++ b/client/index.js @@ -9,6 +9,11 @@ const Sound = require('./lib/sound.js'); const Matrix = require('./lib/matrix.js'); const {Eye, Plane} = require('./lib/eye.js'); +const LightingModule = require('./lib/lighting.js'); +const IconLoader = require('./lib/icon_loader.js'); +const Renderer = require('./lib/renderer.js'); +const AudioLoader = require('./lib/audio_loader.js'); + class BluespessClient extends EventEmitter { constructor(wsurl, resRoot = "") { super(); @@ -36,7 +41,7 @@ class BluespessClient extends EventEmitter { if(global.AudioContext) this.audio_ctx = new AudioContext(); } - this.importModule(require('./lib/lighting.js')); + this.importModule(LightingModule); } handle_login() { @@ -315,10 +320,9 @@ BluespessClient.dropdown = function(elem1, elem2, {point = null, autoremove = tr if(autoremove) elem2.focus(); }; - -BluespessClient.prototype.enqueue_icon_meta_load = require('./lib/icon_loader.js'); -BluespessClient.prototype.anim_loop = require('./lib/renderer.js'); -BluespessClient.prototype.get_audio_buffer = require('./lib/audio_loader.js'); +BluespessClient.prototype.enqueue_icon_meta_load = IconLoader; +BluespessClient.prototype.anim_loop = Renderer; +BluespessClient.prototype.get_audio_buffer = AudioLoader; BluespessClient.Atom = Atom; BluespessClient.Component = Component; diff --git a/client/lib/lighting.js b/client/lib/lighting.js index 033bc66..2b6b792 100644 --- a/client/lib/lighting.js +++ b/client/lib/lighting.js @@ -1,5 +1,5 @@ 'use strict'; -const {Component} = require('../index.js'); +const Component = require('./component.js'); class LightingObject extends Component { constructor(atom, template) { diff --git a/lib/atom/atom.js b/lib/atom/atom.js index 930a8fc..c376b0f 100644 --- a/lib/atom/atom.js +++ b/lib/atom/atom.js @@ -1,6 +1,6 @@ 'use strict'; const EventEmitter = require('events'); -const mob_symbols = require('./mob.js')._symbols; +const mob_symbols = require('./mob')._symbols; const {has_component} = require('../utils.js'); const Component = require('./component.js'); diff --git a/lib/atom/component.js b/lib/atom/component.js index 58835cf..c1a646e 100644 --- a/lib/atom/component.js +++ b/lib/atom/component.js @@ -1,6 +1,6 @@ 'use strict'; const EventEmitter = require('events'); -const mob_symbols = require('./mob.js')._symbols; +const mob_symbols = require('./mob/symbols.js'); const _networked_vars = Symbol('_networked_vars'); /** diff --git a/lib/atom/lighting.js b/lib/atom/lighting.js index f1cc311..07fae9d 100644 --- a/lib/atom/lighting.js +++ b/lib/atom/lighting.js @@ -1,6 +1,7 @@ 'use strict'; -const {Component, Atom} = require('../server.js'); +const Atom = require('./atom.js'); +const Component = require('./component.js'); const _enabled = Symbol('_enabled'); const _color = Symbol('_color'); diff --git a/lib/atom/mob.js b/lib/atom/mob/index.js similarity index 93% rename from lib/atom/mob.js rename to lib/atom/mob/index.js index f7d8188..56048b6 100644 --- a/lib/atom/mob.js +++ b/lib/atom/mob/index.js @@ -1,24 +1,11 @@ 'use strict'; -const {chain_func, is_atom, to_chat, has_component} = require('../utils.js'); -const _observers = Symbol('_observers'); -const _viewers = Symbol('_viewers'); -const _viewing = Symbol('_viewing'); -const _key = Symbol('_key'); -const _client = Symbol('_client'); -const _server_to_net = Symbol('_server_to_net'); -const _visible_tiles = Symbol('_visible_tiles'); -const _screen_set = Symbol('_screen_set'); -const _update_var = Symbol('_update_var'); -const _add_viewing = Symbol('_add_viewing'); -const _remove_viewing = Symbol('_remove_viewing'); -const _common_tiles_count = Symbol('_common_tiles_count'); -const _panel_map = Symbol('_panel_map'); -const _visgroups = Symbol('_visgroups'); -const _eye_to_eyeid = Symbol('_eye_to_eyeid'); -module.exports._symbols = {_observers, _client, _viewers, _viewing, _visible_tiles, _server_to_net, _add_viewing, _remove_viewing, _update_var, _common_tiles_count, _visgroups, _key}; - -const Component = require('./component.js'); +const {chain_func, is_atom, to_chat, has_component} = require('../../utils.js'); + +const {_observers, _viewers, _viewing, _key, _client, _server_to_net, _visible_tiles, _screen_set, _update_var, _add_viewing, _remove_viewing, _common_tiles_count, _panel_map, _visgroups, _eye_to_eyeid} = require('./symbols.js'); +module.exports._symbols = require('./symbols.js'); + +const Component = require('../component.js'); var id_counter = 0; @@ -75,7 +62,7 @@ class Eye extends Component { if(this.a.c.Hearer) this.a.c.Hearer.show_message = chain_func(this.a.c.Hearer.show_message, this.show_message.bind(this)); - + /** @type {boolean} */this.xray; } diff --git a/lib/atom/mob/symbols.js b/lib/atom/mob/symbols.js new file mode 100644 index 0000000..6c9ce6f --- /dev/null +++ b/lib/atom/mob/symbols.js @@ -0,0 +1,17 @@ +const _observers = Symbol('_observers'); +const _viewers = Symbol('_viewers'); +const _viewing = Symbol('_viewing'); +const _key = Symbol('_key'); +const _client = Symbol('_client'); +const _server_to_net = Symbol('_server_to_net'); +const _visible_tiles = Symbol('_visible_tiles'); +const _screen_set = Symbol('_screen_set'); +const _update_var = Symbol('_update_var'); +const _add_viewing = Symbol('_add_viewing'); +const _remove_viewing = Symbol('_remove_viewing'); +const _common_tiles_count = Symbol('_common_tiles_count'); +const _panel_map = Symbol('_panel_map'); +const _visgroups = Symbol('_visgroups'); +const _eye_to_eyeid = Symbol('_eye_to_eyeid'); + +module.exports = {_observers, _client, _viewers, _viewing, _visible_tiles, _server_to_net, _add_viewing, _remove_viewing, _update_var, _common_tiles_count, _visgroups, _key}; diff --git a/lib/atom/visgroup.js b/lib/atom/visgroup.js index 4a871c4..a17a4bf 100644 --- a/lib/atom/visgroup.js +++ b/lib/atom/visgroup.js @@ -1,8 +1,8 @@ 'use strict'; const {chain_func} = require('../utils.js'); -const mob_symbols = require('./mob.js')._symbols; +const mob_symbols = require('./mob')._symbols; -/** +/** * @typedef {import('./atom')} Bluespess.Atom */ diff --git a/lib/client.js b/lib/client.js index 3638d57..06e6441 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,7 +1,7 @@ 'use strict'; const {has_component} = require('./utils.js'); -const mob_symbols = require('./atom/mob.js')._symbols; +const mob_symbols = require('./atom/mob')._symbols; const EventEmitter = require('events'); const Component = require('./atom/component.js'); diff --git a/lib/server.js b/lib/server.js index 7c44232..413b423 100644 --- a/lib/server.js +++ b/lib/server.js @@ -11,6 +11,10 @@ const utils = require('./utils.js'); const VisibilityGroup = require('./atom/visgroup.js'); const Dimension = require('./dimension.js'); +const MobModule = require('./atom/mob'); +const LightingModule = require('./atom/lighting.js'); +const HearerModule = require('./atom/hearer.js'); + const _net_tick = Symbol('_net_tick'); const _is_template_processed = Symbol('_is_template_processed'); const _is_server_started = Symbol('_is_server_started'); @@ -56,9 +60,9 @@ class Bluespess extends EventEmitter { this.demo_stream = null; // Import default modules - this.importModule(require('./atom/mob.js')); - this.importModule(require('./atom/lighting.js')); - this.importModule(require('./atom/hearer.js')); + this.importModule(MobModule); + this.importModule(LightingModule); + this.importModule(HearerModule); this.net_tick_delay = 50;