diff --git a/packages/server/src/Game/Map.ts b/packages/server/src/Game/Map.ts index 03edc434..2c568257 100644 --- a/packages/server/src/Game/Map.ts +++ b/packages/server/src/Game/Map.ts @@ -1,6 +1,6 @@ import { RpgCommonMap, Utils, RpgShape, RpgCommonGame, AbstractObject } from '@rpgjs/common' import { TiledParserFile, TiledParser, TiledTileset } from '@rpgjs/tiled' -import { EventOptions } from '../decorators/event' +import { EventData, EventOptions } from '../decorators/event' import { RpgPlayer, RpgEvent, RpgClassEvent } from '../Player/Player' import { Move } from '../Player/MoveManager' import { RpgServerEngine } from '../server' @@ -398,13 +398,7 @@ export class RpgMap extends RpgCommonMap { if ('$decorator' in event) { const options = event.$decorator - event.mode = options.mode || EventMode.Shared - event.width = options.width - event.height = options.height - event.hitbox = options.hitbox - event._name = options.name - event.prototype._name = options.name - event.prototype.mode = event.mode + EventData(options)(event) } // The event is ignored if the mode is different. diff --git a/packages/server/src/decorators/event.ts b/packages/server/src/decorators/event.ts index 4e05d554..db35316c 100644 --- a/packages/server/src/decorators/event.ts +++ b/packages/server/src/decorators/event.ts @@ -21,7 +21,7 @@ export interface EventOptions { * @memberof EventData * */ mode?: EventMode, - + width?: number, height?: number, @@ -31,8 +31,8 @@ export interface EventOptions { * @prop { { width: number, height: number }} [hitbox] * @memberof EventData * */ - hitbox?: { - width?: number, + hitbox?: { + width?: number, height?: number }, @@ -47,6 +47,12 @@ export interface EventOptions { export function EventData(options: EventOptions) { return (target) => { - target.$decorator = options + target.mode = options.mode || EventMode.Shared + target.width = options.width + target.height = options.height + target.hitbox = options.hitbox + target._name = options.name + target.prototype._name = options.name + target.prototype.mode = target.mode } } \ No newline at end of file