@adatechnology/game-items 0.2.25 → 0.3.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.js CHANGED
@@ -871,11 +871,597 @@ var itemsFromArsenal = (arsenal, options = {}) => {
871
871
  }
872
872
  return { id: "arsenal", items, categories: ARSENAL_CATEGORIES };
873
873
  };
874
+
875
+ // src/data/hand-uses.json
876
+ var hand_uses_default = [
877
+ {
878
+ id: "eat_food",
879
+ body: "mouth",
880
+ duration: 3.4,
881
+ note: "three bites: the food to the mouth, a bite, down a little to chew, and again",
882
+ keys: [
883
+ {
884
+ t: 0,
885
+ position: [
886
+ 0.22,
887
+ -0.2,
888
+ -0.4
889
+ ],
890
+ rotation: [
891
+ 0,
892
+ 0,
893
+ 0
894
+ ]
895
+ },
896
+ {
897
+ t: 0.45,
898
+ position: [
899
+ 0.01,
900
+ 0,
901
+ -0.17
902
+ ],
903
+ rotation: [
904
+ -0.3,
905
+ 0,
906
+ 0
907
+ ],
908
+ action: "bite"
909
+ },
910
+ {
911
+ t: 0.8,
912
+ position: [
913
+ 0.05,
914
+ -0.08,
915
+ -0.26
916
+ ],
917
+ rotation: [
918
+ -0.15,
919
+ 0,
920
+ 0
921
+ ]
922
+ },
923
+ {
924
+ t: 1.25,
925
+ position: [
926
+ 0.01,
927
+ 0,
928
+ -0.17
929
+ ],
930
+ rotation: [
931
+ -0.3,
932
+ 0,
933
+ 0
934
+ ],
935
+ action: "bite"
936
+ },
937
+ {
938
+ t: 1.6,
939
+ position: [
940
+ 0.05,
941
+ -0.08,
942
+ -0.26
943
+ ],
944
+ rotation: [
945
+ -0.15,
946
+ 0,
947
+ 0
948
+ ]
949
+ },
950
+ {
951
+ t: 2.05,
952
+ position: [
953
+ 0.01,
954
+ 0,
955
+ -0.17
956
+ ],
957
+ rotation: [
958
+ -0.3,
959
+ 0,
960
+ 0
961
+ ],
962
+ action: "bite"
963
+ },
964
+ {
965
+ t: 2.8,
966
+ position: [
967
+ 0.05,
968
+ -0.08,
969
+ -0.26
970
+ ],
971
+ rotation: [
972
+ -0.15,
973
+ 0,
974
+ 0
975
+ ]
976
+ },
977
+ {
978
+ t: 3.4,
979
+ position: [
980
+ 0.22,
981
+ -0.2,
982
+ -0.4
983
+ ],
984
+ rotation: [
985
+ 0,
986
+ 0,
987
+ 0
988
+ ]
989
+ }
990
+ ]
991
+ },
992
+ {
993
+ id: "drink",
994
+ body: "mouth",
995
+ duration: 2.5,
996
+ note: "a drink without a liquid of its own (a juice box): to the mouth and tipped up, as the fluid drink",
997
+ keys: [
998
+ {
999
+ t: 0,
1000
+ position: [
1001
+ 0.22,
1002
+ -0.2,
1003
+ -0.4
1004
+ ],
1005
+ rotation: [
1006
+ 0,
1007
+ 0,
1008
+ 0
1009
+ ]
1010
+ },
1011
+ {
1012
+ t: 0.5,
1013
+ position: [
1014
+ 0,
1015
+ 0.02,
1016
+ -0.2
1017
+ ],
1018
+ rotation: [
1019
+ 0,
1020
+ 0,
1021
+ 0
1022
+ ]
1023
+ },
1024
+ {
1025
+ t: 0.8,
1026
+ position: [
1027
+ 0,
1028
+ 0.02,
1029
+ -0.2
1030
+ ],
1031
+ rotation: [
1032
+ -1.22,
1033
+ 0,
1034
+ 0
1035
+ ],
1036
+ action: "swallow"
1037
+ },
1038
+ {
1039
+ t: 2,
1040
+ position: [
1041
+ 0,
1042
+ 0.02,
1043
+ -0.2
1044
+ ],
1045
+ rotation: [
1046
+ -1.22,
1047
+ 0,
1048
+ 0
1049
+ ]
1050
+ },
1051
+ {
1052
+ t: 2.5,
1053
+ position: [
1054
+ 0.22,
1055
+ -0.2,
1056
+ -0.4
1057
+ ],
1058
+ rotation: [
1059
+ 0,
1060
+ 0,
1061
+ 0
1062
+ ]
1063
+ }
1064
+ ]
1065
+ },
1066
+ {
1067
+ id: "take_medicine",
1068
+ body: "mouth",
1069
+ duration: 2.6,
1070
+ note: "the box before the chest, shaken for a pill, the pill to the mouth and swallowed",
1071
+ keys: [
1072
+ {
1073
+ t: 0,
1074
+ position: [
1075
+ 0.22,
1076
+ -0.2,
1077
+ -0.4
1078
+ ],
1079
+ rotation: [
1080
+ 0,
1081
+ 0,
1082
+ 0
1083
+ ]
1084
+ },
1085
+ {
1086
+ t: 0.4,
1087
+ position: [
1088
+ 0.06,
1089
+ -0.16,
1090
+ -0.3
1091
+ ],
1092
+ rotation: [
1093
+ 0,
1094
+ 0,
1095
+ 0
1096
+ ]
1097
+ },
1098
+ {
1099
+ t: 0.65,
1100
+ position: [
1101
+ 0.06,
1102
+ -0.16,
1103
+ -0.3
1104
+ ],
1105
+ rotation: [
1106
+ 0,
1107
+ 0,
1108
+ 0.5
1109
+ ]
1110
+ },
1111
+ {
1112
+ t: 0.85,
1113
+ position: [
1114
+ 0.06,
1115
+ -0.16,
1116
+ -0.3
1117
+ ],
1118
+ rotation: [
1119
+ 0,
1120
+ 0,
1121
+ -0.5
1122
+ ]
1123
+ },
1124
+ {
1125
+ t: 1.05,
1126
+ position: [
1127
+ 0.06,
1128
+ -0.16,
1129
+ -0.3
1130
+ ],
1131
+ rotation: [
1132
+ 0,
1133
+ 0,
1134
+ 0
1135
+ ]
1136
+ },
1137
+ {
1138
+ t: 1.6,
1139
+ position: [
1140
+ 0,
1141
+ 0.02,
1142
+ -0.18
1143
+ ],
1144
+ rotation: [
1145
+ -0.6,
1146
+ 0,
1147
+ 0
1148
+ ],
1149
+ action: "swallow"
1150
+ },
1151
+ {
1152
+ t: 2,
1153
+ position: [
1154
+ 0,
1155
+ 0.02,
1156
+ -0.18
1157
+ ],
1158
+ rotation: [
1159
+ -0.6,
1160
+ 0,
1161
+ 0
1162
+ ]
1163
+ },
1164
+ {
1165
+ t: 2.6,
1166
+ position: [
1167
+ 0.22,
1168
+ -0.2,
1169
+ -0.4
1170
+ ],
1171
+ rotation: [
1172
+ 0,
1173
+ 0,
1174
+ 0
1175
+ ]
1176
+ }
1177
+ ]
1178
+ },
1179
+ {
1180
+ id: "apply_dressing",
1181
+ body: "two_hands",
1182
+ duration: 3.2,
1183
+ note: "the dressing laid on the other forearm and wound round it twice",
1184
+ keys: [
1185
+ {
1186
+ t: 0,
1187
+ position: [
1188
+ 0.22,
1189
+ -0.2,
1190
+ -0.4
1191
+ ],
1192
+ rotation: [
1193
+ 0,
1194
+ 0,
1195
+ 0
1196
+ ]
1197
+ },
1198
+ {
1199
+ t: 0.5,
1200
+ position: [
1201
+ -0.06,
1202
+ -0.12,
1203
+ -0.3
1204
+ ],
1205
+ rotation: [
1206
+ 0,
1207
+ 0,
1208
+ 1.2
1209
+ ]
1210
+ },
1211
+ {
1212
+ t: 1,
1213
+ position: [
1214
+ -0.1,
1215
+ -0.15,
1216
+ -0.28
1217
+ ],
1218
+ rotation: [
1219
+ 0.4,
1220
+ 0,
1221
+ 1.4
1222
+ ],
1223
+ action: "apply"
1224
+ },
1225
+ {
1226
+ t: 1.5,
1227
+ position: [
1228
+ -0.02,
1229
+ -0.1,
1230
+ -0.32
1231
+ ],
1232
+ rotation: [
1233
+ 0,
1234
+ 0,
1235
+ 1.2
1236
+ ]
1237
+ },
1238
+ {
1239
+ t: 2,
1240
+ position: [
1241
+ -0.1,
1242
+ -0.15,
1243
+ -0.28
1244
+ ],
1245
+ rotation: [
1246
+ 0.4,
1247
+ 0,
1248
+ 1.4
1249
+ ],
1250
+ action: "apply"
1251
+ },
1252
+ {
1253
+ t: 2.6,
1254
+ position: [
1255
+ -0.06,
1256
+ -0.12,
1257
+ -0.3
1258
+ ],
1259
+ rotation: [
1260
+ 0,
1261
+ 0,
1262
+ 1.2
1263
+ ]
1264
+ },
1265
+ {
1266
+ t: 3.2,
1267
+ position: [
1268
+ 0.22,
1269
+ -0.2,
1270
+ -0.4
1271
+ ],
1272
+ rotation: [
1273
+ 0,
1274
+ 0,
1275
+ 0
1276
+ ]
1277
+ }
1278
+ ]
1279
+ },
1280
+ {
1281
+ id: "use_hygiene",
1282
+ body: "two_hands",
1283
+ duration: 3,
1284
+ note: "soap (or what is rubbed in) between both hands in front of the body, rubbed side to side",
1285
+ keys: [
1286
+ {
1287
+ t: 0,
1288
+ position: [
1289
+ 0.22,
1290
+ -0.2,
1291
+ -0.4
1292
+ ],
1293
+ rotation: [
1294
+ 0,
1295
+ 0,
1296
+ 0
1297
+ ]
1298
+ },
1299
+ {
1300
+ t: 0.4,
1301
+ position: [
1302
+ 0.02,
1303
+ -0.18,
1304
+ -0.32
1305
+ ],
1306
+ rotation: [
1307
+ 0,
1308
+ 0,
1309
+ 1.5
1310
+ ]
1311
+ },
1312
+ {
1313
+ t: 0.7,
1314
+ position: [
1315
+ -0.04,
1316
+ -0.18,
1317
+ -0.32
1318
+ ],
1319
+ rotation: [
1320
+ 0,
1321
+ 0,
1322
+ 1.5
1323
+ ],
1324
+ action: "scrub"
1325
+ },
1326
+ {
1327
+ t: 1,
1328
+ position: [
1329
+ 0.06,
1330
+ -0.18,
1331
+ -0.32
1332
+ ],
1333
+ rotation: [
1334
+ 0,
1335
+ 0,
1336
+ 1.5
1337
+ ]
1338
+ },
1339
+ {
1340
+ t: 1.3,
1341
+ position: [
1342
+ -0.04,
1343
+ -0.18,
1344
+ -0.32
1345
+ ],
1346
+ rotation: [
1347
+ 0,
1348
+ 0,
1349
+ 1.5
1350
+ ],
1351
+ action: "scrub"
1352
+ },
1353
+ {
1354
+ t: 1.6,
1355
+ position: [
1356
+ 0.06,
1357
+ -0.18,
1358
+ -0.32
1359
+ ],
1360
+ rotation: [
1361
+ 0,
1362
+ 0,
1363
+ 1.5
1364
+ ]
1365
+ },
1366
+ {
1367
+ t: 1.9,
1368
+ position: [
1369
+ -0.04,
1370
+ -0.18,
1371
+ -0.32
1372
+ ],
1373
+ rotation: [
1374
+ 0,
1375
+ 0,
1376
+ 1.5
1377
+ ],
1378
+ action: "scrub"
1379
+ },
1380
+ {
1381
+ t: 2.3,
1382
+ position: [
1383
+ 0.02,
1384
+ -0.18,
1385
+ -0.32
1386
+ ],
1387
+ rotation: [
1388
+ 0,
1389
+ 0,
1390
+ 1.5
1391
+ ]
1392
+ },
1393
+ {
1394
+ t: 3,
1395
+ position: [
1396
+ 0.22,
1397
+ -0.2,
1398
+ -0.4
1399
+ ],
1400
+ rotation: [
1401
+ 0,
1402
+ 0,
1403
+ 0
1404
+ ]
1405
+ }
1406
+ ]
1407
+ }
1408
+ ];
1409
+
1410
+ // src/hand-use.ts
1411
+ var HAND_USES = hand_uses_default;
1412
+ var handUseOf = (id, defs = HAND_USES) => defs.find((def) => def.id === id);
1413
+ var lerp = (a, b, k) => [
1414
+ a[0] + (b[0] - a[0]) * k,
1415
+ a[1] + (b[1] - a[1]) * k,
1416
+ a[2] + (b[2] - a[2]) * k
1417
+ ];
1418
+ var createHandUse = (def) => {
1419
+ const keys = [...def.keys].sort((a, b) => a.t - b.t);
1420
+ const actions = keys.filter((key) => key.action !== void 0);
1421
+ let time = 0;
1422
+ let reached = 0;
1423
+ let done = keys.length === 0 || def.duration <= 0;
1424
+ const pose = () => {
1425
+ const first = keys[0];
1426
+ if (!first) return { position: [0, 0, 0], rotation: [0, 0, 0] };
1427
+ let index = 0;
1428
+ while (index + 1 < keys.length && keys[index + 1].t <= time) index++;
1429
+ const a = keys[index];
1430
+ const b = keys[Math.min(index + 1, keys.length - 1)];
1431
+ const k = b.t > a.t ? Math.min(1, Math.max(0, (time - a.t) / (b.t - a.t))) : 1;
1432
+ return { position: lerp(a.position, b.position, k), rotation: lerp(a.rotation, b.rotation, k) };
1433
+ };
1434
+ return {
1435
+ def,
1436
+ get time() {
1437
+ return time;
1438
+ },
1439
+ get done() {
1440
+ return done;
1441
+ },
1442
+ pose,
1443
+ update(dt) {
1444
+ if (done) return [];
1445
+ time = Math.min(def.duration, time + Math.max(0, dt));
1446
+ const events = [];
1447
+ while (reached < actions.length && actions[reached].t <= time) {
1448
+ reached++;
1449
+ events.push({ action: actions[reached - 1].action, share: reached / actions.length });
1450
+ }
1451
+ done = time >= def.duration;
1452
+ return events;
1453
+ },
1454
+ cancel() {
1455
+ done = true;
1456
+ }
1457
+ };
1458
+ };
874
1459
  export {
875
1460
  ARSENAL_CATEGORIES,
876
1461
  BODY_SLOTS,
877
1462
  DEFAULT_RULES,
878
1463
  DURABILITY_KINDS,
1464
+ HAND_USES,
879
1465
  ITEM_CATEGORIES,
880
1466
  RARITIES,
881
1467
  advanceAge,
@@ -888,12 +1474,14 @@ export {
888
1474
  checkItems,
889
1475
  craft,
890
1476
  createFindsProvider,
1477
+ createHandUse,
891
1478
  createInventory,
892
1479
  createItems,
893
1480
  depletionFactor,
894
1481
  failsToStart,
895
1482
  fitsInside,
896
1483
  freshness,
1484
+ handUseOf,
897
1485
  itemLitres,
898
1486
  itemsFromArsenal,
899
1487
  loadState,