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:
parent
95b9fb55c7
commit
afa0451a66
6 changed files with 56 additions and 49 deletions
|
|
@ -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':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue