PlaceableHusbandryAnimalsDealer = {};

local function getSpecName(self, specName)
	local spec = self["spec_".. Utils.getNoNil(RegisterSpecialization.modName, g_currentModName).. ".".. specName];
	if spec ~= nil then
        return spec;
    end;
    return self["spec_".. specName];
end;

function PlaceableHusbandryAnimalsDealer.prerequisitesPresent(specializations)
    return SpecializationUtil.hasSpecialization(PlaceableHusbandry, specializations) or true;
end;

function PlaceableHusbandryAnimalsDealer.registerEventListeners(placeableType)    
    SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableHusbandryAnimalsDealer);    
end;

function PlaceableHusbandryAnimalsDealer:onLoad(savegame)    
	local isLoaded = false;
	local spec = self.spec_husbandryAnimals;
    local specTrigger = self.spec_animalLoadingTrigger;
	local husbandry = self.husbandry;
	if spec ~= nil and spec.animalLoadingTrigger ~= nil then
		if spec.animalLoadingTrigger.isDealer then
			isLoaded = g_additionalContractMapData:insertTypeObject("animalDealer", spec.animalLoadingTrigger, true, "trigger");			
		end;	
	end;
	if specTrigger ~= nil and specTrigger.animalLoadingTrigger ~= nil then
		if specTrigger.animalLoadingTrigger.isDealer then
			isLoaded = g_additionalContractMapData:insertTypeObject("animalDealer", specTrigger.animalLoadingTrigger, true, "trigger");			
		end;	
	end;
	if self.husbandry ~= nil and self.isDealer then
		isLoaded = g_additionalContractMapData:insertTypeObject("animalDealer", self, true, "trigger");		
	end;	
end;
