@quenty/adorneeboundingbox 8.20.0 → 8.20.1

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
+ ## [8.20.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/adorneeboundingbox@8.20.0...@quenty/adorneeboundingbox@8.20.1) (2025-04-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
12
+
13
+
14
+
15
+
16
+
6
17
  # [8.20.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/adorneeboundingbox@8.19.4...@quenty/adorneeboundingbox@8.20.0) (2025-04-02)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/adorneeboundingbox
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/adorneeboundingbox",
3
- "version": "8.20.0",
3
+ "version": "8.20.1",
4
4
  "description": "Handles logic for reactive bounding box monitoring",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,20 +25,20 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/baseobject": "^10.8.0",
29
- "@quenty/brio": "^14.17.0",
30
- "@quenty/draw": "^7.8.1",
31
- "@quenty/instanceutils": "^13.17.0",
32
- "@quenty/loader": "^10.8.0",
33
- "@quenty/maid": "^3.4.0",
34
- "@quenty/observablecollection": "^12.20.0",
35
- "@quenty/rx": "^13.17.0",
36
- "@quenty/selectionutils": "^8.17.0",
37
- "@quenty/signal": "^7.10.0",
38
- "@quenty/valueobject": "^13.17.0"
28
+ "@quenty/baseobject": "^10.8.1",
29
+ "@quenty/brio": "^14.17.1",
30
+ "@quenty/draw": "^7.8.2",
31
+ "@quenty/instanceutils": "^13.17.1",
32
+ "@quenty/loader": "^10.8.1",
33
+ "@quenty/maid": "^3.4.1",
34
+ "@quenty/observablecollection": "^12.20.1",
35
+ "@quenty/rx": "^13.17.1",
36
+ "@quenty/selectionutils": "^8.17.1",
37
+ "@quenty/signal": "^7.10.1",
38
+ "@quenty/valueobject": "^13.17.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "e8ea56930e65322fcffc05a1556d5df988068f0b"
43
+ "gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
44
44
  }
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  @class AdorneeBoundingBox
3
4
  ]=]
@@ -5,6 +6,7 @@
5
6
  local require = require(script.Parent.loader).load(script)
6
7
 
7
8
  local AdorneeModelBoundingBox = require("AdorneeModelBoundingBox")
9
+ local AdorneePartBoundingBox = require("AdorneePartBoundingBox")
8
10
  local BaseObject = require("BaseObject")
9
11
  local Maid = require("Maid")
10
12
  local Rx = require("Rx")
@@ -12,14 +14,16 @@ local RxBrioUtils = require("RxBrioUtils")
12
14
  local RxInstanceUtils = require("RxInstanceUtils")
13
15
  local RxPartBoundingBoxUtils = require("RxPartBoundingBoxUtils")
14
16
  local ValueObject = require("ValueObject")
15
- local AdorneePartBoundingBox = require("AdorneePartBoundingBox")
17
+ local _Observable = require("Observable")
16
18
 
17
19
  local AdorneeBoundingBox = setmetatable({}, BaseObject)
18
20
  AdorneeBoundingBox.ClassName = "AdorneeBoundingBox"
19
21
  AdorneeBoundingBox.__index = AdorneeBoundingBox
20
22
 
21
- function AdorneeBoundingBox.new(initialAdornee)
22
- local self = setmetatable(BaseObject.new(), AdorneeBoundingBox)
23
+ export type AdorneeBoundingBox = typeof(setmetatable({}, AdorneeBoundingBox))
24
+
25
+ function AdorneeBoundingBox.new(initialAdornee: Instance): AdorneeBoundingBox
26
+ local self = setmetatable(BaseObject.new() :: any, AdorneeBoundingBox)
23
27
 
24
28
  self._adornee = self._maid:Add(ValueObject.new(initialAdornee))
25
29
  self._bbCFrame = self._maid:Add(ValueObject.new(nil))
@@ -41,7 +45,7 @@ function AdorneeBoundingBox.new(initialAdornee)
41
45
  return self
42
46
  end
43
47
 
44
- function AdorneeBoundingBox:SetAdornee(adornee)
48
+ function AdorneeBoundingBox:SetAdornee(adornee: Instance?): () -> ()
45
49
  assert(typeof(adornee) == "Instance" or adornee == nil, "Bad adornee")
46
50
 
47
51
  self._adornee.Value = adornee
@@ -53,18 +57,31 @@ function AdorneeBoundingBox:SetAdornee(adornee)
53
57
  end
54
58
  end
55
59
 
56
- function AdorneeBoundingBox:ObserveBoundingBox()
60
+ export type BoundingBoxData = {
61
+ CFrame: CFrame,
62
+ Size: Vector3,
63
+ }
64
+
65
+ --[=[
66
+ Observes the bounding box of the adornee
67
+ @return Observable<BoundingBoxData>
68
+ ]=]
69
+ function AdorneeBoundingBox:ObserveBoundingBox(): _Observable.Observable<BoundingBoxData>
57
70
  return Rx.combineLatest({
58
71
  CFrame = self:ObserveCFrame(),
59
72
  Size = self:ObserveSize(),
60
73
  }):Pipe({
61
- Rx.where(function(state)
74
+ Rx.where(function(state: any)
62
75
  return state.CFrame and state.Size
63
- end),
64
- })
76
+ end) :: any,
77
+ }) :: any
65
78
  end
66
79
 
67
- function AdorneeBoundingBox:GetBoundingBox()
80
+ --[=[
81
+ Gets the bounding box of the adornee
82
+ @return BoundingBoxData?
83
+ ]=]
84
+ function AdorneeBoundingBox:GetBoundingBox(): BoundingBoxData?
68
85
  local cframe = self._bbCFrame.Value
69
86
  local size = self._bbSize.Value
70
87
 
@@ -82,7 +99,7 @@ end
82
99
  Observes the cframe of the adornee
83
100
  @return Observable<Vector3>
84
101
  ]=]
85
- function AdorneeBoundingBox:ObserveCFrame()
102
+ function AdorneeBoundingBox:ObserveCFrame(): _Observable.Observable<CFrame>
86
103
  return self._bbCFrame:Observe()
87
104
  end
88
105
 
@@ -90,7 +107,7 @@ end
90
107
  Gets the CFrame of the adornee
91
108
  @return Vector3
92
109
  ]=]
93
- function AdorneeBoundingBox:GetCFrame()
110
+ function AdorneeBoundingBox:GetCFrame(): CFrame?
94
111
  return self._bbCFrame.Value
95
112
  end
96
113
 
@@ -98,7 +115,7 @@ end
98
115
  Observes the size of the adornee
99
116
  @return Observable<Vector3>
100
117
  ]=]
101
- function AdorneeBoundingBox:ObserveSize()
118
+ function AdorneeBoundingBox:ObserveSize(): _Observable.Observable<Vector3>
102
119
  return self._bbSize:Observe()
103
120
  end
104
121
 
@@ -106,11 +123,11 @@ end
106
123
  Gets the size of the adornee
107
124
  @return Vector3
108
125
  ]=]
109
- function AdorneeBoundingBox:GetSize()
126
+ function AdorneeBoundingBox:GetSize(): Vector3
110
127
  return self._bbSize.Value
111
128
  end
112
129
 
113
- function AdorneeBoundingBox:_setup(maid, adornee)
130
+ function AdorneeBoundingBox:_setup(maid: Maid.Maid, adornee: Instance)
114
131
  if adornee:IsA("BasePart") then
115
132
  maid:GiveTask(self:_setupPart(adornee))
116
133
  elseif adornee:IsA("Model") then
@@ -133,7 +150,7 @@ function AdorneeBoundingBox:_setup(maid, adornee)
133
150
  end
134
151
  end
135
152
 
136
- function AdorneeBoundingBox:_setupTool(tool)
153
+ function AdorneeBoundingBox:_setupTool(tool: Tool): Maid.Maid
137
154
  assert(typeof(tool) == "Instance" and tool:IsA("Tool"), "Bad tool")
138
155
 
139
156
  local topMaid = Maid.new()
@@ -153,7 +170,7 @@ function AdorneeBoundingBox:_setupTool(tool)
153
170
  return topMaid
154
171
  end
155
172
 
156
- function AdorneeBoundingBox:_setupModel(model)
173
+ function AdorneeBoundingBox:_setupModel(model: Model): Maid.Maid
157
174
  assert(typeof(model) == "Instance" and model:IsA("Model"), "Bad model")
158
175
 
159
176
  local topMaid = Maid.new()
@@ -169,20 +186,19 @@ function AdorneeBoundingBox:_setupModel(model)
169
186
  return topMaid
170
187
  end
171
188
 
172
- function AdorneeBoundingBox:_setupHumanoid(humanoid: Humanoid)
189
+ function AdorneeBoundingBox:_setupHumanoid(humanoid: Humanoid): Maid.Maid
173
190
  assert(typeof(humanoid) == "Instance" and humanoid:IsA("Humanoid"), "Bad humanoid")
174
191
 
175
192
  local topMaid = Maid.new()
176
193
 
177
- topMaid:GiveTask(RxInstanceUtils.observePropertyBrio(humanoid, "Parent", function(parent)
178
- return parent ~= nil and parent:IsA("Model")
194
+ topMaid:GiveTask(RxInstanceUtils.observePropertyBrio(humanoid, "Parent", function(parent: Instance)
195
+ return parent:IsA("Model")
179
196
  end):Subscribe(function(brio)
180
197
  if brio:IsDead() then
181
198
  return
182
199
  end
183
200
 
184
- local maid = brio:ToMaid()
185
- local model = brio:GetValue()
201
+ local maid, model = brio:ToMaidAndValue()
186
202
 
187
203
  maid:GiveTask(self:_setupModel(model))
188
204
  end))
@@ -190,7 +206,7 @@ function AdorneeBoundingBox:_setupHumanoid(humanoid: Humanoid)
190
206
  return topMaid
191
207
  end
192
208
 
193
- function AdorneeBoundingBox:_setupAttachment(attachment)
209
+ function AdorneeBoundingBox:_setupAttachment(attachment: Attachment): Maid.Maid
194
210
  assert(typeof(attachment) == "Instance" and attachment:IsA("Attachment"), "Bad attachment")
195
211
 
196
212
  local maid = Maid.new()
@@ -207,9 +223,9 @@ function AdorneeBoundingBox:_setupAttachment(attachment)
207
223
  partCFrame = RxPartBoundingBoxUtils.observePartCFrame(parent),
208
224
  attachmentCFrame = RxInstanceUtils.observeProperty(attachment, "CFrame"),
209
225
  }):Pipe({
210
- Rx.map(function(state)
226
+ Rx.map(function(state: any)
211
227
  return state.partCFrame * state.attachmentCFrame
212
- end),
228
+ end) :: any,
213
229
  })
214
230
  else
215
231
  return Rx.of(nil)
@@ -224,7 +240,7 @@ function AdorneeBoundingBox:_setupAttachment(attachment)
224
240
  return maid
225
241
  end
226
242
 
227
- function AdorneeBoundingBox:_setupPart(part)
243
+ function AdorneeBoundingBox:_setupPart(part: BasePart): Maid.Maid
228
244
  assert(typeof(part) == "Instance" and part:IsA("BasePart"), "Bad part")
229
245
 
230
246
  local maid = Maid.new()
@@ -12,12 +12,13 @@ local ObservableSet = require("ObservableSet")
12
12
  local Rx = require("Rx")
13
13
  local RxInstanceUtils = require("RxInstanceUtils")
14
14
  local ValueObject = require("ValueObject")
15
+ local _Observable = require("Observable")
15
16
 
16
17
  local AdorneeModelBoundingBox = setmetatable({}, BaseObject)
17
18
  AdorneeModelBoundingBox.ClassName = "AdorneeModelBoundingBox"
18
19
  AdorneeModelBoundingBox.__index = AdorneeModelBoundingBox
19
20
 
20
- function AdorneeModelBoundingBox.new(model)
21
+ function AdorneeModelBoundingBox.new(model: Model)
21
22
  local self = setmetatable(BaseObject.new(model), AdorneeModelBoundingBox)
22
23
 
23
24
  self._bbCFrame = self._maid:Add(ValueObject.new(nil))
@@ -41,33 +42,39 @@ function AdorneeModelBoundingBox.new(model)
41
42
  self._isDirty.Value = true
42
43
  end))
43
44
 
44
- self._maid:GiveTask(self._isDirty:Observe():Pipe({
45
- Rx.where(function(value)
46
- return value
47
- end);
48
- Rx.throttleDefer();
49
- }):Subscribe(function()
50
- debug.profilebegin("modelboundingbox")
51
- self._isDirty.Value = false
52
-
53
- local bbCFrame, bbSize = self._obj:GetBoundingBox()
54
- self._bbSize.Value = bbSize
55
- self._bbCFrame.Value = bbCFrame
56
- debug.profileend()
57
- end))
58
-
59
- self._maid:GiveTask(self._unanchoredPartsSet:ObserveCount():Pipe({
60
- Rx.map(function(value)
61
- return value > 0
62
- end);
63
- Rx.distinct();
64
- }):Subscribe(function(hasUnanchoredParts)
65
- if hasUnanchoredParts then
66
- self._maid._current = self:_setupUnanchoredLoop()
67
- else
68
- self._maid._current = nil
69
- end
70
- end))
45
+ self._maid:GiveTask(self._isDirty
46
+ :Observe()
47
+ :Pipe({
48
+ Rx.where(function(value)
49
+ return value
50
+ end),
51
+ Rx.throttleDefer(),
52
+ })
53
+ :Subscribe(function()
54
+ debug.profilebegin("modelboundingbox")
55
+ self._isDirty.Value = false
56
+
57
+ local bbCFrame, bbSize = self._obj:GetBoundingBox()
58
+ self._bbSize.Value = bbSize
59
+ self._bbCFrame.Value = bbCFrame
60
+ debug.profileend()
61
+ end))
62
+
63
+ self._maid:GiveTask(self._unanchoredPartsSet
64
+ :ObserveCount()
65
+ :Pipe({
66
+ Rx.map(function(value)
67
+ return value > 0
68
+ end),
69
+ Rx.distinct(),
70
+ })
71
+ :Subscribe(function(hasUnanchoredParts)
72
+ if hasUnanchoredParts then
73
+ self._maid._current = self:_setupUnanchoredLoop()
74
+ else
75
+ self._maid._current = nil
76
+ end
77
+ end))
71
78
 
72
79
  return self
73
80
  end
@@ -83,7 +90,7 @@ function AdorneeModelBoundingBox:_setupUnanchoredLoop()
83
90
  return maid
84
91
  end
85
92
 
86
- function AdorneeModelBoundingBox:_handlePart(topMaid, part)
93
+ function AdorneeModelBoundingBox:_handlePart(topMaid, part: BasePart)
87
94
  topMaid:GiveTask(RxInstanceUtils.observePropertyBrio(part, "Anchored", function(isAnchored)
88
95
  return not isAnchored
89
96
  end):Subscribe(function(brio)
@@ -112,15 +119,15 @@ function AdorneeModelBoundingBox:_observeBasisChanged()
112
119
  else
113
120
  return RxInstanceUtils.observeProperty(self._obj, "WorldPivot")
114
121
  end
115
- end)
122
+ end),
116
123
  })
117
124
  end
118
125
 
119
- function AdorneeModelBoundingBox:ObserveCFrame()
126
+ function AdorneeModelBoundingBox:ObserveCFrame(): _Observable.Observable<CFrame>
120
127
  return self._bbCFrame:Observe()
121
128
  end
122
129
 
123
- function AdorneeModelBoundingBox:ObserveSize()
130
+ function AdorneeModelBoundingBox:ObserveSize(): _Observable.Observable<Vector3>
124
131
  return self._bbSize:Observe()
125
132
  end
126
133
 
@@ -9,12 +9,13 @@ local RunService = game:GetService("RunService")
9
9
  local BaseObject = require("BaseObject")
10
10
  local ValueObject = require("ValueObject")
11
11
  local RxInstanceUtils = require("RxInstanceUtils")
12
+ local _Observable = require("Observable")
12
13
 
13
14
  local AdorneePartBoundingBox = setmetatable({}, BaseObject)
14
15
  AdorneePartBoundingBox.ClassName = "AdorneePartBoundingBox"
15
16
  AdorneePartBoundingBox.__index = AdorneePartBoundingBox
16
17
 
17
- function AdorneePartBoundingBox.new(part)
18
+ function AdorneePartBoundingBox.new(part: BasePart)
18
19
  assert(typeof(part) == "Instance" and part:IsA("BasePart"), "Bad part")
19
20
 
20
21
  local self = setmetatable(BaseObject.new(part), AdorneePartBoundingBox)
@@ -55,11 +56,11 @@ function AdorneePartBoundingBox:_setupUnanchoredLoop(maid)
55
56
  end))
56
57
  end
57
58
 
58
- function AdorneePartBoundingBox:ObserveCFrame()
59
+ function AdorneePartBoundingBox:ObserveCFrame(): _Observable.Observable<CFrame>
59
60
  return self._bbCFrame:Observe()
60
61
  end
61
62
 
62
- function AdorneePartBoundingBox:ObserveSize()
63
+ function AdorneePartBoundingBox:ObserveSize(): _Observable.Observable<Vector3>
63
64
  return self._bbSize:Observe()
64
65
  end
65
66
 
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  @class RxPartBoundingBoxUtils
3
4
  ]=]
@@ -5,13 +6,14 @@
5
6
  local require = require(script.Parent.loader).load(script)
6
7
 
7
8
  local RxInstanceUtils = require("RxInstanceUtils")
9
+ local _Observable = require("Observable")
8
10
 
9
11
  local RxPartBoundingBoxUtils = {}
10
12
 
11
- function RxPartBoundingBoxUtils.observePartCFrame(part)
13
+ function RxPartBoundingBoxUtils.observePartCFrame(part: BasePart): _Observable.Observable<CFrame>
12
14
  assert(typeof(part) == "Instance" and part:IsA("BasePart"), "Bad part")
13
15
 
14
- return RxInstanceUtils.observeProperty(part, "CFrame")
16
+ return RxInstanceUtils.observeProperty(part, "CFrame") :: any
15
17
  end
16
18
 
17
19
  return RxPartBoundingBoxUtils