Kinkocalypse = Kinkocalypse or {}

local function KinkocalypseOnNewGame(player, square)
	if player:HasTrait("BondageLover") then
		local bondageSet = player:getInventory():AddItem("Kinkocalypse.RestrainsControllCenter")
		ISTimedActionQueue.add(ISWearClothing:new(player, bondageSet, 1))
	end
end

Events.OnNewGame.Add(KinkocalypseOnNewGame)

local function isModActivate(ModID)
	return getActivatedMods():contains(ModID)
end

local function KinkocalypseOnGameBoot()
	-- Apply other mods overrides
	if ClothesAboutToChange ~= nil and Kinkocalypse.ClothesAboutToChangeOrig == nil then
		print("Override ClothesAboutToChange from LifeStyle mod...")
		Kinkocalypse.ClothesAboutToChangeOrig = ClothesAboutToChange
		ClothesAboutToChange = Kinkocalypse.ClothesAboutToChange
	end
	
	local ConditionalSpeechStatus, ConditionalSpeech = pcall(require, "ConditionalSpeech02_Core")
	if ConditionalSpeech and ConditionalSpeech.Say ~= nil and Kinkocalypse.ConditionalSpeechSayOrig == nil then
		print("Override Say from ConditionalSpeech mod...")
		Kinkocalypse.ConditionalSpeechSayOrig = ConditionalSpeech.Say
		ConditionalSpeech.Say = Kinkocalypse.ConditionalSpeechSay
	end
	
	if ISAnimationAction then
		Kinkocalypse.ZomboWinISAnimationActionOrigStart = ISAnimationAction.start
		ISAnimationAction.start = function(self) Kinkocalypse.ISAnimationActionStart(self) end
	end
	
	-- if Excrementum then	
	if isModActivate(Excrementum41) then
		Kinkocalypse.ExcrementumDefecateDropPantsActionStart = DefecateDropPantsAction.start
		Kinkocalypse.ExcrementumUrinateDropPantsActionStart = UrinateDropPantsAction.start
		
		DefecateDropPantsAction.start = function(self)
			local equipedTags = Kinkocalypse.GetPlayerEquipedRestrictionsTags()
			if equipedTags["ChainedHandsBack"] ~= nil then
				DefecateDropPantsAction.stop(self)
				return
			end
			Kinkocalypse.ExcrementumDefecateDropPantsActionStart(self)
		end
		
		UrinateDropPantsAction.start = function(self)
			local equipedTags = Kinkocalypse.GetPlayerEquipedRestrictionsTags()
			if equipedTags["ChainedHandsBack"] ~= nil then
				UrinateDropPantsAction.stop(self)
				return
			end
			Kinkocalypse.ExcrementumUrinateDropPantsActionStart(self)
		end
	end
end

Events.OnGameBoot.Add(KinkocalypseOnGameBoot)