@adatechnology/game-crowd 0.7.1 → 0.7.2
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/index.d.ts +12 -1
- package/dist/index.global.js +45 -5
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -1205,6 +1205,17 @@ type Crowd = {
|
|
|
1205
1205
|
*/
|
|
1206
1206
|
declare function createCrowd(options: CrowdOptions): Crowd;
|
|
1207
1207
|
|
|
1208
|
+
/**
|
|
1209
|
+
* A corpse lies elsewhere than where it died (a blast pushed it): the ledger takes the new place and so does the mound, which is made again from it every fixed step, so
|
|
1210
|
+
* the horde climbs it where the body is drawn and where the engine has it. Call it inside the fixed step (the physics applier's `onSettled`); false when no corpse has that id.
|
|
1211
|
+
*/
|
|
1212
|
+
declare const relocateCorpse: (crowd: Pick<Crowd, "corpses">, move: {
|
|
1213
|
+
readonly id: number;
|
|
1214
|
+
readonly x: number;
|
|
1215
|
+
readonly z: number;
|
|
1216
|
+
readonly yaw: number;
|
|
1217
|
+
}) => boolean;
|
|
1218
|
+
|
|
1208
1219
|
type NavObstacleBindingOptions = {
|
|
1209
1220
|
/** Height (m) from which a box is a solid instead of a low wall (default 1.2). */
|
|
1210
1221
|
readonly lowWallMaxHeight?: number;
|
|
@@ -1788,4 +1799,4 @@ type WorkerPort = {
|
|
|
1788
1799
|
*/
|
|
1789
1800
|
declare function attachPhysicsWorker(port: WorkerPort): void;
|
|
1790
1801
|
|
|
1791
|
-
export { AGENT_FIELDS, BALANCE, CELL, CIVILIAN_DEFAULTS, CROWD_DEFAULTS, CROWD_PHYSICS_DEFAULTS, type Civilian, type CivilianBuilding, type CivilianEventMap, type CivilianEventName, type CivilianNumbers, type CivilianOptions, type CivilianSpec, type CivilianState, type Civilians, type ContactParams, type ContactResult, type ContactView, type Corpse, type Crowd, type CrowdAge, type CrowdBalanceOptions, type CrowdBalanceTraits, type CrowdBand, type CrowdBlast, type CrowdBlastOptions, type CrowdCaliber, type CrowdContactOptions, type CrowdDamageResult, type CrowdDensityOptions, type CrowdEffectId, type CrowdEventMap, type CrowdEventName, type CrowdHit, type CrowdMessageId, type CrowdMoundOptions, type CrowdMovable, type CrowdNumbers, type CrowdOptions, type CrowdOutfit, type CrowdPack, type CrowdPersonalityOptions, type CrowdPhysicsInit, type CrowdPhysicsOptions, type CrowdPlayerPressureOptions, type CrowdPlugin, type CrowdPressureOptions, type CrowdShove, type CrowdSoundId, type CrowdStore, type CrowdTarget, type CrowdThrownOptions, type CrowdTraits, type CrowdType, type CrowdUpdateContext, type CrowdView, DOOR_DEFAULTS, type Door, type DoorEventMap, type DoorEventName, type DoorNumbers, type Doors, FALL_CAUSE, type Flock, type FlockBird, type FlockMode, type FlockOptions, HERD_DEFAULTS, HERD_ROLES, HORDE_COMMAND, HORDE_SIM_ID, type Herd, type HerdAnimal, type HerdAnimalSpec, type HerdEventMap, type HerdEventName, type HerdNumbers, type HerdOptions, type HerdRole, type HordeSimInit, type HordeThreadLike, type InfectionBinding, type InfectionBindingOptions, type InfectionModelLike, MISSING, type MigrationOptions, type MovableContacts, type MovableHit, type NavGrid, type NavGridOptions, type NavObstacleBinding, type NavObstacleBindingOptions, type OffloadTransport, type PhysicsStats, type PhysicsWorkerFactory, type PhysicsWorkerHandle, type PlayerCrowdLike, type Region, type ResolvedPhysics, STATE, type ThrownPool, type WorkerPort, attachPhysicsWorker, bindInfection, bindNavObstacles, carrionCenter, contactStep, createCivilians, createContactView, createCoordinatorRunner, createCrowd, createDoors, createFlock, createHerd, createHordeCrowd, createMovableContacts, createNavGrid, createRng, createStore, crowdPhysicsKind, hordeSimModule, hordeSnapshotBytes, hordeSnapshotLayout, identityOf, mix32, readHordeSnapshot, resolvePhysics, unit, walksInto, writeHordeSnapshot };
|
|
1802
|
+
export { AGENT_FIELDS, BALANCE, CELL, CIVILIAN_DEFAULTS, CROWD_DEFAULTS, CROWD_PHYSICS_DEFAULTS, type Civilian, type CivilianBuilding, type CivilianEventMap, type CivilianEventName, type CivilianNumbers, type CivilianOptions, type CivilianSpec, type CivilianState, type Civilians, type ContactParams, type ContactResult, type ContactView, type Corpse, type Crowd, type CrowdAge, type CrowdBalanceOptions, type CrowdBalanceTraits, type CrowdBand, type CrowdBlast, type CrowdBlastOptions, type CrowdCaliber, type CrowdContactOptions, type CrowdDamageResult, type CrowdDensityOptions, type CrowdEffectId, type CrowdEventMap, type CrowdEventName, type CrowdHit, type CrowdMessageId, type CrowdMoundOptions, type CrowdMovable, type CrowdNumbers, type CrowdOptions, type CrowdOutfit, type CrowdPack, type CrowdPersonalityOptions, type CrowdPhysicsInit, type CrowdPhysicsOptions, type CrowdPlayerPressureOptions, type CrowdPlugin, type CrowdPressureOptions, type CrowdShove, type CrowdSoundId, type CrowdStore, type CrowdTarget, type CrowdThrownOptions, type CrowdTraits, type CrowdType, type CrowdUpdateContext, type CrowdView, DOOR_DEFAULTS, type Door, type DoorEventMap, type DoorEventName, type DoorNumbers, type Doors, FALL_CAUSE, type Flock, type FlockBird, type FlockMode, type FlockOptions, HERD_DEFAULTS, HERD_ROLES, HORDE_COMMAND, HORDE_SIM_ID, type Herd, type HerdAnimal, type HerdAnimalSpec, type HerdEventMap, type HerdEventName, type HerdNumbers, type HerdOptions, type HerdRole, type HordeSimInit, type HordeThreadLike, type InfectionBinding, type InfectionBindingOptions, type InfectionModelLike, MISSING, type MigrationOptions, type MovableContacts, type MovableHit, type NavGrid, type NavGridOptions, type NavObstacleBinding, type NavObstacleBindingOptions, type OffloadTransport, type PhysicsStats, type PhysicsWorkerFactory, type PhysicsWorkerHandle, type PlayerCrowdLike, type Region, type ResolvedPhysics, STATE, type ThrownPool, type WorkerPort, attachPhysicsWorker, bindInfection, bindNavObstacles, carrionCenter, contactStep, createCivilians, createContactView, createCoordinatorRunner, createCrowd, createDoors, createFlock, createHerd, createHordeCrowd, createMovableContacts, createNavGrid, createRng, createStore, crowdPhysicsKind, hordeSimModule, hordeSnapshotBytes, hordeSnapshotLayout, identityOf, mix32, readHordeSnapshot, relocateCorpse, resolvePhysics, unit, walksInto, writeHordeSnapshot };
|
package/dist/index.global.js
CHANGED
|
@@ -59,6 +59,7 @@ var GameCrowd = (() => {
|
|
|
59
59
|
identityOf: () => identityOf,
|
|
60
60
|
mix32: () => mix32,
|
|
61
61
|
readHordeSnapshot: () => readHordeSnapshot,
|
|
62
|
+
relocateCorpse: () => relocateCorpse,
|
|
62
63
|
resolvePhysics: () => resolvePhysics,
|
|
63
64
|
unit: () => unit,
|
|
64
65
|
walksInto: () => walksInto,
|
|
@@ -378,6 +379,14 @@ var GameCrowd = (() => {
|
|
|
378
379
|
};
|
|
379
380
|
var createCorpseLedger = (options) => {
|
|
380
381
|
const entries = [];
|
|
382
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
383
|
+
let nextId = 1;
|
|
384
|
+
const announceAdded = (entry) => {
|
|
385
|
+
for (const listener of listeners) listener.added?.(entry);
|
|
386
|
+
};
|
|
387
|
+
const announceRemoved = (entry, reason) => {
|
|
388
|
+
for (const listener of listeners) listener.removed?.(entry, reason);
|
|
389
|
+
};
|
|
381
390
|
return {
|
|
382
391
|
entries,
|
|
383
392
|
get count() {
|
|
@@ -385,14 +394,19 @@ var GameCrowd = (() => {
|
|
|
385
394
|
},
|
|
386
395
|
add(data) {
|
|
387
396
|
if (entries.length < options.max) {
|
|
388
|
-
|
|
397
|
+
const added2 = { id: nextId++, age: 0, data };
|
|
398
|
+
entries.push(added2);
|
|
399
|
+
announceAdded(added2);
|
|
389
400
|
return void 0;
|
|
390
401
|
}
|
|
391
402
|
let oldest = 0;
|
|
392
403
|
for (let index = 1; index < entries.length; index++) if (entries[index].age > entries[oldest].age) oldest = index;
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
404
|
+
const evicted = entries[oldest];
|
|
405
|
+
const added = { id: nextId++, age: 0, data };
|
|
406
|
+
entries[oldest] = added;
|
|
407
|
+
announceRemoved(evicted, "replaced");
|
|
408
|
+
announceAdded(added);
|
|
409
|
+
return evicted.data;
|
|
396
410
|
},
|
|
397
411
|
update(dt) {
|
|
398
412
|
const removed = [];
|
|
@@ -403,6 +417,7 @@ var GameCrowd = (() => {
|
|
|
403
417
|
removed.push(entry.data);
|
|
404
418
|
entries[index] = entries[entries.length - 1];
|
|
405
419
|
entries.pop();
|
|
420
|
+
announceRemoved(entry, "expired");
|
|
406
421
|
index--;
|
|
407
422
|
}
|
|
408
423
|
return removed;
|
|
@@ -412,10 +427,22 @@ var GameCrowd = (() => {
|
|
|
412
427
|
if (!entry) return void 0;
|
|
413
428
|
entries[index] = entries[entries.length - 1];
|
|
414
429
|
entries.pop();
|
|
430
|
+
announceRemoved(entry, "taken");
|
|
415
431
|
return entry.data;
|
|
416
432
|
},
|
|
417
433
|
clear() {
|
|
418
|
-
|
|
434
|
+
const gone = entries.splice(0);
|
|
435
|
+
for (const entry of gone) announceRemoved(entry, "cleared");
|
|
436
|
+
},
|
|
437
|
+
replace(id, data) {
|
|
438
|
+
const index = entries.findIndex((entry) => entry.id === id);
|
|
439
|
+
if (index < 0) return false;
|
|
440
|
+
entries[index] = { ...entries[index], data };
|
|
441
|
+
return true;
|
|
442
|
+
},
|
|
443
|
+
subscribe(listener) {
|
|
444
|
+
listeners.add(listener);
|
|
445
|
+
return () => void listeners.delete(listener);
|
|
419
446
|
}
|
|
420
447
|
};
|
|
421
448
|
};
|
|
@@ -908,6 +935,13 @@ var GameCrowd = (() => {
|
|
|
908
935
|
thighLengthRatio: body_default.anthropometry.thighLengthRatio,
|
|
909
936
|
shinLengthRatio: body_default.anthropometry.shinLengthRatio
|
|
910
937
|
};
|
|
938
|
+
var R1_HEAD = ["head", "jaw"];
|
|
939
|
+
var R1_LEGS = SEGMENT_TREE.filter((node) => node.region === "legL" || node.region === "legR").map((node) => node.id);
|
|
940
|
+
var R1_TRUNK = SEGMENT_IDS.filter((id) => !R1_HEAD.includes(id) && !R1_LEGS.includes(id));
|
|
941
|
+
var SEGMENTS_OF = {
|
|
942
|
+
R0: SEGMENT_IDS.map((id) => [id]),
|
|
943
|
+
R1: [R1_TRUNK, R1_HEAD, R1_LEGS]
|
|
944
|
+
};
|
|
911
945
|
var gait_default = {
|
|
912
946
|
cascade: {
|
|
913
947
|
hip: 16,
|
|
@@ -5312,6 +5346,12 @@ var GameCrowd = (() => {
|
|
|
5312
5346
|
return crowd;
|
|
5313
5347
|
}
|
|
5314
5348
|
|
|
5349
|
+
// src/corpse-relocate.ts
|
|
5350
|
+
var relocateCorpse = (crowd, move) => {
|
|
5351
|
+
const entry = crowd.corpses.entries.find((candidate) => candidate.id === move.id);
|
|
5352
|
+
return entry !== void 0 && crowd.corpses.replace(move.id, { ...entry.data, x: move.x, z: move.z, yaw: move.yaw });
|
|
5353
|
+
};
|
|
5354
|
+
|
|
5315
5355
|
// src/obstacles.ts
|
|
5316
5356
|
var LOW_WALL_MAX_HEIGHT = 1.2;
|
|
5317
5357
|
var rangeOf = (grid, rect) => [
|