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:
michael.reiswich
2021-04-03 16:06:44 +02:00
parent 894ae7465f
commit 0543775330
11 changed files with 147 additions and 30 deletions

View File

@@ -23,40 +23,62 @@ export default function attachmentManager(game: IGame) {
return;
}
++attachId;
let entity: IEntity;
if (entityRage.type === "player") {
var player = game.players.at(entityRage.remoteId);
entity = player;
mp.gui.chat.push(`ATTACH: ${attachId} - Player: ${player.name}`);
} else if (entityRage.type === "vehicle") {
var vehicle = game.vehicles.at(entityRage.remoteId);
entity = vehicle;
var realName = mp.game.ui.getLabelText(mp.game.vehicle.getDisplayNameFromVehicleModel(entityRage.model));
mp.gui.chat.push(`ATTACH: ${attachId} - Vehicle: ${vehicle.remoteId}, ${realName}`);
} else if (entityRage.type === "object") {
return;
}
let e = game.attachments.get(entity);
if (this.attachments.hasOwnProperty(id)) {
if (e.__attachmentObjects == undefined) { e.__attachmentObjects = []; }
if (!e.__attachmentObjects) { e.__attachmentObjects = []; }
if (!e.__attachmentObjects.hasOwnProperty(id)) {
let attInfo = this.attachments[id];
let object = mp.objects.new(attInfo.model, entityRage.position);
let rageObject = mp.objects.new(attInfo.model, entityRage.position);
var bone = (typeof (attInfo.boneName) === 'string') ? entityRage.getBoneIndexByName(attInfo.boneName) : entityRage.getBoneIndex(attInfo.boneName)
let attachmentData = {
targetEntity: entity.id,
bone: bone,
offset: attInfo.offset,
rotation: attInfo.rotation
};
game.objects.setData(rageObject, attachmentData); // hier hakt es mein freund
let object = game.objects.at(rageObject.remoteId);
//DEBUG MSG
mp.gui.chat.push(`ATTACH: ${attachId} - bone = ${bone}`)
object.attachTo(entity.id,
bone,
attInfo.offset.x, attInfo.offset.y, attInfo.offset.z,
attInfo.rotation.x, attInfo.rotation.y, attInfo.rotation.z,
false, false, false, false, 2, true);
rageObject.notifyStreaming = true;
mp.gui.chat.push("Notified Stream.");
game.wait(200);
//DEBUG MSG
mp.gui.chat.push(`ATTACH: ${attachId} - Attaching ${JSON.stringify(attInfo)}`);
e.__attachmentObjects[id] = object;
e.__attachmentObjects[id] = rageObject;;
}
}
/* else {
@@ -187,15 +209,46 @@ export default function attachmentManager(game: IGame) {
mp.events.add("entityStreamIn", (entityRage) => {
if (entityRage.type === "player" || entityRage.type === "vehicle") {
let entity;
if (entityRage.type === "player") {
entity = game.players.at(entityRage.remoteId);
} else if (entityRage.type === "vehicle") {
entity = game.vehicles.at(entityRage.remoteId);
}
let e = game.attachments.get(entity);
if (entityRage.tye === "object") { //if is object
game.wait(200);
mp.gui.chat.push("object streamed");
entity = game.objects.at(entityRage.remoteId);
game.wait(200);
mp.gui.chat.push("object try get data");
game.wait(200);
const { targetEntity, bone, offset, rotation } = entity.__attachmentData;
game.wait(200);
+
mp.gui.chat.push(targetEntity + "," + bone + "," + offset + "," + rotation);
game.wait(200);
entity.attachTo(
targetEntity, bone,
offset.x, offset.y, offset.z,
rotation.x, rotation.y, rotation.z,
false, false, false, false, 2, true
);
return;
}
let e = game.attachments.get(entity); //if player or vehicle
if (e != null) {
if (e.__attachments) {
game.wait(5000);
attachmentMngr.initFor(entityRage);
}
}
@@ -282,7 +335,7 @@ export default function attachmentManager(game: IGame) {
e.__attachmentObjects = [];
}
});
/*
game.vehicles.forEach(_veh => {
let vehicle = mp.vehicles.at(_veh.remoteId);
@@ -304,7 +357,9 @@ export default function attachmentManager(game: IGame) {
e.__attachmentObjects = [];
}
});
*/
}
InitAttachmentsOnJoin();
mp.events.add("playerReady", () => { //player finished doenloading assets from server.
InitAttachmentsOnJoin();
});
}