---@class GuardPetInfo GuardPetInfo = class() local this = GuardPetInfo function this:ctor() end function this:Reset() end function this:Init() self.guardPetInfoList={} self:InitData() self:RegistMessages() end function this:InitData() end function this:RegistMessages() SL:RegisterLuaNetMsg(LuaMessageIdToClient.EQUIP_GUARD_ALL_RES,self.EquipGuardAllRes,self) SL:RegisterLuaNetMsg(LuaMessageIdToClient.EQUIP_GUARD_RES,self.EquipGuardRes,self) SL:RegisterLUAEvent(LUA_EVENT_GUARDPET_PUT,self.LUA_EVENT_GUARDPET_PUT,self) end function this:LUA_EVENT_GUARDPET_PUT(_,data) local _data = data._data local tbl = SL:GetConfig("cfg_equip_guard",data.cfgId) local data = { id = _data.id, cfgId = data.cfgId, x = _data.oldCoord.x, y = _data.oldCoord.z, isUI = _data.isUI, guardTbl = tbl} SL:CreateGuardPet(data) end function this:EquipGuardAllRes(_,message) if message == "" then return end for i, v in pairs(message) do self.guardPetInfoList[v.id] = v end end function this:EquipGuardRes(_,message) if message == "" then return end self.guardPetInfoList[message.id] = message end function this:GetGuardHp(id) if self.guardPetInfoList[id] then return self.guardPetInfoList[id].hp end SL:LogWarning("this guard id->hp is nil") return 0 end function this:GetGuardBaseAttr(equip_pos, cfgId, id) local itemInfo = SL:GetPosItemInfo(equip_pos, cfgId, id) --玩家背包穿戴读不到就去读配置表 local grade = SL:GetEquipValue(EMetaVarGetKey.EQUIP_GRADE, equip_pos, cfgId, id) local attribute = SL:GetConfig("cfg_equip_guard",cfgId).stage if attribute then local baseAttr = {} for i, v in pairs(attribute) do local oneAttr = {} oneAttr.type = v[1] oneAttr.num = v[2] table.insert(baseAttr, oneAttr) end return baseAttr end end function this:GetGuardSpecialShowData(cfgId) ---@type cfg_equip_guard_column local guardInfo = SL:GetConfig("cfg_equip_guard",cfgId) local attr = {} if guardInfo.ability == 1 then table.insert(attr,{title = "tips_attribute20"}) table.insert(attr,{name="自动拾取",value = ""}) --elseif guardInfo.ability == 2 then -- table.insert(attr,{title = "tips_attribute20"}) -- for i, skill_id in pairs(guardInfo.abilityParameter) do -- local skill_name = SL:GetConfig("cfg_skill",skill_id).name -- table.insert(attr, { name = skill_name, value = "" }) -- end end return attr end