local L=game:GetService("\083\101\114\118\101\114\083\099\114\105\112\116\083\101\114\118\105\099\101")local P=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local Y=require(P.Packages.RECS)local B=require(L.Components.Example)local s=Y.System:extend("\069\120\097\109\112\108\101")function s.init(L)for P,Y in L.core:components(B)do L:added(P,Y)end L.componentAddedSignal=L.core:getComponentAddedSignal(B)L.maid.componentAddedConnection=L.componentAddedSignal:connect(function(P,Y)L:added(Y,P)end)L.componentRemovingSignal=L.core:getComponentRemovingSignal(B)L.maid.componentRemovingConnection=L.componentRemovingSignal:connect(function(P,Y)L:removing(P,Y)end)end function s.added(Y,L,P)wait()end function s.removing(Y,L,P)wait()end function s.step(L) end return s
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RECS = require(ReplicatedStorage.Packages.RECS)
local ExampleComponent = require(ServerScriptService.Components.Example)

--[[
	System setup
	================
]]

local Example = RECS.System:extend("Example")

function Example:init()
	for instance, component in self.core:components(ExampleComponent) do
		self:added(instance, component)
	end

	self.componentAddedSignal = self.core:getComponentAddedSignal(ExampleComponent)
	self.maid.componentAddedConnection = self.componentAddedSignal:connect(function(component, instance)
		self:added(instance, component)
	end)

	self.componentRemovingSignal = self.core:getComponentRemovingSignal(ExampleComponent)
	self.maid.componentRemovingConnection = self.componentRemovingSignal:connect(function(instance, component)
		self:removing(instance, component)
	end)
end

function Example:added(instance, component)
	wait() -- HACK, having to wait for the inst to have the component applied

	-- Do added stuff with the component here!
end

function Example:removing(instance, component)
	wait() -- HACK, having to wait for the inst to have the component applied

	-- Do removing stuff with the component here!
end

function Example:step()
	-- Do stuff on step!
end

return Example
