mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-24 00:10:52 +01:00
48 lines
897 B
TypeScript
48 lines
897 B
TypeScript
|
import { IRoomObjectModel } from './IRoomObjectModel';
|
||
|
|
||
|
export class RoomObjectModel implements IRoomObjectModel
|
||
|
{
|
||
|
private _map: Map<string, unknown>;
|
||
|
private _updateCounter: number;
|
||
|
|
||
|
constructor()
|
||
|
{
|
||
|
this._map = new Map();
|
||
|
this._updateCounter = 0;
|
||
|
}
|
||
|
|
||
|
public dispose(): void
|
||
|
{
|
||
|
this._map.clear();
|
||
|
|
||
|
this._updateCounter = 0;
|
||
|
}
|
||
|
|
||
|
public getValue<T>(key: string): T
|
||
|
{
|
||
|
const existing = this._map.get(key);
|
||
|
|
||
|
return (existing as T);
|
||
|
}
|
||
|
|
||
|
public setValue<T>(key: string, value: T): void
|
||
|
{
|
||
|
this._map.set(key, (value as T));
|
||
|
|
||
|
this._updateCounter++;
|
||
|
}
|
||
|
|
||
|
public removeKey(key: string): void
|
||
|
{
|
||
|
if(!key) return;
|
||
|
|
||
|
this._map.delete(key);
|
||
|
|
||
|
this._updateCounter++;
|
||
|
}
|
||
|
|
||
|
public get updateCounter(): number
|
||
|
{
|
||
|
return this._updateCounter;
|
||
|
}
|
||
|
}
|