LogicManager_Npc_Userdata = class("LogicManager_Creature_Userdata",LogicManager_Creature_Userdata)

function LogicManager_Npc_Userdata:ctor()
	LogicManager_Npc_Userdata.super.ctor(self)
	self:AddSetCall(ProtoCommon_pb.EUSERDATATYPE_ALPHA,self.SetAlpha)
	self:AddUpdateCall(ProtoCommon_pb.EUSERDATATYPE_ALPHA,self.UpdateAlpha)

	self:AddUpdateCall(ProtoCommon_pb.EUSERDATATYPE_HAIR,self.SetChangeDressDirty)
	self:AddUpdateCall(ProtoCommon_pb.EUSERDATATYPE_LEFTHAND,self.SetChangeDressDirty)
	self:AddUpdateCall(ProtoCommon_pb.EUSERDATATYPE_RIGHTHAND,self.SetChangeDressDirty)
	self:AddUpdateCall(ProtoCommon_pb.EUSERDATATYPE_HEAD,self.SetChangeDressDirty)
	self:AddUpdateCall(ProtoCommon_pb.EUSERDATATYPE_BACK,self.SetChangeDressDirty)
end

function LogicManager_Npc_Userdata:SetAlpha(ncreature,userDataID,oldValue,newValue)
	local value = newValue/1000
	ncreature:Server_SetAlpha(value)
end

function LogicManager_Npc_Userdata:UpdateAlpha(ncreature,userDataID,oldValue,newValue)
	local value = newValue/1000
	ncreature:Server_SetAlpha(value)
end

--npc 換裝開始
function LogicManager_Npc_Userdata:SetChangeDressDirty(ncreature,userDataID,oldValue,newValue)
	self.changeDressDirty = true
	if(newValue~=0 and ncreature ~=nil and ncreature.data ~=nil) then

	-- redlog("SetChangeDressDirty",ncreature,userDataID,oldValue,newValue)
		ncreature.data:SetUseServerDressData(true)
	end
	if ncreature and ncreature.data and ncreature.data:IsPet() then
		GameFacade.Instance:sendNotification(PetCreatureEvent.PetChangeDress, ncreature)
	end
end

local superCheckDressDirty = LogicManager_Npc_Userdata.super.CheckDressDirty
function LogicManager_Npc_Userdata:CheckDressDirty(ncreature)
	if(self.changeDressDirty) then
		if(not self:CheckHasAnyDressData(ncreature)) then
			ncreature.data:SetUseServerDressData(false)
		end
	end
	superCheckDressDirty(self,ncreature)
end
--npc 換裝結束
