--[[
	Sets the locked status of the given emote for the specified player. The
	player will be updated of this change via a RemoteEvent.

	Parameters:
	- player - The Player whose emote lock status will be changed
	- emoteName - The name of the emote that will have its lock status changed
	- isLocked - The lock status to change to
]]

function EmoteManager:setEmoteIsLockedForPlayer(player, emoteName, isLocked)
	-- Wait for all setup for the player to complete before changing the locked
	-- status of an emote
	if not self.playerOwnedEmotes[player.UserId] then
		local updatedPlayerId = nil
		while updatedPlayerId ~= player.UserId do
			updatedPlayerId = self.updatedPlayerEmotes.Event:Wait()
		end
	end

	local allPlayerEmotes = self.playerEmoteConfig[player.UserId]

	local emote = allPlayerEmotes[emoteName]
	if emote then
		local newEmotes = Cryo.Dictionary.join(allPlayerEmotes, {
			[emoteName] = Cryo.Dictionary.join(emote, {
				isLocked = isLocked,
			}),
		})

		self.playerEmoteConfig[player.UserId] = newEmotes
		self.remotes.sendUpdatedEmotes:FireClient(player, newEmotes)
	else
		error(string.format("The emote with the name %s does not exist", emoteName))
	end
end
