s2cfgtojson 7.0.7 → 7.0.9
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/Struct.mts +13 -12
- package/Struct.test.mts +5 -0
- package/package.json +1 -1
- package/types.mts +8 -7
- package/utility-types.mts +1 -0
package/Struct.mts
CHANGED
|
@@ -11,10 +11,10 @@ export type Internal =
|
|
|
11
11
|
| "forEach"
|
|
12
12
|
| "filter"
|
|
13
13
|
| "map"
|
|
14
|
-
| "fromJson"
|
|
15
14
|
| "toJson"
|
|
16
|
-
| "toString"
|
|
17
|
-
|
|
15
|
+
| "toString";
|
|
16
|
+
|
|
17
|
+
export type InternalPlus = Internal | "fromString" | "fromJson";
|
|
18
18
|
|
|
19
19
|
export interface DefaultEntries {
|
|
20
20
|
bpatch?: boolean;
|
|
@@ -33,8 +33,8 @@ export type GetStructType<In> =
|
|
|
33
33
|
? Struct & { [key: `${number}`]: GetStructType<In[typeof key]> }
|
|
34
34
|
: In extends Record<any, any>
|
|
35
35
|
? Struct & {
|
|
36
|
-
[key in keyof In]: key extends
|
|
37
|
-
?
|
|
36
|
+
[key in keyof In]: key extends Internal
|
|
37
|
+
? Struct[key]
|
|
38
38
|
: GetStructType<In[key]>;
|
|
39
39
|
}
|
|
40
40
|
: In extends string
|
|
@@ -90,7 +90,7 @@ const REF_INTERNAL_PROPS_INV = new Map(
|
|
|
90
90
|
* This file is part of the Stalker 2 Modding Tools project.
|
|
91
91
|
* This is a base class for all structs.
|
|
92
92
|
*/
|
|
93
|
-
export class Struct {
|
|
93
|
+
export class Struct implements Record<Internal, any> {
|
|
94
94
|
__internal__: Refs = new Refs();
|
|
95
95
|
|
|
96
96
|
/**
|
|
@@ -174,7 +174,7 @@ export class Struct {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
entries<
|
|
177
|
-
K extends Exclude<keyof this,
|
|
177
|
+
K extends Exclude<keyof this, InternalPlus>,
|
|
178
178
|
V extends (typeof this)[K],
|
|
179
179
|
>() {
|
|
180
180
|
return Object.entries(this).filter(
|
|
@@ -182,9 +182,10 @@ export class Struct {
|
|
|
182
182
|
) as [K, V][];
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
forEach<
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
forEach<
|
|
186
|
+
K extends Exclude<keyof this, InternalPlus>,
|
|
187
|
+
V extends (typeof this)[K],
|
|
188
|
+
>(callback: ([key, value]: [K, V], i: number, arr: [K, V][]) => void): void {
|
|
188
189
|
this.entries().forEach(([key, value], i, arr) =>
|
|
189
190
|
callback([key as K, value as V], i, arr as any),
|
|
190
191
|
);
|
|
@@ -195,7 +196,7 @@ export class Struct {
|
|
|
195
196
|
* @param callback
|
|
196
197
|
*/
|
|
197
198
|
filter<
|
|
198
|
-
K extends Exclude<keyof this,
|
|
199
|
+
K extends Exclude<keyof this, InternalPlus>,
|
|
199
200
|
V extends (typeof this)[K],
|
|
200
201
|
S extends this,
|
|
201
202
|
>(callback: (value: [K, V], index: number, array: [K, V][]) => boolean): S {
|
|
@@ -212,7 +213,7 @@ export class Struct {
|
|
|
212
213
|
* Maps the struct entries based on a callback function. Returns a copy.
|
|
213
214
|
* @param callback
|
|
214
215
|
*/
|
|
215
|
-
map<K extends Exclude<keyof this,
|
|
216
|
+
map<K extends Exclude<keyof this, InternalPlus>, V extends (typeof this)[K]>(
|
|
216
217
|
callback: ([key, value]: [K, V], i: number, arr: [K, V][]) => V,
|
|
217
218
|
): this {
|
|
218
219
|
const clone = this.clone();
|
package/Struct.test.mts
CHANGED
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
Struct,
|
|
7
7
|
ArmorPrototype,
|
|
8
8
|
Refs,
|
|
9
|
+
QuestNodePrototypeRandom,
|
|
10
|
+
QuestNodePrototypeLaunchers,
|
|
9
11
|
} from "./Struct.mjs";
|
|
10
12
|
import fs from "node:fs";
|
|
11
13
|
|
|
@@ -481,3 +483,6 @@ struct.end`);
|
|
|
481
483
|
const MyRank: ERank = "ERank::Experienced, ERank::Veteran, ERank::Master";
|
|
482
484
|
// noinspection BadExpressionStatementJS
|
|
483
485
|
({}) as ArmorPrototype["MeshGenerator"];
|
|
486
|
+
|
|
487
|
+
(new Struct() as QuestNodePrototypeRandom).Launchers =
|
|
488
|
+
{} as QuestNodePrototypeLaunchers;
|
package/package.json
CHANGED
package/types.mts
CHANGED
|
@@ -207,6 +207,7 @@ import {
|
|
|
207
207
|
ScenarioGroup,
|
|
208
208
|
SID,
|
|
209
209
|
StringArray,
|
|
210
|
+
VariableValue,
|
|
210
211
|
WeaponShootDistance,
|
|
211
212
|
WeatherSelection,
|
|
212
213
|
} from "./utility-types.mts";
|
|
@@ -3957,7 +3958,7 @@ export type DialogPrototypeConditionsItemItem = GetStructType<{
|
|
|
3957
3958
|
TargetPlaceholder: string;
|
|
3958
3959
|
TargetPoint: AIGlobalRelativeLocation;
|
|
3959
3960
|
Trigger: string;
|
|
3960
|
-
VariableValue:
|
|
3961
|
+
VariableValue: VariableValue;
|
|
3961
3962
|
Weather: EWeather;
|
|
3962
3963
|
WithEquipped: boolean;
|
|
3963
3964
|
WithInventory: boolean;
|
|
@@ -3974,7 +3975,7 @@ export type DialogPrototypeDialogActionsItem = GetStructType<{
|
|
|
3974
3975
|
DialogActionParam: DialogPrototypeMoney;
|
|
3975
3976
|
GlobalVariablePrototypeSID: string;
|
|
3976
3977
|
ItemsCount: DialogPrototypeMoney;
|
|
3977
|
-
VariableValue:
|
|
3978
|
+
VariableValue: VariableValue;
|
|
3978
3979
|
WithEquipped: boolean;
|
|
3979
3980
|
}>;
|
|
3980
3981
|
|
|
@@ -4010,14 +4011,14 @@ export type DialogPrototypeGestureTiming = GetStructType<(number | string)[]>;
|
|
|
4010
4011
|
|
|
4011
4012
|
export type DialogPrototypeItemPrototypeSID = GetStructType<{
|
|
4012
4013
|
VariableType: EGlobalVariableType;
|
|
4013
|
-
VariableValue:
|
|
4014
|
+
VariableValue: VariableValue;
|
|
4014
4015
|
}>;
|
|
4015
4016
|
|
|
4016
4017
|
export type DialogPrototypeLocalizedSequences = StringArray;
|
|
4017
4018
|
|
|
4018
4019
|
export type DialogPrototypeMoney = GetStructType<{
|
|
4019
4020
|
VariableType: EGlobalVariableType;
|
|
4020
|
-
VariableValue:
|
|
4021
|
+
VariableValue: VariableValue;
|
|
4021
4022
|
}>;
|
|
4022
4023
|
|
|
4023
4024
|
export type DialogPrototypeNextDialogOptions = GetStructType<
|
|
@@ -5218,7 +5219,7 @@ export type InfotopicPrototypeBlockingGlobalVariables = GetStructType<
|
|
|
5218
5219
|
|
|
5219
5220
|
export type InfotopicPrototypeBlockingGlobalVariablesItem = GetStructType<{
|
|
5220
5221
|
GlobalVariablePrototypeSID: string;
|
|
5221
|
-
GlobalVariableValue:
|
|
5222
|
+
GlobalVariableValue: VariableValue;
|
|
5222
5223
|
}>;
|
|
5223
5224
|
|
|
5224
5225
|
export type InfotopicPrototypeBlockingNPCs = GetStructType<{
|
|
@@ -8550,7 +8551,7 @@ export type QuestNodePrototypeConditionsItemItem = GetStructType<{
|
|
|
8550
8551
|
TargetPoint: AIGlobalRelativeLocation;
|
|
8551
8552
|
ThreatAwareness: EThreatAwareness;
|
|
8552
8553
|
Trigger: string;
|
|
8553
|
-
VariableValue:
|
|
8554
|
+
VariableValue: VariableValue;
|
|
8554
8555
|
Weather: EWeather;
|
|
8555
8556
|
WithBodyArmor: boolean;
|
|
8556
8557
|
WithEquipped: boolean;
|
|
@@ -9652,7 +9653,7 @@ export type QuestNodePrototypeSetGlobalVariable = GetStructType<{
|
|
|
9652
9653
|
QuestSID: string;
|
|
9653
9654
|
Repeatable: boolean;
|
|
9654
9655
|
SID: string;
|
|
9655
|
-
VariableValue:
|
|
9656
|
+
VariableValue: VariableValue;
|
|
9656
9657
|
}>;
|
|
9657
9658
|
|
|
9658
9659
|
export type QuestNodePrototypeSetHubOwner = GetStructType<{
|
package/utility-types.mts
CHANGED
|
@@ -29,6 +29,7 @@ export type Caliber =
|
|
|
29
29
|
| "AVOG"
|
|
30
30
|
| "None";
|
|
31
31
|
|
|
32
|
+
export type VariableValue = boolean | number | string;
|
|
32
33
|
export type WeaponShootDistance = "Long" | "Medium" | "Short";
|
|
33
34
|
export type SID = string;
|
|
34
35
|
export type Rank = "Newbie" | "Experienced" | "Veteran" | "Master";
|