local AttrComponent = class("AttrComponent") local private = {} local FP=FP local LuaConst=LuaConst local ipairs=ipairs local tostring=tostring local pairs=pairs local type=type local EDependType = { LIMIT = 1, RATIO_PLUS = 2, --a依赖b,则a会增加b比例的a的基础值 } --默认属性依赖规则,目前的需求是所有单位都统一,未来可能会有极小可能根据职业改变的需求 local DEFAULT_ATTR_DEPEND_RULES = { {attr = "hp",dependToAttr = "hplmt",dependType = EDependType.LIMIT,dependParam1 = FP.Const.Zero}, {attr = "hplmt",dependToAttr = "hplmtRatio",dependType = EDependType.RATIO_PLUS}, {attr = "sa",dependToAttr = "salmt",dependType = EDependType.LIMIT,dependParam1 = FP.Const.Zero}, {attr = "am",dependToAttr = "amlmt",dependType = EDependType.LIMIT,dependParam1 = FP.Const.Zero}, {attr = "atk",dependToAttr = "atkRatio",dependType = EDependType.RATIO_PLUS}, {attr = "def",dependToAttr = "defRatio",dependType = EDependType.RATIO_PLUS}, } local DEFAULT_DEPEND_ATTR_DIC = {} --有哪些属性依赖别人,key是attr,value是一个数组,数组元素是rule local DEFAULT_DEPENDED_ATTR_DIC = {} --有哪些属性被被人依赖,key是被依赖的attr,value是一个数组,数组元素是rule --预处理规则,使访问更快 for i,rule in ipairs(DEFAULT_ATTR_DEPEND_RULES) do DEFAULT_DEPEND_ATTR_DIC[rule.attr] = DEFAULT_DEPEND_ATTR_DIC[rule.attr] or {} table.insert(DEFAULT_DEPEND_ATTR_DIC[rule.attr],rule) DEFAULT_DEPENDED_ATTR_DIC[rule.dependToAttr] = DEFAULT_DEPENDED_ATTR_DIC[rule.dependToAttr] or {} table.insert(DEFAULT_DEPENDED_ATTR_DIC[rule.dependToAttr],rule) end function AttrComponent:initialize(entity, attrTable, attrID, initHP) self.Entity = entity --需预测回滚 -- 继承自己属性的列表:{ attrComp ,attrComp } self.SonAttrCompList = {} -- 自己属性来自谁 ,父亲的entity等于 FatherAttrComp.Entity self.FatherAttrComp = nil self.InheritFatherAttrType = 0 -- 当属性需要随着父entity属性变化而变化时,控制哪些属性需要随之变化。 --初始化属性,最原始的无污染的属性 self.InitAttr = {} --属性--记录buff需要恢复的属性字典数据(血、无双、霸体、护盾 不记录) {[attrType] = {modifydata,modifydata}} --元素是list,list的元素是RuntimeDataManager.New_AttrCalculate的返回值,包含Value、AssignType self.AttrModificationDic = {} self.AttrBaseValDic = {} --血量 self.hp = FP.newV1(0) --self.AttrBaseValDic["hp"] = self.hp:cloneV1() --动态属性不需要设置基础值 --无双值 self.sa = FP.newV1(0) --self.AttrBaseValDic["sa"] = self.sa:cloneV1() --动态属性不需要设置基础值 --霸体值(superArom) self.am = FP.newV1(0) --self.AttrBaseValDic["am"] = self.am:cloneV1() --动态属性不需要设置基础值 --护盾,抵挡伤害用(Protective cover) self.pc = FP.newV1(0) --self.AttrBaseValDic["pc"] = self.pc:cloneV1() --动态属性不需要设置基础值 self.gs = 0 --持有护盾数值的buff ,{{buffid ,leftDamge} ,{buffid ,leftDamge}} self.PCBuffList = {} --不需要预测回滚 --玩家属性-可变化的属性 = 初始化属性+buffs属性 ,但是不包含上面的血无霸三属性 self.AttrInfo = {} self._dependRecalcSafeGuard = 0 -- RecalculateDepend堆栈深度 private.InitAttributeData(self, entity, attrTable, attrID, initHP) self:SetGs(LevelManager.GetLevelGs()) end --设置战力 function AttrComponent:SetGs(gs) self.gs = gs or 0 end --返回战力,可能返回 function AttrComponent:GetGs() return self.gs end function AttrComponent:AddGs(delta) self.gs = (self.gs or 0) + (delta or 0) end function AttrComponent:IsAlive() return self.hp > FP.Const.Zero end --[[ 总血量 --]] function AttrComponent:MaxHP() return self.AttrInfo[LuaConst.AttrType.hplmt] end --[[ 总无双值 --]] function AttrComponent:MaxSA() return self.AttrInfo[LuaConst.AttrType.salmt] end --[[ 总霸体值 --]] function AttrComponent:MaxAM() local vla = self.AttrInfo[LuaConst.AttrType.amlmt] if vla == nil then return FP.Const.Zero end return vla end --[[ 是否无双值满了 --]] function AttrComponent:IsSAFilled() if GlobalBattleData.Get_IsSkillNoCD() then return true end return self.sa >= self.AttrInfo[LuaConst.AttrType.salmt] end --[[ 血量比例,1是满血,0.5是半血 ... --]] function AttrComponent:HitPointPercents(outResult) local maxHp = self:MaxHP() if outResult then if maxHp == FP.Const.Zero then outResult:Reset() else outResult:Reset(self.hp):Div(maxHp) end return outResult end return maxHp ~= FP.Const.Zero and self.hp / maxHp or FP.Const.Zero end local _tempV1_CVAAV = FP.newV1(0) -- CVAAV 是 CalcVariableAdaptiveAttrValue的缩写 function private.CalcVariableAdaptiveAttrValue(calcParams,adaptiveVar) local result = FP.newV1(0) local a = calcParams.ParaA local b = calcParams.ParaB local c = calcParams.ParaC local d = calcParams.ParaD if a ~= 0 then if a >= 0.001 then _tempV1_CVAAV:Reset(a):Mul(adaptiveVar):Mul(adaptiveVar):Mul(adaptiveVar) else --如果小于帧同步的精度,则需要做特殊处理 a = a * 10 _tempV1_CVAAV:Reset(a):Mul(adaptiveVar):Mul(adaptiveVar):Mul(adaptiveVar):Div(10) end result:Add(_tempV1_CVAAV) end if b ~= 0 then if b >= 0.001 then _tempV1_CVAAV:Reset(b):Mul(adaptiveVar):Mul(adaptiveVar) else --如果小于帧同步的精度,则需要做特殊处理 b = b * 10 _tempV1_CVAAV:Reset(b):Mul(adaptiveVar):Mul(adaptiveVar):Div(10) end result:Add(_tempV1_CVAAV) end if c ~= 0 then if c >= 0.001 then _tempV1_CVAAV:Reset(c):Mul(adaptiveVar) else --如果小于帧同步的精度,则需要做特殊处理 c = c * 10 _tempV1_CVAAV:Reset(c):Mul(adaptiveVar):Div(10) end result:Add(_tempV1_CVAAV) end result:Add(d) return result end --[[ 属性初始化 --]] function private.InitAttributeData(self, entity, attrTable, attrID, initHP) if entity.isPickupItem then self.hp = FP.newV1(1) self.AttrInfo[LuaConst.AttrType.hplmt] = FP.newV1(1) return end self:InitAttrDependRules() --monsterValue表配置默认属性 self.InitAttr[LuaConst.AttrType.findmgvar] = FP.newV1(0) self.InitAttr[LuaConst.AttrType.anitfindmgvar] = FP.newV1(0) local AdaptiveType = entity._logicInitData._characterData.AdaptiveType if AdaptiveType == LuaConst.EValueAdaptiveType.DEFAULT_DIFFICULTY or AdaptiveType == LuaConst.EValueAdaptiveType.BY_DIFFICULTY or AdaptiveType == LuaConst.EValueAdaptiveType.DEFAULT_DIFFICULTY_COULD_OVERRIDE_BY_SERVER then local difficulty = 1 if AdaptiveType == LuaConst.EValueAdaptiveType.BY_DIFFICULTY then difficulty = LevelManager:GetLevelDifficulty() elseif AdaptiveType == LuaConst.EValueAdaptiveType.DEFAULT_DIFFICULTY or AdaptiveType == LuaConst.EValueAdaptiveType.DEFAULT_DIFFICULTY_COULD_OVERRIDE_BY_SERVER then difficulty = 1 end local groupId = attrID or entity._logicInitData._characterData.AdaptiveParam local monsterValue = DataSheetManager.MonsterValueData:GetDataByGroupID_Difficulty(groupId,difficulty) if monsterValue then local value = nil for i,attrName in ipairs(LuaConst.AttrIntType) do value = monsterValue[attrName] if value then self.InitAttr[attrName] = FP.newV1(value) self:SetAttrBaseValue(attrName,value) --self.AttrInfo[attrName] = self.InitAttr[attrName]:cloneV1() --base old HYW end end else logging.error(LTAG.ERROR, "HYW :策划注意 monsterValue 为空 ! groupId : ", groupId, " difficulty : ", difficulty, " characterID : ", entity._logicInitData.CharacterID) end elseif AdaptiveType == LuaConst.EValueAdaptiveType.BY_FORMULA then -- local lv = PlayerInfoManager.GetMainPlayerLv() -- local levelRange = PlayerInfoManager.GetLvRange(lv) local adaptiveVariable = LevelManager.GetFormulaAdaptiveVariable()-- local variableRange = LevelManager.GetFormulaAdaptiveVariableRange(adaptiveVariable) local groupId = entity._logicInitData._characterData.AdaptiveParam local adaptedLevelData = DataSheetManager.MonsterAdaptedLevelData:GetDataByGroupID_LevelRange(groupId,variableRange) if adaptedLevelData then local attrName for i,calcParams in ipairs(adaptedLevelData.CalcParams_Table) do attrName = LuaConst.AttrIntType[calcParams.AttrType] self.InitAttr[attrName] = private.CalcVariableAdaptiveAttrValue(calcParams,adaptiveVariable) --self.AttrInfo[attrName] = self.InitAttr[attrName]:cloneV1()--base old HYW self:SetAttrBaseValue(attrName,self.InitAttr[attrName]) end else self.InitAttr["hplmt"] = FP.newV1(1) self:SetAttrBaseValue("hplmt",self.InitAttr["hplmt"]) --强行设置血量为1,以避免一些后续的问题,比如玩家回不了主城 logging.error(LTAG.ERROR, "HYW : 致命错误! MonsterAdaptedLevelData表中找不到数据! characterID : ", entity:GetCharacterID(), " groupId : ", groupId, " variableRange:", variableRange) end elseif AdaptiveType == LuaConst.EValueAdaptiveType.BY_FORMULA_SERVER_GS or AdaptiveType == LuaConst.EValueAdaptiveType.BY_FORMULA_SERVER_GS_HeroCount then local FormulaCalculator = require"Battle/Logic/Missile/FormulaCalculator" local attrDic = FormulaCalculator.CalculateMonsterAttrByStandardPlayerAttr( LevelManager.CurLevelFunc:GetStandardPlayerAttrDic(entity), LevelManager.CurLevelFunc:GetMonsterValueDataByPowerPoint(entity), AdaptiveType == LuaConst.EValueAdaptiveType.BY_FORMULA_SERVER_GS_HeroCount) attrTable = nil for attrName, value in pairs(attrDic) do -- pairs safe 属性数据初始化对顺序不敏感 self.InitAttr[attrName] = value:cloneV1() self:SetAttrBaseValue(attrName, self.InitAttr[attrName]) end elseif AdaptiveType ~= nil then logging.error(LTAG.ERROR, "HYW : AdaptiveType bad value : ", AdaptiveType) end --服务器下发玩家的部分属性(可以覆盖上面的默认属性) if attrTable then for key,attr in ipairs(attrTable) do if attr ~= -1 then local attrName = LuaConst.AttrIntType[key] local attrFp = FP.newV1(attr) self.InitAttr[attrName] = attrFp --self.AttrInfo[attrName] = attrFp:cloneV1()--base old HYW self:SetAttrBaseValue(attrName,attrFp) end end end if AdaptiveType == LuaConst.EValueAdaptiveType.DEFAULT_DIFFICULTY_COULD_OVERRIDE_BY_SERVER then local serverAttrInfos = LevelManager.GetServerAttrInfos() if serverAttrInfos then for i,attrInfo in ipairs(serverAttrInfos) do local attrName = LuaConst.AttrIntType[attrInfo.attrId] local attrFp = FP.rawV1(attrInfo.attrValue) --服务器发过来的是int,是乘以1000了的数,直接rawV1 self.InitAttr[attrName] = attrFp self:SetAttrBaseValue(attrName, attrFp) end end end --(部分属性配置在怪物表) self.InitAttr[LuaConst.AttrType.spd] = entity._logicInitData._characterData.Speed self.InitAttr[LuaConst.AttrType.angvel] = entity._logicInitData._characterData.AngleSpeed self:SetAttrBaseValue(LuaConst.AttrType.spd,self.InitAttr[LuaConst.AttrType.spd]) self:SetAttrBaseValue(LuaConst.AttrType.angvel,self.InitAttr[LuaConst.AttrType.angvel]) local horseMoveData = entity._logicInitData.HorseMoveData if horseMoveData then self.InitAttr[LuaConst.AttrType.ridespd] = horseMoveData.MaxSpd self.InitAttr[LuaConst.AttrType.rideangvel] = horseMoveData.MaxAngleSpd self.InitAttr[LuaConst.AttrType.ridespdacc] = horseMoveData.SpdAccele self.InitAttr[LuaConst.AttrType.ridespddec] = horseMoveData.SpdDecele self.InitAttr[LuaConst.AttrType.ridegear] = horseMoveData.SpdGear self.InitAttr[LuaConst.AttrType.rideangacc] = horseMoveData.AngleAccele self.InitAttr[LuaConst.AttrType.rideheadacc] = horseMoveData.HeadAccele self.InitAttr[LuaConst.AttrType.rideheaddec] = horseMoveData.HeadStopDecele self:SetAttrBaseValue(LuaConst.AttrType.ridespd,self.InitAttr[LuaConst.AttrType.ridespd]) self:SetAttrBaseValue(LuaConst.AttrType.rideangvel,self.InitAttr[LuaConst.AttrType.rideangvel]) self:SetAttrBaseValue(LuaConst.AttrType.ridespdacc,self.InitAttr[LuaConst.AttrType.ridespdacc]) self:SetAttrBaseValue(LuaConst.AttrType.ridespddec,self.InitAttr[LuaConst.AttrType.ridespddec]) self:SetAttrBaseValue(LuaConst.AttrType.ridegear,self.InitAttr[LuaConst.AttrType.ridegear]) self:SetAttrBaseValue(LuaConst.AttrType.rideangacc,self.InitAttr[LuaConst.AttrType.rideangacc]) self:SetAttrBaseValue(LuaConst.AttrType.rideheadacc,self.InitAttr[LuaConst.AttrType.rideheadacc]) self:SetAttrBaseValue(LuaConst.AttrType.rideheaddec,self.InitAttr[LuaConst.AttrType.rideheaddec]) end --尝试补充空值 for k,attrType in pairs(LuaConst.AttrType) do if not self.AttrInfo[attrType] then --self.AttrInfo[attrType] = FP.newV1(0) --base old HYW self:SetAttrBaseValue(attrType,0) end end for k,attrType in pairs(LuaConst.AttrType) do if not self.InitAttr[attrType] then self.InitAttr[attrType] = self.AttrInfo[attrType]:cloneV1() end end if initHP then --self.hp:Reset(initHP) self:SetAttrBaseValue("hp",initHP) else --self.hp:Reset(self.InitAttr[LuaConst.AttrType.hplmt]) local curBossHp, maxBossHp = LevelManager.GetServerBossHp() if self.Entity:IsBoss() and LevelManager.GetServerBossHp() and LevelManager.GetServerBossHp() > 0 then self.InitAttr[LuaConst.AttrType.hplmt]:Reset(maxBossHp) self:SetAttrBaseValue("hplmt", self.InitAttr[LuaConst.AttrType.hplmt]) self:SetAttrBaseValue("hp", curBossHp) else self:SetAttrBaseValue("hp", self.InitAttr[LuaConst.AttrType.hplmt]) end end if self.InitAttr[LuaConst.AttrType.amlmt] then --self.am:Reset(self.InitAttr[LuaConst.AttrType.amlmt]) self:SetAttrBaseValue("am",self.InitAttr[LuaConst.AttrType.amlmt]) end end --初始化属性依赖规则 function AttrComponent:InitAttrDependRules() --目前的需求,只要用默认的就可以了 self.dependRules = DEFAULT_ATTR_DEPEND_RULES self.dependAttrDic = DEFAULT_DEPEND_ATTR_DIC --有哪些属性依赖别人,key是attr,value是一个数组,数组元素是rule self.dependedAttrDic = DEFAULT_DEPENDED_ATTR_DIC --有哪些属性被被人依赖,key是attr,value是一个数组,数组元素是rule end --可传入LuaConst.AttrType、LuaConst.RealtimeAttrType --返回FP对象,是原值的clone function AttrComponent:GetAttrValueClone(attrType) local attrValue = self:GetAttrValue(attrType) if attrValue then return attrValue:cloneV1() end end --返回number function AttrComponent:GetAttrValueNum(attrType) local num = nil local attrValueFp = self:GetAttrValue(attrType) if attrValueFp then num = FP.tonumberV1(attrValueFp) end return num end --返回指定属性的最终值 --可传入LuaConst.AttrType、LuaConst.RealtimeAttrType --返回FP对象,是引用,修改这个引用会直接修改属性值 function AttrComponent:GetAttrValue(attrType) local value = nil if attrType == LuaConst.RealtimeAttrType.hp or attrType == LuaConst.RealtimeAttrType.sa or attrType == LuaConst.RealtimeAttrType.am or attrType == LuaConst.RealtimeAttrType.pc then value = self[attrType] else value = self.AttrInfo[attrType] end return value end function AttrComponent:GetAttrBaseValue(attrType) if attrType == LuaConst.RealtimeAttrType.hp or attrType == LuaConst.RealtimeAttrType.sa or attrType == LuaConst.RealtimeAttrType.am or attrType == LuaConst.RealtimeAttrType.pc then --这几种动态属性,最终值就是基础值 return self[attrType] else return self.AttrBaseValDic[attrType] end end ------------- InitAttr Setter---------------- function AttrComponent:InitAttrAdd(attrType,value) self.InitAttr[attrType]:Add(value) end function AttrComponent:InitAttrSub(attrType,value) self.InitAttr[attrType]:Sub(value) end function AttrComponent:InitAttrMul(attrType,value) self.InitAttr[attrType]:Mul(value) end function AttrComponent:InitAttrDiv(attrType,value) self.InitAttr[attrType]:Div(value) end function AttrComponent:ResetInitAttrValue(attrType,value) self.InitAttr[attrType]:Reset(value) end --如果attrType指定的初始属性不存在,会新建属性 function AttrComponent:SetInitAttrValue(attrType,value) if self.InitAttr[attrType] then self.InitAttr[attrType]:Reset(value) else if type(value) == "number" then value = FP.newV1(value) end self.InitAttr[attrType] = value end end --↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ----------------------- attr base值 setter--------------------------------- --设置属性基础值(注意是基础值) --attrType是string类型的,比如"hp"、"atk"这种, value可以是FP,也可以是number --如果attrType指定的属性不存在,会新建属性 function AttrComponent:SetAttrBaseValue(attrType,value) local isChange = false if type(value) == "number" then isChange = self:GetAttrBaseValue(attrType) == nil or (FP.tonumberV1(self:GetAttrBaseValue(attrType)) ~= value) else isChange = self:GetAttrBaseValue(attrType) ~= value end --if self:GetAttrBaseValue(attrType) ~= value then if isChange then if attrType == LuaConst.RealtimeAttrType.hp or attrType == LuaConst.RealtimeAttrType.sa or attrType == LuaConst.RealtimeAttrType.am or attrType == LuaConst.RealtimeAttrType.pc then --这几种动态属性,基础值就是最终值 self[attrType]:Reset(value) else if self.AttrBaseValDic[attrType] then self.AttrBaseValDic[attrType]:Reset(value) else if type(value) == "number" then value = FP.newV1(value) else value = value:cloneV1() end self.AttrBaseValDic[attrType] = value end end self:OnAttrChanged(attrType) end end --基础值加 function AttrComponent:AttrAdd(attrType,value) self:GetAttrBaseValue(attrType):Add(value) self:OnAttrChanged(attrType) end --基础值减 function AttrComponent:AttrSub(attrType,value) self:GetAttrBaseValue(attrType):Sub(value) self:OnAttrChanged(attrType) end --基础值乘 function AttrComponent:AttrMul(attrType,value) self:GetAttrBaseValue(attrType):Mul(value) self:OnAttrChanged(attrType) end --基础值除 function AttrComponent:AttrDiv(attrType,value) self:GetAttrBaseValue(attrType):Div(value) self:OnAttrChanged(attrType) end local _saTemp1 = FP.newV1(0) local _saTemp2 = FP.newV1(0) local _saTemp3 = FP.newV1(0) --[[ 添加无双值 sa,因为需要给父级增加sa,所以提取了方法 --]] function AttrComponent:AddSA(addval,opEntity,dontSendEvent, ignoreSaSpd) --new↓ 直接使用masterEntity来做Sa添加,这样不会带来问题,因为如果子单位的子弹添加sa,那么可以认为一定是要给Master添加Sa,因为可以断定所有作为子单位的都不是英雄,都不存在sa属性 if self:GetAttrValue(LuaConst.AttrType.salmt) <= FP.Const.Zero then local masterEntity = self.Entity:GetMasterEntity() if masterEntity then masterEntity.components.attr:AddSA(addval, opEntity, dontSendEvent, ignoreSaSpd) return end end --new↑ _saTemp2:Reset(self.sa):Negative() _saTemp3:Reset(self:GetAttrValue(LuaConst.AttrType.salmt)):Sub(self.sa) local saspd = ignoreSaSpd and 0 or self:GetAttrValueNum(LuaConst.AttrType.saspd) if saspd then _saTemp1:Reset(1):Add(saspd):Mul(addval) else _saTemp1:Reset(addval) end _saTemp1:Clamp(_saTemp2,_saTemp3) self:AttrAdd("sa",_saTemp1) if not dontSendEvent then BattleEventSystem.AfterEntityAttrChange(FP.tonumberV1(_saTemp1),"sa",self.Entity,opEntity) end SystemManager.OnSAChange(self.Entity ,_saTemp1,self.sa) -- old↓ 这个 FatherAttrComp 有细节,不用做给父级加sa的判断了,直接使用masterEntity -- if self.FatherAttrComp then -- self.FatherAttrComp:AddSA(addval, opEntity, dontSendEvent) -- end -- old↑ end function AttrComponent:SetOnRevive() -- ↓ 这段代码一直以来都有bug,self.InitAttr是一个以string为key的dic,无法用ipairs,一直都是无效代码。虽然是无效代码,但是目前没有任何策划报不符合需求的,因此这段代码直接注掉,而不是改为正确的。 -- for key,val in ipairs(self.InitAttr) do -- self:SetAttrBaseValue(key,val) -- end -- ↑ self:SetAttrBaseValue("hp",self:GetAttrValue(LuaConst.AttrType.hplmt)) if self.InitAttr[LuaConst.AttrType.amlmt] == nil then self:SetAttrBaseValue("am",0) else self:SetAttrBaseValue("am",self.InitAttr[LuaConst.AttrType.amlmt]) end --self:SetAttrBaseValue("sa",0) 复活无双不清空 self:SetAttrBaseValue("pc",0) self.PCBuffList = {} end --↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ function AttrComponent:OnAttrChanged(attrType) self:RecalculateDepend(attrType) end local _tempV1 = FP.newV1(0) local _tempV2 = FP.newV1(0) --重算依赖 function AttrComponent:RecalculateDepend(attrType) self._dependRecalcSafeGuard = self._dependRecalcSafeGuard + 1 if self._dependRecalcSafeGuard > 10 then logging.error(LTAG.ERROR, "HYW : 属性依赖过深,超过10了,估计是死循环了,强制跳出!!") return end _tempV1:Reset(self:GetAttrBaseValue(attrType)) --应用依赖 local rules = self.dependAttrDic[attrType] if rules then for i,rule in ipairs(rules) do local dependToAttrValue = self:GetAttrValue(rule.dependToAttr) if dependToAttrValue then if rule.dependType == EDependType.LIMIT then if _tempV1 > dependToAttrValue then _tempV1:Reset(dependToAttrValue) end if rule.dependParam1 then if _tempV1 < rule.dependParam1 then _tempV1:Reset(rule.dependParam1) end end break elseif rule.dependType == EDependType.RATIO_PLUS then if dependToAttrValue ~= FP.Zero then _tempV2:Reset(1) _tempV1 = _tempV1:Mul(_tempV2:Add(dependToAttrValue)) end end end end end --↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ private.SetAttrFinalValue(self,attrType,_tempV1)--设置最终值 --更新被依赖 rules = self.dependedAttrDic[attrType] if rules then for i,rule in ipairs(rules) do self:RecalculateDepend(rule.attr) end end self._dependRecalcSafeGuard = self._dependRecalcSafeGuard - 1 end function private.SetAttrFinalValue(self,attrType,value) if attrType == LuaConst.RealtimeAttrType.hp or attrType == LuaConst.RealtimeAttrType.sa or attrType == LuaConst.RealtimeAttrType.am or attrType == LuaConst.RealtimeAttrType.pc then self[attrType]:Reset(value) else if self.AttrInfo[attrType] then self.AttrInfo[attrType]:Reset(value) else if type(value) == "number" then value = FP.newV1(value) else value = value:cloneV1() end self.AttrInfo[attrType] = value end end end return AttrComponent