@quenty/actionmanager 13.33.1 → 13.34.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 +10 -0
- package/package.json +3 -3
- package/src/Client/ActionManager.lua +25 -15
- package/src/Client/BaseAction.lua +52 -20
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
# [13.34.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/actionmanager@13.33.1...@quenty/actionmanager@13.34.0) (2026-07-14)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **actionmanager:** cast enabledmixin application for strict EnabledMixin ([9c257d3](https://github.com/Quenty/NevermoreEngine/commit/9c257d3229574baacc636de89ede4e2dc0ae2d84))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **actionmanager:** convert package to --!strict ([969be92](https://github.com/Quenty/NevermoreEngine/commit/969be92474791bab5c6c2515ff14557cdd0e3f9a))
|
|
15
|
+
|
|
6
16
|
## [13.33.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/actionmanager@13.33.0...@quenty/actionmanager@13.33.1) (2026-05-30)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @quenty/actionmanager
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/actionmanager",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.34.0",
|
|
4
4
|
"description": "Holds single toggleable actions (like a tool system)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"Quenty"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/enabledmixin": "11.
|
|
31
|
+
"@quenty/enabledmixin": "11.27.0",
|
|
32
32
|
"@quenty/loader": "10.11.0",
|
|
33
33
|
"@quenty/maid": "3.9.0",
|
|
34
34
|
"@quenty/signal": "7.13.1",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "13f0162f4971a77378e55e9b7236aea94f0dd3a8"
|
|
41
41
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
Holds single toggleable actions (like a tool system).
|
|
4
4
|
|
|
@@ -13,6 +13,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
13
13
|
|
|
14
14
|
local ContextActionService = game:GetService("ContextActionService")
|
|
15
15
|
|
|
16
|
+
local BaseAction = require("BaseAction")
|
|
16
17
|
local Maid = require("Maid")
|
|
17
18
|
local Signal = require("Signal")
|
|
18
19
|
local ValueObject = require("ValueObject")
|
|
@@ -21,14 +22,24 @@ local ActionManager = {}
|
|
|
21
22
|
ActionManager.__index = ActionManager
|
|
22
23
|
ActionManager.ClassName = "ActionManager"
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
export type ActionManager = typeof(setmetatable(
|
|
26
|
+
{} :: {
|
|
27
|
+
_maid: Maid.Maid,
|
|
28
|
+
_actions: { [string]: BaseAction.BaseAction },
|
|
29
|
+
ActiveAction: ValueObject.ValueObject<BaseAction.BaseAction?>,
|
|
30
|
+
ActionAdded: Signal.Signal<BaseAction.BaseAction>,
|
|
31
|
+
},
|
|
32
|
+
{} :: typeof({ __index = ActionManager })
|
|
33
|
+
))
|
|
34
|
+
|
|
35
|
+
function ActionManager.new(): ActionManager
|
|
36
|
+
local self: ActionManager = setmetatable({} :: any, ActionManager)
|
|
26
37
|
|
|
27
38
|
self._maid = Maid.new()
|
|
28
39
|
self._actions = {}
|
|
29
40
|
|
|
30
|
-
self.ActiveAction = self._maid:Add(ValueObject.new())
|
|
31
|
-
self.ActionAdded = self._maid:Add(Signal.new()) -- :Fire(action)
|
|
41
|
+
self.ActiveAction = self._maid:Add(ValueObject.new() :: ValueObject.ValueObject<BaseAction.BaseAction?>)
|
|
42
|
+
self.ActionAdded = self._maid:Add(Signal.new() :: any) -- :Fire(action)
|
|
32
43
|
|
|
33
44
|
-- Stop actions while tool is in play
|
|
34
45
|
self._maid.ToolEquipped = ContextActionService.LocalToolEquipped:Connect(function(_)
|
|
@@ -42,7 +53,7 @@ function ActionManager.new()
|
|
|
42
53
|
value:Deactivate()
|
|
43
54
|
end)
|
|
44
55
|
maid:GiveTask(value.Deactivated:Connect(function()
|
|
45
|
-
if self.ActiveAction == value then
|
|
56
|
+
if self.ActiveAction.Value == value then
|
|
46
57
|
self.ActiveAction.Value = nil
|
|
47
58
|
end
|
|
48
59
|
end))
|
|
@@ -64,11 +75,11 @@ function ActionManager.new()
|
|
|
64
75
|
return self
|
|
65
76
|
end
|
|
66
77
|
|
|
67
|
-
function ActionManager
|
|
78
|
+
function ActionManager.StopCurrentAction(self: ActionManager): ()
|
|
68
79
|
self.ActiveAction.Value = nil
|
|
69
80
|
end
|
|
70
81
|
|
|
71
|
-
function ActionManager
|
|
82
|
+
function ActionManager.ActivateAction(self: ActionManager, name: string, ...): ()
|
|
72
83
|
local action = self:GetAction(name)
|
|
73
84
|
if action then
|
|
74
85
|
action:Activate(...)
|
|
@@ -77,26 +88,25 @@ function ActionManager:ActivateAction(name, ...)
|
|
|
77
88
|
end
|
|
78
89
|
end
|
|
79
90
|
|
|
80
|
-
function ActionManager
|
|
91
|
+
function ActionManager.GetAction(self: ActionManager, name: string): BaseAction.BaseAction?
|
|
81
92
|
return self._actions[name]
|
|
82
93
|
end
|
|
83
94
|
|
|
84
|
-
function ActionManager
|
|
85
|
-
local list = {}
|
|
95
|
+
function ActionManager.GetActions(self: ActionManager): { BaseAction.BaseAction }
|
|
96
|
+
local list: { BaseAction.BaseAction } = {}
|
|
86
97
|
|
|
87
98
|
for _, action in self._actions do
|
|
88
|
-
table.insert(list, action)
|
|
99
|
+
table.insert(list, action :: any)
|
|
89
100
|
end
|
|
90
101
|
|
|
91
102
|
return list
|
|
92
103
|
end
|
|
93
104
|
|
|
94
|
-
function ActionManager
|
|
105
|
+
function ActionManager.AddAction(self: ActionManager, action: BaseAction.BaseAction): ActionManager
|
|
95
106
|
local name = action:GetName()
|
|
96
107
|
|
|
97
108
|
if self._actions[name] then
|
|
98
109
|
error(string.format("[ActionManager] - action with name '%s' already exists", tostring(name)))
|
|
99
|
-
return
|
|
100
110
|
end
|
|
101
111
|
|
|
102
112
|
self._actions[name] = action
|
|
@@ -116,7 +126,7 @@ function ActionManager:AddAction(action)
|
|
|
116
126
|
return self
|
|
117
127
|
end
|
|
118
128
|
|
|
119
|
-
function ActionManager
|
|
129
|
+
function ActionManager.Destroy(self: ActionManager): ()
|
|
120
130
|
self._maid:Destroy()
|
|
121
131
|
end
|
|
122
132
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
BaseAction state for [ActionManager].
|
|
4
4
|
|
|
@@ -15,6 +15,7 @@ local ContextActionService = game:GetService("ContextActionService")
|
|
|
15
15
|
|
|
16
16
|
local EnabledMixin = require("EnabledMixin")
|
|
17
17
|
local Maid = require("Maid")
|
|
18
|
+
local Observable = require("Observable")
|
|
18
19
|
local Signal = require("Signal")
|
|
19
20
|
local ValueObject = require("ValueObject")
|
|
20
21
|
|
|
@@ -22,20 +23,51 @@ local BaseAction = {}
|
|
|
22
23
|
BaseAction.__index = BaseAction
|
|
23
24
|
BaseAction.ClassName = "BaseAction"
|
|
24
25
|
|
|
25
|
-
EnabledMixin:Add(BaseAction)
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
(EnabledMixin :: any):Add(BaseAction)
|
|
27
|
+
|
|
28
|
+
export type ActionData = {
|
|
29
|
+
Name: string,
|
|
30
|
+
Shortcuts: { any }?,
|
|
31
|
+
[any]: any,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type BaseAction = typeof(setmetatable(
|
|
35
|
+
{} :: {
|
|
36
|
+
_maid: Maid.Maid,
|
|
37
|
+
_name: string,
|
|
38
|
+
_contextActionKey: string,
|
|
39
|
+
_activateData: { any }?,
|
|
40
|
+
_actionData: ActionData,
|
|
41
|
+
Activated: Signal.Signal<...any>,
|
|
42
|
+
Deactivated: Signal.Signal<()>,
|
|
43
|
+
IsActivatedValue: ValueObject.ValueObject<boolean>,
|
|
44
|
+
|
|
45
|
+
-- EnabledMixin surface (methods injected at runtime via EnabledMixin:Add)
|
|
46
|
+
_enabledMaidReference: Maid.Maid,
|
|
47
|
+
_enabledState: ValueObject.ValueObject<boolean>,
|
|
48
|
+
EnabledChanged: Signal.Signal<(boolean, boolean?)>,
|
|
49
|
+
InitEnabledMixin: (self: any, maid: Maid.Maid?) -> (),
|
|
50
|
+
IsEnabled: (self: any) -> boolean,
|
|
51
|
+
Enable: (self: any, doNotAnimate: boolean?) -> (),
|
|
52
|
+
Disable: (self: any, doNotAnimate: boolean?) -> (),
|
|
53
|
+
SetEnabled: (self: any, isEnabled: boolean, doNotAnimate: boolean?) -> (),
|
|
54
|
+
ObserveIsEnabled: (self: any) -> Observable.Observable<boolean>,
|
|
55
|
+
},
|
|
56
|
+
{} :: typeof({ __index = BaseAction })
|
|
57
|
+
))
|
|
58
|
+
|
|
59
|
+
function BaseAction.new(actionData: ActionData): BaseAction
|
|
28
60
|
assert(type(actionData) == "table", "Bad actionData")
|
|
29
61
|
|
|
30
|
-
local self = setmetatable({}, BaseAction)
|
|
62
|
+
local self: BaseAction = setmetatable({} :: any, BaseAction)
|
|
31
63
|
|
|
32
64
|
self._maid = Maid.new()
|
|
33
65
|
self._name = actionData.Name or error("No name")
|
|
34
66
|
self._contextActionKey = string.format("%s_ContextAction", tostring(self._name))
|
|
35
67
|
self._activateData = nil -- Data to be fired with the Activated event
|
|
36
68
|
|
|
37
|
-
self.Activated = self._maid:Add(Signal.new()) -- :Fire(actionMaid, ... (activateData))
|
|
38
|
-
self.Deactivated = self._maid:Add(Signal.new()) -- :Fire()
|
|
69
|
+
self.Activated = self._maid:Add(Signal.new() :: Signal.Signal<...any>) -- :Fire(actionMaid, ... (activateData))
|
|
70
|
+
self.Deactivated = self._maid:Add(Signal.new() :: Signal.Signal<()>) -- :Fire()
|
|
39
71
|
|
|
40
72
|
self.IsActivatedValue = self._maid:Add(ValueObject.new(false, "boolean"))
|
|
41
73
|
|
|
@@ -55,7 +87,7 @@ function BaseAction.new(actionData)
|
|
|
55
87
|
return self
|
|
56
88
|
end
|
|
57
89
|
|
|
58
|
-
function BaseAction
|
|
90
|
+
function BaseAction._handleEnabledChanged(self: BaseAction, isEnabled: boolean): ()
|
|
59
91
|
if not isEnabled then
|
|
60
92
|
self:Deactivate()
|
|
61
93
|
end
|
|
@@ -63,11 +95,11 @@ function BaseAction:_handleEnabledChanged(isEnabled)
|
|
|
63
95
|
self:_updateShortcuts()
|
|
64
96
|
end
|
|
65
97
|
|
|
66
|
-
function BaseAction
|
|
98
|
+
function BaseAction._handleIsActiveValueChanged(self: BaseAction): ()
|
|
67
99
|
if self.IsActivatedValue.Value then
|
|
68
100
|
local actionMaid = Maid.new()
|
|
69
101
|
self._maid._actionMaid = actionMaid
|
|
70
|
-
self.Activated:Fire(actionMaid, unpack(self._activateData))
|
|
102
|
+
self.Activated:Fire(actionMaid, unpack(self._activateData or {}))
|
|
71
103
|
self._activateData = nil
|
|
72
104
|
else
|
|
73
105
|
self._maid._actionMaid = nil
|
|
@@ -75,11 +107,11 @@ function BaseAction:_handleIsActiveValueChanged()
|
|
|
75
107
|
end
|
|
76
108
|
end
|
|
77
109
|
|
|
78
|
-
function BaseAction
|
|
110
|
+
function BaseAction.GetName(self: BaseAction): string
|
|
79
111
|
return self._name
|
|
80
112
|
end
|
|
81
113
|
|
|
82
|
-
function BaseAction
|
|
114
|
+
function BaseAction._withActionData(self: BaseAction, actionData: ActionData): BaseAction
|
|
83
115
|
self._actionData = actionData or error("No actionData")
|
|
84
116
|
|
|
85
117
|
self:_updateShortcuts()
|
|
@@ -87,7 +119,7 @@ function BaseAction:_withActionData(actionData)
|
|
|
87
119
|
return self
|
|
88
120
|
end
|
|
89
121
|
|
|
90
|
-
function BaseAction
|
|
122
|
+
function BaseAction._updateShortcuts(self: BaseAction): ()
|
|
91
123
|
if not self._actionData then
|
|
92
124
|
return
|
|
93
125
|
end
|
|
@@ -108,11 +140,11 @@ function BaseAction:_updateShortcuts()
|
|
|
108
140
|
end
|
|
109
141
|
end
|
|
110
142
|
|
|
111
|
-
function BaseAction
|
|
143
|
+
function BaseAction.GetData(self: BaseAction): ActionData
|
|
112
144
|
return self._actionData
|
|
113
145
|
end
|
|
114
146
|
|
|
115
|
-
function BaseAction
|
|
147
|
+
function BaseAction.ToggleActivate(self: BaseAction, ...): ()
|
|
116
148
|
self._activateData = { ... }
|
|
117
149
|
|
|
118
150
|
if self:IsEnabled() then
|
|
@@ -123,15 +155,15 @@ function BaseAction:ToggleActivate(...)
|
|
|
123
155
|
end
|
|
124
156
|
end
|
|
125
157
|
|
|
126
|
-
function BaseAction
|
|
158
|
+
function BaseAction.IsActive(self: BaseAction): boolean
|
|
127
159
|
return self.IsActivatedValue.Value
|
|
128
160
|
end
|
|
129
161
|
|
|
130
|
-
function BaseAction
|
|
162
|
+
function BaseAction.Deactivate(self: BaseAction): ()
|
|
131
163
|
self.IsActivatedValue.Value = false
|
|
132
164
|
end
|
|
133
165
|
|
|
134
|
-
function BaseAction
|
|
166
|
+
function BaseAction.Activate(self: BaseAction, ...): ()
|
|
135
167
|
self._activateData = { ... }
|
|
136
168
|
|
|
137
169
|
if self:IsEnabled() then
|
|
@@ -141,10 +173,10 @@ function BaseAction:Activate(...)
|
|
|
141
173
|
end
|
|
142
174
|
end
|
|
143
175
|
|
|
144
|
-
function BaseAction
|
|
176
|
+
function BaseAction.Destroy(self: BaseAction): ()
|
|
145
177
|
self._maid:DoCleaning()
|
|
146
178
|
|
|
147
|
-
setmetatable(self, nil)
|
|
179
|
+
setmetatable(self :: any, nil)
|
|
148
180
|
end
|
|
149
181
|
|
|
150
182
|
return BaseAction
|