@quenty/soundgroup 1.20.0-canary.544.de8fcee.0 → 1.20.1-canary.545.2374fb2.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 +20 -1
- package/package.json +11 -11
- package/src/Client/SoundGroupServiceClient.lua +2 -1
- package/src/Server/SoundGroupService.lua +2 -1
- package/src/Shared/Effects/SoundEffectsList.lua +2 -2
- package/src/Shared/SoundEffectService.lua +6 -5
- package/src/Shared/Utils/SoundGroupPathUtils.lua +52 -19
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,26 @@
|
|
|
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
|
-
|
|
6
|
+
## [1.20.1-canary.545.2374fb2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/soundgroup@1.20.0...@quenty/soundgroup@1.20.1-canary.545.2374fb2.0) (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
|
+
|
|
17
|
+
# [1.20.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/soundgroup@1.19.4...@quenty/soundgroup@1.20.0) (2025-04-02)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @quenty/soundgroup
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [1.19.4](https://github.com/Quenty/NevermoreEngine/compare/@quenty/soundgroup@1.19.3...@quenty/soundgroup@1.19.4) (2025-03-31)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @quenty/soundgroup
|
|
9
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/soundgroup",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.1-canary.545.2374fb2.0",
|
|
4
4
|
"description": "Service and utility methods to working with sound groups and sounds in Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/baseobject": "10.8.0",
|
|
29
|
-
"@quenty/counter": "7.17.
|
|
30
|
-
"@quenty/instanceutils": "13.17.
|
|
31
|
-
"@quenty/loader": "10.8.0",
|
|
32
|
-
"@quenty/maid": "3.4.0",
|
|
33
|
-
"@quenty/observablecollection": "12.20.
|
|
34
|
-
"@quenty/rx": "13.17.
|
|
35
|
-
"@quenty/table": "3.7.
|
|
36
|
-
"@quenty/valueobject": "13.17.
|
|
28
|
+
"@quenty/baseobject": "10.8.1-canary.545.2374fb2.0",
|
|
29
|
+
"@quenty/counter": "7.17.1-canary.545.2374fb2.0",
|
|
30
|
+
"@quenty/instanceutils": "13.17.1-canary.545.2374fb2.0",
|
|
31
|
+
"@quenty/loader": "10.8.1-canary.545.2374fb2.0",
|
|
32
|
+
"@quenty/maid": "3.4.1-canary.545.2374fb2.0",
|
|
33
|
+
"@quenty/observablecollection": "12.20.1-canary.545.2374fb2.0",
|
|
34
|
+
"@quenty/rx": "13.17.1-canary.545.2374fb2.0",
|
|
35
|
+
"@quenty/table": "3.7.2-canary.545.2374fb2.0",
|
|
36
|
+
"@quenty/valueobject": "13.17.1-canary.545.2374fb2.0"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "2374fb2b043cfbe0e9b507b3316eec46a4e353a0"
|
|
42
42
|
}
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
local require = require(script.Parent.loader).load(script)
|
|
6
6
|
|
|
7
7
|
local Maid = require("Maid")
|
|
8
|
+
local _ServiceBag = require("ServiceBag")
|
|
8
9
|
|
|
9
10
|
local SoundGroupServiceClient = {}
|
|
10
11
|
SoundGroupServiceClient.ServiceName = "SoundGroupServiceClient"
|
|
11
12
|
|
|
12
|
-
function SoundGroupServiceClient:Init(serviceBag)
|
|
13
|
+
function SoundGroupServiceClient:Init(serviceBag: _ServiceBag.ServiceBag)
|
|
13
14
|
assert(not self._serviceBag, "Already initialized")
|
|
14
15
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
15
16
|
self._maid = Maid.new()
|
|
@@ -6,11 +6,12 @@ local require = require(script.Parent.loader).load(script)
|
|
|
6
6
|
|
|
7
7
|
local Maid = require("Maid")
|
|
8
8
|
local WellKnownSoundGroups = require("WellKnownSoundGroups")
|
|
9
|
+
local _ServiceBag = require("ServiceBag")
|
|
9
10
|
|
|
10
11
|
local SoundGroupService = {}
|
|
11
12
|
SoundGroupService.ServiceName = "SoundGroupService"
|
|
12
13
|
|
|
13
|
-
function SoundGroupService:Init(serviceBag)
|
|
14
|
+
function SoundGroupService:Init(serviceBag: _ServiceBag.ServiceBag)
|
|
14
15
|
assert(not self._serviceBag, "Already initialized")
|
|
15
16
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
16
17
|
self._maid = Maid.new()
|
|
@@ -47,7 +47,7 @@ function SoundEffectsList:ObserveHasEffects()
|
|
|
47
47
|
return self._hasEffects:Observe()
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
function SoundEffectsList:IsActive()
|
|
50
|
+
function SoundEffectsList:IsActive(): boolean
|
|
51
51
|
return self._isActive.Value
|
|
52
52
|
end
|
|
53
53
|
|
|
@@ -58,7 +58,7 @@ end
|
|
|
58
58
|
@param effect (instance) -> MaidTask
|
|
59
59
|
@return () -> () -- Cleanup call
|
|
60
60
|
]=]
|
|
61
|
-
function SoundEffectsList:PushEffect(effect)
|
|
61
|
+
function SoundEffectsList:PushEffect(effect: () -> ())
|
|
62
62
|
assert(type(effect) == "function", "Bad effect")
|
|
63
63
|
|
|
64
64
|
return self._effectList:Add(effect)
|
|
@@ -14,11 +14,12 @@ local SoundEffectsRegistry = require("SoundEffectsRegistry")
|
|
|
14
14
|
local SoundGroupPathUtils = require("SoundGroupPathUtils")
|
|
15
15
|
local SoundGroupTracker = require("SoundGroupTracker")
|
|
16
16
|
local WellKnownSoundGroups = require("WellKnownSoundGroups")
|
|
17
|
+
local _ServiceBag = require("ServiceBag")
|
|
17
18
|
|
|
18
19
|
local SoundEffectService = {}
|
|
19
20
|
SoundEffectService.ServiceName = "SoundEffectService"
|
|
20
21
|
|
|
21
|
-
function SoundEffectService:Init(serviceBag)
|
|
22
|
+
function SoundEffectService:Init(serviceBag: _ServiceBag.ServiceBag)
|
|
22
23
|
assert(not self._serviceBag, "Already initialized")
|
|
23
24
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
24
25
|
self._maid = Maid.new()
|
|
@@ -36,14 +37,14 @@ end
|
|
|
36
37
|
@param sound Sound
|
|
37
38
|
@param soundGroupPath string? -- Optional
|
|
38
39
|
]=]
|
|
39
|
-
function SoundEffectService:RegisterSFX(sound, soundGroupPath)
|
|
40
|
+
function SoundEffectService:RegisterSFX(sound: Sound, soundGroupPath: string?)
|
|
40
41
|
assert(typeof(sound) == "Instance" and sound:IsA("Sound"), "Bad sound")
|
|
41
42
|
assert(SoundGroupPathUtils.isSoundGroupPath(soundGroupPath) or soundGroupPath == nil, "Bad soundGroupPath")
|
|
42
43
|
|
|
43
44
|
sound.SoundGroup = self:GetOrCreateSoundGroup(soundGroupPath or WellKnownSoundGroups.SFX)
|
|
44
45
|
end
|
|
45
46
|
|
|
46
|
-
function SoundEffectService:GetOrCreateSoundGroup(soundGroupPath)
|
|
47
|
+
function SoundEffectService:GetOrCreateSoundGroup(soundGroupPath: string): SoundGroup
|
|
47
48
|
assert(SoundGroupPathUtils.isSoundGroupPath(soundGroupPath), "Bad soundGroupPath")
|
|
48
49
|
|
|
49
50
|
local found = self:GetSoundGroup(soundGroupPath)
|
|
@@ -55,7 +56,7 @@ function SoundEffectService:GetOrCreateSoundGroup(soundGroupPath)
|
|
|
55
56
|
return SoundGroupPathUtils.findOrCreateSoundGroup(soundGroupPath)
|
|
56
57
|
end
|
|
57
58
|
|
|
58
|
-
function SoundEffectService:GetSoundGroup(soundGroupPath)
|
|
59
|
+
function SoundEffectService:GetSoundGroup(soundGroupPath: string): SoundGroup
|
|
59
60
|
assert(SoundGroupPathUtils.isSoundGroupPath(soundGroupPath), "Bad soundGroupPath")
|
|
60
61
|
|
|
61
62
|
if not self._tracker then
|
|
@@ -75,7 +76,7 @@ function SoundEffectService:GetSoundGroup(soundGroupPath)
|
|
|
75
76
|
return SoundGroupPathUtils.findOrCreateSoundGroup(soundGroupPath)
|
|
76
77
|
end
|
|
77
78
|
|
|
78
|
-
function SoundEffectService:PushEffect(soundGroupPath, effect)
|
|
79
|
+
function SoundEffectService:PushEffect(soundGroupPath: string, effect)
|
|
79
80
|
assert(SoundGroupPathUtils.isSoundGroupPath(soundGroupPath), "Bad soundGroupPath")
|
|
80
81
|
assert(type(effect) == "function", "Bad effect")
|
|
81
82
|
|
|
@@ -1,60 +1,93 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
@class SoundGroupPathUtils
|
|
3
4
|
]=]
|
|
4
5
|
|
|
5
|
-
local require = require(script.Parent.loader).load(script)
|
|
6
|
-
|
|
7
6
|
local SoundService = game:GetService("SoundService")
|
|
8
7
|
|
|
9
8
|
local SoundGroupPathUtils = {}
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
--[=[
|
|
11
|
+
Checks if the given string is a valid sound group path.
|
|
12
|
+
|
|
13
|
+
@param soundGroupPath string
|
|
14
|
+
@return boolean
|
|
15
|
+
]=]
|
|
16
|
+
function SoundGroupPathUtils.isSoundGroupPath(soundGroupPath: string): boolean
|
|
12
17
|
return type(soundGroupPath) == "string"
|
|
13
18
|
end
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
--[=[
|
|
21
|
+
Converts a sound group path into a table of strings.
|
|
22
|
+
|
|
23
|
+
@param soundGroupPath string
|
|
24
|
+
@return { string }
|
|
25
|
+
]=]
|
|
26
|
+
function SoundGroupPathUtils.toPathTable(soundGroupPath: string): { string }
|
|
16
27
|
assert(type(soundGroupPath) == "string", "Bad soundGroupPath")
|
|
17
28
|
|
|
18
29
|
return string.split(soundGroupPath, ".")
|
|
19
30
|
end
|
|
20
31
|
|
|
21
|
-
|
|
32
|
+
--[=[
|
|
33
|
+
Converts a table of strings into a sound group path.
|
|
34
|
+
|
|
35
|
+
@param soundGroupPath string
|
|
36
|
+
@param root Instance?
|
|
37
|
+
@return SoundGroup
|
|
38
|
+
]=]
|
|
39
|
+
function SoundGroupPathUtils.findSoundGroup(soundGroupPath: string, root: Instance?): SoundGroup?
|
|
22
40
|
assert(type(soundGroupPath) == "string", "Bad soundGroupPath")
|
|
23
41
|
assert(typeof(root) == "Instance" or root == nil, "Bad root")
|
|
24
42
|
|
|
25
|
-
local current = SoundService
|
|
43
|
+
local current: Instance = root or SoundService
|
|
26
44
|
for _, soundGroupName in SoundGroupPathUtils.toPathTable(soundGroupPath) do
|
|
27
|
-
|
|
28
|
-
if not
|
|
45
|
+
local found = SoundGroupPathUtils._findSoundGroup(current, soundGroupName)
|
|
46
|
+
if not found then
|
|
29
47
|
return nil
|
|
30
48
|
end
|
|
49
|
+
current = found
|
|
31
50
|
end
|
|
32
51
|
|
|
33
|
-
|
|
52
|
+
if current ~= root and current:IsA("SoundGroup") then
|
|
53
|
+
return current
|
|
54
|
+
else
|
|
55
|
+
return nil
|
|
56
|
+
end
|
|
34
57
|
end
|
|
35
58
|
|
|
36
|
-
|
|
59
|
+
--[=[
|
|
60
|
+
Converts a table of strings into a sound group path.
|
|
61
|
+
|
|
62
|
+
@param soundGroupPath string
|
|
63
|
+
@return SoundGroup
|
|
64
|
+
]=]
|
|
65
|
+
function SoundGroupPathUtils.findOrCreateSoundGroup(soundGroupPath: string, root: Instance?): SoundGroup
|
|
37
66
|
assert(type(soundGroupPath) == "string", "Bad soundGroupPath")
|
|
38
67
|
assert(typeof(root) == "Instance" or root == nil, "Bad root")
|
|
39
68
|
|
|
40
|
-
local current = root or SoundService
|
|
69
|
+
local current: Instance = root or SoundService
|
|
41
70
|
|
|
42
71
|
for _, soundGroupName in SoundGroupPathUtils.toPathTable(soundGroupPath) do
|
|
43
72
|
local parent = current
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if
|
|
47
|
-
current =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
73
|
+
local found = SoundGroupPathUtils._findSoundGroup(parent, soundGroupName)
|
|
74
|
+
|
|
75
|
+
if found then
|
|
76
|
+
current = found
|
|
77
|
+
else
|
|
78
|
+
local constructed = Instance.new("SoundGroup")
|
|
79
|
+
constructed.Name = soundGroupName
|
|
80
|
+
constructed.Volume = 1
|
|
81
|
+
constructed.Parent = parent
|
|
82
|
+
current = constructed
|
|
51
83
|
end
|
|
52
84
|
end
|
|
53
85
|
|
|
86
|
+
assert(current:IsA("SoundGroup"), "Current is not a SoundGroup")
|
|
54
87
|
return current
|
|
55
88
|
end
|
|
56
89
|
|
|
57
|
-
function SoundGroupPathUtils._findSoundGroup(parent, soundGroupName)
|
|
90
|
+
function SoundGroupPathUtils._findSoundGroup(parent: Instance, soundGroupName: string): SoundGroup?
|
|
58
91
|
for _, item in parent:GetChildren() do
|
|
59
92
|
if item:IsA("SoundGroup") and item.Name == soundGroupName then
|
|
60
93
|
return item
|