@quake2ts/game 0.0.869 → 0.0.873

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import { AmmoItemId, AmmoType, ZERO_VEC3, createRandomGenerator, WeaponId, PowerupId, normalizeVec3, subtractVec3, vectorToAngles, angleVectors, vectorToYaw, scaleVec3, addVec3, lengthVec3, copyVec3 as copyVec3$1, SoundChannel, ATTN_NORM as ATTN_NORM$1, MASK_SHOT, distanceBetweenBoxesSquared, dotVec3, ServerCommand, TempEntity, MASK_SOLID, angleMod, CONTENTS_MONSTER, CONTENTS_PLAYER, CONTENTS_DEADMONSTER, RenderFx, degToRad, MASK_MONSTERSOLID, closestPointToBox, CONTENTS_SLIME, CONTENTS_LAVA, MASK_WATER, CONTENTS_SOLID, CONTENTS_WATER, AMMO_TYPE_COUNT, WaterLevel, boxesIntersect, RandomGenerator, BinaryWriter, writePlayerState, writeDeltaEntity, PmType, clipVelocityVec3, rotatePointAroundVector, MZ_GRENADE, ATTN_IDLE, ConfigStringIndex, CvarFlags, applyPmove, MASK_CURRENT, CONTENTS_CURRENT_0, CONTENTS_CURRENT_90, CONTENTS_CURRENT_180, CONTENTS_CURRENT_270, CONTENTS_CURRENT_UP, CONTENTS_CURRENT_DOWN, distance, PlayerStat, WEAPON_WHEEL_ORDER, AMMO_MAX, G_SetAmmoStat, G_SetPowerupStat, MZ_SHOTGUN, MZ_SSHOTGUN, MZ_MACHINEGUN, MZ_ROCKET, MZ_HYPERBLASTER, MZ_RAILGUN, MZ_BFG, MZ_BLASTER, MASK_PROJECTILE, MZ_CHAINGUN1 } from '@quake2ts/shared';
2
2
  export { AMMO_TYPE_COUNT, AmmoItemId, AmmoType, PowerupId, WeaponId } from '@quake2ts/shared';
3
3
 
4
- // src/entities/entity.ts
4
+ var __defProp = Object.defineProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
7
  var AMMO_ITEM_DEFINITIONS = {
6
8
  [AmmoItemId.Shells]: { id: AmmoItemId.Shells, ammoType: AmmoType.Shells, quantity: 10, weaponAmmo: false },
7
9
  [AmmoItemId.Bullets]: { id: AmmoItemId.Bullets, ammoType: AmmoType.Bullets, quantity: 50, weaponAmmo: false },
@@ -892,97 +894,119 @@ var DEFAULT_MONSTER_INFO = Object.freeze({
892
894
  });
893
895
  var Entity = class {
894
896
  constructor(index) {
895
- this.linkcount = 0;
896
- this.inUse = false;
897
- this.freePending = false;
898
- this.linkPrevious = null;
899
- this.linkNext = null;
900
- this.classname = "";
901
- this.spawnflags = 0;
902
- this.inventory = {};
903
- this.origin = copyVec3();
904
- this.old_origin = copyVec3();
905
- this.velocity = copyVec3();
906
- this.avelocity = copyVec3();
907
- this.angles = copyVec3();
908
- this.pos1 = copyVec3();
909
- this.pos2 = copyVec3();
910
- this.gravityVector = copyVec3();
911
- this.viewheight = 0;
912
- this.mins = copyVec3();
913
- this.maxs = copyVec3();
914
- this.absmin = copyVec3();
915
- this.absmax = copyVec3();
916
- this.size = copyVec3();
917
- this.mass = 0;
918
- this.gravity = 1;
919
- this.bounce = 1;
920
- this.movetype = 0 /* None */;
921
- this.movedir = copyVec3();
922
- this.modelindex = 0;
923
- this.frame = 0;
924
- this.skin = 0;
925
- this.effects = 0;
926
- this.renderfx = 0;
927
- this.health = 0;
928
- this.max_health = 0;
929
- this.spawn_count = 0;
930
- this.takedamage = false;
931
- this.dmg = 0;
932
- this.radius_dmg = 0;
933
- this.dmg_radius = 0;
934
- this.speed = 0;
935
- this.accel = 0;
936
- this.decel = 0;
937
- this.height = 0;
938
- this.deadflag = 0 /* Alive */;
939
- this.count = 0;
940
- this.wait = 0;
941
- this.delay = 0;
942
- this.random = 0;
943
- this.timestamp = 0;
944
- this.lip = 0;
945
- this.state = 0;
946
- this.style = 0;
947
- this.sounds = 0;
948
- this.noise_index = 0;
949
- this.attenuation = 0;
950
- this.volume = 0;
951
- this.fly_sound_debounce_time = 0;
952
- this.last_move_time = 0;
953
- this.damage_debounce_time = 0;
954
- this.enemy = null;
955
- this.movetarget = null;
956
- this.target_ent = null;
957
- this.goalentity = null;
958
- this.ideal_yaw = 0;
959
- this.yaw_speed = 0;
960
- this.search_time = 0;
961
- this.attack_finished_time = 0;
962
- this.pain_finished_time = 0;
963
- this.pain_debounce_time = 0;
964
- this.trail_time = 0;
965
- this.groundentity = null;
966
- this.groundentity_linkcount = 0;
967
- this.waterlevel = 0;
968
- this.watertype = 0;
969
- this.nextthink = 0;
970
- this.activator = null;
971
- this.alpha = 0;
972
- this.solid = 0 /* Not */;
973
- this.clipmask = 0;
974
- this.flags = 0;
975
- this.svflags = 0;
976
- this.monsterinfo = { ...DEFAULT_MONSTER_INFO, last_sighting: copyVec3() };
977
- this.hackflags = 0;
978
- this.plat2flags = 0;
979
- this.fov = 0;
980
- this.show_hostile = 0;
981
- this.light_level = 0;
982
- this.owner = null;
983
- this.beam = null;
984
- this.beam2 = null;
985
- this.chain = null;
897
+ __publicField(this, "index");
898
+ __publicField(this, "linkcount", 0);
899
+ __publicField(this, "inUse", false);
900
+ __publicField(this, "freePending", false);
901
+ __publicField(this, "linkPrevious", null);
902
+ __publicField(this, "linkNext", null);
903
+ __publicField(this, "classname", "");
904
+ __publicField(this, "spawnflags", 0);
905
+ __publicField(this, "target");
906
+ __publicField(this, "targetname");
907
+ __publicField(this, "killtarget");
908
+ __publicField(this, "team");
909
+ __publicField(this, "message");
910
+ __publicField(this, "pathtarget");
911
+ __publicField(this, "model");
912
+ __publicField(this, "item");
913
+ __publicField(this, "map");
914
+ __publicField(this, "inventory", {});
915
+ __publicField(this, "origin", copyVec3());
916
+ __publicField(this, "old_origin", copyVec3());
917
+ __publicField(this, "velocity", copyVec3());
918
+ __publicField(this, "avelocity", copyVec3());
919
+ __publicField(this, "angles", copyVec3());
920
+ __publicField(this, "pos1", copyVec3());
921
+ __publicField(this, "pos2", copyVec3());
922
+ __publicField(this, "gravityVector", copyVec3());
923
+ __publicField(this, "viewheight", 0);
924
+ __publicField(this, "mins", copyVec3());
925
+ __publicField(this, "maxs", copyVec3());
926
+ __publicField(this, "absmin", copyVec3());
927
+ __publicField(this, "absmax", copyVec3());
928
+ __publicField(this, "size", copyVec3());
929
+ __publicField(this, "mass", 0);
930
+ __publicField(this, "gravity", 1);
931
+ __publicField(this, "bounce", 1);
932
+ __publicField(this, "movetype", 0 /* None */);
933
+ __publicField(this, "movedir", copyVec3());
934
+ __publicField(this, "modelindex", 0);
935
+ __publicField(this, "frame", 0);
936
+ __publicField(this, "skin", 0);
937
+ __publicField(this, "effects", 0);
938
+ __publicField(this, "renderfx", 0);
939
+ __publicField(this, "health", 0);
940
+ __publicField(this, "max_health", 0);
941
+ __publicField(this, "spawn_count", 0);
942
+ __publicField(this, "takedamage", false);
943
+ __publicField(this, "dmg", 0);
944
+ __publicField(this, "radius_dmg", 0);
945
+ __publicField(this, "dmg_radius", 0);
946
+ __publicField(this, "speed", 0);
947
+ __publicField(this, "accel", 0);
948
+ __publicField(this, "decel", 0);
949
+ __publicField(this, "height", 0);
950
+ __publicField(this, "deadflag", 0 /* Alive */);
951
+ __publicField(this, "count", 0);
952
+ __publicField(this, "wait", 0);
953
+ __publicField(this, "delay", 0);
954
+ __publicField(this, "random", 0);
955
+ __publicField(this, "timestamp", 0);
956
+ __publicField(this, "lip", 0);
957
+ __publicField(this, "state", 0);
958
+ __publicField(this, "style", 0);
959
+ __publicField(this, "sounds", 0);
960
+ __publicField(this, "noise_index", 0);
961
+ __publicField(this, "attenuation", 0);
962
+ __publicField(this, "volume", 0);
963
+ __publicField(this, "fly_sound_debounce_time", 0);
964
+ __publicField(this, "last_move_time", 0);
965
+ __publicField(this, "damage_debounce_time", 0);
966
+ __publicField(this, "enemy", null);
967
+ __publicField(this, "movetarget", null);
968
+ __publicField(this, "target_ent", null);
969
+ __publicField(this, "goalentity", null);
970
+ __publicField(this, "ideal_yaw", 0);
971
+ __publicField(this, "yaw_speed", 0);
972
+ __publicField(this, "search_time", 0);
973
+ __publicField(this, "attack_finished_time", 0);
974
+ __publicField(this, "pain_finished_time", 0);
975
+ __publicField(this, "pain_debounce_time", 0);
976
+ __publicField(this, "trail_time", 0);
977
+ __publicField(this, "groundentity", null);
978
+ __publicField(this, "groundentity_linkcount", 0);
979
+ __publicField(this, "waterlevel", 0);
980
+ __publicField(this, "watertype", 0);
981
+ __publicField(this, "nextthink", 0);
982
+ __publicField(this, "think");
983
+ __publicField(this, "touch");
984
+ __publicField(this, "use");
985
+ __publicField(this, "blocked");
986
+ __publicField(this, "pain");
987
+ __publicField(this, "die");
988
+ __publicField(this, "postthink");
989
+ __publicField(this, "activator", null);
990
+ __publicField(this, "alpha", 0);
991
+ __publicField(this, "solid", 0 /* Not */);
992
+ __publicField(this, "clipmask", 0);
993
+ __publicField(this, "flags", 0);
994
+ __publicField(this, "svflags", 0);
995
+ __publicField(this, "monsterinfo", { ...DEFAULT_MONSTER_INFO, last_sighting: copyVec3() });
996
+ __publicField(this, "moveinfo");
997
+ __publicField(this, "hackflags", 0);
998
+ __publicField(this, "plat2flags", 0);
999
+ __publicField(this, "fov", 0);
1000
+ __publicField(this, "combattarget");
1001
+ __publicField(this, "show_hostile", 0);
1002
+ __publicField(this, "light_level", 0);
1003
+ __publicField(this, "owner", null);
1004
+ __publicField(this, "beam", null);
1005
+ __publicField(this, "beam2", null);
1006
+ __publicField(this, "chain", null);
1007
+ __publicField(this, "client");
1008
+ __publicField(this, "_regularArmor");
1009
+ __publicField(this, "_powerArmor");
986
1010
  this.index = index;
987
1011
  }
988
1012
  get regularArmor() {
@@ -2984,9 +3008,10 @@ var MAX_EDICTS = 2048;
2984
3008
  var WORLD_INDEX = 0;
2985
3009
  var EntityPool = class {
2986
3010
  constructor(maxEntities = MAX_EDICTS) {
2987
- this.freeList = [];
2988
- this.pendingFree = [];
2989
- this.activeHead = null;
3011
+ __publicField(this, "entities");
3012
+ __publicField(this, "freeList", []);
3013
+ __publicField(this, "pendingFree", []);
3014
+ __publicField(this, "activeHead", null);
2990
3015
  if (maxEntities < 1 || !Number.isInteger(maxEntities)) {
2991
3016
  throw new Error("EntityPool requires a positive integer size");
2992
3017
  }
@@ -3165,7 +3190,7 @@ var EntityPool = class {
3165
3190
  // src/entities/thinkScheduler.ts
3166
3191
  var ThinkScheduler = class {
3167
3192
  constructor() {
3168
- this.queue = [];
3193
+ __publicField(this, "queue", []);
3169
3194
  }
3170
3195
  schedule(entity, timeSeconds) {
3171
3196
  entity.nextthink = timeSeconds;
@@ -3225,8 +3250,8 @@ function getCellKey(x, y, z) {
3225
3250
  var SpatialGrid = class {
3226
3251
  constructor(cellSize = CELL_SIZE) {
3227
3252
  this.cellSize = cellSize;
3228
- this.cells = /* @__PURE__ */ new Map();
3229
- this.entityCells = /* @__PURE__ */ new Map();
3253
+ __publicField(this, "cells", /* @__PURE__ */ new Map());
3254
+ __publicField(this, "entityCells", /* @__PURE__ */ new Map());
3230
3255
  }
3231
3256
  getCellRange(min, max) {
3232
3257
  return [Math.floor(min / this.cellSize), Math.floor(max / this.cellSize)];
@@ -3353,14 +3378,28 @@ function deserializeInventory(value) {
3353
3378
  var EntitySystem = class {
3354
3379
  constructor(engine, imports, gravity, maxEntities, callbackRegistry, deathmatch, skill, random5, coop, friendlyFire = false) {
3355
3380
  this.friendlyFire = friendlyFire;
3356
- this.targetNameIndex = /* @__PURE__ */ new Map();
3357
- this.currentTimeSeconds = 0;
3358
- this.currentDeltaSeconds = 0;
3359
- this.frameNumber = 0;
3360
- this.spawnCount = 0;
3381
+ __publicField(this, "pool");
3382
+ __publicField(this, "thinkScheduler");
3383
+ __publicField(this, "targetNameIndex", /* @__PURE__ */ new Map());
3384
+ __publicField(this, "random");
3385
+ __publicField(this, "callbackToName");
3386
+ __publicField(this, "spawnRegistry");
3387
+ __publicField(this, "currentTimeSeconds", 0);
3388
+ __publicField(this, "currentDeltaSeconds", 0);
3389
+ __publicField(this, "frameNumber", 0);
3390
+ __publicField(this, "spawnCount", 0);
3391
+ __publicField(this, "spatialGrid");
3392
+ __publicField(this, "targetAwareness");
3361
3393
  // Persistent state for cross-level logic
3362
- this.crossLevelFlags = 0;
3363
- this.crossUnitFlags = 0;
3394
+ __publicField(this, "crossLevelFlags", 0);
3395
+ __publicField(this, "crossUnitFlags", 0);
3396
+ __publicField(this, "level");
3397
+ __publicField(this, "engine");
3398
+ __publicField(this, "imports");
3399
+ __publicField(this, "gravity");
3400
+ __publicField(this, "deathmatch");
3401
+ __publicField(this, "skill");
3402
+ __publicField(this, "coop");
3364
3403
  this.pool = new EntityPool(maxEntities);
3365
3404
  this.thinkScheduler = new ThinkScheduler();
3366
3405
  this.engine = engine;
@@ -23107,7 +23146,7 @@ function parseEntityLump(text) {
23107
23146
  }
23108
23147
  var SpawnRegistry = class {
23109
23148
  constructor() {
23110
- this.registry = /* @__PURE__ */ new Map();
23149
+ __publicField(this, "registry", /* @__PURE__ */ new Map());
23111
23150
  }
23112
23151
  register(classname, spawn) {
23113
23152
  this.registry.set(classname, spawn);
@@ -23263,23 +23302,23 @@ var orderedStageNames = [
23263
23302
  ];
23264
23303
  var GameFrameLoop = class {
23265
23304
  constructor(initialStages) {
23266
- this.timeMs = 0;
23267
- this.frame = 0;
23268
- this.stageHandlers = {
23305
+ __publicField(this, "timeMs", 0);
23306
+ __publicField(this, "frame", 0);
23307
+ __publicField(this, "stageHandlers", {
23269
23308
  prep: [],
23270
23309
  simulate: [],
23271
23310
  finish: []
23272
- };
23273
- this.stageCounts = {
23311
+ });
23312
+ __publicField(this, "stageCounts", {
23274
23313
  prep: 0,
23275
23314
  simulate: 0,
23276
23315
  finish: 0
23277
- };
23278
- this.stageCompactionNeeded = {
23316
+ });
23317
+ __publicField(this, "stageCompactionNeeded", {
23279
23318
  prep: false,
23280
23319
  simulate: false,
23281
23320
  finish: false
23282
- };
23321
+ });
23283
23322
  if (initialStages) {
23284
23323
  for (const stageName of orderedStageNames) {
23285
23324
  const handler = initialStages[stageName];
@@ -23367,7 +23406,7 @@ var ZERO_STATE = {
23367
23406
  };
23368
23407
  var LevelClock = class {
23369
23408
  constructor() {
23370
- this.state = ZERO_STATE;
23409
+ __publicField(this, "state", ZERO_STATE);
23371
23410
  }
23372
23411
  start(startTimeMs) {
23373
23412
  const startSeconds = startTimeMs / 1e3;
@@ -24162,7 +24201,7 @@ function estimateSizeBytes(save) {
24162
24201
  }
24163
24202
  var MemorySaveAdapter = class {
24164
24203
  constructor() {
24165
- this.records = /* @__PURE__ */ new Map();
24204
+ __publicField(this, "records", /* @__PURE__ */ new Map());
24166
24205
  }
24167
24206
  async init() {
24168
24207
  return Promise.resolve();
@@ -24202,7 +24241,7 @@ var IndexedDbSaveAdapter = class {
24202
24241
  this.indexedDB = indexedDB;
24203
24242
  this.dbName = dbName;
24204
24243
  this.storeName = storeName;
24205
- this.db = null;
24244
+ __publicField(this, "db", null);
24206
24245
  }
24207
24246
  async init() {
24208
24247
  if (this.db) {
@@ -24261,6 +24300,7 @@ var IndexedDbSaveAdapter = class {
24261
24300
  };
24262
24301
  var _SaveStorage = class _SaveStorage {
24263
24302
  constructor(options = {}) {
24303
+ __publicField(this, "adapter");
24264
24304
  const { dbName = _SaveStorage.DEFAULT_DB_NAME, storeName = _SaveStorage.DEFAULT_STORE } = options;
24265
24305
  const indexedDBFactory = options.indexedDB ?? globalThis.indexedDB;
24266
24306
  if (indexedDBFactory) {
@@ -24309,9 +24349,9 @@ var _SaveStorage = class _SaveStorage {
24309
24349
  return this.load(_SaveStorage.QUICK_SLOT, options);
24310
24350
  }
24311
24351
  };
24312
- _SaveStorage.DEFAULT_DB_NAME = "quake2ts-saves";
24313
- _SaveStorage.DEFAULT_STORE = "saves";
24314
- _SaveStorage.QUICK_SLOT = "quicksave";
24352
+ __publicField(_SaveStorage, "DEFAULT_DB_NAME", "quake2ts-saves");
24353
+ __publicField(_SaveStorage, "DEFAULT_STORE", "saves");
24354
+ __publicField(_SaveStorage, "QUICK_SLOT", "quicksave");
24315
24355
  var SaveStorage = _SaveStorage;
24316
24356
 
24317
24357
  // src/entities/templates.ts
@@ -25021,7 +25061,7 @@ function populatePlayerStats(player, timeSeconds) {
25021
25061
  // src/scripting/hooks.ts
25022
25062
  var ScriptHookRegistry = class {
25023
25063
  constructor() {
25024
- this.hooks = [];
25064
+ __publicField(this, "hooks", []);
25025
25065
  }
25026
25066
  /**
25027
25067
  * Register a new set of hooks.