Pet updates

This commit is contained in:
Bill 2021-12-10 23:55:18 -05:00
parent 858dbdb5ff
commit 116eaa4913
11 changed files with 160 additions and 19 deletions

View File

@ -179,6 +179,7 @@ import { RoomReadyMessageEvent } from './messages/incoming/room/mapping/RoomRead
import { RoomVisualizationSettingsEvent } from './messages/incoming/room/mapping/RoomVisualizationSettingsEvent';
import { PetFigureUpdateEvent } from './messages/incoming/room/pet/PetFigureUpdateEvent';
import { PetInfoEvent } from './messages/incoming/room/pet/PetInfoEvent';
import { PetStatusUpdateEvent } from './messages/incoming/room/pet/PetStatusUpdateEvent';
import { YouArePlayingGameEvent } from './messages/incoming/room/session/YouArePlayingGameEvent';
import { FloodControlEvent } from './messages/incoming/room/unit/chat/FloodControlEvent';
import { RemainingMuteEvent } from './messages/incoming/room/unit/chat/RemainingMuteEvent';
@ -808,6 +809,7 @@ export class NitroMessages implements IMessageConfiguration
this._events.set(IncomingHeader.ROOM_MODEL_BLOCKED_TILES, RoomOccupiedTilesMessageEvent);
this._events.set(IncomingHeader.PET_FIGURE_UPDATE, PetFigureUpdateEvent);
this._events.set(IncomingHeader.PET_INFO, PetInfoEvent);
this._events.set(IncomingHeader.PET_STATUS, PetStatusUpdateEvent);
this._events.set(IncomingHeader.PET_EXPERIENCE, PetExperienceEvent);
this._events.set(IncomingHeader.PLAYING_GAME, YouArePlayingGameEvent);
this._events.set(IncomingHeader.UNIT_DANCE, RoomUnitDanceEvent);

View File

@ -363,4 +363,5 @@ export class IncomingHeader
public static CHAT_REVIEW_SESSION_STARTED = 143;
public static CHAT_REVIEW_SESSION_VOTING_STATUS = 1829;
public static SCR_SEND_KICKBACK_INFO = 3277;
public static PET_STATUS = 1907;
}

View File

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

View File

@ -0,0 +1,67 @@
import { IMessageDataWrapper, IMessageParser } from '../../../../../../core';
export class PetStatusUpdateParser implements IMessageParser
{
private _roomIndex: number;
private _petId: number;
private _canBreed: boolean;
private _canHarvest: boolean;
private _canRevive: boolean;
private _hasBreedingPermission: boolean;
public flush(): boolean
{
this._roomIndex = -1;
this._petId = -1;
this._canBreed = false;
this._canHarvest = false;
this._canRevive = false;
this._hasBreedingPermission = false;
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
this._roomIndex = wrapper.readInt();
this._petId = wrapper.readInt();
this._canBreed = wrapper.readBoolean();
this._canHarvest = wrapper.readBoolean();
this._canRevive = wrapper.readBoolean();
this._hasBreedingPermission = wrapper.readBoolean();
return true;
}
public get roomIndex(): number
{
return this._roomIndex;
}
public get petId(): number
{
return this._petId;
}
public get canBreed(): boolean
{
return this._canBreed;
}
public get canHarvest(): boolean
{
return this._canHarvest;
}
public get canRevive(): boolean
{
return this._canRevive;
}
public get hasBreedingPermission(): boolean
{
return this._hasBreedingPermission;
}
}

View File

@ -1,3 +1,4 @@
export * from './PetExperienceParser';
export * from './PetFigureUpdateParser';
export * from './PetInfoParser';
export * from './PetStatusUpdateParser';

View File

@ -715,6 +715,8 @@ export class RoomMessageHandler extends Disposable
this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, user.roomIndex, RoomObjectVariable.FIGURE_IS_MUTED, (this._roomCreator.sessionDataManager.isUserIgnored(user.name) ? 1 : 0));
}
this.updateGuideMarker();
}
private onRoomUnitExpressionEvent(event: RoomUnitExpressionEvent): void
@ -761,6 +763,8 @@ export class RoomMessageHandler extends Disposable
if(!(event instanceof RoomUnitRemoveEvent) || !event.connection || !this._roomCreator) return;
this._roomCreator.removeRoomObjectUser(this._currentRoomId, event.getParser().unitId);
this.updateGuideMarker();
}
private onRoomUnitStatusEvent(event: RoomUnitStatusEvent): void
@ -840,6 +844,8 @@ export class RoomMessageHandler extends Disposable
if(postureUpdate) this._roomCreator.updateRoomObjectUserPosture(this._currentRoomId, status.id, postureType, parameter);
else if(isPosture) this._roomCreator.updateRoomObjectUserPosture(this._currentRoomId, status.id, RoomObjectVariable.STD, '');
}
this.updateGuideMarker();
}
private onRoomUnitChatEvent(event: RoomUnitChatEvent): void

View File

@ -12,10 +12,6 @@ export class LayerData
public static DEFAULT_YOFFSET: number = 0;
public static DEFAULT_ZOFFSET: number = 0;
public static ADD_INK: number = BLEND_MODES.ADD;
public static SUBTRACT_INK: number = BLEND_MODES.NORMAL;
public static DARKEN_INK: number = BLEND_MODES.NORMAL;
private _tag: string;
private _ink: number;
private _alpha: number;

View File

@ -174,6 +174,34 @@ export class UserDataManager extends Disposable
userData.custom = custom;
}
public updateAchievementScore(roomIndex: number, score: number): void
{
const userData = this.getUserDataByIndex(roomIndex);
if(!userData) return;
userData.activityPoints = score;
}
public updatePetLevel(roomIndex: number, level: number): void
{
const userData = this.getUserDataByIndex(roomIndex);
if(userData) userData.petLevel = level;
}
public updatePetBreedingStatus(roomIndex: number, canBreed: boolean, canHarvest: boolean, canRevive: boolean, hasBreedingPermission: boolean): void
{
const userData = this.getUserDataByIndex(roomIndex);
if(!userData) return;
userData.canBreed = canBreed;
userData.canHarvest = canHarvest;
userData.canRevive = canRevive;
userData.hasBreedingPermission = hasBreedingPermission;
}
public requestPetInfo(id: number): void
{
if(!this._connection) return;

View File

@ -11,15 +11,15 @@ export class RoomSessionPetStatusUpdateEvent extends RoomSessionEvent
private _canRevive: boolean;
private _hasBreedingPermission: boolean;
constructor(k: IRoomSession, _arg_2: number, _arg_3: boolean, _arg_4: boolean, _arg_5: boolean, _arg_6: boolean)
constructor(roomSession: IRoomSession, petId: number, canBreed: boolean, canHarvest: boolean, canRevive: boolean, hasBreedingPermission: boolean)
{
super(RoomSessionPetStatusUpdateEvent.PET_STATUS_UPDATE, k);
super(RoomSessionPetStatusUpdateEvent.PET_STATUS_UPDATE, roomSession);
this._petId = _arg_2;
this._canBreed = _arg_3;
this._canHarvest = _arg_4;
this._canRevive = _arg_5;
this._hasBreedingPermission = _arg_6;
this._petId = petId;
this._canBreed = canBreed;
this._canHarvest = canHarvest;
this._canRevive = canRevive;
this._hasBreedingPermission = hasBreedingPermission;
}
public get petId(): number

View File

@ -11,14 +11,15 @@ export class RoomSessionUserFigureUpdateEvent extends RoomSessionEvent
private _customInfo: string = '';
private _achievementScore: number;
constructor(k: IRoomSession, _arg_2: number, _arg_3: string, _arg_4: string, _arg_5: string, _arg_6: number)
constructor(session: IRoomSession, userId: number, figure: string, gender: string, customInfo: string, achievementScore: number)
{
super(RoomSessionUserFigureUpdateEvent.USER_FIGURE, k);
this._userId = _arg_2;
this._figure = _arg_3;
this._gender = _arg_4;
this._customInfo = _arg_5;
this._achievementScore = _arg_6;
super(RoomSessionUserFigureUpdateEvent.USER_FIGURE, session);
this._userId = userId;
this._figure = figure;
this._gender = gender;
this._customInfo = customInfo;
this._achievementScore = achievementScore;
}
public get userId(): number

View File

@ -5,13 +5,14 @@ import { BotErrorEvent } from '../../communication/messages/incoming/notificatio
import { PetPlacingErrorEvent } from '../../communication/messages/incoming/notifications/PetPlacingErrorEvent';
import { RoomDoorbellEvent } from '../../communication/messages/incoming/room/access/doorbell/RoomDoorbellEvent';
import { PetInfoEvent } from '../../communication/messages/incoming/room/pet/PetInfoEvent';
import { PetStatusUpdateEvent } from '../../communication/messages/incoming/room/pet/PetStatusUpdateEvent';
import { RoomUnitDanceEvent } from '../../communication/messages/incoming/room/unit/RoomUnitDanceEvent';
import { RoomUnitEvent } from '../../communication/messages/incoming/room/unit/RoomUnitEvent';
import { RoomUnitInfoEvent } from '../../communication/messages/incoming/room/unit/RoomUnitInfoEvent';
import { RoomUnitRemoveEvent } from '../../communication/messages/incoming/room/unit/RoomUnitRemoveEvent';
import { UserCurrentBadgesEvent } from '../../communication/messages/incoming/user/data/UserCurrentBadgesEvent';
import { UserNameChangeMessageEvent } from '../../communication/messages/incoming/user/data/UserNameChangeMessageEvent';
import { RoomSessionPetFigureUpdateEvent } from '../events';
import { RoomSessionPetFigureUpdateEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserFigureUpdateEvent } from '../events';
import { RoomSessionDanceEvent } from '../events/RoomSessionDanceEvent';
import { RoomSessionDoorbellEvent } from '../events/RoomSessionDoorbellEvent';
import { RoomSessionErrorMessageEvent } from '../events/RoomSessionErrorMessageEvent';
@ -39,6 +40,7 @@ export class RoomUsersHandler extends BaseHandler
connection.addMessageEvent(new UserNameChangeMessageEvent(this.onUserNameChangeMessageEvent.bind(this)));
connection.addMessageEvent(new NewFriendRequestEvent(this.onNewFriendRequestEvent.bind(this)));
connection.addMessageEvent(new PetInfoEvent(this.onPetInfoEvent.bind(this)));
connection.addMessageEvent(new PetStatusUpdateEvent(this.onPetStatusUpdateEvent.bind(this)));
connection.addMessageEvent(new PetFigureUpdateEvent(this.onPetFigureUpdateEvent.bind(this)));
connection.addMessageEvent(new PetPlacingErrorEvent(this.onPetPlacingError.bind(this)));
connection.addMessageEvent(new BotErrorEvent(this.onBotError.bind(this)));
@ -110,6 +112,10 @@ export class RoomUsersHandler extends BaseHandler
session.userDataManager.updateFigure(parser.unitId, parser.figure, parser.gender, false, false);
session.userDataManager.updateMotto(parser.unitId, parser.motto);
session.userDataManager.updateAchievementScore(parser.unitId, parser.achievementScore);
this.listener.events.dispatchEvent(new RoomSessionUserFigureUpdateEvent(session, parser.unitId, parser.figure, parser.gender, parser.motto, parser.achievementScore));
}
private onRoomUnitRemoveEvent(event: RoomUnitRemoveEvent): void
@ -250,6 +256,23 @@ export class RoomUsersHandler extends BaseHandler
this.listener.events.dispatchEvent(new RoomSessionPetInfoUpdateEvent(session, petData));
}
private onPetStatusUpdateEvent(event: PetStatusUpdateEvent): void
{
if(!this.listener) return;
const parser = event.getParser();
if(!parser) return;
const session = this.listener.getSession(this.roomId);
if(!session) return;
session.userDataManager.updatePetBreedingStatus(parser.roomIndex, parser.canBreed, parser.canHarvest, parser.canRevive, parser.hasBreedingPermission);
this.listener.events.dispatchEvent(new RoomSessionPetStatusUpdateEvent(session, parser.petId, parser.canBreed, parser.canHarvest, parser.canRevive, parser.hasBreedingPermission));
}
private onPetFigureUpdateEvent(event: PetFigureUpdateEvent): void
{
if(!this.listener) return;