@quenty/cooldown 1.3.1 → 1.4.1-canary.8533eea.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,28 @@
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
+ ## [1.4.1-canary.8533eea.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/cooldown@1.4.0...@quenty/cooldown@1.4.1-canary.8533eea.0) (2021-12-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * Allow CooldownTracker to be initialized without the cooldown binders being initialized. ([4633d7c](https://github.com/Quenty/NevermoreEngine/commit/4633d7c0e11530d827e39994d5f84d0280652d96))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/cooldown@1.3.1...@quenty/cooldown@1.4.0) (2021-12-14)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * Cooldown package uses RxBinderUtils to observe bound class changing properly ([c005479](https://github.com/Quenty/NevermoreEngine/commit/c0054792dc12ccb03000bbbc3acb27ac24858f48))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [1.3.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/cooldown@1.3.0...@quenty/cooldown@1.3.1) (2021-12-04)
7
29
 
8
30
 
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014 Quenty
3
+ Copyright (c) 2014-2021 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/cooldown",
3
- "version": "1.3.1",
3
+ "version": "1.4.1-canary.8533eea.0",
4
4
  "description": "Generalized networked cooldown system for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,20 +25,21 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/baseobject": "^3.2.0",
29
- "@quenty/binder": "^4.3.1",
30
- "@quenty/loader": "^3.1.1",
31
- "@quenty/maid": "^2.0.1",
32
- "@quenty/promise": "^3.2.0",
33
- "@quenty/remoting": "^3.2.0",
34
- "@quenty/servicebag": "^3.2.1",
35
- "@quenty/signal": "^2.0.0",
36
- "@quenty/table": "^2.1.0",
37
- "@quenty/timesyncservice": "^3.2.0",
38
- "@quenty/valueobject": "^3.3.0"
28
+ "@quenty/baseobject": "3.2.0",
29
+ "@quenty/binder": "4.4.1-canary.8533eea.0",
30
+ "@quenty/loader": "3.1.1",
31
+ "@quenty/maid": "2.0.1",
32
+ "@quenty/promise": "3.2.1-canary.8533eea.0",
33
+ "@quenty/remoting": "3.2.1-canary.8533eea.0",
34
+ "@quenty/rxbinderutils": "4.5.1-canary.8533eea.0",
35
+ "@quenty/servicebag": "3.2.1",
36
+ "@quenty/signal": "2.0.0",
37
+ "@quenty/table": "2.1.0",
38
+ "@quenty/timesyncservice": "3.2.1-canary.8533eea.0",
39
+ "@quenty/valueobject": "3.4.1-canary.8533eea.0"
39
40
  },
40
41
  "publishConfig": {
41
42
  "access": "public"
42
43
  },
43
- "gitHead": "a0583027b100d718bce1603ec6c525ad99adeeac"
44
+ "gitHead": "8533eeade3bf6835c0295785c1c326b9abee3222"
44
45
  }
@@ -6,8 +6,8 @@ local require = require(script.Parent.loader).load(script)
6
6
 
7
7
  local BaseObject = require("BaseObject")
8
8
  local CooldownBindersClient = require("CooldownBindersClient")
9
- local CooldownConstants = require("CooldownConstants")
10
9
  local ValueObject = require("ValueObject")
10
+ local RxBinderUtils = require("RxBinderUtils")
11
11
 
12
12
  local CooldownTracker = setmetatable({}, BaseObject)
13
13
  CooldownTracker.ClassName = "CooldownTracker"
@@ -16,9 +16,11 @@ CooldownTracker.__index = CooldownTracker
16
16
  function CooldownTracker.new(serviceBag, parent)
17
17
  local self = setmetatable(BaseObject.new(parent), CooldownTracker)
18
18
 
19
- self._serviceBag = assert(serviceBag, "No serviceBag")
20
19
  assert(parent, "No parent")
21
20
 
21
+ self._serviceBag = assert(serviceBag, "No serviceBag")
22
+ self._cooldownBinders = self._serviceBag:GetService(CooldownBindersClient)
23
+
22
24
  self.CurrentCooldown = ValueObject.new()
23
25
  self._maid:GiveTask(self.CurrentCooldown)
24
26
 
@@ -26,17 +28,27 @@ function CooldownTracker.new(serviceBag, parent)
26
28
  self:_handleNewCooldown(...)
27
29
  end))
28
30
 
29
- self._maid:GiveTask(self._obj.ChildAdded:Connect(function(child)
30
- self:_handleChild(child)
31
- end))
31
+ -- Handle not running
32
+ self._maid:GivePromise(self._cooldownBinders:PromiseBinder("Cooldown"))
33
+ :Then(function(cooldownBinder)
34
+ self._maid:GiveTask(RxBinderUtils.observeBoundChildClassBrio(cooldownBinder, self._obj)
35
+ :Subscribe(function(brio)
36
+ if brio:IsDead() then
37
+ return
38
+ end
32
39
 
33
- -- Do initial loading
34
- do
35
- local child = self._obj:FindFirstChild(CooldownConstants.COOLDOWN_NAME)
36
- if child then
37
- self:_handleChild(child)
38
- end
39
- end
40
+ -- TODO: Use stack (with multiple cooldowns)
41
+ local cooldown = brio:GetValue()
42
+ local maid = brio:ToMaid()
43
+ self.CurrentCooldown.Value = cooldown
44
+
45
+ maid:GiveTask(function()
46
+ if self.CurrentCooldown.Value == cooldown then
47
+ self.CurrentCooldown.Value = nil
48
+ end
49
+ end)
50
+ end))
51
+ end)
40
52
 
41
53
  return self
42
54
  end
@@ -51,10 +63,4 @@ function CooldownTracker:_handleNewCooldown(new, _old, maid)
51
63
  end
52
64
  end
53
65
 
54
- function CooldownTracker:_handleChild(child)
55
- if child.Name == CooldownConstants.COOLDOWN_NAME then
56
- self.CurrentCooldown.Value = self._serviceBag:GetService(CooldownBindersClient).Cooldown:Get(child)
57
- end
58
- end
59
-
60
66
  return CooldownTracker
@@ -23,7 +23,7 @@ function Cooldown.new(obj, serviceBag)
23
23
  self._startTime.Parent = self._obj
24
24
 
25
25
  -- Delay for cooldown time
26
- delay(self._obj.Value, function()
26
+ task.delay(self._obj.Value, function()
27
27
  if self.Destroy then
28
28
  self._obj:Destroy()
29
29
  end
@@ -48,7 +48,7 @@ function CooldownBase:GetTimeRemaining()
48
48
  return nil
49
49
  end
50
50
 
51
- return endTime - self._syncedClock:GetTime()
51
+ return math.max(0, endTime - self._syncedClock:GetTime())
52
52
  end
53
53
 
54
54
  function CooldownBase:GetEndTime()