Miese Corona Zeiten push für Lenhardt

This commit is contained in:
Siga
2020-05-10 19:19:53 +02:00
parent 15e4cec8ee
commit efbff34c21
159 changed files with 8042 additions and 8695 deletions

View File

@@ -1,4 +1,4 @@
import { IEntity, IPlayer, IPlayerPool, IVehicle, IVehiclePool, VehicleSeat, EntityType } from "../../game";
import { IEntity, IPlayer, IEntityAttachments, IEntityAttachmentPool, IPlayerPool, IVehicle, IVehiclePool, VehicleSeat, EntityType } from "../../game";
import { parseJson } from "../../util";
class RageEntity implements IEntity {
@@ -8,6 +8,10 @@ class RageEntity implements IEntity {
return this.entity.id;
}
get remoteId(): any {
return this.entity.remoteId;
}
constructor(entity: EntityMp) {
this.entity = entity;
}
@@ -32,6 +36,8 @@ 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;
@@ -52,6 +58,78 @@ class RagePlayer extends RageEntity implements IPlayer {
}
}
class RageAttachments implements IEntityAttachments {
remoteId: any;
public __attachments: any[];
public __attachmentObjects: any[];
constructor(entity: IEntity, attachments: any[], attachmentObjects: any[]) {
this.remoteId = entity.remoteId;
this.__attachments = attachments;
this.__attachmentObjects = attachmentObjects;
}
}
class RageEntityAttachmentPool implements IEntityAttachmentPool {
public attachmentPool: IEntityAttachments[];
remove(entity: IEntity) {
for (let obj of this.attachmentPool.keys()) {
if (entity.remoteId == this.attachmentPool[obj].remoteId) delete this.attachmentPool[obj];
}
}
find(entity: EntityMp): IEntityAttachments {
for (let i of this.attachmentPool.keys()) {
let pool = this.attachmentPool[i];
for (let obj of pool.__attachmentObjects) {
if (entity == obj) { return pool;}
}
}
return null;
}
set(entity: IEntity, attachments: any[], attachmentObjects: any[]): IEntityAttachments {
if (!this.attachmentPool) {
let e = new RageAttachments(entity, attachments, attachmentObjects);
this.attachmentPool = [];
this.attachmentPool.push(e);
return e;
}
for (let obj of this.attachmentPool.keys()) {
if (entity.remoteId == this.attachmentPool[obj].remoteId) { this.remove(entity); }
}
let e = new RageAttachments(entity, attachments, attachmentObjects);
this.attachmentPool.push(e);
return e;
}
at(remoteId: any): IEntityAttachments {
if (!this.attachmentPool) {
return null;
}
for (let obj of this.attachmentPool.keys()) {
if (remoteId == this.attachmentPool[obj].remoteId) { return this.attachmentPool[obj]; }
}
return null;
}
get(entity: IEntity): IEntityAttachments {
if (!this.attachmentPool) {
return null;
}
for (let obj of this.attachmentPool.keys()) {
if (entity.remoteId == this.attachmentPool[obj].remoteId) { return this.attachmentPool[obj]; }
}
return null;
}
}
class RagePlayerPool implements IPlayerPool {
get local(): IPlayer {
return new RagePlayer(mp.players.local);
@@ -103,14 +181,14 @@ class RageVehiclePool implements IVehiclePool {
fn(new RageVehicle(e));
})
}
}
export {
RageEntity,
RagePlayer,
RagePlayerPool,
RageAttachments,
RageEntityAttachmentPool,
RageVehicle,
RageVehiclePool,
}
}

View File

@@ -1,12 +1,12 @@
import { IGame, IUi, IEvents, IPlayerPool, IVehiclePool } from "../../game";
import { IGame, IUi, IEvents, IPlayerPool, IVehiclePool, IEntityAttachmentPool } from "../../game";
import RageEvents from "./events";
import RageUi from "./ui";
import { RagePlayerPool, RageVehiclePool } from "./entities";
import { RagePlayerPool, RageVehiclePool, RageEntityAttachmentPool } from "./entities";
export default class RageGame implements IGame {
players: IPlayerPool = new RagePlayerPool();
vehicles: IVehiclePool = new RageVehiclePool();
attachments: IEntityAttachmentPool = new RageEntityAttachmentPool();
events: IEvents = new RageEvents;
ui: IUi = new RageUi;