Changes on Attachment Manager.
Removed attachment due to failure in attachment manager. Changed Database to Live Database -> will be changed after Master merge Add to enteties.ts RageObject and RageObjectPool for Attachment Manager
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { IEntity, IPlayer, IEntityAttachments, IEntityAttachmentPool, IPlayerPool, IVehicle, IVehiclePool, VehicleSeat, EntityType } from "../../game";
|
||||
import { IEntity, IPlayer, IEntityAttachments, IEntityAttachmentPool, IPlayerPool, IVehicle, IVehiclePool, VehicleSeat, EntityType, IObjectPool, IObject } from "../../game";
|
||||
import { parseJson } from "../../util";
|
||||
import game from "../..";
|
||||
|
||||
class RageEntity implements IEntity {
|
||||
private entity: EntityMp;
|
||||
public __attachments: any[];
|
||||
public __attachmentObjects: any[];
|
||||
|
||||
get id(): number {
|
||||
if (!this.entity) {
|
||||
@@ -57,8 +59,6 @@ class RageEntity implements IEntity {
|
||||
|
||||
class RagePlayer extends RageEntity implements IPlayer {
|
||||
private player: PlayerMp;
|
||||
public __attachments: any[];
|
||||
public __attachmentObjects: any[];
|
||||
|
||||
get name(): string {
|
||||
return this.player.name;
|
||||
@@ -176,6 +176,20 @@ class RagePlayerPool implements IPlayerPool {
|
||||
}
|
||||
}
|
||||
|
||||
class RageObject extends RageEntity implements IObject {
|
||||
public object: ObjectMp;
|
||||
public __attachmentData: object;
|
||||
|
||||
constructor(object: ObjectMp, attachmentData: object) {
|
||||
if (!object) {
|
||||
throw "Object is undefined"
|
||||
}
|
||||
super(object);
|
||||
this.object = object;
|
||||
this.__attachmentData = attachmentData;
|
||||
}
|
||||
}
|
||||
|
||||
class RageVehicle extends RageEntity implements IVehicle {
|
||||
private vehicle: VehicleMp;
|
||||
|
||||
@@ -212,6 +226,38 @@ class RageVehicle extends RageEntity implements IVehicle {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class RageObjectPool implements IObjectPool {
|
||||
public attachmentDataMap: Map<ObjectMp, object>;
|
||||
|
||||
|
||||
setData(entity: ObjectMp, attachmentData: object): void {
|
||||
if (!this.attachmentDataMap)
|
||||
this.attachmentDataMap = new Map<ObjectMp, object>();
|
||||
|
||||
this.attachmentDataMap.set(entity, attachmentData);
|
||||
}
|
||||
|
||||
at(id: number): IObject {
|
||||
var object = mp.objects.atRemoteId(Number(id));
|
||||
|
||||
if (!object)
|
||||
return null;
|
||||
|
||||
return new RageObject(object, this.attachmentDataMap.get(object));
|
||||
}
|
||||
|
||||
forEach(fn: (entity: IObject) => void): void {
|
||||
mp.objects.forEach(e => {
|
||||
if (!e) {
|
||||
game.ui.sendChatMessage("forEach - e is null");
|
||||
return;
|
||||
}
|
||||
fn(new RageObject(e, this.attachmentDataMap.get(e)));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
class RageVehiclePool implements IVehiclePool {
|
||||
at(id: number): IVehicle {
|
||||
var veh = mp.vehicles.atRemoteId(Number(id));
|
||||
@@ -242,4 +288,6 @@ export {
|
||||
RageEntityAttachmentPool,
|
||||
RageVehicle,
|
||||
RageVehiclePool,
|
||||
RageObject,
|
||||
RageObjectPool,
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
import { IGame, IUi, IEvents, IPlayerPool, IVehiclePool, IEntityAttachmentPool } from "../../game";
|
||||
import { IGame, IUi, IEvents, IPlayerPool, IVehiclePool, IEntityAttachmentPool, IObjectPool } from "../../game";
|
||||
import RageEvents from "./events";
|
||||
import RageUi from "./ui";
|
||||
import { RagePlayerPool, RageVehiclePool, RageEntityAttachmentPool } from "./entities";
|
||||
import { RagePlayerPool, RageVehiclePool, RageEntityAttachmentPool, RageObjectPool } from "./entities";
|
||||
|
||||
export default class RageGame implements IGame {
|
||||
players: IPlayerPool = new RagePlayerPool();
|
||||
vehicles: IVehiclePool = new RageVehiclePool();
|
||||
attachments: IEntityAttachmentPool = new RageEntityAttachmentPool();
|
||||
objects: IObjectPool = new RageObjectPool();
|
||||
events: IEvents = new RageEvents;
|
||||
ui: IUi = new RageUi;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user