Add BotOptionFlags.StoreMyAttachmentsOnly for ultra light-weight footprint

This commit is contained in:
Casper Warden
2017-12-14 02:18:50 +00:00
parent 60e300f052
commit ba121281dc
16 changed files with 96 additions and 17 deletions

View File

@@ -18,6 +18,7 @@ import {KillObjectMessage} from './messages/KillObject';
import {IObjectStore} from './interfaces/IObjectStore';
import {GameObjectLite} from './GameObjectLite';
import {NameValue} from './NameValue';
import {BotOptionFlags} from '../enums/BotOptionFlags';
export class ObjectStoreLite implements IObjectStore
{
@@ -27,9 +28,11 @@ export class ObjectStoreLite implements IObjectStore
private objectsByUUID: { [key: string]: number } = {};
private objectsByParent: { [key: number]: number[] } = {};
private clientEvents: ClientEvents;
private options: BotOptionFlags;
constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents)
constructor(circuit: Circuit, agent: Agent, clientEvents: ClientEvents, options: BotOptionFlags)
{
this.options = options;
this.clientEvents = clientEvents;
this.circuit = circuit;
this.agent = agent;
@@ -94,6 +97,16 @@ export class ObjectStoreLite implements IObjectStore
{
this.objectsByParent[parentID].push(localID);
}
if (this.options & BotOptionFlags.StoreMyAttachmentsOnly)
{
if (this.agent.localID !== 0 && obj.ParentID !== this.agent.localID)
{
// Drop object
this.deleteObject(localID);
return;
}
}
});
break;
case Message.ObjectUpdateCached:
@@ -189,6 +202,15 @@ export class ObjectStoreLite implements IObjectStore
}
o.ParentID = newParentID;
}
if (newObj && this.options & BotOptionFlags.StoreMyAttachmentsOnly)
{
if (this.agent.localID !== 0 && o.ParentID !== this.agent.localID)
{
// Drop object
this.deleteObject(localID);
return;
}
}
if (compressedflags & CompressedFlags.Tree)
{
pos++;