@quenty/adorneevalue 10.18.2 → 10.18.3
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 +8 -0
- package/package.json +7 -7
- package/src/Shared/AdorneeValue.lua +38 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [10.18.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/adorneevalue@10.18.2...@quenty/adorneevalue@10.18.3) (2025-04-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/adorneevalue
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [10.18.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/adorneevalue@10.18.0...@quenty/adorneevalue@10.18.2) (2025-04-07)
|
|
7
15
|
|
|
8
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/adorneevalue",
|
|
3
|
-
"version": "10.18.
|
|
3
|
+
"version": "10.18.3",
|
|
4
4
|
"description": "Adorneevalue - Helper class to transform a an adornee into relative positions/information.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@quenty/adorneeutils": "^3.3.3",
|
|
29
|
-
"@quenty/baseobject": "^10.8.
|
|
30
|
-
"@quenty/blend": "^12.18.
|
|
31
|
-
"@quenty/loader": "^10.8.
|
|
32
|
-
"@quenty/maid": "^3.4.
|
|
33
|
-
"@quenty/valueobject": "^13.17.
|
|
29
|
+
"@quenty/baseobject": "^10.8.3",
|
|
30
|
+
"@quenty/blend": "^12.18.3",
|
|
31
|
+
"@quenty/loader": "^10.8.3",
|
|
32
|
+
"@quenty/maid": "^3.4.3",
|
|
33
|
+
"@quenty/valueobject": "^13.17.3"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "b06c070ae91d5dab7bd8de6e290ad2caabb15d8f"
|
|
39
39
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Helper class to transform a an adornee into relative positions/information
|
|
3
4
|
@class AdorneeValue
|
|
@@ -12,21 +13,32 @@ local BaseObject = require("BaseObject")
|
|
|
12
13
|
local Blend = require("Blend")
|
|
13
14
|
local ValueObject = require("ValueObject")
|
|
14
15
|
local _Observable = require("Observable")
|
|
16
|
+
local _Signal = require("Signal")
|
|
15
17
|
|
|
16
18
|
local AdorneeValue = setmetatable({}, BaseObject)
|
|
17
19
|
AdorneeValue.ClassName = "AdorneeValue"
|
|
18
20
|
AdorneeValue.__index = AdorneeValue
|
|
19
21
|
|
|
22
|
+
export type AdorneeValueOption = Instance | CFrame | Vector3
|
|
23
|
+
|
|
24
|
+
export type AdorneeValue = typeof(setmetatable(
|
|
25
|
+
{} :: {
|
|
26
|
+
_adornee: ValueObject.ValueObject<AdorneeValueOption?>,
|
|
27
|
+
Value: AdorneeValueOption?,
|
|
28
|
+
Changed: _Signal.Signal<(AdorneeValueOption?, AdorneeValueOption?)>,
|
|
29
|
+
},
|
|
30
|
+
{} :: typeof({ __index = AdorneeValue })
|
|
31
|
+
)) & BaseObject.BaseObject
|
|
32
|
+
|
|
20
33
|
--[=[
|
|
21
34
|
Constructs a new AdorneeValue
|
|
22
35
|
|
|
23
36
|
@return AdorneeValue
|
|
24
37
|
]=]
|
|
25
|
-
function AdorneeValue.new()
|
|
26
|
-
local self = setmetatable(BaseObject.new(), AdorneeValue)
|
|
38
|
+
function AdorneeValue.new(): AdorneeValue
|
|
39
|
+
local self: AdorneeValue = setmetatable(BaseObject.new() :: any, AdorneeValue)
|
|
27
40
|
|
|
28
|
-
self._adornee = ValueObject.new()
|
|
29
|
-
self._maid:GiveTask(self._adornee)
|
|
41
|
+
self._adornee = self._maid:Add(ValueObject.new())
|
|
30
42
|
|
|
31
43
|
return self
|
|
32
44
|
end
|
|
@@ -36,7 +48,7 @@ end
|
|
|
36
48
|
|
|
37
49
|
@return Instance | CFrame | Vector3 | nil
|
|
38
50
|
]=]
|
|
39
|
-
function AdorneeValue
|
|
51
|
+
function AdorneeValue.GetAdornee(self: AdorneeValue): (Instance | CFrame | Vector3)?
|
|
40
52
|
return self._adornee.Value
|
|
41
53
|
end
|
|
42
54
|
|
|
@@ -45,7 +57,7 @@ end
|
|
|
45
57
|
|
|
46
58
|
@return Observable<Instance | CFrame | Vector3 | nil>
|
|
47
59
|
]=]
|
|
48
|
-
function AdorneeValue
|
|
60
|
+
function AdorneeValue.Observe(self: AdorneeValue): _Observable.Observable<(Instance | CFrame | Vector3)?>
|
|
49
61
|
return self._adornee:Observe()
|
|
50
62
|
end
|
|
51
63
|
|
|
@@ -61,7 +73,7 @@ end
|
|
|
61
73
|
@prop Value Instance | CFrame | Vector3 | nil
|
|
62
74
|
@within AdorneeValue
|
|
63
75
|
]=]
|
|
64
|
-
|
|
76
|
+
(AdorneeValue :: any).__index = function(self, index)
|
|
65
77
|
if index == "Value" then
|
|
66
78
|
return self._adornee.Value
|
|
67
79
|
elseif index == "Changed" then
|
|
@@ -76,7 +88,7 @@ function AdorneeValue:__index(index)
|
|
|
76
88
|
end
|
|
77
89
|
end
|
|
78
90
|
|
|
79
|
-
function AdorneeValue
|
|
91
|
+
function AdorneeValue.__newindex(self, index, value)
|
|
80
92
|
if index == "Value" then
|
|
81
93
|
assert(
|
|
82
94
|
typeof(value) == "Instance" or typeof(value) == "Vector3" or typeof(value) == "CFrame" or value == nil,
|
|
@@ -100,7 +112,7 @@ end
|
|
|
100
112
|
|
|
101
113
|
@return Observable<CFrame | nil>
|
|
102
114
|
]=]
|
|
103
|
-
function AdorneeValue
|
|
115
|
+
function AdorneeValue.ObserveBottomCFrame(self: AdorneeValue)
|
|
104
116
|
return Blend.Computed(self._adornee, function(adornee: Instance): CFrame?
|
|
105
117
|
if typeof(adornee) == "CFrame" then
|
|
106
118
|
return adornee
|
|
@@ -128,7 +140,7 @@ end
|
|
|
128
140
|
|
|
129
141
|
@return Observable<Vector3 | nil>
|
|
130
142
|
]=]
|
|
131
|
-
function AdorneeValue
|
|
143
|
+
function AdorneeValue.ObserveCenterPosition(self: AdorneeValue): _Observable.Observable<Vector3?>
|
|
132
144
|
return Blend.Computed(self._adornee, function()
|
|
133
145
|
return self:GetCenterPosition()
|
|
134
146
|
end)
|
|
@@ -139,7 +151,7 @@ end
|
|
|
139
151
|
|
|
140
152
|
@return Vector3 | nil
|
|
141
153
|
]=]
|
|
142
|
-
function AdorneeValue
|
|
154
|
+
function AdorneeValue.GetCenterPosition(self: AdorneeValue): Vector3?
|
|
143
155
|
local adornee = self._adornee.Value
|
|
144
156
|
|
|
145
157
|
if typeof(adornee) == "CFrame" then
|
|
@@ -162,7 +174,7 @@ end
|
|
|
162
174
|
|
|
163
175
|
@return Observable<number?>
|
|
164
176
|
]=]
|
|
165
|
-
function AdorneeValue
|
|
177
|
+
function AdorneeValue.ObserveRadius(self: AdorneeValue)
|
|
166
178
|
return Blend.Computed(self._adornee, function()
|
|
167
179
|
return self:GetRadius()
|
|
168
180
|
end)
|
|
@@ -173,7 +185,7 @@ end
|
|
|
173
185
|
|
|
174
186
|
@return number?
|
|
175
187
|
]=]
|
|
176
|
-
function AdorneeValue
|
|
188
|
+
function AdorneeValue.GetRadius(self: AdorneeValue): number?
|
|
177
189
|
local adornee = self._adornee.Value
|
|
178
190
|
|
|
179
191
|
if typeof(adornee) == "CFrame" then
|
|
@@ -204,7 +216,7 @@ end
|
|
|
204
216
|
@param observeRadius Observable<number>
|
|
205
217
|
@return Observable
|
|
206
218
|
]=]
|
|
207
|
-
function AdorneeValue
|
|
219
|
+
function AdorneeValue.ObservePositionTowards(self: AdorneeValue, observeTargetPosition, observeRadius)
|
|
208
220
|
-- TODO: Some sort of de-duplication/multicast.
|
|
209
221
|
|
|
210
222
|
return Blend.Computed(
|
|
@@ -226,16 +238,21 @@ end
|
|
|
226
238
|
@param center Vector3
|
|
227
239
|
@return Vector3
|
|
228
240
|
]=]
|
|
229
|
-
function AdorneeValue
|
|
241
|
+
function AdorneeValue.GetPositionTowards(self: AdorneeValue, target: Vector3, radius: number, center: Vector3): Vector3?
|
|
230
242
|
assert(typeof(target) == "Vector3", "Bad target")
|
|
231
243
|
|
|
232
|
-
center = center or self:GetCenterPosition()
|
|
233
|
-
radius = radius or self:GetRadius()
|
|
244
|
+
center = center or assert(self:GetCenterPosition(), "Bad center")
|
|
245
|
+
radius = radius or assert(self:GetRadius(), "Bad radius")
|
|
234
246
|
|
|
235
247
|
return self:_getPositionTowards(target, radius, center)
|
|
236
248
|
end
|
|
237
249
|
|
|
238
|
-
function AdorneeValue
|
|
250
|
+
function AdorneeValue._getPositionTowards(
|
|
251
|
+
_self: AdorneeValue,
|
|
252
|
+
target: Vector3,
|
|
253
|
+
radius: number,
|
|
254
|
+
center: Vector3
|
|
255
|
+
): Vector3?
|
|
239
256
|
if not (radius and target and center) then
|
|
240
257
|
return nil
|
|
241
258
|
end
|
|
@@ -245,7 +262,7 @@ function AdorneeValue:_getPositionTowards(target: Vector3, radius: number, cente
|
|
|
245
262
|
return nil
|
|
246
263
|
end
|
|
247
264
|
|
|
248
|
-
return center + offset.
|
|
265
|
+
return center + offset.Unit * radius
|
|
249
266
|
end
|
|
250
267
|
|
|
251
268
|
--[=[
|
|
@@ -254,7 +271,7 @@ end
|
|
|
254
271
|
|
|
255
272
|
@return Observable<Instance?>
|
|
256
273
|
]=]
|
|
257
|
-
function AdorneeValue
|
|
274
|
+
function AdorneeValue.ObserveAttachmentParent(self: AdorneeValue)
|
|
258
275
|
return Blend.Computed(self._adornee, function(adornee): Instance?
|
|
259
276
|
if typeof(adornee) == "Instance" then
|
|
260
277
|
-- TODO: Nearest bounding box stuff.
|
|
@@ -283,7 +300,7 @@ end
|
|
|
283
300
|
@param props {} -- Takes [Blend.Children] as an option
|
|
284
301
|
@return Observable<Instance?>
|
|
285
302
|
]=]
|
|
286
|
-
function AdorneeValue
|
|
303
|
+
function AdorneeValue.RenderPositionAttachment(self: AdorneeValue, props)
|
|
287
304
|
props = props or {}
|
|
288
305
|
|
|
289
306
|
local observeWorldPosition = props.WorldPosition or self:ObserveCenterPosition()
|