@adatechnology/game-contracts 0.24.0 → 0.25.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 +38 -2
- package/dist/index.global.js +21 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/blast-shove.ts
|
|
2
2
|
var DEFAULT_BLAST_SHOVE = { coupling: 0.02, maxSpeed: 20, lift: 0.3, minSpeed: 0.3, falloffPower: 2 };
|
|
3
|
+
var clampShare = (share) => Math.min(1, Math.max(0, share));
|
|
3
4
|
function blastShove(blast, target, options = {}) {
|
|
4
5
|
const o = { ...DEFAULT_BLAST_SHOVE, ...options };
|
|
5
6
|
const dx = target.position[0] - blast.point[0];
|
|
@@ -9,7 +10,8 @@ function blastShove(blast, target, options = {}) {
|
|
|
9
10
|
if (!(blast.radius > 0) || distance > blast.radius) return void 0;
|
|
10
11
|
const falloff = (1 - distance / blast.radius) ** o.falloffPower;
|
|
11
12
|
const mass = Math.max(target.mass, 0.05);
|
|
12
|
-
const
|
|
13
|
+
const reach = clampShare(blast.reach ?? 1);
|
|
14
|
+
const speed = Math.sqrt(reach) * Math.min(o.maxSpeed, Math.sqrt(2 * blast.energy * o.coupling / mass)) * falloff;
|
|
13
15
|
if (!(speed >= o.minSpeed)) return void 0;
|
|
14
16
|
const direction = distance > 1e-4 ? [dx / distance, dy / distance + o.lift, dz / distance] : [0, 1, 0];
|
|
15
17
|
const length = Math.hypot(direction[0], direction[1], direction[2]);
|
|
@@ -115,6 +117,16 @@ function stepKnock(knock, position, dt, groundAt, alive) {
|
|
|
115
117
|
} else if (knock.lying > 0) knock.lying = Math.max(0, knock.lying - dt / RISE_SECONDS);
|
|
116
118
|
return !moving && !knock.down && knock.lying === 0;
|
|
117
119
|
}
|
|
120
|
+
var LAUNCHED = "launched";
|
|
121
|
+
function launchBody(root, velocity) {
|
|
122
|
+
root.userData[LAUNCHED] = [velocity[0], velocity[1], velocity[2]];
|
|
123
|
+
}
|
|
124
|
+
function takeLaunch(root) {
|
|
125
|
+
const velocity = root.userData[LAUNCHED];
|
|
126
|
+
if (!velocity) return void 0;
|
|
127
|
+
delete root.userData[LAUNCHED];
|
|
128
|
+
return { velocity: [velocity[0], velocity[1], velocity[2]], airborne: true, lying: 0, lieLeft: 0, down: true };
|
|
129
|
+
}
|
|
118
130
|
|
|
119
131
|
// src/impact-cost.ts
|
|
120
132
|
var DEFAULT_COST_READS = 1e4;
|
|
@@ -1139,6 +1151,8 @@ var MATERIAL_SURFACES = {
|
|
|
1139
1151
|
mortar: "concrete",
|
|
1140
1152
|
stone: "concrete",
|
|
1141
1153
|
brick: "concrete",
|
|
1154
|
+
cobble: "concrete",
|
|
1155
|
+
paver: "concrete",
|
|
1142
1156
|
plaster: "concrete",
|
|
1143
1157
|
asphalt: "asphalt",
|
|
1144
1158
|
wood_soft: "wood",
|
|
@@ -1149,6 +1163,8 @@ var MATERIAL_SURFACES = {
|
|
|
1149
1163
|
ceramic: "tile",
|
|
1150
1164
|
plastic: "tile",
|
|
1151
1165
|
soil: "dirt",
|
|
1166
|
+
mud: "dirt",
|
|
1167
|
+
clay: "dirt",
|
|
1152
1168
|
wax: "dirt",
|
|
1153
1169
|
flesh_fruit: "dirt",
|
|
1154
1170
|
turf: "grass",
|
|
@@ -1156,6 +1172,8 @@ var MATERIAL_SURFACES = {
|
|
|
1156
1172
|
cactus: "grass",
|
|
1157
1173
|
gravel: "gravel",
|
|
1158
1174
|
sand: "sand",
|
|
1175
|
+
// no snow surface yet: packed snow crunches closest to sand underfoot
|
|
1176
|
+
snow: "sand",
|
|
1159
1177
|
steel: "metal",
|
|
1160
1178
|
cast_iron: "metal",
|
|
1161
1179
|
aluminium: "metal",
|
|
@@ -1234,6 +1252,7 @@ export {
|
|
|
1234
1252
|
kitOriginOf,
|
|
1235
1253
|
knockOf,
|
|
1236
1254
|
landSoundId,
|
|
1255
|
+
launchBody,
|
|
1237
1256
|
leadClipEvents,
|
|
1238
1257
|
markKitOrigin,
|
|
1239
1258
|
mergeById,
|
|
@@ -1252,6 +1271,7 @@ export {
|
|
|
1252
1271
|
stepKnock,
|
|
1253
1272
|
surfaceOfMaterial,
|
|
1254
1273
|
swingSoundId,
|
|
1274
|
+
takeLaunch,
|
|
1255
1275
|
toolAnimationStep,
|
|
1256
1276
|
twistStroke,
|
|
1257
1277
|
unmarkedDrawings,
|