1
0
Fork 0
mirror of https://github.com/demostf/demo.js synced 2026-06-04 00:54:14 +02:00

per packet entities

This commit is contained in:
Robin Appelman 2017-02-14 22:12:06 +01:00
commit afa0451a66
6 changed files with 56 additions and 49 deletions

View file

@ -1,15 +1,28 @@
import {PacketEntitiesPacket} from "../Data/Packet";
import {Match} from "../Data/Match";
import {PacketEntity} from "../Data/PacketEntity";
import {PacketEntity, PVS} from "../Data/PacketEntity";
import {Vector} from "../Data/Vector";
import {Player} from "../Data/Player";
export function handlePacketEntities(packet: PacketEntitiesPacket, match: Match) {
for (const removedEntityId of packet.removedEntities) {
delete match.entityClasses[removedEntityId];
}
for (const entity of packet.entities) {
saveEntity(entity, match);
handleEntity(entity, match);
}
}
function saveEntity(packetEntity: PacketEntity, match: Match) {
if (packetEntity.pvs === PVS.DELETE) {
delete match.entityClasses[packetEntity.entityIndex];
}
match.entityClasses[packetEntity.entityIndex] = packetEntity.serverClass;
}
function handleEntity(entity: PacketEntity, match: Match) {
switch (entity.serverClass.name) {
case 'CWorld':