-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrc.lua
More file actions
93 lines (81 loc) · 2.9 KB
/
src.lua
File metadata and controls
93 lines (81 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
local Class = require(script.Class)
local Nocturne = Class.new("Nocturne")
local SecurityService = require(script.SecurityService)
local NetworkModule = require(script.NetworkModule)
---@class Nocturne
---@brief Manages core functionalities for the game, including assets, remotes, and security.
function Nocturne:initialize()
self.loadedAssets = {}
self.remotes = {}
self.controllerServiceLoader = ControllerServiceLoader.new()
self.securityService = SecurityService.new()
self.networkModule = NetworkModule.new()
self.securityService:start()
-- Connect security checks to player events
game.Players.PlayerAdded:Connect(function(player)
self.securityService:checkSuspiciousBehavior(player)
self.securityService:monitorHealth(player)
self.securityService:validateInventory(player)
self.securityService:checkPlayerVelocity(player)
self.securityService:monitorPlayerState(player)
self.securityService:validatePlayerPosition(player)
end)
end
---@param assetId string The ID of the asset to load.
---@return Asset The loaded asset.
function Nocturne:loadAsset(assetId)
local asset = game.Assets:Load(assetId)
self.loadedAssets[assetId] = asset
return asset
end
---@param assetId string The ID of the asset to unload.
function Nocturne:unloadAsset(assetId)
local asset = self.loadedAssets[assetId]
if asset then
game.Assets:Unload(assetId)
self.loadedAssets[assetId] = nil
end
end
---@return number The number of loaded assets.
function Nocturne:getAssetCount()
return #self.loadedAssets
end
---@param eventName string The name of the remote event.
---@param ... any The arguments to pass to the remote event.
function Nocturne:fireRemoteEvent(eventName, ...)
local remote = self.remotes[eventName]
if remote then
self.networkModule:fireRemoteEvent(remote, ...)
else
warn("Remote event not found: " .. eventName)
end
end
---@param eventName string The name of the remote event.
---@param callback function The callback function to execute when the remote event is fired.
function Nocturne:connectRemoteEvent(eventName, callback)
local remote = self.remotes[eventName]
if remote then
self.networkModule:onServerEvent(remote, callback)
else
warn("Remote event not found: " .. eventName)
end
end
---@param eventName string The name of the remote event.
---@param callback function The callback function to disconnect.
function Nocturne:disconnectRemoteEvent(eventName, callback)
local remote = self.remotes[eventName]
if remote then
remote.OnServerEvent:Disconnect(callback)
else
warn("Remote event not found: " .. eventName)
end
end
---@return ControllerServiceLoader The controller and service loader.
function Nocturne:getControllerServiceLoader()
return self.controllerServiceLoader
end
---@return SecurityService The security and exploit prevention service.
function Nocturne:getSecurityService()
return self.securityService
end
return Nocturne