mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-26 17:30:52 +01:00
Update configruation
This commit is contained in:
parent
a86ab2bb3b
commit
bc066e2916
@ -194,12 +194,12 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
||||
|
||||
if(!encoded)
|
||||
{
|
||||
if(Nitro.instance.getConfiguration<boolean>('communication.packet.log')) console.log(`Encoding Failed: ${ composer.constructor.name }`);
|
||||
if(Nitro.instance.getConfiguration<boolean>('system.packet.log')) console.log(`Encoding Failed: ${ composer.constructor.name }`);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(Nitro.instance.getConfiguration<boolean>('communication.packet.log')) console.log(`OutgoingComposer: [${ header }] ${ composer.constructor.name }`, message);
|
||||
if(Nitro.instance.getConfiguration<boolean>('system.packet.log')) console.log(`OutgoingComposer: [${ header }] ${ composer.constructor.name }`, message);
|
||||
|
||||
this.write(encoded.getBuffer());
|
||||
}
|
||||
@ -257,7 +257,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
||||
|
||||
if(!messages || !messages.length) continue;
|
||||
|
||||
if(Nitro.instance.getConfiguration<boolean>('communication.packet.log'))
|
||||
if(Nitro.instance.getConfiguration<boolean>('system.packet.log'))
|
||||
{
|
||||
console.log(`IncomingMessage: [${ wrapper.header }] ${ messages[0].constructor.name }`, messages[0].parser);
|
||||
}
|
||||
@ -291,7 +291,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
||||
|
||||
if(!events || !events.length)
|
||||
{
|
||||
if(Nitro.instance.getConfiguration<boolean>('communication.packet.log'))
|
||||
if(Nitro.instance.getConfiguration<boolean>('system.packet.log'))
|
||||
{
|
||||
console.log(`IncomingMessage: [${ wrapper.header }] UNREGISTERED`, wrapper);
|
||||
}
|
||||
|
@ -6,12 +6,14 @@ import { IConfigurationManager } from './IConfigurationManager';
|
||||
export class ConfigurationManager extends NitroManager implements IConfigurationManager
|
||||
{
|
||||
private _definitions: AdvancedMap<string, unknown>;
|
||||
private _pendingUrls: string[];
|
||||
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
|
||||
this._definitions = new AdvancedMap();
|
||||
this._pendingUrls = [];
|
||||
|
||||
this.onConfigurationLoaded = this.onConfigurationLoaded.bind(this);
|
||||
}
|
||||
@ -19,7 +21,38 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
|
||||
protected onInit(): void
|
||||
{
|
||||
//@ts-ignore
|
||||
this.loadConfigurationFromUrl(NitroConfig.configurationUrl);
|
||||
let urls: string[] = NitroConfig.configurationUrls;
|
||||
|
||||
if(!urls || !urls.length)
|
||||
{
|
||||
//@ts-ignore
|
||||
const url: string = NitroConfig.configurationUrl;
|
||||
|
||||
if(url && url.length) urls = [ url ];
|
||||
}
|
||||
|
||||
if(!urls || !urls.length)
|
||||
{
|
||||
this.dispatchConfigurationEvent(ConfigurationEvent.FAILED);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._pendingUrls = urls;
|
||||
|
||||
this.loadNextConfiguration();
|
||||
}
|
||||
|
||||
private loadNextConfiguration(): void
|
||||
{
|
||||
if(!this._pendingUrls.length)
|
||||
{
|
||||
this.dispatchConfigurationEvent(ConfigurationEvent.LOADED);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.loadConfigurationFromUrl(this._pendingUrls[0]);
|
||||
}
|
||||
|
||||
public loadConfigurationFromUrl(url: string): void
|
||||
@ -33,17 +66,21 @@ export class ConfigurationManager extends NitroManager implements IConfiguration
|
||||
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => this.onConfigurationLoaded(data))
|
||||
.then(data => this.onConfigurationLoaded(data, url))
|
||||
.catch(err => this.onConfigurationFailed(err));
|
||||
}
|
||||
|
||||
private onConfigurationLoaded(data: { [index: string]: any }): void
|
||||
private onConfigurationLoaded(data: { [index: string]: any }, url: string): void
|
||||
{
|
||||
if(!data) return;
|
||||
|
||||
if(this.parseConfiguration(data))
|
||||
{
|
||||
this.dispatchConfigurationEvent(ConfigurationEvent.LOADED);
|
||||
const index = this._pendingUrls.indexOf(url);
|
||||
|
||||
if(index >= 0) this._pendingUrls.splice(index, 1);
|
||||
|
||||
this.loadNextConfiguration();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -217,8 +217,8 @@ export class Nitro extends Application implements INitro
|
||||
|
||||
private onConfigurationLoadedEvent(event: ConfigurationEvent): void
|
||||
{
|
||||
const animationFPS = this.getConfiguration<number>('animation.fps', 24);
|
||||
const limitsFPS = this.getConfiguration<boolean>('limits.fps', true);
|
||||
const animationFPS = this.getConfiguration<number>('system.animation.fps', 24);
|
||||
const limitsFPS = this.getConfiguration<boolean>('system.limits.fps', true);
|
||||
|
||||
if(limitsFPS) Nitro.instance.ticker.maxFPS = animationFPS;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ export class NitroCommunicationDemo extends NitroManager
|
||||
|
||||
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ESTABLISHED, connection);
|
||||
|
||||
if(Nitro.instance.getConfiguration<boolean>('communication.pong.manually', false)) this.startPonging();
|
||||
if(Nitro.instance.getConfiguration<boolean>('system.pong.manually', false)) this.startPonging();
|
||||
|
||||
this.startHandshake(connection);
|
||||
|
||||
@ -177,7 +177,7 @@ export class NitroCommunicationDemo extends NitroManager
|
||||
{
|
||||
this.stopPonging();
|
||||
|
||||
this._pongInterval = setInterval(this.sendPong, Nitro.instance.getConfiguration<number>('communication.pong.interval.ms', 20000));
|
||||
this._pongInterval = setInterval(this.sendPong, Nitro.instance.getConfiguration<number>('system.pong.interval.ms', 20000));
|
||||
}
|
||||
|
||||
private stopPonging(): void
|
||||
|
@ -139,8 +139,8 @@ export class LandscapeRasterizer extends PlaneRasterizer
|
||||
const assetId = item.assetId;
|
||||
const x = this.getCoordinateValue(item.x || '', item.randomX || '');
|
||||
const y = this.getCoordinateValue(item.y || '', item.randomY || '');
|
||||
const speedX = item.speedX ? item.speedX / Nitro.instance.getConfiguration<number>('animation.fps') : 0;
|
||||
const speedY = item.speedY ? item.speedY / Nitro.instance.getConfiguration<number>('animation.fps') : 0;
|
||||
const speedX = item.speedX ? item.speedX / Nitro.instance.getConfiguration<number>('system.animation.fps') : 0;
|
||||
const speedY = item.speedY ? item.speedY / Nitro.instance.getConfiguration<number>('system.animation.fps') : 0;
|
||||
|
||||
animationItems.push({
|
||||
asset: assetId,
|
||||
|
@ -74,7 +74,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
||||
this._container = container;
|
||||
|
||||
this._geometry = new RoomGeometry(scale, new Vector3d(-135, 30, 0), new Vector3d(11, 11, 5), new Vector3d(-135, 0.5, 0));
|
||||
this._animationFPS = Nitro.instance.getConfiguration<number>('animation.fps', 24);
|
||||
this._animationFPS = Nitro.instance.getConfiguration<number>('system.animation.fps', 24);
|
||||
this._renderTimestamp = 0;
|
||||
this._totalTimeRunning = 0;
|
||||
this._lastFrame = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user