--[[
	Function called upon entering the state
]]

function PlayerCamera.onEnter(stateMachine, serverPlayer, event, from, to)
	local player = serverPlayer.player

	coroutine.wrap(
		function()
			local character = player.Character or player.CharacterAdded:Wait()
			local primaryPart = character.PrimaryPart

			onCharacterAdded(stateMachine, player, character)

			MonsterManager.createInterestWhileTrue(
				primaryPart.Position,
				NOISE_GENERATED,
				function()
					return stateMachine.current == "camera"
				end
			)
		end
	)()

	connections.leaveCamera =
		LeaveCamera.OnServerEvent:Connect(
		function(sendingPlayer)
			if sendingPlayer == player then
				stateMachine:endCamera()
			end
		end
	)
end
