Merge remote-tracking branch 'github/nitro-v2-updates' into fix/variable-cleanup

This commit is contained in:
Dank074 2021-06-12 00:21:04 -05:00
commit 6a8ce00266
21 changed files with 338 additions and 131 deletions

View File

@ -221,7 +221,7 @@ export class Nitro extends Application implements INitro
const animationFPS = this.getConfiguration<number>('animation.fps', 24);
const limitsFPS = this.getConfiguration<boolean>('limits.fps', true);
Nitro.instance.ticker.maxFPS = animationFPS;
if(limitsFPS) Nitro.instance.ticker.maxFPS = animationFPS;
}
private onRoomEngineReady(event: RoomEngineEvent): void

View File

@ -1,5 +1,5 @@
import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration';
import { ApproveNameMessageComposer, CatalogApproveNameResultEvent, ChangeUserNameResultMessageEvent, SellablePetPalettesEvent } from './messages';
import { ApproveNameMessageComposer, CatalogApproveNameResultEvent, SellablePetPalettesEvent } from './messages';
import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent';
import { CatalogClubEvent } from './messages/incoming/catalog/CatalogClubEvent';
import { CatalogClubGiftsEvent } from './messages/incoming/catalog/CatalogClubGiftsEvent';
@ -130,6 +130,7 @@ import { RoomSettingsEvent } from './messages/incoming/room/data/RoomSettingsEve
import { RoomSettingsSavedEvent } from './messages/incoming/room/data/RoomSettingsSavedEvent';
import { RoomSettingsUpdatedEvent } from './messages/incoming/room/data/RoomSettingsUpdatedEvent';
import { RoomUsersWithRightsEvent } from './messages/incoming/room/data/RoomUsersWithRightsEvent';
import { ObjectsDataUpdateEvent } from './messages/incoming/room/engine/ObjectsDataUpdateEvent';
import { ObjectsRollingEvent } from './messages/incoming/room/engine/ObjectsRollingEvent';
import { RoomCreatedEvent } from './messages/incoming/room/engine/RoomCreatedEvent';
import { FurnitureFloorAddEvent } from './messages/incoming/room/furniture/floor/FurnitureFloorAddEvent';
@ -592,6 +593,7 @@ export class NitroMessages implements IMessageConfiguration
this._events.set(IncomingHeader.LOVELOCK_FURNI_FINISHED, LoveLockFurniFinishedEvent);
this._events.set(IncomingHeader.LOVELOCK_FURNI_FRIEND_COMFIRMED, LoveLockFurniFriendConfirmedEvent);
this._events.set(IncomingHeader.LOVELOCK_FURNI_START, LoveLockFurniStartEvent);
this._events.set(IncomingHeader.OBJECTS_DATA_UPDATE, ObjectsDataUpdateEvent);
// FLOOR
this._events.set(IncomingHeader.FURNITURE_FLOOR_ADD, FurnitureFloorAddEvent);
@ -1022,3 +1024,7 @@ export class NitroMessages implements IMessageConfiguration
return this._composers;
}
}
function ChangeUserNameResultMessageEvent(USER_CHANGE_NAME: number, ChangeUserNameResultMessageEvent: any)
{
throw new Error('Function not implemented.');
}

View File

@ -247,4 +247,5 @@ export class IncomingHeader
public static MARKETPLACE_AFTER_ORDER_STATUS = 2032;
public static CATALOG_RECEIVE_PET_BREEDS = 3331;
public static CATALOG_APPROVE_NAME_RESULT = 1503;
public static OBJECTS_DATA_UPDATE = 1453;
}

View File

@ -0,0 +1,30 @@
import { IObjectData } from '../../../../../room';
export class ObjectData
{
private _id: number = 0;
private _state: number = 0;
private _data: IObjectData;
constructor(id: number, state: number, objectData: IObjectData)
{
this._id = id;
this._state = state;
this._data = objectData;
}
public get id(): number
{
return this._id;
}
public get state(): number
{
return this._state;
}
public get data(): IObjectData
{
return this._data;
}
}

View File

@ -0,0 +1,16 @@
import { IMessageEvent } from '../../../../../../core/communication/messages/IMessageEvent';
import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent';
import { ObjectsDataUpdateParser } from '../../../parser/room/engine/ObjectsDataUpdateParser';
export class ObjectsDataUpdateEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, ObjectsDataUpdateParser);
}
public getParser(): ObjectsDataUpdateParser
{
return this.parser as ObjectsDataUpdateParser;
}
}

View File

@ -1,2 +1,4 @@
export * from './ObjectData';
export * from './ObjectsDataUpdateEvent';
export * from './ObjectsRollingEvent';
export * from './RoomCreatedEvent';

View File

@ -0,0 +1,41 @@
import { IMessageDataWrapper } from '../../../../../../core/communication/messages/IMessageDataWrapper';
import { IMessageParser } from '../../../../../../core/communication/messages/IMessageParser';
import { ObjectData } from '../../../incoming/room/engine/ObjectData';
import { FurnitureDataParser } from '../furniture/FurnitureDataParser';
export class ObjectsDataUpdateParser implements IMessageParser
{
private _objects: ObjectData[];
public flush(): boolean
{
this._objects = [];
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
let totalObjects = wrapper.readInt();
while(totalObjects > 0)
{
const id = wrapper.readInt();
const stuffData = FurnitureDataParser.parseObjectData(wrapper);
const state = parseFloat(stuffData.getLegacyString());
this._objects.push(new ObjectData(id, state, stuffData));
totalObjects--;
}
return true;
}
public get objects(): ObjectData[]
{
return this._objects;
}
}

View File

@ -21,7 +21,7 @@ export class ObjectsRollingParser implements IMessageParser
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return;
if(!wrapper) return false;
const x = wrapper.readInt();
const y = wrapper.readInt();

View File

@ -16,7 +16,7 @@ export class RoomCreatedParser implements IMessageParser
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return;
if(!wrapper) return false;
this._roomId = wrapper.readInt();
this._roomName = wrapper.readString();

View File

@ -1,2 +1,3 @@
export * from './ObjectsDataUpdateParser';
export * from './ObjectsRollingParser';
export * from './RoomCreatedParser';

View File

@ -45,7 +45,8 @@ export class UserSubscriptionParser implements IMessageParser
this._isVip = wrapper.readBoolean();
this._pastClubDays = wrapper.readInt();
this._pastVIPDays = wrapper.readInt();
this._totalSeconds = wrapper.readInt();
if(wrapper.bytesAvailable) this._totalSeconds = wrapper.readInt();
return true;
}

View File

@ -153,7 +153,48 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca
{
for(let i = 0; i < parameters.length; i++)
{
value = value.replace('%' + parameters[i] + '%', replacements[i]);
const parameter = parameters[i];
const replacement = replacements[i];
value = value.replace('%' + parameter + '%', replacement);
if(value.startsWith('%{'))
{
const regex = new RegExp('%{' + parameter.toUpperCase() + '\\|([^|]*)\\|([^|]*)\\|([^|]*)}');
const result = value.match(regex);
if(!result) continue;
const replacementAsNumber = parseInt(replacement);
let indexKey = -1;
let replace = false;
switch(replacementAsNumber)
{
case 0:
indexKey = 1;
break;
case 1:
indexKey = 2;
break;
case 2:
default:
indexKey = 3;
replace = true;
break;
}
if((indexKey === -1) || (typeof result[indexKey] === 'undefined')) continue;
const valueFromResults = result[indexKey];
if(valueFromResults)
{
value = valueFromResults.replace('%%', replacement);
}
}
}
}

View File

@ -2476,6 +2476,8 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
else if(type === MouseEventType.MOUSE_DOWN) eventType = RoomObjectMouseEvent.MOUSE_DOWN;
else if(type === MouseEventType.MOUSE_DOWN_LONG) eventType = RoomObjectMouseEvent.MOUSE_DOWN_LONG;
else if(type === MouseEventType.MOUSE_UP) eventType = RoomObjectMouseEvent.MOUSE_UP;
}
@ -2506,9 +2508,8 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
}
}
}
else
{
if(type === MouseEventType.MOUSE_UP)
else if(type === MouseEventType.MOUSE_UP)
{
if(this._activeRoomIsDragged)
{
@ -2541,9 +2542,8 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
}
}
}
else
{
if(type === MouseEventType.MOUSE_MOVE)
else if(type === MouseEventType.MOUSE_MOVE)
{
if(this._activeRoomIsDragged)
{
@ -2570,9 +2570,8 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
}
}
}
else
{
if((type === MouseEventType.MOUSE_CLICK) || (type === MouseEventType.DOUBLE_CLICK))
else if((type === MouseEventType.MOUSE_CLICK) || (type === MouseEventType.DOUBLE_CLICK))
{
this._activeRoomIsDragged = false;
@ -2583,9 +2582,6 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
return true;
}
}
}
}
}
return false;
}

View File

@ -3,6 +3,7 @@ import { IConnection } from '../../core/communication/connections/IConnection';
import { IVector3D } from '../../room/utils/IVector3D';
import { Vector3d } from '../../room/utils/Vector3d';
import { PetType } from '../avatar/pets/PetType';
import { ObjectsDataUpdateEvent } from '../communication';
import { ObjectsRollingEvent } from '../communication/messages/incoming/room/engine/ObjectsRollingEvent';
import { FurnitureFloorAddEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorAddEvent';
import { FurnitureFloorEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorEvent';
@ -113,6 +114,7 @@ export class RoomMessageHandler extends Disposable
this._connection.addMessageEvent(new RoomThicknessEvent(this.onRoomThicknessEvent.bind(this)));
this._connection.addMessageEvent(new RoomDoorEvent(this.onRoomDoorEvent.bind(this)));
this._connection.addMessageEvent(new ObjectsRollingEvent(this.onRoomRollingEvent.bind(this)));
this._connection.addMessageEvent(new ObjectsDataUpdateEvent(this.onObjectsDataUpdateEvent.bind(this)));
this._connection.addMessageEvent(new FurnitureAliasesEvent(this.onFurnitureAliasesEvent.bind(this)));
this._connection.addMessageEvent(new FurnitureFloorAddEvent(this.onFurnitureFloorAddEvent.bind(this)));
this._connection.addMessageEvent(new FurnitureFloorEvent(this.onFurnitureFloorEvent.bind(this)));
@ -459,6 +461,20 @@ export class RoomMessageHandler extends Disposable
}
}
private onObjectsDataUpdateEvent(event: ObjectsDataUpdateEvent): void
{
if(!(event instanceof ObjectsDataUpdateEvent) || !event.connection || !this._roomCreator) return;
const parser = event.getParser();
if(!parser) return;
for(const object of parser.objects)
{
this._roomCreator.updateRoomObjectFloor(this._currentRoomId, object.id, null, null, object.state, object.data);
}
}
private onFurnitureAliasesEvent(event: FurnitureAliasesEvent): void
{
if(!(event instanceof FurnitureAliasesEvent) || !event.connection || !this._roomCreator) return;

View File

@ -338,6 +338,9 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
case RoomObjectMouseEvent.MOUSE_DOWN:
this.handleRoomObjectMouseDownEvent(event, roomId);
return;
case RoomObjectMouseEvent.MOUSE_DOWN_LONG:
this.handleRoomObjectMouseDownLongEvent(event, roomId);
return;
case RoomObjectMouseEvent.MOUSE_ENTER:
this.handleRoomObjectMouseEnterEvent(event, roomId);
return;
@ -605,6 +608,32 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
}
}
private handleRoomObjectMouseDownLongEvent(event: RoomObjectMouseEvent, roomId: number): void
{
if(!event) return;
let operation = RoomObjectOperationType.OBJECT_UNDEFINED;
const selectedData = this.getSelectedRoomObjectData(roomId);
if(selectedData) operation = selectedData.operation;
const category = this._roomEngine.getRoomObjectCategoryForType(event.objectType);
switch(operation)
{
case RoomObjectOperationType.OBJECT_UNDEFINED:
if((category === RoomObjectCategory.FLOOR) || (category === RoomObjectCategory.WALL) || (event.objectType === RoomObjectUserType.MONSTER_PLANT))
{
if((!event.ctrlKey && !event.shiftKey) || this._Str_25211(event))
{
if(this._roomEngine.events) this._roomEngine.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.REQUEST_MANIPULATION, roomId, event.objectId, category));
}
}
return;
}
}
private handleRoomObjectMouseEnterEvent(event: RoomObjectMouseEvent, roomId: number): void
{
const id = event.objectId;

View File

@ -11,6 +11,7 @@ export class RoomEngineObjectEvent extends RoomEngineEvent
public static CONTENT_UPDATED: string = 'REOE_CONTENT_UPDATED';
public static REQUEST_MOVE: string = 'REOE_REQUEST_MOVE';
public static REQUEST_ROTATE: string = 'REOE_REQUEST_ROTATE';
public static REQUEST_MANIPULATION: string = 'REOE_REQUEST_MANIPULATION';
public static MOUSE_ENTER: string = 'REOE_MOUSE_ENTER';
public static MOUSE_LEAVE: string = 'REOE_MOUSE_LEAVE';

View File

@ -62,7 +62,7 @@ export class FurnitureLogic extends MovingObjectLogic
public getEventTypes(): string[]
{
const types = [ RoomObjectStateChangedEvent.STATE_CHANGE, RoomObjectMouseEvent.CLICK, RoomObjectMouseEvent.MOUSE_DOWN ];
const types = [ RoomObjectStateChangedEvent.STATE_CHANGE, RoomObjectMouseEvent.CLICK, RoomObjectMouseEvent.MOUSE_DOWN, RoomObjectMouseEvent.MOUSE_DOWN_LONG ];
if(this.widget) types.push(RoomObjectWidgetRequestEvent.OPEN_WIDGET, RoomObjectWidgetRequestEvent.CLOSE_WIDGET);
@ -316,6 +316,14 @@ export class FurnitureLogic extends MovingObjectLogic
this.eventDispatcher.dispatchEvent(mouseEvent);
}
return;
case MouseEventType.MOUSE_DOWN_LONG:
if(this.eventDispatcher)
{
const mouseEvent = new RoomObjectMouseEvent(RoomObjectMouseEvent.MOUSE_DOWN_LONG, this.object, event._Str_3463, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown);
this.eventDispatcher.dispatchEvent(mouseEvent);
}
return;
}
}

View File

@ -4,6 +4,7 @@ export class MouseEventType
public static DOUBLE_CLICK: string = 'double_click';
public static MOUSE_MOVE: string = 'mousemove';
public static MOUSE_DOWN: string = 'mousedown';
public static MOUSE_DOWN_LONG: string = 'mousedown_long';
public static MOUSE_UP: string = 'mouseup';
public static ROLL_OVER: string = 'mouseover';
public static ROLL_OUT: string = 'mouseout';

View File

@ -4,4 +4,5 @@ export class TouchEventType
public static TOUCH_MOVE: string = 'touchmove';
public static TOUCH_CANCEL: string = 'touchcancel';
public static TOUCH_END: string = 'touchend';
public static TOUCH_LONG: string = 'touchlong';
}

View File

@ -7,6 +7,7 @@ export class RoomObjectMouseEvent extends RoomObjectEvent
public static DOUBLE_CLICK: string = 'ROE_MOUSE_DOUBLE_CLICK';
public static MOUSE_MOVE: string = 'ROE_MOUSE_MOVE';
public static MOUSE_DOWN: string = 'ROE_MOUSE_DOWN';
public static MOUSE_DOWN_LONG: string = 'ROE_MOUSE_DOWN_LONG';
public static MOUSE_UP: string = 'ROE_MOUSE_UP';
public static MOUSE_ENTER: string = 'ROE_MOUSE_ENTER';
public static MOUSE_LEAVE: string = 'ROE_MOUSE_LEAVE';

View File

@ -26,7 +26,10 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
private _container: IRoomSpriteCanvasContainer;
private _geometry: RoomGeometry;
private _animationFPS: number;
private _renderTimestamp: number;
private _totalTimeRunning: number;
private _lastFrame: number;
private _master: Sprite;
private _display: Container;
@ -71,7 +74,10 @@ 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._renderTimestamp = 0;
this._totalTimeRunning = 0;
this._lastFrame = 0;
this._master = null;
this._display = null;
@ -321,12 +327,14 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
{
this._canvasUpdated = false;
this._totalTimeRunning += Nitro.instance.ticker.deltaTime;
if(this._totalTimeRunning === this._renderTimestamp) return;
if(time === -1) time = (this._renderTimestamp + 1);
if(!this._container || !this._geometry) return;
if(time === this._renderTimestamp) return;
if((this._width !== this._renderedWidth) || (this._height !== this._renderedHeight)) update = true;
if((this._display.x !== this._screenOffsetX) || (this._display.y !== this._screenOffsetY))
@ -344,6 +352,12 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
update = true;
}
const frame = Math.round(this._totalTimeRunning / (60 / this._animationFPS));
if(frame !== this._lastFrame)
{
this._lastFrame = frame;
let spriteCount = 0;
const objects = this._container.objects;
@ -380,10 +394,11 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
}
this.cleanSprites(spriteCount);
}
if(update) this._canvasUpdated = true;
this._renderTimestamp = time;
this._renderTimestamp = this._totalTimeRunning;
this._renderedWidth = this._width;
this._renderedHeight = this._height;
}