Skip to content

Commit

Permalink
fix: Rx works without promise
Browse files Browse the repository at this point in the history
  • Loading branch information
Quenty committed Feb 18, 2025
1 parent d7799a4 commit 267f976
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function RacketingRopeConstraint:_handleActiveChanged()

self:_update()
else
self._isConstrained.Value = false
self._maid._updateHeartbeat = nil
self._maid._pendingConstrainedPromise = nil
self._smallestDistance = START_DISTANCE
Expand All @@ -101,7 +102,7 @@ function RacketingRopeConstraint:_handleActiveChanged()
end

function RacketingRopeConstraint:_update()
assert(self:_isValid())
assert(self:_isValid(), "Not valid state")

local currentDistance = (self._obj.Attachment0.WorldPosition - self._obj.Attachment1.WorldPosition).magnitude
self._smallestDistance = math.clamp(currentDistance, self._targetDistance, self._smallestDistance)
Expand All @@ -110,15 +111,17 @@ function RacketingRopeConstraint:_update()

if self:_queryIsConstrained() then
self._maid._updateHeartbeat = nil
self._isConstrained.Value = true

if self._maid._pendingConstrainedPromise then
if self:_isValid() and self:_queryIsConstrained() then
self._isConstrained.Value = true
self._maid._pendingConstrainedPromise:Resolve()
end

self._maid._pendingConstrainedPromise = nil
end
else
self._isConstrained.Value = false
end
end

Expand Down

0 comments on commit 267f976

Please sign in to comment.