local A=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local p=A:WaitForChild("\077\111\100\117\108\101\115")local f=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local R=p:WaitForChild("\115\114\099")local u=A:WaitForChild("\077\111\100\101\108\115")local K=require(p.src.GameDatastore)local d=require(R.utils.Logger)local i=require(p.src.assets)local g=require(p.src.actions.toClient.clientSendNotification)local S=require(p.M)local T={}function T.flickerLight(p,A)A.Enabled=true wait(math.random(1,10)/20)A.Enabled=false wait(math.random(1,10)/20)end function T.shakePart(R,A,p)local u=TweenInfo.new(.05,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,50,true,.05)local K={Position=A.Position+Vector3.new(0,0,.1)}local d=f:Create(A,u,K)d:Play()d.Completed:Connect(p)end function T.collectorTrigger(u,A,p,f,R)p.Character.Humanoid:TakeDamage(33)f("\069\118\105\108\095\076\097\117\103\104",A)local d=500 K:incrementCoins(p,d)R:dispatch(g(p,"\084\104\101 \067\111\108\108\101\099\116\111\114 \103\097\118\101 "..(d.." \099\111\105\110\115"),i.money["\099\111\105\110\115-\112\105\108\101"]))wait(5)end function T.ShakeAndFlickerTrigger(u,A,p,f,R)local K=A.Parent.monster.PrimaryPart f("\067\104\097\114\108\105\101\095\072\101\097\100",K)local d=A.Parent.lightPart.PointLight local i=true spawn(function()T:shakePart(K,function()i=false return end)end)while i do T:flickerLight(d)end end function T.trigger(u,A,p,f,R)if A.Name=="\084\104\101\067\111\108\108\101\099\116\111\114"then T:collectorTrigger(A,p,f,R)elseif A.Name=="\083\104\097\107\101\065\110\100\070\108\105\099\107\101\114\084\114\105\103\103\101\114"then T:ShakeAndFlickerTrigger(A,p,f,R)end end return T
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local TweenService = game:GetService('TweenService')
local src = Modules:WaitForChild('src')
local Models = ReplicatedStorage:WaitForChild('Models')
local GameDatastore = require(Modules.src.GameDatastore)
local logger = require(src.utils.Logger)
local assets = require(Modules.src.assets)
local clientSendNotification = require(Modules.src.actions.toClient.clientSendNotification)
local M = require(Modules.M)

local LogicTriggerManager = {}

function LogicTriggerManager:flickerLight(light)
	light.Enabled = true
	wait(math.random(1, 10) / 20)
	light.Enabled = false
	wait(math.random(1, 10) / 20)
end

function LogicTriggerManager:shakePart(part, endFunction)
	local info = TweenInfo.new(
		-- Delay between each tween.
		0.05, -- Time
		Enum.EasingStyle.Linear, -- EasingStyle
		Enum.EasingDirection.Out, -- Easing Direction
		50, -- Repeat Count
		true, -- Reverses to initial position? (true/false)
		0.05
	)
	local goals = { Position = part.Position + Vector3.new(0, 0, 0.1) }
	local Tween = TweenService:Create(part, info, goals)
	Tween:Play()

	Tween.Completed:Connect(endFunction)
end

function LogicTriggerManager:collectorTrigger(part, player, playSound, store)
	player.Character.Humanoid:TakeDamage(33)
	playSound('Evil_Laugh', part)

	local bloodMoney = 500
	GameDatastore:incrementCoins(player, bloodMoney)
	store:dispatch(
		clientSendNotification(
			player,
			'The Collector gave ' .. bloodMoney .. ' coins',
			assets.money['coins-pile']
		)
	)
	wait(5)
end

function LogicTriggerManager:ShakeAndFlickerTrigger(part, player, playSound, store)
	local head = part.Parent.monster.PrimaryPart
	playSound('Charlie_Head', head)

	local light = part.Parent.lightPart.PointLight
	local enabled = true
	spawn(function()
		LogicTriggerManager:shakePart(head, function()
			enabled = false
			return
		end)
	end)

	while enabled do
		LogicTriggerManager:flickerLight(light)
	end
end

function LogicTriggerManager:trigger(part, player, playSound, store)
	if part.Name == 'TheCollector' then
		LogicTriggerManager:collectorTrigger(part, player, playSound, store)
	elseif part.Name == 'ShakeAndFlickerTrigger' then
		LogicTriggerManager:ShakeAndFlickerTrigger(part, player, playSound, store)
	end
end

return LogicTriggerManager