@quenty/rogue-properties 11.1.0 → 11.2.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
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rogue-properties@11.1.0...@quenty/rogue-properties@11.2.0) (2024-03-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Adjust calculations for additive providers ([b8e15e0](https://github.com/Quenty/NevermoreEngine/commit/b8e15e071499bbc55631ab5f0183e37c42b1d242))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [11.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rogue-properties@11.0.0...@quenty/rogue-properties@11.1.0) (2024-03-09)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/rogue-properties
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/rogue-properties",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "Roguelike properties which can be modified by external provides",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@quenty/baseobject": "^10.1.0",
|
|
28
|
-
"@quenty/binder": "^14.
|
|
28
|
+
"@quenty/binder": "^14.2.0",
|
|
29
29
|
"@quenty/brio": "^14.1.0",
|
|
30
30
|
"@quenty/defaultvalueutils": "^1.1.0",
|
|
31
31
|
"@quenty/ducktype": "^5.1.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@quenty/loader": "^10.1.0",
|
|
36
36
|
"@quenty/maid": "^3.1.0",
|
|
37
37
|
"@quenty/rx": "^13.1.0",
|
|
38
|
-
"@quenty/rxbinderutils": "^14.
|
|
38
|
+
"@quenty/rxbinderutils": "^14.2.0",
|
|
39
39
|
"@quenty/rxsignal": "^7.1.0",
|
|
40
40
|
"@quenty/servicebag": "^11.1.0",
|
|
41
41
|
"@quenty/signal": "^7.1.0",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "ab3631a54c4e8d448b4229c7e422a9c7f43c0dd7"
|
|
52
52
|
}
|
|
@@ -12,8 +12,7 @@ local BinderUtils = require("BinderUtils")
|
|
|
12
12
|
local RoguePropertyModifierUtils = require("RoguePropertyModifierUtils")
|
|
13
13
|
local RoguePropertyService = require("RoguePropertyService")
|
|
14
14
|
local Observable = require("Observable")
|
|
15
|
-
local
|
|
16
|
-
local ValueObject = require("ValueObject")
|
|
15
|
+
local RxBrioUtils = require("RxBrioUtils")
|
|
17
16
|
|
|
18
17
|
local RogueAdditiveProvider = {}
|
|
19
18
|
RogueAdditiveProvider.ServiceName = "RogueAdditiveProvider"
|
|
@@ -56,13 +55,7 @@ end
|
|
|
56
55
|
|
|
57
56
|
function RogueAdditiveProvider:GetInvertedVersion(propObj, rogueProperty, baseValue)
|
|
58
57
|
if rogueProperty:GetDefinition():GetValueType() == "number" then
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
for _, item in pairs(self:_getAdditives(propObj)) do
|
|
62
|
-
value = value - item:GetAdditive()
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
return value
|
|
58
|
+
return baseValue - self:_getTotalAdditive(propObj)
|
|
66
59
|
else
|
|
67
60
|
return baseValue
|
|
68
61
|
end
|
|
@@ -70,58 +63,39 @@ end
|
|
|
70
63
|
|
|
71
64
|
function RogueAdditiveProvider:GetModifiedVersion(propObj, rogueProperty, baseValue)
|
|
72
65
|
if rogueProperty:GetDefinition():GetValueType() == "number" then
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
for _, item in pairs(self:_getAdditives(propObj)) do
|
|
76
|
-
value = value + item:GetAdditive()
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
return value
|
|
66
|
+
return baseValue + self:_getTotalAdditive(propObj)
|
|
80
67
|
else
|
|
81
68
|
return baseValue
|
|
82
69
|
end
|
|
83
70
|
end
|
|
84
71
|
|
|
85
72
|
function RogueAdditiveProvider:ObserveModifiedVersion(propObj, rogueProperty, observeBaseValue)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
local topMaid = Maid.new()
|
|
89
|
-
|
|
90
|
-
local lastValue = topMaid:Add(ValueObject.fromObservable(observeBaseValue))
|
|
91
|
-
|
|
92
|
-
local function update()
|
|
93
|
-
sub:Fire(lastValue.Value)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
topMaid:GiveTask(self:_observeAddersBrio(propObj):Subscribe(function(brio)
|
|
97
|
-
if brio:IsDead() then
|
|
98
|
-
return
|
|
99
|
-
end
|
|
73
|
+
assert(rogueProperty, "No rogueProperty")
|
|
74
|
+
assert(Observable.isObservable(observeBaseValue), "Bad observeBaseValue")
|
|
100
75
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
Rx.map(function(baseValue)
|
|
123
|
-
return self:GetModifiedVersion(propObj, rogueProperty, baseValue)
|
|
76
|
+
if rogueProperty:GetDefinition():GetValueType() == "number" then
|
|
77
|
+
return RxBrioUtils.flatCombineLatest({
|
|
78
|
+
baseValue = observeBaseValue;
|
|
79
|
+
additive = self:_observeAddersBrio(propObj):Pipe({
|
|
80
|
+
RxBrioUtils.flatMapBrio(function(item)
|
|
81
|
+
return item:ObserveAdditive();
|
|
82
|
+
end);
|
|
83
|
+
RxBrioUtils.reduceToAliveList();
|
|
84
|
+
RxBrioUtils.switchMapBrio(function(state)
|
|
85
|
+
local additive = 0
|
|
86
|
+
for _, item in pairs(state) do
|
|
87
|
+
additive = additive + item
|
|
88
|
+
end
|
|
89
|
+
return Rx.of(additive)
|
|
90
|
+
end);
|
|
91
|
+
RxBrioUtils.emitOnDeath(0);
|
|
92
|
+
Rx.distinct();
|
|
93
|
+
});
|
|
94
|
+
}):Pipe({
|
|
95
|
+
Rx.map(function(state)
|
|
96
|
+
return state.baseValue + state.additive
|
|
124
97
|
end);
|
|
98
|
+
Rx.distinct();
|
|
125
99
|
})
|
|
126
100
|
else
|
|
127
101
|
return observeBaseValue
|
|
@@ -132,8 +106,12 @@ function RogueAdditiveProvider:_observeAddersBrio(propObj)
|
|
|
132
106
|
return RxBinderUtils.observeBoundChildClassBrio(self._rogueAdditiveBinder, propObj)
|
|
133
107
|
end
|
|
134
108
|
|
|
135
|
-
function RogueAdditiveProvider:
|
|
136
|
-
|
|
109
|
+
function RogueAdditiveProvider:_getTotalAdditive(propObj)
|
|
110
|
+
local additive = 0
|
|
111
|
+
for _, item in pairs(BinderUtils.getChildren(self._rogueAdditiveBinder, propObj)) do
|
|
112
|
+
additive = additive + item:GetAdditive()
|
|
113
|
+
end
|
|
114
|
+
return additive
|
|
137
115
|
end
|
|
138
116
|
|
|
139
117
|
return RogueAdditiveProvider
|
|
@@ -12,8 +12,7 @@ local BinderUtils = require("BinderUtils")
|
|
|
12
12
|
local RoguePropertyModifierUtils = require("RoguePropertyModifierUtils")
|
|
13
13
|
local RoguePropertyService = require("RoguePropertyService")
|
|
14
14
|
local Observable = require("Observable")
|
|
15
|
-
local
|
|
16
|
-
local ValueObject = require("ValueObject")
|
|
15
|
+
local RxBrioUtils = require("RxBrioUtils")
|
|
17
16
|
|
|
18
17
|
local RogueMultiplierProvider = {}
|
|
19
18
|
RogueMultiplierProvider.ServiceName = "RogueMultiplierProvider"
|
|
@@ -56,11 +55,7 @@ end
|
|
|
56
55
|
|
|
57
56
|
function RogueMultiplierProvider:GetInvertedVersion(propObj, rogueProperty, baseValue)
|
|
58
57
|
if rogueProperty:GetDefinition():GetValueType() == "number" then
|
|
59
|
-
local multiplier =
|
|
60
|
-
|
|
61
|
-
for _, item in pairs(self:_getMultipliers(propObj)) do
|
|
62
|
-
multiplier = multiplier*item:GetMultiplier()
|
|
63
|
-
end
|
|
58
|
+
local multiplier = self:_getTotalMultiplier(propObj)
|
|
64
59
|
|
|
65
60
|
return baseValue/multiplier
|
|
66
61
|
else
|
|
@@ -70,11 +65,7 @@ end
|
|
|
70
65
|
|
|
71
66
|
function RogueMultiplierProvider:GetModifiedVersion(propObj, rogueProperty, baseValue)
|
|
72
67
|
if rogueProperty:GetDefinition():GetValueType() == "number" then
|
|
73
|
-
local multiplier =
|
|
74
|
-
|
|
75
|
-
for _, item in pairs(self:_getMultipliers(propObj)) do
|
|
76
|
-
multiplier = multiplier*item:GetMultiplier()
|
|
77
|
-
end
|
|
68
|
+
local multiplier = self:_getTotalMultiplier(propObj)
|
|
78
69
|
|
|
79
70
|
return baseValue*multiplier
|
|
80
71
|
else
|
|
@@ -83,45 +74,32 @@ function RogueMultiplierProvider:GetModifiedVersion(propObj, rogueProperty, base
|
|
|
83
74
|
end
|
|
84
75
|
|
|
85
76
|
function RogueMultiplierProvider:ObserveModifiedVersion(propObj, rogueProperty, observeBaseValue)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
local topMaid = Maid.new()
|
|
89
|
-
|
|
90
|
-
local lastValue = topMaid:Add(ValueObject.fromObservable(observeBaseValue))
|
|
91
|
-
|
|
92
|
-
local function update()
|
|
93
|
-
sub:Fire(lastValue.Value)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
topMaid:GiveTask(self:_observeMultipliersBrio(propObj):Subscribe(function(brio)
|
|
97
|
-
if brio:IsDead() then
|
|
98
|
-
return
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
local maid = brio:ToMaid()
|
|
102
|
-
local value = brio:GetValue()
|
|
77
|
+
assert(rogueProperty, "No rogueProperty")
|
|
78
|
+
assert(Observable.isObservable(observeBaseValue), "Bad observeBaseValue")
|
|
103
79
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
80
|
+
if rogueProperty:GetDefinition():GetValueType() == "number" then
|
|
81
|
+
return RxBrioUtils.flatCombineLatest({
|
|
82
|
+
baseValue = observeBaseValue;
|
|
83
|
+
multiplier = self:_observeMultipliersBrio(propObj):Pipe({
|
|
84
|
+
RxBrioUtils.flatMapBrio(function(item)
|
|
85
|
+
return item:ObserveMultiplier();
|
|
86
|
+
end);
|
|
87
|
+
RxBrioUtils.reduceToAliveList();
|
|
88
|
+
RxBrioUtils.switchMapBrio(function(state)
|
|
89
|
+
local multiplier = 1
|
|
90
|
+
for _, item in pairs(state) do
|
|
91
|
+
multiplier = multiplier*item
|
|
92
|
+
end
|
|
93
|
+
return Rx.of(multiplier)
|
|
94
|
+
end);
|
|
95
|
+
RxBrioUtils.emitOnDeath(1);
|
|
96
|
+
Rx.distinct();
|
|
97
|
+
});
|
|
98
|
+
}):Pipe({
|
|
99
|
+
Rx.map(function(state)
|
|
100
|
+
return state.baseValue*state.multiplier
|
|
124
101
|
end);
|
|
102
|
+
Rx.distinct();
|
|
125
103
|
})
|
|
126
104
|
else
|
|
127
105
|
return observeBaseValue
|
|
@@ -132,8 +110,12 @@ function RogueMultiplierProvider:_observeMultipliersBrio(propObj)
|
|
|
132
110
|
return RxBinderUtils.observeBoundChildClassBrio(self._rogueMultiplierBinder, propObj)
|
|
133
111
|
end
|
|
134
112
|
|
|
135
|
-
function RogueMultiplierProvider:
|
|
136
|
-
|
|
113
|
+
function RogueMultiplierProvider:_getTotalMultiplier(propObj)
|
|
114
|
+
local multiplier = 1
|
|
115
|
+
for _, item in pairs(BinderUtils.getChildren(self._rogueMultiplierBinder, propObj)) do
|
|
116
|
+
multiplier = multiplier*item:GetMultiplier()
|
|
117
|
+
end
|
|
118
|
+
return multiplier
|
|
137
119
|
end
|
|
138
120
|
|
|
139
121
|
return RogueMultiplierProvider
|
|
@@ -11,6 +11,7 @@ local BinderUtils = require("BinderUtils")
|
|
|
11
11
|
local RoguePropertyModifierUtils = require("RoguePropertyModifierUtils")
|
|
12
12
|
local RoguePropertyService = require("RoguePropertyService")
|
|
13
13
|
local ValueBaseUtils = require("ValueBaseUtils")
|
|
14
|
+
local Observable = require("Observable")
|
|
14
15
|
|
|
15
16
|
local RogueSetterProvider = {}
|
|
16
17
|
RogueSetterProvider.ServiceName = "RogueSetterProvider"
|
|
@@ -67,19 +68,37 @@ function RogueSetterProvider:GetModifiedVersion(propObj, _rogueProperty, baseVal
|
|
|
67
68
|
end
|
|
68
69
|
|
|
69
70
|
function RogueSetterProvider:ObserveModifiedVersion(propObj, rogueProperty, observeBaseValue)
|
|
71
|
+
assert(rogueProperty, "No rogueProperty")
|
|
72
|
+
assert(Observable.isObservable(observeBaseValue), "Bad observeBaseValue")
|
|
73
|
+
|
|
70
74
|
-- TODO: optimize this.
|
|
71
75
|
return RxBrioUtils.flatCombineLatest({
|
|
72
76
|
value = observeBaseValue;
|
|
73
|
-
|
|
77
|
+
prioritySetter = self:_observeSettersBrio(propObj):Pipe({
|
|
74
78
|
RxBrioUtils.flatMapBrio(function(item)
|
|
75
79
|
return item:ObserveValue();
|
|
76
|
-
end);
|
|
77
|
-
|
|
80
|
+
end);
|
|
81
|
+
RxBrioUtils.reduceToAliveList();
|
|
82
|
+
RxBrioUtils.switchMapBrio(function(state)
|
|
83
|
+
local lastSetter = nil
|
|
84
|
+
for _, item in pairs(state) do
|
|
85
|
+
lastSetter = item
|
|
86
|
+
end
|
|
87
|
+
return Rx.of(lastSetter)
|
|
88
|
+
end);
|
|
89
|
+
-- TODO: Emit token instead
|
|
90
|
+
RxBrioUtils.emitOnDeath(nil);
|
|
91
|
+
Rx.distinct();
|
|
78
92
|
});
|
|
79
93
|
}):Pipe({
|
|
80
94
|
Rx.map(function(state)
|
|
81
|
-
|
|
95
|
+
if state.prioritySetter ~= nil then
|
|
96
|
+
return state.prioritySetter
|
|
97
|
+
else
|
|
98
|
+
return state.value
|
|
99
|
+
end
|
|
82
100
|
end);
|
|
101
|
+
Rx.distinct();
|
|
83
102
|
})
|
|
84
103
|
end
|
|
85
104
|
|