warscript 0.0.1-dev.f1df135 → 0.0.1-dev.f4350ae
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/attributes.d.ts +5 -0
- package/attributes.lua +8 -1
- package/core/types/sound.lua +5 -0
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/damage.d.ts +6 -3
- package/engine/behaviour/ability/damage.lua +24 -36
- package/engine/behaviour/ability/emulate-impact.lua +7 -0
- package/engine/internal/ability.d.ts +2 -0
- package/engine/internal/ability.lua +7 -0
- package/engine/internal/item.d.ts +2 -1
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/unit+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit.d.ts +16 -3
- package/engine/internal/unit.lua +126 -37
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type.lua +7 -0
- package/engine/object-data/entry/buff-type/applicable.lua +5 -0
- package/engine/object-data/entry/buff-type.d.ts +5 -11
- package/engine/object-data/entry/buff-type.lua +11 -27
- package/engine/object-data/entry/unit-type.d.ts +2 -2
- package/engine/object-data/entry/unit-type.lua +94 -84
- package/engine/object-field/ability.d.ts +1 -1
- package/engine/object-field/unit.d.ts +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +9 -1
- package/engine/object-field.lua +158 -76
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/objutil/buff.lua +1 -2
- package/package.json +2 -2
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +3 -0
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +3 -0
- package/utility/lua-maps.lua +16 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +3 -0
|
@@ -2,11 +2,22 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
4
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local ____unit = require("engine.internal.unit")
|
|
7
8
|
local Unit = ____unit.Unit
|
|
8
9
|
local ____object_2Dfield = require("engine.object-field")
|
|
9
10
|
local ObjectField = ____object_2Dfield.ObjectField
|
|
11
|
+
local ObjectLevelField = ____object_2Dfield.ObjectLevelField
|
|
12
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
13
|
+
local nonEmptyLinkedSetOf = ____linked_2Dset.nonEmptyLinkedSetOf
|
|
14
|
+
local convertUnitBooleanField = ConvertUnitBooleanField
|
|
15
|
+
local convertUnitIntegerField = ConvertUnitIntegerField
|
|
16
|
+
local convertUnitRealField = ConvertUnitRealField
|
|
17
|
+
local convertUnitStringField = ConvertUnitStringField
|
|
18
|
+
local convertUnitWeaponIntegerField = ConvertUnitWeaponIntegerField
|
|
19
|
+
local getUnitWeaponIntegerField = BlzGetUnitWeaponIntegerField
|
|
20
|
+
local setUnitWeaponIntegerField = BlzSetUnitWeaponIntegerField
|
|
10
21
|
____exports.UnitField = __TS__Class()
|
|
11
22
|
local UnitField = ____exports.UnitField
|
|
12
23
|
UnitField.name = "UnitField"
|
|
@@ -14,6 +25,9 @@ __TS__ClassExtends(UnitField, ObjectField)
|
|
|
14
25
|
function UnitField.prototype.getObjectDataEntryId(self, instance)
|
|
15
26
|
return instance.typeId
|
|
16
27
|
end
|
|
28
|
+
function UnitField.prototype.hasNativeFieldValue(self)
|
|
29
|
+
return true
|
|
30
|
+
end
|
|
17
31
|
__TS__SetDescriptor(
|
|
18
32
|
UnitField.prototype,
|
|
19
33
|
"instanceClass",
|
|
@@ -22,22 +36,79 @@ __TS__SetDescriptor(
|
|
|
22
36
|
end},
|
|
23
37
|
true
|
|
24
38
|
)
|
|
39
|
+
____exports.UnitBooleanField = __TS__Class()
|
|
40
|
+
local UnitBooleanField = ____exports.UnitBooleanField
|
|
41
|
+
UnitBooleanField.name = "UnitBooleanField"
|
|
42
|
+
__TS__ClassExtends(UnitBooleanField, ____exports.UnitField)
|
|
43
|
+
function UnitBooleanField.prototype.getNativeFieldById(self, id)
|
|
44
|
+
return convertUnitBooleanField(id)
|
|
45
|
+
end
|
|
46
|
+
function UnitBooleanField.prototype.getNativeFieldValue(self, instance)
|
|
47
|
+
return instance:getField(self.nativeField)
|
|
48
|
+
end
|
|
49
|
+
function UnitBooleanField.prototype.setNativeFieldValue(self, instance, value)
|
|
50
|
+
return instance:setField(self.nativeField, value)
|
|
51
|
+
end
|
|
52
|
+
__TS__SetDescriptor(
|
|
53
|
+
UnitBooleanField.prototype,
|
|
54
|
+
"defaultValue",
|
|
55
|
+
{get = function(self)
|
|
56
|
+
return false
|
|
57
|
+
end},
|
|
58
|
+
true
|
|
59
|
+
)
|
|
60
|
+
____exports.UnitFloatField = __TS__Class()
|
|
61
|
+
local UnitFloatField = ____exports.UnitFloatField
|
|
62
|
+
UnitFloatField.name = "UnitFloatField"
|
|
63
|
+
__TS__ClassExtends(UnitFloatField, ____exports.UnitField)
|
|
64
|
+
function UnitFloatField.prototype.getNativeFieldById(self, id)
|
|
65
|
+
return convertUnitRealField(id)
|
|
66
|
+
end
|
|
67
|
+
function UnitFloatField.prototype.getNativeFieldValue(self, instance)
|
|
68
|
+
return instance:getField(self.nativeField)
|
|
69
|
+
end
|
|
70
|
+
function UnitFloatField.prototype.setNativeFieldValue(self, instance, value)
|
|
71
|
+
return instance:setField(self.nativeField, value)
|
|
72
|
+
end
|
|
73
|
+
__TS__SetDescriptor(
|
|
74
|
+
UnitFloatField.prototype,
|
|
75
|
+
"defaultValue",
|
|
76
|
+
{get = function(self)
|
|
77
|
+
return 0
|
|
78
|
+
end},
|
|
79
|
+
true
|
|
80
|
+
)
|
|
81
|
+
____exports.UnitIntegerField = __TS__Class()
|
|
82
|
+
local UnitIntegerField = ____exports.UnitIntegerField
|
|
83
|
+
UnitIntegerField.name = "UnitIntegerField"
|
|
84
|
+
__TS__ClassExtends(UnitIntegerField, ____exports.UnitField)
|
|
85
|
+
function UnitIntegerField.prototype.getNativeFieldById(self, id)
|
|
86
|
+
return convertUnitIntegerField(id)
|
|
87
|
+
end
|
|
88
|
+
function UnitIntegerField.prototype.getNativeFieldValue(self, instance)
|
|
89
|
+
return instance:getField(self.nativeField)
|
|
90
|
+
end
|
|
91
|
+
function UnitIntegerField.prototype.setNativeFieldValue(self, instance, value)
|
|
92
|
+
return instance:setField(self.nativeField, value)
|
|
93
|
+
end
|
|
94
|
+
__TS__SetDescriptor(
|
|
95
|
+
UnitIntegerField.prototype,
|
|
96
|
+
"defaultValue",
|
|
97
|
+
{get = function(self)
|
|
98
|
+
return 0
|
|
99
|
+
end},
|
|
100
|
+
true
|
|
101
|
+
)
|
|
25
102
|
____exports.UnitStringField = __TS__Class()
|
|
26
103
|
local UnitStringField = ____exports.UnitStringField
|
|
27
104
|
UnitStringField.name = "UnitStringField"
|
|
28
105
|
__TS__ClassExtends(UnitStringField, ____exports.UnitField)
|
|
29
106
|
function UnitStringField.prototype.getNativeFieldById(self, id)
|
|
30
|
-
return
|
|
31
|
-
end
|
|
32
|
-
function UnitStringField.prototype.hasNativeFieldValue(self)
|
|
33
|
-
return true
|
|
107
|
+
return convertUnitStringField(id)
|
|
34
108
|
end
|
|
35
109
|
function UnitStringField.prototype.getNativeFieldValue(self, instance)
|
|
36
110
|
return instance:getField(self.nativeField)
|
|
37
111
|
end
|
|
38
|
-
function UnitStringField.prototype.getObjectDataEntryId(self, instance)
|
|
39
|
-
return instance.typeId
|
|
40
|
-
end
|
|
41
112
|
function UnitStringField.prototype.setNativeFieldValue(self, instance, value)
|
|
42
113
|
return instance:setField(self.nativeField, value)
|
|
43
114
|
end
|
|
@@ -49,4 +120,99 @@ __TS__SetDescriptor(
|
|
|
49
120
|
end},
|
|
50
121
|
true
|
|
51
122
|
)
|
|
123
|
+
____exports.UnitWeaponField = __TS__Class()
|
|
124
|
+
local UnitWeaponField = ____exports.UnitWeaponField
|
|
125
|
+
UnitWeaponField.name = "UnitWeaponField"
|
|
126
|
+
__TS__ClassExtends(UnitWeaponField, ObjectLevelField)
|
|
127
|
+
function UnitWeaponField.prototype.getLevelCount(self)
|
|
128
|
+
return 2
|
|
129
|
+
end
|
|
130
|
+
function UnitWeaponField.prototype.getObjectDataEntryId(self, instance)
|
|
131
|
+
return instance.typeId
|
|
132
|
+
end
|
|
133
|
+
function UnitWeaponField.prototype.hasNativeFieldValue(self)
|
|
134
|
+
return true
|
|
135
|
+
end
|
|
136
|
+
__TS__SetDescriptor(
|
|
137
|
+
UnitWeaponField.prototype,
|
|
138
|
+
"instanceClass",
|
|
139
|
+
{get = function(self)
|
|
140
|
+
return Unit
|
|
141
|
+
end},
|
|
142
|
+
true
|
|
143
|
+
)
|
|
144
|
+
__TS__ObjectDefineProperty(
|
|
145
|
+
UnitWeaponField,
|
|
146
|
+
"valueChangeEvent",
|
|
147
|
+
{get = function(self)
|
|
148
|
+
return self:getOrCreateValueChangeEvent()
|
|
149
|
+
end}
|
|
150
|
+
)
|
|
151
|
+
____exports.UnitNumberWeaponField = __TS__Class()
|
|
152
|
+
local UnitNumberWeaponField = ____exports.UnitNumberWeaponField
|
|
153
|
+
UnitNumberWeaponField.name = "UnitNumberWeaponField"
|
|
154
|
+
__TS__ClassExtends(UnitNumberWeaponField, ____exports.UnitWeaponField)
|
|
155
|
+
__TS__SetDescriptor(
|
|
156
|
+
UnitNumberWeaponField.prototype,
|
|
157
|
+
"defaultValue",
|
|
158
|
+
{get = function(self)
|
|
159
|
+
return 0
|
|
160
|
+
end},
|
|
161
|
+
true
|
|
162
|
+
)
|
|
163
|
+
__TS__ObjectDefineProperty(
|
|
164
|
+
UnitNumberWeaponField,
|
|
165
|
+
"valueChangeEvent",
|
|
166
|
+
{get = function(self)
|
|
167
|
+
return self:getOrCreateValueChangeEvent()
|
|
168
|
+
end}
|
|
169
|
+
)
|
|
170
|
+
____exports.UnitEnumWeaponField = __TS__Class()
|
|
171
|
+
local UnitEnumWeaponField = ____exports.UnitEnumWeaponField
|
|
172
|
+
UnitEnumWeaponField.name = "UnitEnumWeaponField"
|
|
173
|
+
__TS__ClassExtends(UnitEnumWeaponField, ____exports.UnitWeaponField)
|
|
174
|
+
function UnitEnumWeaponField.prototype.getNativeFieldById(self, id)
|
|
175
|
+
return convertUnitWeaponIntegerField(id)
|
|
176
|
+
end
|
|
177
|
+
function UnitEnumWeaponField.prototype.getNativeFieldValue(self, instance, index)
|
|
178
|
+
local value = getUnitWeaponIntegerField(instance.handle, self.nativeField, index)
|
|
179
|
+
if self.values:contains(value) then
|
|
180
|
+
return value
|
|
181
|
+
end
|
|
182
|
+
return self.values:first()
|
|
183
|
+
end
|
|
184
|
+
function UnitEnumWeaponField.prototype.setNativeFieldValue(self, instance, index, value)
|
|
185
|
+
return setUnitWeaponIntegerField(instance.handle, self.nativeField, index, value)
|
|
186
|
+
end
|
|
187
|
+
__TS__SetDescriptor(
|
|
188
|
+
UnitEnumWeaponField.prototype,
|
|
189
|
+
"defaultValue",
|
|
190
|
+
{get = function(self)
|
|
191
|
+
return self.values:first()
|
|
192
|
+
end},
|
|
193
|
+
true
|
|
194
|
+
)
|
|
195
|
+
__TS__ObjectDefineProperty(
|
|
196
|
+
UnitEnumWeaponField,
|
|
197
|
+
"valueChangeEvent",
|
|
198
|
+
{get = function(self)
|
|
199
|
+
return self:getOrCreateValueChangeEvent()
|
|
200
|
+
end}
|
|
201
|
+
)
|
|
202
|
+
____exports.UnitAttackTypeWeaponField = __TS__Class()
|
|
203
|
+
local UnitAttackTypeWeaponField = ____exports.UnitAttackTypeWeaponField
|
|
204
|
+
UnitAttackTypeWeaponField.name = "UnitAttackTypeWeaponField"
|
|
205
|
+
__TS__ClassExtends(UnitAttackTypeWeaponField, ____exports.UnitEnumWeaponField)
|
|
206
|
+
function UnitAttackTypeWeaponField.prototype.____constructor(self, ...)
|
|
207
|
+
UnitAttackTypeWeaponField.____super.prototype.____constructor(self, ...)
|
|
208
|
+
self.values = nonEmptyLinkedSetOf(
|
|
209
|
+
1,
|
|
210
|
+
2,
|
|
211
|
+
3,
|
|
212
|
+
0,
|
|
213
|
+
5,
|
|
214
|
+
4,
|
|
215
|
+
6
|
|
216
|
+
)
|
|
217
|
+
end
|
|
52
218
|
return ____exports
|
package/engine/object-field.d.ts
CHANGED
|
@@ -35,14 +35,22 @@ export type ObjectFieldValueChangeEvent<T extends ObjectField<any, any, any, any
|
|
|
35
35
|
]> : never;
|
|
36
36
|
export type ReadonlyObjectFieldType<T extends ObjectField<any, any, any, any>> = Omit<T, "setValue" | "removeValue" | "trySetValue">;
|
|
37
37
|
type ReadonlyObjectFieldConstructor<T extends ObjectField> = OmitConstructor<typeof ObjectField> & (abstract new (...args: any[]) => ReadonlyObjectFieldType<T>);
|
|
38
|
+
type ObjectFieldModifier<InstanceType extends AnyNotNil, ValueType extends number | string | boolean> = (instance: InstanceType, currentValue: ValueType, originalValue: ValueType) => ValueType;
|
|
38
39
|
export declare abstract class ObjectField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType, NativeFieldType> {
|
|
39
40
|
protected abstract readonly defaultValue: ValueType;
|
|
40
41
|
protected abstract getNativeFieldValue(instance: InstanceType): ValueType;
|
|
41
42
|
protected abstract setNativeFieldValue(instance: InstanceType, value: ValueType): boolean;
|
|
42
|
-
|
|
43
|
+
private originalValueByInstance?;
|
|
44
|
+
private modifiersByInstance?;
|
|
45
|
+
getValue(entry: ObjectDataEntryType | InstanceType, includeModifiers?: boolean): ValueType;
|
|
43
46
|
setValue(entry: ObjectDataEntryType | InstanceType, value: ValueType): boolean;
|
|
47
|
+
applyModifier(instance: InstanceType, modifier: ObjectFieldModifier<InstanceType, ValueType>): void;
|
|
48
|
+
removeModifier(instance: InstanceType, modifier: ObjectFieldModifier<InstanceType, ValueType>): boolean;
|
|
44
49
|
removeValue(entry: ObjectDataEntryType): boolean;
|
|
45
50
|
trySetValue(entry: ObjectDataEntryType | InstanceType, value: unknown): boolean;
|
|
51
|
+
private getActualValue;
|
|
52
|
+
private setActualValue;
|
|
53
|
+
private calculateActualValue;
|
|
46
54
|
private invokeValueChangeEvent;
|
|
47
55
|
private invokeValueChangeEventRecursive;
|
|
48
56
|
protected static getOrCreateValueChangeEvent<T extends ObjectField, R extends ReadonlyObjectFieldType<T>>(this: ReadonlyObjectFieldConstructor<T>): ObjectFieldValueChangeEvent<R>;
|
package/engine/object-field.lua
CHANGED
|
@@ -20,6 +20,11 @@ local extractObjectDataEntryLevelFieldValue = ____entry.extractObjectDataEntryLe
|
|
|
20
20
|
local ObjectDataEntry = ____entry.ObjectDataEntry
|
|
21
21
|
local ____object_2Ddata_2Dentry_2Did_2Dgenerator = require("engine.object-data.utility.object-data-entry-id-generator")
|
|
22
22
|
local ObjectDataEntryIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.ObjectDataEntryIdGenerator
|
|
23
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
24
|
+
local mutableLinkedSet = ____linked_2Dset.mutableLinkedSet
|
|
25
|
+
local ____lua_2Dmaps = require("utility.lua-maps")
|
|
26
|
+
local getOrPut = ____lua_2Dmaps.getOrPut
|
|
27
|
+
local mutableWeakLuaMap = ____lua_2Dmaps.mutableWeakLuaMap
|
|
23
28
|
local compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId = {}
|
|
24
29
|
local defaultValueByObjectDataEntryIdByObjectFieldId = postcompile(function() return compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId end)
|
|
25
30
|
local objectFieldById = {}
|
|
@@ -75,7 +80,7 @@ ____exports.ObjectField = __TS__Class()
|
|
|
75
80
|
local ObjectField = ____exports.ObjectField
|
|
76
81
|
ObjectField.name = "ObjectField"
|
|
77
82
|
__TS__ClassExtends(ObjectField, ObjectFieldBase)
|
|
78
|
-
function ObjectField.prototype.getValue(self, entry)
|
|
83
|
+
function ObjectField.prototype.getValue(self, entry, includeModifiers)
|
|
79
84
|
if __TS__InstanceOf(entry, ObjectDataEntry) then
|
|
80
85
|
local defaultValueByObjectDataEntryId = (warpack.compiletime and compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId or defaultValueByObjectDataEntryIdByObjectFieldId)[self.id]
|
|
81
86
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
@@ -86,22 +91,16 @@ function ObjectField.prototype.getValue(self, entry)
|
|
|
86
91
|
end
|
|
87
92
|
return self.defaultValue
|
|
88
93
|
end
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
____self_valueByInstance_entry_0 = defaultValue
|
|
94
|
+
if includeModifiers == false then
|
|
95
|
+
local originalValueByInstance = self.originalValueByInstance
|
|
96
|
+
if originalValueByInstance ~= nil then
|
|
97
|
+
local originalValue = originalValueByInstance[entry]
|
|
98
|
+
if originalValue ~= nil then
|
|
99
|
+
return originalValue
|
|
96
100
|
end
|
|
97
|
-
return ____self_valueByInstance_entry_0
|
|
98
101
|
end
|
|
99
102
|
end
|
|
100
|
-
|
|
101
|
-
if ____temp_1 == nil then
|
|
102
|
-
____temp_1 = self.defaultValue
|
|
103
|
-
end
|
|
104
|
-
return ____temp_1
|
|
103
|
+
return self:getActualValue(entry)
|
|
105
104
|
end
|
|
106
105
|
function ObjectField.prototype.setValue(self, entry, value)
|
|
107
106
|
if __TS__InstanceOf(entry, ObjectDataEntry) then
|
|
@@ -116,37 +115,53 @@ function ObjectField.prototype.setValue(self, entry, value)
|
|
|
116
115
|
defaultValueByObjectDataEntryId[entry.id] = value
|
|
117
116
|
return true
|
|
118
117
|
end
|
|
119
|
-
local
|
|
120
|
-
if
|
|
121
|
-
local
|
|
122
|
-
if
|
|
123
|
-
local
|
|
124
|
-
if
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
local ____self_valueByInstance_entry_2_3 = ____self_valueByInstance_entry_2
|
|
128
|
-
if ____self_valueByInstance_entry_2_3 == nil then
|
|
129
|
-
____self_valueByInstance_entry_2_3 = self.defaultValue
|
|
130
|
-
end
|
|
131
|
-
local previousValue = ____self_valueByInstance_entry_2_3
|
|
132
|
-
if value ~= previousValue then
|
|
133
|
-
self.valueByInstance[entry] = value
|
|
134
|
-
self:invokeValueChangeEvent(entry, self, previousValue, value)
|
|
118
|
+
local modifiersByInstance = self.modifiersByInstance
|
|
119
|
+
if modifiersByInstance ~= nil then
|
|
120
|
+
local modifiers = modifiersByInstance[entry]
|
|
121
|
+
if modifiers ~= nil and modifiers.size ~= 0 then
|
|
122
|
+
local originalValueByInstance = self.originalValueByInstance
|
|
123
|
+
if originalValueByInstance == nil then
|
|
124
|
+
originalValueByInstance = mutableWeakLuaMap()
|
|
125
|
+
self.originalValueByInstance = originalValueByInstance
|
|
135
126
|
end
|
|
136
|
-
|
|
127
|
+
originalValueByInstance[entry] = value
|
|
128
|
+
value = self:calculateActualValue(entry)
|
|
137
129
|
end
|
|
138
130
|
end
|
|
139
|
-
|
|
140
|
-
|
|
131
|
+
return self:setActualValue(entry, value)
|
|
132
|
+
end
|
|
133
|
+
function ObjectField.prototype.applyModifier(self, instance, modifier)
|
|
134
|
+
local modifiersByInstance = self.modifiersByInstance
|
|
135
|
+
if modifiersByInstance == nil then
|
|
136
|
+
modifiersByInstance = mutableWeakLuaMap()
|
|
137
|
+
self.modifiersByInstance = modifiersByInstance
|
|
138
|
+
end
|
|
139
|
+
if getOrPut(modifiersByInstance, instance, mutableLinkedSet):add(modifier) then
|
|
140
|
+
local originalValueByInstance = self.originalValueByInstance
|
|
141
|
+
if originalValueByInstance == nil then
|
|
142
|
+
originalValueByInstance = mutableWeakLuaMap()
|
|
143
|
+
self.originalValueByInstance = originalValueByInstance
|
|
144
|
+
end
|
|
145
|
+
originalValueByInstance[instance] = self:getActualValue(instance)
|
|
146
|
+
self:setActualValue(
|
|
147
|
+
instance,
|
|
148
|
+
self:calculateActualValue(instance)
|
|
149
|
+
)
|
|
141
150
|
end
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
end
|
|
152
|
+
function ObjectField.prototype.removeModifier(self, instance, modifier)
|
|
153
|
+
local modifiersByInstance = self.modifiersByInstance
|
|
154
|
+
if modifiersByInstance ~= nil then
|
|
155
|
+
local modifiers = modifiersByInstance[instance]
|
|
156
|
+
if modifiers ~= nil and modifiers:remove(modifier) then
|
|
157
|
+
self:setActualValue(
|
|
158
|
+
instance,
|
|
159
|
+
self:calculateActualValue(instance)
|
|
160
|
+
)
|
|
161
|
+
return true
|
|
146
162
|
end
|
|
147
|
-
self:invokeValueChangeEvent(entry, self, previousValue, value)
|
|
148
163
|
end
|
|
149
|
-
return
|
|
164
|
+
return false
|
|
150
165
|
end
|
|
151
166
|
function ObjectField.prototype.removeValue(self, entry)
|
|
152
167
|
if not warpack.compiletime then
|
|
@@ -168,6 +183,73 @@ function ObjectField.prototype.trySetValue(self, entry, value)
|
|
|
168
183
|
end
|
|
169
184
|
return self:setValue(entry, value)
|
|
170
185
|
end
|
|
186
|
+
function ObjectField.prototype.getActualValue(self, instance)
|
|
187
|
+
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
188
|
+
if defaultValueByObjectDataEntryId ~= nil then
|
|
189
|
+
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
190
|
+
if defaultValue ~= nil then
|
|
191
|
+
local ____self_valueByInstance_instance_0 = self.valueByInstance[instance]
|
|
192
|
+
if ____self_valueByInstance_instance_0 == nil then
|
|
193
|
+
____self_valueByInstance_instance_0 = defaultValue
|
|
194
|
+
end
|
|
195
|
+
return ____self_valueByInstance_instance_0
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
local ____temp_1 = self:getNativeFieldValue(instance)
|
|
199
|
+
if ____temp_1 == nil then
|
|
200
|
+
____temp_1 = self.defaultValue
|
|
201
|
+
end
|
|
202
|
+
return ____temp_1
|
|
203
|
+
end
|
|
204
|
+
function ObjectField.prototype.setActualValue(self, instance, value)
|
|
205
|
+
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
206
|
+
if defaultValueByObjectDataEntryId ~= nil then
|
|
207
|
+
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
208
|
+
if defaultValue ~= nil then
|
|
209
|
+
local ____self_valueByInstance_instance_2 = self.valueByInstance[instance]
|
|
210
|
+
if ____self_valueByInstance_instance_2 == nil then
|
|
211
|
+
____self_valueByInstance_instance_2 = defaultValue
|
|
212
|
+
end
|
|
213
|
+
local ____self_valueByInstance_instance_2_3 = ____self_valueByInstance_instance_2
|
|
214
|
+
if ____self_valueByInstance_instance_2_3 == nil then
|
|
215
|
+
____self_valueByInstance_instance_2_3 = self.defaultValue
|
|
216
|
+
end
|
|
217
|
+
local previousValue = ____self_valueByInstance_instance_2_3
|
|
218
|
+
if value ~= previousValue then
|
|
219
|
+
self.valueByInstance[instance] = value
|
|
220
|
+
self:invokeValueChangeEvent(instance, self, previousValue, value)
|
|
221
|
+
end
|
|
222
|
+
return true
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
if not self:hasNativeFieldValue(instance) then
|
|
226
|
+
return false
|
|
227
|
+
end
|
|
228
|
+
local previousValue = self:getNativeFieldValue(instance)
|
|
229
|
+
if value ~= previousValue then
|
|
230
|
+
if not self:setNativeFieldValue(instance, value) then
|
|
231
|
+
return false
|
|
232
|
+
end
|
|
233
|
+
self:invokeValueChangeEvent(instance, self, previousValue, value)
|
|
234
|
+
end
|
|
235
|
+
return true
|
|
236
|
+
end
|
|
237
|
+
function ObjectField.prototype.calculateActualValue(self, instance)
|
|
238
|
+
local ____opt_4 = self.originalValueByInstance
|
|
239
|
+
local originalValue = ____opt_4 and ____opt_4[instance]
|
|
240
|
+
local ____opt_6 = self.modifiersByInstance
|
|
241
|
+
local modifiers = ____opt_6 and ____opt_6[instance]
|
|
242
|
+
if originalValue ~= nil then
|
|
243
|
+
local value = originalValue
|
|
244
|
+
if modifiers ~= nil then
|
|
245
|
+
for modifier in pairs(modifiers) do
|
|
246
|
+
value = modifier(instance, value, originalValue)
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
return value
|
|
250
|
+
end
|
|
251
|
+
return self.defaultValue
|
|
252
|
+
end
|
|
171
253
|
function ObjectField.prototype.invokeValueChangeEvent(self, ...)
|
|
172
254
|
self:invokeValueChangeEventRecursive(
|
|
173
255
|
getClass(self),
|
|
@@ -221,17 +303,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
221
303
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
222
304
|
local value = defaultValueByObjectDataEntryId[entry.id]
|
|
223
305
|
if value ~= nil then
|
|
224
|
-
local
|
|
306
|
+
local ____temp_9
|
|
225
307
|
if index == nil then
|
|
226
|
-
|
|
308
|
+
____temp_9 = value
|
|
227
309
|
else
|
|
228
|
-
local
|
|
229
|
-
if
|
|
230
|
-
|
|
310
|
+
local ____value_index_8 = value[index + 1]
|
|
311
|
+
if ____value_index_8 == nil then
|
|
312
|
+
____value_index_8 = self.defaultValue
|
|
231
313
|
end
|
|
232
|
-
|
|
314
|
+
____temp_9 = ____value_index_8
|
|
233
315
|
end
|
|
234
|
-
return
|
|
316
|
+
return ____temp_9
|
|
235
317
|
end
|
|
236
318
|
end
|
|
237
319
|
return index == nil and ({}) or self.defaultValue
|
|
@@ -241,17 +323,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
241
323
|
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
242
324
|
if defaultValue ~= nil then
|
|
243
325
|
local value = self.valueByInstance[entry] or defaultValue
|
|
244
|
-
local
|
|
326
|
+
local ____temp_11
|
|
245
327
|
if index == nil then
|
|
246
|
-
|
|
328
|
+
____temp_11 = value
|
|
247
329
|
else
|
|
248
|
-
local
|
|
249
|
-
if
|
|
250
|
-
|
|
330
|
+
local ____value_index_10 = value[index + 1]
|
|
331
|
+
if ____value_index_10 == nil then
|
|
332
|
+
____value_index_10 = self.defaultValue
|
|
251
333
|
end
|
|
252
|
-
|
|
334
|
+
____temp_11 = ____value_index_10
|
|
253
335
|
end
|
|
254
|
-
return
|
|
336
|
+
return ____temp_11
|
|
255
337
|
end
|
|
256
338
|
end
|
|
257
339
|
if index ~= nil then
|
|
@@ -296,11 +378,11 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
296
378
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
297
379
|
local valueByLevel = defaultValueByObjectDataEntryId[entry.id]
|
|
298
380
|
if valueByLevel ~= nil then
|
|
299
|
-
local
|
|
300
|
-
if
|
|
301
|
-
|
|
381
|
+
local ____valueByLevel_index_12 = valueByLevel[level + 1]
|
|
382
|
+
if ____valueByLevel_index_12 == nil then
|
|
383
|
+
____valueByLevel_index_12 = self.defaultValue
|
|
302
384
|
end
|
|
303
|
-
return
|
|
385
|
+
return ____valueByLevel_index_12
|
|
304
386
|
end
|
|
305
387
|
end
|
|
306
388
|
return self.defaultValue
|
|
@@ -309,23 +391,23 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
309
391
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
310
392
|
local defaultValueByLevel = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
311
393
|
if defaultValueByLevel ~= nil then
|
|
312
|
-
local
|
|
313
|
-
local
|
|
314
|
-
if
|
|
315
|
-
|
|
394
|
+
local ____opt_13 = self.valueByInstance[entry]
|
|
395
|
+
local ____temp_15 = ____opt_13 and ____opt_13[level + 1]
|
|
396
|
+
if ____temp_15 == nil then
|
|
397
|
+
____temp_15 = defaultValueByLevel[level + 1]
|
|
316
398
|
end
|
|
317
|
-
local
|
|
318
|
-
if
|
|
319
|
-
|
|
399
|
+
local ____temp_15_16 = ____temp_15
|
|
400
|
+
if ____temp_15_16 == nil then
|
|
401
|
+
____temp_15_16 = self.defaultValue
|
|
320
402
|
end
|
|
321
|
-
return
|
|
403
|
+
return ____temp_15_16
|
|
322
404
|
end
|
|
323
405
|
end
|
|
324
|
-
local
|
|
325
|
-
if
|
|
326
|
-
|
|
406
|
+
local ____temp_17 = self:getNativeFieldValue(entry, level)
|
|
407
|
+
if ____temp_17 == nil then
|
|
408
|
+
____temp_17 = self.defaultValue
|
|
327
409
|
end
|
|
328
|
-
return
|
|
410
|
+
return ____temp_17
|
|
329
411
|
end
|
|
330
412
|
function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
331
413
|
if value == nil then
|
|
@@ -374,15 +456,15 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
|
374
456
|
valueByLevel = {}
|
|
375
457
|
self.valueByInstance[entry] = valueByLevel
|
|
376
458
|
end
|
|
377
|
-
local
|
|
378
|
-
if
|
|
379
|
-
|
|
459
|
+
local ____valueByLevel_index_18 = valueByLevel[level + 1]
|
|
460
|
+
if ____valueByLevel_index_18 == nil then
|
|
461
|
+
____valueByLevel_index_18 = defaultValueByLevel[level + 1]
|
|
380
462
|
end
|
|
381
|
-
local
|
|
382
|
-
if
|
|
383
|
-
|
|
463
|
+
local ____valueByLevel_index_18_19 = ____valueByLevel_index_18
|
|
464
|
+
if ____valueByLevel_index_18_19 == nil then
|
|
465
|
+
____valueByLevel_index_18_19 = self.defaultValue
|
|
384
466
|
end
|
|
385
|
-
local previousValue =
|
|
467
|
+
local previousValue = ____valueByLevel_index_18_19
|
|
386
468
|
if value ~= previousValue then
|
|
387
469
|
valueByLevel[level + 1] = value
|
|
388
470
|
self:invokeValueChangeEvent(
|
package/objutil/buff.lua
CHANGED
|
@@ -20,7 +20,6 @@ local AbilityDefinitionInnerFire = ____ability.AbilityDefinitionInnerFire
|
|
|
20
20
|
local AbilityDefinitionSearingArrows = ____ability.AbilityDefinitionSearingArrows
|
|
21
21
|
local AbilityDefinitionSlowPoison = ____ability.AbilityDefinitionSlowPoison
|
|
22
22
|
local ____unit = require("core.types.unit")
|
|
23
|
-
local AttackType = ____unit.AttackType
|
|
24
23
|
local DamageType = ____unit.DamageType
|
|
25
24
|
local Unit = ____unit.Unit
|
|
26
25
|
local ____dummy = require("core.dummy")
|
|
@@ -756,7 +755,7 @@ for ____, pointDispelAbilityId in ipairs(pointDispelAbilityIds) do
|
|
|
756
755
|
end)
|
|
757
756
|
end
|
|
758
757
|
Unit.onDamaging:addListener(function(source, target, event)
|
|
759
|
-
if event.amount == 0 and event.attackType ==
|
|
758
|
+
if event.amount == 0 and event.attackType == 0 and event.damageType == DamageType.NORMAL and not event.isAttack then
|
|
760
759
|
Timer:run(function()
|
|
761
760
|
checkBuffs(target, true, source)
|
|
762
761
|
end)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "warscript",
|
|
4
|
-
"version": "0.0.1-dev.
|
|
4
|
+
"version": "0.0.1-dev.f4350ae",
|
|
5
5
|
"description": "A typescript library for Warcraft III using Warpack.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"warcraft",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@warscript/language-extensions": "^0.0.1",
|
|
25
25
|
"@warscript/tstl-plugin": "^0.0.4",
|
|
26
26
|
"lua-types": "^2.13.1",
|
|
27
|
-
"warpack": "0.0.1-dev.
|
|
27
|
+
"warpack": "0.0.1-dev.fa5e065"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
package/utility/arrays.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare const mapToLuaSet: {
|
|
|
22
22
|
<T, R extends AnyNotNil>(array: readonly T[], transform: (value: T) => R): LuaSet<R>;
|
|
23
23
|
<T, K extends KeysOfType<T, AnyNotNil>>(array: readonly T[], key: K): LuaSet<T[K] extends AnyNotNil ? T[K] : never>;
|
|
24
24
|
};
|
|
25
|
+
export declare const flatten: <T>(array: readonly (readonly T[])[]) => T[];
|
|
25
26
|
export declare const flatMap: {
|
|
26
27
|
<T, R>(array: readonly T[], transform: (value: T) => readonly R[]): R[];
|
|
27
28
|
<T, K extends KeysOfType<T, readonly any[]>>(array: readonly T[], key: K): (T[K] extends readonly (infer R)[] ? R : never)[];
|
package/utility/arrays.lua
CHANGED
|
@@ -3,6 +3,8 @@ local __TS__New = ____lualib.__TS__New
|
|
|
3
3
|
local ____exports = {}
|
|
4
4
|
local ____exception = require("exception")
|
|
5
5
|
local IllegalArgumentException = ____exception.IllegalArgumentException
|
|
6
|
+
local ____functions = require("utility.functions")
|
|
7
|
+
local identity = ____functions.identity
|
|
6
8
|
local mathMax = math.max
|
|
7
9
|
local mathMin = math.min
|
|
8
10
|
local select = _G.select
|
|
@@ -120,6 +122,7 @@ ____exports.mapToLuaSet = function(array, transform)
|
|
|
120
122
|
end
|
|
121
123
|
return result
|
|
122
124
|
end
|
|
125
|
+
____exports.flatten = function(array) return ____exports.flatMap(array, identity) end
|
|
123
126
|
____exports.flatMap = function(array, transform)
|
|
124
127
|
local result = {}
|
|
125
128
|
local k = 1
|
package/utility/functions.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare const apply: {
|
|
|
3
3
|
<T, ConsumerParameters extends any[]>(object: T, consumer: (value: T, ...parameters: ConsumerParameters) => void, ...parameters: ConsumerParameters): T;
|
|
4
4
|
<T, ConsumerParameters extends any[], K extends KeysOfType<T, (...parameters: ConsumerParameters) => void>>(object: T, key: K, ...parameters: ConsumerParameters): T;
|
|
5
5
|
};
|
|
6
|
+
export declare const identity: <T>(value: T) => T;
|
package/utility/functions.lua
CHANGED
package/utility/linked-set.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export declare class LinkedSet<T extends AnyNotNil> implements ReadonlyLinkedSet
|
|
|
50
50
|
protected __pairs(this: LinkedSet<T>): LuaIterator<T | undefined, IteratorState<T>>;
|
|
51
51
|
}
|
|
52
52
|
export declare const emptyLinkedSet: <T extends AnyNotNil>() => ReadonlyLinkedSet<T>;
|
|
53
|
+
export declare const mutableLinkedSet: <T extends AnyNotNil>() => LinkedSet<T>;
|
|
53
54
|
export declare const mutableLinkedSetOf: <T extends AnyNotNil>(...elements: ReadonlyArray<T>) => LinkedSet<T>;
|
|
54
55
|
export declare const mutableLinkedSetOfNotNull: <T extends AnyNotNil>(...elements: readonly (T | undefined | null)[]) => LinkedSet<T>;
|
|
55
56
|
export declare const linkedSetOf: <T extends AnyNotNil>(...elements: ReadonlyArray<T>) => ReadonlyLinkedSet<T>;
|