@adatechnology/game-weapons-three 0.4.1 → 0.5.0
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 +23 -2
- package/dist/index.global.js +50 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -6528,7 +6528,7 @@ var explosivePart = (def, shape) => ({
|
|
|
6528
6528
|
shape: shape.shape,
|
|
6529
6529
|
position: shape.position,
|
|
6530
6530
|
...SHELL,
|
|
6531
|
-
explodes: { energy: def.energy, radius: def.injuryRadius, ...def.chain ? { chain: { ...def.chain } } : {} }
|
|
6531
|
+
explodes: { energy: def.energy, radius: def.injuryRadius, effect: def.id, ...def.chain ? { chain: { ...def.chain } } : {} }
|
|
6532
6532
|
});
|
|
6533
6533
|
var meshOf = (THREE, shape) => {
|
|
6534
6534
|
const geometry = shape.shape.kind === "cylinder" ? new THREE.CylinderGeometry(shape.shape.radius, shape.shape.radius, shape.shape.height, 16) : shape.shape.kind === "box" ? new THREE.BoxGeometry(...shape.shape.size) : new THREE.SphereGeometry(0.2);
|
|
@@ -6556,6 +6556,51 @@ var worldExplosiveItem = (def, name) => {
|
|
|
6556
6556
|
};
|
|
6557
6557
|
};
|
|
6558
6558
|
|
|
6559
|
+
// src/data/world-effects.json
|
|
6560
|
+
var world_effects_default = {
|
|
6561
|
+
pistol: { muzzle: "muzzle_glock", casing: "casing_brass" },
|
|
6562
|
+
tiny: { muzzle: "muzzle_glock", casing: "casing_brass" },
|
|
6563
|
+
rifle: { muzzle: "muzzle_ak", casing: "casing_brass" },
|
|
6564
|
+
shell: { muzzle: "muzzle_r870", casing: "casing_shell" },
|
|
6565
|
+
big: { muzzle: "muzzle_barrett", casing: "casing_50" }
|
|
6566
|
+
};
|
|
6567
|
+
|
|
6568
|
+
// src/world-effects.ts
|
|
6569
|
+
var WORLD_EFFECTS = world_effects_default;
|
|
6570
|
+
var PORT_BACK = 0.35;
|
|
6571
|
+
var PORT_RIGHT = 0.04;
|
|
6572
|
+
function createWorldEffects(options) {
|
|
6573
|
+
const ids = options.ids ?? WORLD_EFFECTS;
|
|
6574
|
+
const caseTypeOf = options.caseTypeOf ?? ((weapon) => {
|
|
6575
|
+
const def = options.arsenal.weapons.get(weapon);
|
|
6576
|
+
return def && def.action.kind === "firearm" ? options.arsenal.calibers.get(def.action.caliber)?.caseType : void 0;
|
|
6577
|
+
});
|
|
6578
|
+
let counter = 0;
|
|
6579
|
+
return {
|
|
6580
|
+
/** Plays what the event asks for and answers how many effects started. */
|
|
6581
|
+
handle(event, sink) {
|
|
6582
|
+
if (!sink || event.type !== "shot" || !event.origin) return 0;
|
|
6583
|
+
const caseType = caseTypeOf(event.weapon) ?? "rifle";
|
|
6584
|
+
const entry = ids[caseType];
|
|
6585
|
+
if (!entry) return 0;
|
|
6586
|
+
const direction = event.direction ?? [0, 0, -1];
|
|
6587
|
+
const seed = ++counter;
|
|
6588
|
+
let started = 0;
|
|
6589
|
+
for (let shot = 0; shot < Math.max(1, event.rounds ?? 1); shot++) {
|
|
6590
|
+
if (sink.play({ effect: entry.muzzle, point: event.origin, direction, seed: seed * 8 + shot }) !== null) started++;
|
|
6591
|
+
}
|
|
6592
|
+
const side = [direction[2], 0, -direction[0]];
|
|
6593
|
+
const port = [
|
|
6594
|
+
event.origin[0] - direction[0] * PORT_BACK + side[0] * PORT_RIGHT,
|
|
6595
|
+
event.origin[1] - direction[1] * PORT_BACK,
|
|
6596
|
+
event.origin[2] - direction[2] * PORT_BACK + side[2] * PORT_RIGHT
|
|
6597
|
+
];
|
|
6598
|
+
if (sink.play({ effect: entry.casing, point: port, direction, seed: seed * 8 + 7 }) !== null) started++;
|
|
6599
|
+
return started;
|
|
6600
|
+
}
|
|
6601
|
+
};
|
|
6602
|
+
}
|
|
6603
|
+
|
|
6559
6604
|
// src/area.ts
|
|
6560
6605
|
var WEAPON_ITEM_PREFIX = "weapon_";
|
|
6561
6606
|
var COUNTER_ITEM_ID = "counter_weapons";
|
|
@@ -6832,7 +6877,9 @@ function createWeaponsTestModule(options = {}) {
|
|
|
6832
6877
|
} else if (change.kind === "control" && change.id === "sound_distance" && typeof change.value === "number") soundDistance = change.value;
|
|
6833
6878
|
else if (change.kind === "control" && change.id === "fuse_length" && typeof change.value === "number") lent.configureTool?.({ fuse_length: String(change.value) });
|
|
6834
6879
|
});
|
|
6880
|
+
const worldEffects = createWorldEffects({ arsenal });
|
|
6835
6881
|
const offEvents = lent.on((event) => {
|
|
6882
|
+
worldEffects.handle(event, lent.effects);
|
|
6836
6883
|
if (event.type === "explosion") {
|
|
6837
6884
|
const away = Math.hypot(event.point[0] - camera.position.x, event.point[1] - camera.position.y, event.point[2] - camera.position.z);
|
|
6838
6885
|
audio?.play("explosion", Math.min(1, EXPLOSION_VOLUME_BASE + event.radius * EXPLOSION_VOLUME_PER_METRE), away);
|
|
@@ -6872,6 +6919,7 @@ export {
|
|
|
6872
6919
|
MOUNTED_M134_ITEM_ID,
|
|
6873
6920
|
WEAPON_ITEM_PREFIX,
|
|
6874
6921
|
WEAPON_THUMBNAILS,
|
|
6922
|
+
WORLD_EFFECTS,
|
|
6875
6923
|
WORLD_EXPLOSIVE_IDS,
|
|
6876
6924
|
WORLD_EXPLOSIVE_PREFIX,
|
|
6877
6925
|
applyCondition,
|
|
@@ -6887,6 +6935,7 @@ export {
|
|
|
6887
6935
|
createWeaponAudio,
|
|
6888
6936
|
createWeaponFx,
|
|
6889
6937
|
createWeaponsTestModule,
|
|
6938
|
+
createWorldEffects,
|
|
6890
6939
|
deriveFrames,
|
|
6891
6940
|
fitAttachmentModels,
|
|
6892
6941
|
hasWeaponModel,
|