@quenty/rogue-properties 11.22.0 → 11.22.2-canary.547.11ae689.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/CHANGELOG.md +23 -0
- package/LICENSE.md +1 -1
- package/package.json +25 -25
- package/src/Shared/Array/RoguePropertyArrayUtils.lua +19 -16
- package/src/Shared/Cache/RoguePropertyCache.lua +0 -1
- package/src/Shared/Cache/RoguePropertyCacheService.lua +3 -3
- package/src/Shared/Definition/RoguePropertyDefinition.lua +2 -2
- package/src/Shared/Definition/RoguePropertyDefinitionArrayHelper.lua +13 -6
- package/src/Shared/Definition/RoguePropertyTableDefinition.lua +17 -14
- package/src/Shared/Implementation/RogueProperty.lua +25 -23
- package/src/Shared/Implementation/RoguePropertyArrayHelper.lua +9 -10
- package/src/Shared/Implementation/RoguePropertyTable.lua +7 -7
- package/src/Shared/RoguePropertyService.lua +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [11.22.2-canary.547.11ae689.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rogue-properties@11.22.0...@quenty/rogue-properties@11.22.2-canary.547.11ae689.0) (2025-04-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
12
|
+
* Bump package versions for republishing ([ba47c62](https://github.com/Quenty/NevermoreEngine/commit/ba47c62e32170bf74377b0c658c60b84306dc294))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [11.22.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rogue-properties@11.22.0...@quenty/rogue-properties@11.22.1) (2025-04-07)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
# [11.22.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rogue-properties@11.21.5...@quenty/rogue-properties@11.22.0) (2025-04-02)
|
|
7
30
|
|
|
8
31
|
**Note:** Version bump only for package @quenty/rogue-properties
|
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2014-
|
|
3
|
+
Copyright (c) 2014-2025 James Onnen (Quenty)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/rogue-properties",
|
|
3
|
-
"version": "11.22.0",
|
|
3
|
+
"version": "11.22.2-canary.547.11ae689.0",
|
|
4
4
|
"description": "Roguelike properties which can be modified by external provides",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -24,33 +24,33 @@
|
|
|
24
24
|
"Quenty"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@quenty/adorneedata": "
|
|
28
|
-
"@quenty/baseobject": "
|
|
29
|
-
"@quenty/binder": "
|
|
30
|
-
"@quenty/brio": "
|
|
31
|
-
"@quenty/defaultvalueutils": "
|
|
32
|
-
"@quenty/ducktype": "
|
|
33
|
-
"@quenty/instanceutils": "
|
|
34
|
-
"@quenty/jsonutils": "
|
|
35
|
-
"@quenty/linkutils": "
|
|
36
|
-
"@quenty/loader": "
|
|
37
|
-
"@quenty/maid": "
|
|
38
|
-
"@quenty/observablecollection": "
|
|
39
|
-
"@quenty/rx": "
|
|
40
|
-
"@quenty/rxbinderutils": "
|
|
41
|
-
"@quenty/rxsignal": "
|
|
42
|
-
"@quenty/servicebag": "
|
|
43
|
-
"@quenty/signal": "
|
|
44
|
-
"@quenty/spring": "
|
|
45
|
-
"@quenty/string": "
|
|
46
|
-
"@quenty/table": "
|
|
47
|
-
"@quenty/tie": "
|
|
48
|
-
"@quenty/valuebaseutils": "
|
|
49
|
-
"@quenty/valueobject": "
|
|
27
|
+
"@quenty/adorneedata": "7.18.2-canary.547.11ae689.0",
|
|
28
|
+
"@quenty/baseobject": "10.8.2-canary.547.11ae689.0",
|
|
29
|
+
"@quenty/binder": "14.19.2-canary.547.11ae689.0",
|
|
30
|
+
"@quenty/brio": "14.17.2-canary.547.11ae689.0",
|
|
31
|
+
"@quenty/defaultvalueutils": "1.2.2-canary.547.11ae689.0",
|
|
32
|
+
"@quenty/ducktype": "5.8.3-canary.547.11ae689.0",
|
|
33
|
+
"@quenty/instanceutils": "13.17.2-canary.547.11ae689.0",
|
|
34
|
+
"@quenty/jsonutils": "10.10.3-canary.547.11ae689.0",
|
|
35
|
+
"@quenty/linkutils": "13.17.2-canary.547.11ae689.0",
|
|
36
|
+
"@quenty/loader": "10.8.2-canary.547.11ae689.0",
|
|
37
|
+
"@quenty/maid": "3.4.2-canary.547.11ae689.0",
|
|
38
|
+
"@quenty/observablecollection": "12.20.2-canary.547.11ae689.0",
|
|
39
|
+
"@quenty/rx": "13.17.2-canary.547.11ae689.0",
|
|
40
|
+
"@quenty/rxbinderutils": "14.19.2-canary.547.11ae689.0",
|
|
41
|
+
"@quenty/rxsignal": "7.17.2-canary.547.11ae689.0",
|
|
42
|
+
"@quenty/servicebag": "11.11.3-canary.547.11ae689.0",
|
|
43
|
+
"@quenty/signal": "7.10.2-canary.547.11ae689.0",
|
|
44
|
+
"@quenty/spring": "10.8.3-canary.547.11ae689.0",
|
|
45
|
+
"@quenty/string": "3.3.3-canary.547.11ae689.0",
|
|
46
|
+
"@quenty/table": "3.7.3-canary.547.11ae689.0",
|
|
47
|
+
"@quenty/tie": "10.20.2-canary.547.11ae689.0",
|
|
48
|
+
"@quenty/valuebaseutils": "13.17.2-canary.547.11ae689.0",
|
|
49
|
+
"@quenty/valueobject": "13.17.2-canary.547.11ae689.0",
|
|
50
50
|
"@quentystudios/t": "^3.0.0"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "11ae6894c9c40c596e521dc1d2a71977af63752f"
|
|
56
56
|
}
|
|
@@ -10,11 +10,11 @@ local DefaultValueUtils = require("DefaultValueUtils")
|
|
|
10
10
|
|
|
11
11
|
local RoguePropertyArrayUtils = {}
|
|
12
12
|
|
|
13
|
-
function RoguePropertyArrayUtils.getNameFromIndex(index)
|
|
13
|
+
function RoguePropertyArrayUtils.getNameFromIndex(index: number): string
|
|
14
14
|
return RoguePropertyArrayConstants.ARRAY_ENTRY_PERFIX .. tostring(index)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
function RoguePropertyArrayUtils.getIndexFromName(name)
|
|
17
|
+
function RoguePropertyArrayUtils.getIndexFromName(name: string): number?
|
|
18
18
|
return tonumber(String.removePrefix(name, RoguePropertyArrayConstants.ARRAY_ENTRY_PERFIX))
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -26,7 +26,7 @@ function RoguePropertyArrayUtils.createRequiredPropertyDefinitionFromArray(array
|
|
|
26
26
|
return nil, "Missing array data"
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
for index, item in
|
|
29
|
+
for index, item in arrayData do
|
|
30
30
|
if typeof(item) ~= expectedType then
|
|
31
31
|
expectedType = nil
|
|
32
32
|
-- TODO: Maybe union?
|
|
@@ -38,7 +38,7 @@ function RoguePropertyArrayUtils.createRequiredPropertyDefinitionFromArray(array
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
function RoguePropertyArrayUtils.createRequiredTableDefinition(arrayData, parentPropertyTableDefinition)
|
|
41
|
-
local RoguePropertyTableDefinition = require("RoguePropertyTableDefinition")
|
|
41
|
+
local RoguePropertyTableDefinition = (require :: any)("RoguePropertyTableDefinition")
|
|
42
42
|
|
|
43
43
|
local entry = arrayData[1]
|
|
44
44
|
if type(entry) ~= "table" then
|
|
@@ -51,7 +51,7 @@ function RoguePropertyArrayUtils.createRequiredTableDefinition(arrayData, parent
|
|
|
51
51
|
propertyDefinition:SetParentPropertyTableDefinition(parentPropertyTableDefinition)
|
|
52
52
|
propertyDefinition:SetDefaultValue(DefaultValueUtils.toDefaultValue(entry))
|
|
53
53
|
|
|
54
|
-
for _, item in
|
|
54
|
+
for _, item in arrayData do
|
|
55
55
|
local canAssign, message = propertyDefinition:CanAssign(item, true)
|
|
56
56
|
if not canAssign then
|
|
57
57
|
return nil, string.format("Cannot assign due to %q", message)
|
|
@@ -61,8 +61,11 @@ function RoguePropertyArrayUtils.createRequiredTableDefinition(arrayData, parent
|
|
|
61
61
|
return propertyDefinition
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
function RoguePropertyArrayUtils.createRequiredPropertyDefinitionFromType(
|
|
65
|
-
|
|
64
|
+
function RoguePropertyArrayUtils.createRequiredPropertyDefinitionFromType(
|
|
65
|
+
expectedType: string,
|
|
66
|
+
parentPropertyTableDefinition
|
|
67
|
+
)
|
|
68
|
+
local RoguePropertyDefinition = (require :: any)("RoguePropertyDefinition")
|
|
66
69
|
|
|
67
70
|
local default = DefaultValueUtils.getDefaultValueForType(expectedType)
|
|
68
71
|
if default == nil then
|
|
@@ -77,13 +80,13 @@ function RoguePropertyArrayUtils.createRequiredPropertyDefinitionFromType(expect
|
|
|
77
80
|
return propertyDefinition
|
|
78
81
|
end
|
|
79
82
|
|
|
80
|
-
function RoguePropertyArrayUtils.createDefinitionsFromContainer(container, parentPropertyTableDefinition)
|
|
81
|
-
local RoguePropertyTableDefinition = require("RoguePropertyTableDefinition")
|
|
82
|
-
local RoguePropertyDefinition = require("RoguePropertyDefinition")
|
|
83
|
+
function RoguePropertyArrayUtils.createDefinitionsFromContainer(container: Instance, parentPropertyTableDefinition)
|
|
84
|
+
local RoguePropertyTableDefinition = (require :: any)("RoguePropertyTableDefinition")
|
|
85
|
+
local RoguePropertyDefinition = (require :: any)("RoguePropertyDefinition")
|
|
83
86
|
|
|
84
87
|
local value = {}
|
|
85
88
|
|
|
86
|
-
for _, item in
|
|
89
|
+
for _, item in container:GetChildren() do
|
|
87
90
|
local index = RoguePropertyArrayUtils.getIndexFromName(item.Name)
|
|
88
91
|
if not index then
|
|
89
92
|
continue
|
|
@@ -108,10 +111,10 @@ function RoguePropertyArrayUtils.createDefinitionsFromContainer(container, paren
|
|
|
108
111
|
return value
|
|
109
112
|
end
|
|
110
113
|
|
|
111
|
-
function RoguePropertyArrayUtils.getDefaultValueMapFromContainer(container)
|
|
114
|
+
function RoguePropertyArrayUtils.getDefaultValueMapFromContainer(container: Instance)
|
|
112
115
|
local value = {}
|
|
113
116
|
|
|
114
|
-
for _, item in
|
|
117
|
+
for _, item in container:GetChildren() do
|
|
115
118
|
local index = RoguePropertyArrayUtils.getIndexFromName(item.Name)
|
|
116
119
|
if index then
|
|
117
120
|
if item:IsA("Folder") then
|
|
@@ -132,11 +135,11 @@ function RoguePropertyArrayUtils.getDefaultValueMapFromContainer(container)
|
|
|
132
135
|
end
|
|
133
136
|
|
|
134
137
|
function RoguePropertyArrayUtils.createDefinitionsFromArrayData(arrayData, propertyTableDefinition)
|
|
135
|
-
local RoguePropertyTableDefinition = require("RoguePropertyTableDefinition")
|
|
136
|
-
local RoguePropertyDefinition = require("RoguePropertyDefinition")
|
|
138
|
+
local RoguePropertyTableDefinition = (require :: any)("RoguePropertyTableDefinition")
|
|
139
|
+
local RoguePropertyDefinition = (require :: any)("RoguePropertyDefinition")
|
|
137
140
|
|
|
138
141
|
local definitions = {}
|
|
139
|
-
for index, defaultValue in
|
|
142
|
+
for index, defaultValue in arrayData do
|
|
140
143
|
local name = RoguePropertyArrayUtils.getNameFromIndex(index)
|
|
141
144
|
|
|
142
145
|
if type(defaultValue) == "table" then
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
@class RoguePropertyCacheService
|
|
6
6
|
]=]
|
|
7
7
|
|
|
8
|
-
local RunService = game:GetService("RunService")
|
|
9
|
-
|
|
10
8
|
local require = require(script.Parent.loader).load(script)
|
|
9
|
+
local RunService = game:GetService("RunService")
|
|
11
10
|
|
|
12
11
|
local RoguePropertyCache = require("RoguePropertyCache")
|
|
12
|
+
local _ServiceBag = require("ServiceBag")
|
|
13
13
|
|
|
14
14
|
local RoguePropertyCacheService = {}
|
|
15
15
|
RoguePropertyCacheService.ServiceName = "RoguePropertyCacheService"
|
|
16
16
|
|
|
17
|
-
function RoguePropertyCacheService:Init(serviceBag)
|
|
17
|
+
function RoguePropertyCacheService:Init(serviceBag: _ServiceBag.ServiceBag)
|
|
18
18
|
assert(not self._serviceBag, "Already initialized")
|
|
19
19
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
20
20
|
|
|
@@ -32,7 +32,7 @@ function RoguePropertyDefinition:SetDefaultValue(defaultValue)
|
|
|
32
32
|
self._encodedDefaultValue = RoguePropertyUtils.encodeProperty(self, self._defaultValue)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
function RoguePropertyDefinition.isRoguePropertyDefinition(value)
|
|
35
|
+
function RoguePropertyDefinition.isRoguePropertyDefinition(value: any): boolean
|
|
36
36
|
return DuckTypeUtils.isImplementation(RoguePropertyDefinition, value)
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -84,7 +84,7 @@ function RoguePropertyDefinition:CanAssign(value, _strict)
|
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
function RoguePropertyDefinition:SetName(name)
|
|
87
|
+
function RoguePropertyDefinition:SetName(name: string)
|
|
88
88
|
assert(type(name) == "string", "Bad name")
|
|
89
89
|
|
|
90
90
|
self._name = name
|
|
@@ -20,7 +20,7 @@ function RoguePropertyDefinitionArrayHelper.new(propertyTableDefinition, default
|
|
|
20
20
|
return self
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
function RoguePropertyDefinitionArrayHelper:IsArray()
|
|
23
|
+
function RoguePropertyDefinitionArrayHelper:IsArray(): boolean
|
|
24
24
|
return self._defaultArrayData ~= nil
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -37,7 +37,8 @@ function RoguePropertyDefinitionArrayHelper:GetDefaultDefinitions()
|
|
|
37
37
|
return self._defaultDefinitions
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
self._defaultDefinitions =
|
|
40
|
+
self._defaultDefinitions =
|
|
41
|
+
RoguePropertyArrayUtils.createDefinitionsFromArrayData(self._defaultArrayData, self._propertyTableDefinition)
|
|
41
42
|
return self._defaultDefinitions
|
|
42
43
|
end
|
|
43
44
|
|
|
@@ -45,16 +46,22 @@ function RoguePropertyDefinitionArrayHelper:GetRequiredPropertyDefinition()
|
|
|
45
46
|
return self._requiredPropertyDefinition
|
|
46
47
|
end
|
|
47
48
|
|
|
48
|
-
function RoguePropertyDefinitionArrayHelper:CanAssign(arrayValue, strict)
|
|
49
|
+
function RoguePropertyDefinitionArrayHelper:CanAssign(arrayValue, strict): boolean
|
|
49
50
|
if type(arrayValue) ~= "table" then
|
|
50
51
|
return false, string.format("got %q, expected %q", self._valueType, typeof(arrayValue))
|
|
51
52
|
end
|
|
52
53
|
|
|
53
|
-
for key, value in
|
|
54
|
+
for key, value in arrayValue do
|
|
54
55
|
if type(key) == "number" then
|
|
55
56
|
local canAssign, message = self._requiredPropertyDefinition:CanAssign(value, strict)
|
|
56
57
|
if not canAssign then
|
|
57
|
-
return false,
|
|
58
|
+
return false,
|
|
59
|
+
string.format(
|
|
60
|
+
"Array at %s was %q, cannot assign due to %q",
|
|
61
|
+
tostring(key),
|
|
62
|
+
typeof(value),
|
|
63
|
+
tostring(message)
|
|
64
|
+
)
|
|
58
65
|
end
|
|
59
66
|
end
|
|
60
67
|
end
|
|
@@ -62,7 +69,7 @@ function RoguePropertyDefinitionArrayHelper:CanAssign(arrayValue, strict)
|
|
|
62
69
|
return true
|
|
63
70
|
end
|
|
64
71
|
|
|
65
|
-
function RoguePropertyDefinitionArrayHelper:CanAssignAsArrayMember(value, strict)
|
|
72
|
+
function RoguePropertyDefinitionArrayHelper:CanAssignAsArrayMember(value, strict): boolean
|
|
66
73
|
assert(type(strict) == "boolean", "Bad strict")
|
|
67
74
|
|
|
68
75
|
return self._requiredPropertyDefinition:CanAssign(value, strict)
|
|
@@ -6,22 +6,23 @@
|
|
|
6
6
|
local require = require(script.Parent.loader).load(script)
|
|
7
7
|
|
|
8
8
|
local DuckTypeUtils = require("DuckTypeUtils")
|
|
9
|
+
local RoguePropertyArrayUtils = (require :: any)("RoguePropertyArrayUtils")
|
|
10
|
+
local RoguePropertyCacheService = require("RoguePropertyCacheService")
|
|
9
11
|
local RoguePropertyDefinition = require("RoguePropertyDefinition")
|
|
10
12
|
local RoguePropertyDefinitionArrayHelper = require("RoguePropertyDefinitionArrayHelper")
|
|
13
|
+
local RoguePropertyService = require("RoguePropertyService")
|
|
11
14
|
local RoguePropertyTable = require("RoguePropertyTable")
|
|
12
15
|
local RxBrioUtils = require("RxBrioUtils")
|
|
13
16
|
local RxInstanceUtils = require("RxInstanceUtils")
|
|
14
17
|
local ServiceBag = require("ServiceBag")
|
|
15
|
-
local RoguePropertyService = require("RoguePropertyService")
|
|
16
|
-
local RoguePropertyArrayUtils = require("RoguePropertyArrayUtils")
|
|
17
18
|
local Set = require("Set")
|
|
18
|
-
local
|
|
19
|
+
local _Table = require("Table")
|
|
19
20
|
|
|
20
21
|
local RoguePropertyTableDefinition = {} -- Inherits from RoguePropertyDefinition
|
|
21
22
|
RoguePropertyTableDefinition.ClassName = "RoguePropertyTableDefinition"
|
|
22
23
|
RoguePropertyTableDefinition.__index = RoguePropertyTableDefinition
|
|
23
24
|
|
|
24
|
-
function RoguePropertyTableDefinition.new(tableName,
|
|
25
|
+
function RoguePropertyTableDefinition.new(tableName: string?, defaultValueTable: _Table.Map<string, any>?)
|
|
25
26
|
local self = setmetatable(RoguePropertyDefinition.new(), RoguePropertyTableDefinition)
|
|
26
27
|
|
|
27
28
|
if tableName then
|
|
@@ -39,7 +40,7 @@ function RoguePropertyTableDefinition.isRoguePropertyTableDefinition(value): boo
|
|
|
39
40
|
return DuckTypeUtils.isImplementation(RoguePropertyTableDefinition, value)
|
|
40
41
|
end
|
|
41
42
|
|
|
42
|
-
function RoguePropertyTableDefinition:SetDefaultValue(defaultValueTable)
|
|
43
|
+
function RoguePropertyTableDefinition:SetDefaultValue(defaultValueTable: _Table.Map<string, any>?)
|
|
43
44
|
assert(type(defaultValueTable) == "table", "Bad defaultValueTable")
|
|
44
45
|
|
|
45
46
|
RoguePropertyDefinition.SetDefaultValue(self, defaultValueTable)
|
|
@@ -48,7 +49,7 @@ function RoguePropertyTableDefinition:SetDefaultValue(defaultValueTable)
|
|
|
48
49
|
|
|
49
50
|
local defaultArrayData = {}
|
|
50
51
|
|
|
51
|
-
for key, defaultValue in
|
|
52
|
+
for key, defaultValue in defaultValueTable do
|
|
52
53
|
if type(key) == "number" then
|
|
53
54
|
table.insert(defaultArrayData, defaultValue)
|
|
54
55
|
else
|
|
@@ -89,7 +90,7 @@ function RoguePropertyTableDefinition:SetDefaultValue(defaultValueTable)
|
|
|
89
90
|
end
|
|
90
91
|
end
|
|
91
92
|
|
|
92
|
-
function RoguePropertyTableDefinition:CanAssign(mainValue, strict: boolean): boolean
|
|
93
|
+
function RoguePropertyTableDefinition:CanAssign(mainValue, strict: boolean): (boolean, string?)
|
|
93
94
|
assert(type(strict) == "boolean", "Bad strict")
|
|
94
95
|
|
|
95
96
|
if type(mainValue) ~= "table" then
|
|
@@ -102,14 +103,14 @@ function RoguePropertyTableDefinition:CanAssign(mainValue, strict: boolean): boo
|
|
|
102
103
|
)
|
|
103
104
|
end
|
|
104
105
|
|
|
105
|
-
local remainingKeys
|
|
106
|
+
local remainingKeys: Set.Set<string>
|
|
106
107
|
if strict then
|
|
107
108
|
remainingKeys = Set.fromKeys(self._definitionMap)
|
|
108
109
|
else
|
|
109
110
|
remainingKeys = {}
|
|
110
111
|
end
|
|
111
112
|
|
|
112
|
-
for key, value in
|
|
113
|
+
for key, value in mainValue do
|
|
113
114
|
remainingKeys[key] = nil
|
|
114
115
|
|
|
115
116
|
if type(key) == "number" then
|
|
@@ -158,13 +159,13 @@ function RoguePropertyTableDefinition:CanAssign(mainValue, strict: boolean): boo
|
|
|
158
159
|
return false,
|
|
159
160
|
string.format(
|
|
160
161
|
"Had %d unassigned keys %q while assigning to %q",
|
|
161
|
-
|
|
162
|
-
table.concat(remainingKeys, ", "),
|
|
162
|
+
Set.count(remainingKeys),
|
|
163
|
+
table.concat(Set.toList(remainingKeys), ", "),
|
|
163
164
|
self:GetFullName()
|
|
164
165
|
)
|
|
165
166
|
end
|
|
166
167
|
|
|
167
|
-
return true
|
|
168
|
+
return true, nil
|
|
168
169
|
end
|
|
169
170
|
|
|
170
171
|
function RoguePropertyTableDefinition:GetDefinitionArrayHelper()
|
|
@@ -195,7 +196,7 @@ end
|
|
|
195
196
|
@param adornee Instance
|
|
196
197
|
@return RoguePropertyTable
|
|
197
198
|
]=]
|
|
198
|
-
function RoguePropertyTableDefinition:Get(serviceBag, adornee)
|
|
199
|
+
function RoguePropertyTableDefinition:Get(serviceBag, adornee: Instance)
|
|
199
200
|
assert(ServiceBag.isServiceBag(serviceBag), "Bad serviceBag")
|
|
200
201
|
assert(typeof(adornee) == "Instance", "Bad adornee")
|
|
201
202
|
|
|
@@ -288,7 +289,7 @@ function RoguePropertyTableDefinition:GetOrCreateInstance(parent)
|
|
|
288
289
|
return folder
|
|
289
290
|
end
|
|
290
291
|
|
|
291
|
-
function RoguePropertyTableDefinition:__index(index)
|
|
292
|
+
function RoguePropertyTableDefinition:__index(index: string)
|
|
292
293
|
assert(type(index) == "string", "Bad index")
|
|
293
294
|
|
|
294
295
|
if index == "_definitionMap" or index == "_arrayDefinitionHelper" or index == "_parentPropertyTableDefinition" then
|
|
@@ -318,6 +319,8 @@ function RoguePropertyTableDefinition:__index(index)
|
|
|
318
319
|
else
|
|
319
320
|
error(string.format("Bad definition %q - Not an array", tostring(index)))
|
|
320
321
|
end
|
|
322
|
+
else
|
|
323
|
+
error(string.format("Bad index %q", tostring(index)))
|
|
321
324
|
end
|
|
322
325
|
end
|
|
323
326
|
|
|
@@ -35,7 +35,7 @@ function RogueProperty.new(adornee, serviceBag, definition)
|
|
|
35
35
|
return setmetatable(self, RogueProperty)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
function RogueProperty:SetCanInitialize(canInitialize)
|
|
38
|
+
function RogueProperty:SetCanInitialize(canInitialize: boolean)
|
|
39
39
|
assert(type(canInitialize) == "boolean", "Bad canInitialize")
|
|
40
40
|
|
|
41
41
|
if rawget(self, "_canInitialize") ~= canInitialize then
|
|
@@ -154,7 +154,7 @@ function RogueProperty:GetValue()
|
|
|
154
154
|
|
|
155
155
|
local current = self:_decodeValue(propObj.Value)
|
|
156
156
|
|
|
157
|
-
for _, rogueModifier in
|
|
157
|
+
for _, rogueModifier in self:GetRogueModifiers() do
|
|
158
158
|
current = rogueModifier:GetModifiedVersion(current)
|
|
159
159
|
end
|
|
160
160
|
|
|
@@ -174,7 +174,7 @@ function RogueProperty:GetRogueModifiers()
|
|
|
174
174
|
local found = RogueModifierInterface:GetChildren(propObj)
|
|
175
175
|
|
|
176
176
|
local orders = {}
|
|
177
|
-
for _, item in
|
|
177
|
+
for _, item in found do
|
|
178
178
|
orders[item] = item.Order.Value
|
|
179
179
|
end
|
|
180
180
|
table.sort(found, function(a, b)
|
|
@@ -190,23 +190,25 @@ function RogueProperty:_observeModifierSortedList()
|
|
|
190
190
|
|
|
191
191
|
local sortedList = topMaid:Add(ObservableSortedList.new())
|
|
192
192
|
|
|
193
|
-
topMaid:GiveTask(self:_observeBaseValueBrio()
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
193
|
+
topMaid:GiveTask(self:_observeBaseValueBrio()
|
|
194
|
+
:Pipe({
|
|
195
|
+
RxBrioUtils.flatMapBrio(function(baseValue)
|
|
196
|
+
return RogueModifierInterface:ObserveChildrenBrio(baseValue)
|
|
197
|
+
end),
|
|
198
|
+
})
|
|
199
|
+
:Subscribe(function(brio)
|
|
200
|
+
if brio:IsDead() then
|
|
201
|
+
return
|
|
202
|
+
end
|
|
203
|
+
local maid, rogueModifier = brio:ToMaidAndValue()
|
|
204
|
+
maid:GiveTask(sortedList:Add(rogueModifier, rogueModifier.Order:Observe()))
|
|
205
|
+
end))
|
|
204
206
|
|
|
205
207
|
sub:Fire(sortedList)
|
|
206
208
|
|
|
207
209
|
return topMaid
|
|
208
210
|
end):Pipe({
|
|
209
|
-
Rx.cache()
|
|
211
|
+
Rx.cache(),
|
|
210
212
|
})
|
|
211
213
|
end
|
|
212
214
|
|
|
@@ -214,19 +216,19 @@ function RogueProperty:Observe()
|
|
|
214
216
|
local observeInitialValue = self:_observeBaseValueBrio():Pipe({
|
|
215
217
|
RxBrioUtils.switchMapBrio(function(baseValue)
|
|
216
218
|
return RxInstanceUtils.observeProperty(baseValue, "Value")
|
|
217
|
-
end)
|
|
218
|
-
RxBrioUtils.emitOnDeath(self._definition:GetDefaultValue())
|
|
219
|
-
Rx.defaultsTo(self._definition:GetDefaultValue())
|
|
220
|
-
Rx.distinct()
|
|
219
|
+
end),
|
|
220
|
+
RxBrioUtils.emitOnDeath(self._definition:GetDefaultValue()),
|
|
221
|
+
Rx.defaultsTo(self._definition:GetDefaultValue()),
|
|
222
|
+
Rx.distinct(),
|
|
221
223
|
})
|
|
222
224
|
|
|
223
225
|
return self:_observeModifierSortedList():Pipe({
|
|
224
226
|
Rx.switchMap(function(sortedList)
|
|
225
|
-
|
|
227
|
+
return sortedList:Observe()
|
|
226
228
|
end);
|
|
227
229
|
Rx.switchMap(function(rogueModifierList)
|
|
228
|
-
|
|
229
|
-
for _, rogueModifier in
|
|
230
|
+
local current = observeInitialValue
|
|
231
|
+
for _, rogueModifier in rogueModifierList do
|
|
230
232
|
current = rogueModifier:ObserveModifiedVersion(current)
|
|
231
233
|
end
|
|
232
234
|
return current
|
|
@@ -269,7 +271,7 @@ function RogueProperty:CreateMultiplier(amount, source)
|
|
|
269
271
|
return multiplier
|
|
270
272
|
end
|
|
271
273
|
|
|
272
|
-
function RogueProperty:CreateAdditive(amount, source)
|
|
274
|
+
function RogueProperty:CreateAdditive(amount: number, source)
|
|
273
275
|
assert(type(amount) == "number", "Bad amount")
|
|
274
276
|
|
|
275
277
|
local baseValue = self:GetBaseValueObject()
|
|
@@ -22,13 +22,13 @@ function RoguePropertyArrayHelper.new(serviceBag, arrayDefinitionHelper, roguePr
|
|
|
22
22
|
return self
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
function RoguePropertyArrayHelper:SetCanInitialize(canInitialize)
|
|
25
|
+
function RoguePropertyArrayHelper:SetCanInitialize(canInitialize: boolean)
|
|
26
26
|
if canInitialize then
|
|
27
27
|
self:GetArrayRogueProperties()
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
function RoguePropertyArrayHelper:GetArrayRogueProperty(index)
|
|
31
|
+
function RoguePropertyArrayHelper:GetArrayRogueProperty(index: number)
|
|
32
32
|
assert(type(index) == "number", "Bad index")
|
|
33
33
|
|
|
34
34
|
-- TODO: Maybe return something general for that index
|
|
@@ -47,7 +47,7 @@ function RoguePropertyArrayHelper:GetArrayRogueProperties()
|
|
|
47
47
|
if not (container and container:GetAttribute("HasInitializedArrayComponent")) then
|
|
48
48
|
container:SetAttribute("HasInitializedArrayComponent", true)
|
|
49
49
|
local properties = self:_getDefaultRogueProperties()
|
|
50
|
-
for _, rogueProperty in
|
|
50
|
+
for _, rogueProperty in properties do
|
|
51
51
|
-- Force initialization once and only once...
|
|
52
52
|
rogueProperty:SetCanInitialize(true)
|
|
53
53
|
rogueProperty:SetCanInitialize(false)
|
|
@@ -65,7 +65,7 @@ function RoguePropertyArrayHelper:GetArrayRogueProperties()
|
|
|
65
65
|
local definitions = RoguePropertyArrayUtils.createDefinitionsFromContainer(container, self._arrayDefinitionHelper:GetPropertyTableDefinition())
|
|
66
66
|
local rogueProperties = {}
|
|
67
67
|
|
|
68
|
-
for index, definition in
|
|
68
|
+
for index, definition in definitions do
|
|
69
69
|
local property = definition:Get(self._serviceBag, adornee)
|
|
70
70
|
property:SetCanInitialize(false) -- Explicitly not going to reinitialize
|
|
71
71
|
rogueProperties[index] = property
|
|
@@ -81,7 +81,7 @@ function RoguePropertyArrayHelper:_getDefaultRogueProperties()
|
|
|
81
81
|
|
|
82
82
|
local defaultRogueProperties = {}
|
|
83
83
|
local adornee = self._roguePropertyTable:GetAdornee()
|
|
84
|
-
for _, definition in
|
|
84
|
+
for _, definition in self._arrayDefinitionHelper:GetDefaultDefinitions() do
|
|
85
85
|
local property = definition:Get(self._serviceBag, adornee)
|
|
86
86
|
table.insert(defaultRogueProperties, property)
|
|
87
87
|
end
|
|
@@ -105,7 +105,7 @@ function RoguePropertyArrayHelper:SetArrayBaseData(arrayData)
|
|
|
105
105
|
local adornee = self._roguePropertyTable:GetAdornee()
|
|
106
106
|
local definitions = RoguePropertyArrayUtils.createDefinitionsFromArrayData(arrayData, parentPropertyTableDefinition)
|
|
107
107
|
|
|
108
|
-
for index, definition in
|
|
108
|
+
for index, definition in definitions do
|
|
109
109
|
if available[index] and available[index]:GetDefinition():GetValueType() == definition:GetValueType() then
|
|
110
110
|
available[index]:SetBaseValue(definition:GetDefaultValue())
|
|
111
111
|
else
|
|
@@ -140,7 +140,7 @@ function RoguePropertyArrayHelper:SetArrayData(arrayData)
|
|
|
140
140
|
local adornee = self._roguePropertyTable:GetAdornee()
|
|
141
141
|
local definitions = RoguePropertyArrayUtils.createDefinitionsFromArrayData(arrayData, parentPropertyTableDefinition)
|
|
142
142
|
|
|
143
|
-
for index, definition in
|
|
143
|
+
for index, definition in definitions do
|
|
144
144
|
if available[index] and available[index]:GetDefinition():GetValueType() == definition:GetValueType() then
|
|
145
145
|
available[index]:SetValue(definition:GetDefaultValue())
|
|
146
146
|
else
|
|
@@ -159,7 +159,7 @@ function RoguePropertyArrayHelper:SetArrayData(arrayData)
|
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
function RoguePropertyArrayHelper:_removeUnspecified(container, definitions)
|
|
162
|
-
for _, item in
|
|
162
|
+
for _, item in container:GetChildren() do
|
|
163
163
|
local index = RoguePropertyArrayUtils.getIndexFromName(item.Name)
|
|
164
164
|
if index then
|
|
165
165
|
if not definitions[index] then
|
|
@@ -169,7 +169,6 @@ function RoguePropertyArrayHelper:_removeUnspecified(container, definitions)
|
|
|
169
169
|
end
|
|
170
170
|
end
|
|
171
171
|
|
|
172
|
-
|
|
173
172
|
function RoguePropertyArrayHelper:GetArrayBaseValues()
|
|
174
173
|
local result = {}
|
|
175
174
|
for index, rogueProperty in pairs(self:GetArrayRogueProperties()) do
|
|
@@ -192,7 +191,7 @@ function RoguePropertyArrayHelper:ObserveArrayValues()
|
|
|
192
191
|
-- TODO: Allow for observing
|
|
193
192
|
local observables = {}
|
|
194
193
|
|
|
195
|
-
for _, rogueProperty in
|
|
194
|
+
for _, rogueProperty in self:GetArrayRogueProperties() do
|
|
196
195
|
table.insert(observables, rogueProperty:Observe())
|
|
197
196
|
end
|
|
198
197
|
|
|
@@ -12,7 +12,7 @@ local RoguePropertyTable = {} -- inherits from RogueProperty
|
|
|
12
12
|
RoguePropertyTable.ClassName = "RoguePropertyTable"
|
|
13
13
|
RoguePropertyTable.__index = RoguePropertyTable
|
|
14
14
|
|
|
15
|
-
function RoguePropertyTable.new(adornee, serviceBag, roguePropertyTableDefinition)
|
|
15
|
+
function RoguePropertyTable.new(adornee: Instance, serviceBag, roguePropertyTableDefinition)
|
|
16
16
|
local self = setmetatable(RogueProperty.new(adornee, serviceBag, roguePropertyTableDefinition), RoguePropertyTable)
|
|
17
17
|
|
|
18
18
|
rawset(self, "_properties", {})
|
|
@@ -25,12 +25,12 @@ function RoguePropertyTable.new(adornee, serviceBag, roguePropertyTableDefinitio
|
|
|
25
25
|
return self
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
function RoguePropertyTable:SetCanInitialize(canInitialize)
|
|
28
|
+
function RoguePropertyTable:SetCanInitialize(canInitialize: boolean)
|
|
29
29
|
assert(type(canInitialize) == "boolean", "Bad canInitialize")
|
|
30
30
|
|
|
31
31
|
RogueProperty.SetCanInitialize(self, canInitialize)
|
|
32
32
|
|
|
33
|
-
for _, property in
|
|
33
|
+
for _, property in self:GetRogueProperties() do
|
|
34
34
|
property:SetCanInitialize(canInitialize)
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -44,7 +44,7 @@ function RoguePropertyTable:ObserveContainerBrio()
|
|
|
44
44
|
return self._definition:ObserveContainerBrio(self._adornee, self:CanInitialize())
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
function RoguePropertyTable:GetContainer()
|
|
47
|
+
function RoguePropertyTable:GetContainer(): Instance
|
|
48
48
|
local cached = rawget(self, "_containerCache")
|
|
49
49
|
if cached and cached:IsDescendantOf(self._adornee) then
|
|
50
50
|
return cached
|
|
@@ -60,7 +60,7 @@ function RoguePropertyTable:SetBaseValue(newBaseValue)
|
|
|
60
60
|
|
|
61
61
|
local arrayData = {}
|
|
62
62
|
|
|
63
|
-
for propertyName, value in
|
|
63
|
+
for propertyName, value in newBaseValue do
|
|
64
64
|
if type(propertyName) == "string" then
|
|
65
65
|
local rogueProperty = self:GetRogueProperty(propertyName)
|
|
66
66
|
if not rogueProperty then
|
|
@@ -88,7 +88,7 @@ function RoguePropertyTable:SetValue(newValue)
|
|
|
88
88
|
|
|
89
89
|
local arrayData = {}
|
|
90
90
|
|
|
91
|
-
for propertyName, value in
|
|
91
|
+
for propertyName, value in newValue do
|
|
92
92
|
if type(propertyName) == "string" then
|
|
93
93
|
local rogueProperty = self:GetRogueProperty(propertyName)
|
|
94
94
|
if not rogueProperty then
|
|
@@ -185,7 +185,7 @@ function RoguePropertyTable:_observeDictionary()
|
|
|
185
185
|
return Rx.combineLatest(toObserve)
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
function RoguePropertyTable:GetRogueProperty(name)
|
|
188
|
+
function RoguePropertyTable:GetRogueProperty(name: string)
|
|
189
189
|
assert(type(name) == "string", "Bad name")
|
|
190
190
|
|
|
191
191
|
-- Caching these things doesn't do a whole lot, but saves on table allocation.
|
|
@@ -10,11 +10,12 @@ local require = require(script.Parent.loader).load(script)
|
|
|
10
10
|
local RunService = game:GetService("RunService")
|
|
11
11
|
|
|
12
12
|
local Maid = require("Maid")
|
|
13
|
+
local _ServiceBag = require("ServiceBag")
|
|
13
14
|
|
|
14
15
|
local RoguePropertyService = {}
|
|
15
16
|
RoguePropertyService.ServiceName = "RoguePropertyService"
|
|
16
17
|
|
|
17
|
-
function RoguePropertyService:Init(serviceBag)
|
|
18
|
+
function RoguePropertyService:Init(serviceBag: _ServiceBag.ServiceBag)
|
|
18
19
|
assert(not self._serviceBag, "Already initialized")
|
|
19
20
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
20
21
|
|
|
@@ -30,7 +31,7 @@ function RoguePropertyService:Init(serviceBag)
|
|
|
30
31
|
self._serviceBag:GetService(require("RogueSetter"))
|
|
31
32
|
end
|
|
32
33
|
|
|
33
|
-
function RoguePropertyService:CanInitializeProperties()
|
|
34
|
+
function RoguePropertyService:CanInitializeProperties(): boolean
|
|
34
35
|
return RunService:IsServer()
|
|
35
36
|
end
|
|
36
37
|
|