| Main/Core/NetworkPackage/CustomServerPack/CustomHB426CombinePack.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB430_tagSCTurnFightReport.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/Battle/BattleField/BattleField.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/Battle/BattleField/RecordActions/SkillRecordAction.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/Battle/BattleObject/BattleObject.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/Battle/RecordPlayer/RecordAction.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/Battle/RecordPlayer/RecordPlayer.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/Battle/Skill/RebornSkill.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/Battle/Skill/SkillBase.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Main/Core/NetworkPackage/CustomServerPack/CustomHB426CombinePack.cs
@@ -18,10 +18,12 @@ public List<GameNetPackBasic> packList = new List<GameNetPackBasic>(); #if UNITY_EDITOR // #if UNITY_EDITOR // 编辑器下保存packList的副本,避免distribute过程中remove导致查看器显示不全 public List<GameNetPackBasic> copiedPackList = new List<GameNetPackBasic>(); #endif // #endif public SkillRecordAction parentSkillAction; private bool isCreated = false; @@ -84,9 +86,9 @@ packList.Add(pack); #if UNITY_EDITOR // #if UNITY_EDITOR copiedPackList.Add(pack); #endif // #endif } @@ -377,11 +379,33 @@ // BattleDebug.LogError("_caster == null : " + (_caster == null) + " skill.ObjID : " + skill.ObjID); isCreated = true; SkillRecordAction skillAction = new SkillRecordAction(battleField, _caster, skill, packList); SetParentNodeAction(skillAction); skillAction.useParentRecordPlayer = NeedWaiting(); skillAction.tracePackUID = packUID; skillAction.parentSkillAction = parentSkillAction; return skillAction; } return null; } protected void SetParentNodeAction(SkillRecordAction skillAction) { for (int i = 0; i < packList.Count; i++) { var pack = packList[i]; if (pack is CustomHB426CombinePack combinePack) { combinePack.SetParentAction(skillAction); } } } protected void SetParentAction(SkillRecordAction skillAction) { parentSkillAction = skillAction; } public bool NeedWaiting() @@ -390,9 +414,26 @@ HB427_tagSCUseSkill hB427_TagSCUseSkill = GetMainHB427SkillPack(); for (int i = 0; i < packList.Count; i++) if (hB427_TagSCUseSkill != null) { var pack = packList[i]; SkillConfig scCfg = SkillConfig.Get((int)hB427_TagSCUseSkill.SkillID); if (!string.IsNullOrEmpty(scCfg.SkillMotionName)) { needWaiting = true; return needWaiting; } // 复活技能 if (scCfg.SkillType == 8) { needWaiting = true; return needWaiting; } } for (int i = 0; i < copiedPackList.Count; i++) { var pack = copiedPackList[i]; if (pack is HB427_tagSCUseSkill skillPack && skillPack != hB427_TagSCUseSkill) { SkillConfig ssc = SkillConfig.Get((int)skillPack.SkillID); @@ -401,6 +442,12 @@ needWaiting = true; break; } if (ssc.SkillType == 8) { needWaiting = true; break; } } else if (pack is HB422_tagMCTurnFightObjDead dead) { Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB430_tagSCTurnFightReport.cs
@@ -575,11 +575,11 @@ string indentStr = GetIndent(indent); // 防止循环引用 if (visitedObjects.Contains(obj)) { sb.AppendLine(indentStr + $"<循环引用: {type.Name}>"); return; } // if (visitedObjects.Contains(obj)) // { // sb.AppendLine(indentStr + $"<循环引用: {type.Name}>"); // return; // } // 基本类型和字符串直接输出 if (type.IsPrimitive || type == typeof(string) || type == typeof(decimal)) Main/System/Battle/BattleField/BattleField.cs
@@ -510,7 +510,7 @@ } } public virtual DeathRecordAction OnObjsDead(List<BattleDeadPack> deadPackList, RecordAction _causingRecordAction = null) public virtual DeathRecordAction OnObjsDead(List<BattleDeadPack> deadPackList, SkillRecordAction _parentSkillAction = null, SkillRecordAction _playSkillRecordAction = null) { DeathRecordAction deathRecordAction = null; if (deadPackList.Count > 0) @@ -547,7 +547,7 @@ // 只处理有效的死亡消息 if (validDeadList.Count > 0) { DeathRecordAction recordAction = new DeathRecordAction(this, validDeadList, _causingRecordAction); DeathRecordAction recordAction = new DeathRecordAction(this, validDeadList, _parentSkillAction, _playSkillRecordAction); deathRecordAction = recordAction; } Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs
@@ -20,7 +20,11 @@ // 标记是否已经分发了死亡后的包 protected bool hasDistributedPacksAfterDeath = false; public DeathRecordAction(BattleField _battleField, List<BattleDeadPack> _deadPackList, RecordAction _causingRecordAction = null) private SkillRecordAction parentSkillAction = null; private SkillRecordAction playSkillRecordAction = null; public DeathRecordAction(BattleField _battleField, List<BattleDeadPack> _deadPackList, SkillRecordAction _parentSkillAction = null, SkillRecordAction _playSkillRecordAction = null) : base(RecordActionType.Death, _battleField, null) { deadPackList = _deadPackList; @@ -32,7 +36,8 @@ // Debug.LogError($"DeathRecordAction: 初始化死亡动作,死亡对象名字={battleObject?.teamHero.name}, hasDeathTriggerSkill={deadPackList[i].deadTriggerSkill != null}"); // } SetParentAction(_causingRecordAction); parentSkillAction = _parentSkillAction; playSkillRecordAction = _playSkillRecordAction; } @@ -63,11 +68,13 @@ { isRunOnce = true; SkillRecordAction waitingAnimeAction = playSkillRecordAction; foreach (var battleDeadPack in deadPackList) { if (battleDeadPack.deadTriggerSkill != null) { var skillAction = battleDeadPack.deadTriggerSkill.CreateSkillAction(); SkillRecordAction skillAction = battleDeadPack.deadTriggerSkill.CreateSkillAction(); if (null != skillAction) { deathActionDict.Add(battleDeadPack, skillAction); @@ -78,7 +85,19 @@ // 使用ImmediatelyPlay并设置WaitingPlay=true,可以让死亡技能等待导致死亡的技能完成 // 如果DeathRecordAction有父节点(导致死亡的技能),则等待那个父节点 // 否则等待DeathRecordAction本身 battleField.recordPlayer.ImmediatelyPlay(skillAction, parentAction == null ? this : parentAction, true); if (waitingAnimeAction == null) { battleField.recordPlayer.ImmediatelyPlay(skillAction, this, true); } else { waitingAnimeAction.GetInnerRecordPlayer().ImmediatelyPlay(skillAction, waitingAnimeAction); } if (battleDeadPack.deadTriggerSkill.NeedWaiting() || waitingAnimeAction != null) { waitingAnimeAction = skillAction; } } } else @@ -141,16 +160,6 @@ isActionCompleted = true; isFinish = true; } } // 确保在innerRecordPlayer中执行死亡后的包 if (hasDistributedPacksAfterDeath && parentAction != null) { var innerPlayer = parentAction.GetInnerRecordPlayer(); if (innerPlayer != null && innerPlayer.IsPlaying()) { innerPlayer.Run(); } } } @@ -292,7 +301,7 @@ // 特殊处理 CustomHB426CombinePack:使用其自己的 Distribute 方法 if (pack is CustomHB426CombinePack combinePack) { combinePack.Distribute(parentAction); combinePack.Distribute(playSkillRecordAction); } // 特殊处理 HB427_tagSCUseSkill:创建技能包并分发 else if (pack is HB427_tagSCUseSkill skillPack) @@ -300,9 +309,9 @@ var skillAction = CustomHB426CombinePack.CreateSkillAction(battleField.guid, new List<GameNetPackBasic>() { skillPack }); if (skillAction != null) { if (parentAction != null) if (playSkillRecordAction != null) { parentAction.GetInnerRecordPlayer().PlayRecord(skillAction); playSkillRecordAction.GetInnerRecordPlayer().PlayRecord(skillAction); } else { @@ -314,11 +323,11 @@ { // 【使用 causingRecordAction 或 battleField.recordPlayer】 // 原因:死亡后的包应该回到导致死亡的技能所在的上下文 // 如果有 parentAction(导致死亡的技能),则分发到它的 innerRecordPlayer // 如果有 parentSkillAction(导致死亡的技能),则分发到它的 innerRecordPlayer // 否则分发到 battleField.recordPlayer(顶层) if (parentAction != null) if (playSkillRecordAction != null) { PackageRegeditEx.DistributeToRecordAction(pack, parentAction); PackageRegeditEx.DistributeToRecordAction(pack, playSkillRecordAction); } else { @@ -343,7 +352,7 @@ } // 如果没有父节点,也可以执行 if (parentAction == null) if (parentSkillAction == null) { return true; } @@ -355,9 +364,9 @@ } // WaitingPlay模式下,需要等待直接父节点的动作完成(不管父节点是否WaitingPlay) if (!parentAction.IsActionCompleted()) if (!parentSkillAction.IsActionCompleted()) { BattleDebug.LogError($"RecordAction.CanStartExecution: {this.GetType().Name} 等待父节点 {parentAction.GetType().Name} 动作完成"); BattleDebug.LogError($"RecordAction.CanStartExecution: {this.GetType().Name} 等待父节点 {parentSkillAction.GetType().Name} 动作完成"); return false; } Main/System/Battle/BattleField/RecordActions/SkillRecordAction.cs
@@ -31,8 +31,10 @@ private bool isCast = false; public SkillBase fromSkill = null; public bool useParentRecordPlayer = false; public SkillRecordAction parentSkillAction; public SkillRecordAction(BattleField _battleField, BattleObject _caster, HB427_tagSCUseSkill vNetData, List<GameNetPackBasic> packList) public SkillRecordAction(BattleField _battleField, BattleObject _caster, HB427_tagSCUseSkill vNetData, List<GameNetPackBasic> packList) : base(RecordActionType.Skill, _battleField, _caster) { // Debug.LogError("_caster == null : " + (_caster == null)); @@ -46,7 +48,7 @@ else { // 让SkillBase知道自己的RecordAction skillBase.SetParentRecordAction(this); skillBase.SetOwnRecordAction(this); } } @@ -54,15 +56,6 @@ { base.AfterAddToQueue(); skillBase?.AfterAddToQueue(); } public override bool IsNeedWaiting() { if (skillBase == null) { return false; } return !string.IsNullOrEmpty(skillBase.skillConfig.SkillMotionName); } Main/System/Battle/BattleObject/BattleObject.cs
@@ -315,7 +315,7 @@ return true; } public virtual DeathRecordAction Hurt(BattleHurtParam battleHurtParam, RecordAction _causingRecordAction = null) public virtual DeathRecordAction Hurt(BattleHurtParam battleHurtParam, SkillRecordAction _parentSkillAction = null) { DeathRecordAction recordAction = null; bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1; @@ -357,7 +357,7 @@ { PushDropItems(battleHurtParam.battleDrops); } recordAction = battleField.OnObjsDead(new List<BattleDeadPack>() { battleHurtParam.deadPack }, _causingRecordAction); recordAction = battleField.OnObjsDead(new List<BattleDeadPack>() { battleHurtParam.deadPack }, _parentSkillAction, _parentSkillAction); } else Main/System/Battle/RecordPlayer/RecordAction.cs
@@ -25,6 +25,8 @@ private bool hasLoggedFirstRun = true; #endif public RecordAction waitingAnimeAction = null; // ===== 父子关系和等待机制 ===== // 父RecordAction引用(如果是通过其他RecordAction内部触发的) @@ -145,11 +147,6 @@ } return true; } public virtual bool IsNeedWaiting() { return false; } // 检查是否完全完成(包括所有子节点) Main/System/Battle/RecordPlayer/RecordPlayer.cs
@@ -54,6 +54,21 @@ recordAction.AfterAddToQueue(); } public void PlayRecord(RecordAction recordAction, RecordAction waitingAnimeAction) { if (recordAction == null) return; recordAction.actionOwner = this; // Debug.LogError("Enqueue record action " + recordAction.GetType() + " to queue"); if (isForceFinish || stepForcefinish) { recordAction.ForceFinish(); return; } recordAction.waitingAnimeAction = waitingAnimeAction; recordActionQueue.Enqueue(recordAction); recordAction.AfterAddToQueue(); } public void PlayRecord(List<RecordAction> recordActions) { for (int i = 0; i < recordActions.Count; i++) @@ -111,6 +126,19 @@ immediatelyActionList.Add(recordAction); } public void ImmediatelyPlay(RecordAction recordAction, RecordAction waitingAnimeAction) { if (recordAction == null) return; recordAction.actionOwner = this; if (isForceFinish || stepForcefinish) { recordAction.ForceFinish(); return; } recordAction.waitingAnimeAction = waitingAnimeAction; immediatelyActionList.Add(recordAction); } // 增强版本:支持父子关系和WaitingPlay标记 public void ImmediatelyPlay(RecordAction recordAction, RecordAction parentAction, bool isWaitingPlay) { @@ -135,6 +163,32 @@ recordAction.SetWaitingPlay(isWaitingPlay); immediatelyActionList.Add(recordAction); } public bool IsActionCompleted() { bool ret = true; foreach (var imac in immediatelyActionList) { if (!imac.IsActionCompleted()) { ret = false; break; } } if (ret == false) { return false; } if (currentRecordAction != null && !currentRecordAction.IsActionCompleted()) { return false; } return ret; } protected void ImmediatelyPlayRun() @@ -186,6 +240,13 @@ if (!action.IsFinished()) { if (action.waitingAnimeAction != null) { if (!action.waitingAnimeAction.IsActionCompleted()) { continue; } } action.Run(); continue; } @@ -233,6 +294,13 @@ if (currentRecordAction != null && !currentRecordAction.IsFinished()) { if (currentRecordAction.waitingAnimeAction != null) { if (!currentRecordAction.waitingAnimeAction.IsActionCompleted()) { return; } } currentRecordAction.Run(); return; } Main/System/Battle/Skill/RebornSkill.cs
@@ -28,7 +28,7 @@ BattleObject battleObject = battleField.battleObjMgr.GetBattleObject((int)hitList[i].ObjID); if (battleObject != null) { battleObject.OnReborn(hurt, hurt.ObjID == caster.teamHero.ObjID, parentRecordAction); battleObject.OnReborn(hurt, hurt.ObjID == caster.teamHero.ObjID, ownRecordAction); rebornTargets.Add(battleObject); } } Main/System/Battle/Skill/SkillBase.cs
@@ -35,7 +35,7 @@ public bool isPlay = false; // 父RecordAction(SkillRecordAction),用于子技能建立父子关系 protected RecordAction parentRecordAction; protected SkillRecordAction ownRecordAction; // 技能动画是否播放完成(针对有动画的技能) protected bool isMotionCompleted = false; @@ -73,9 +73,9 @@ } // 设置父RecordAction public void SetParentRecordAction(RecordAction recordAction) public void SetOwnRecordAction(SkillRecordAction recordAction) { parentRecordAction = recordAction; ownRecordAction = recordAction; } #if UNITY_EDITOR @@ -513,6 +513,10 @@ { break; } if (ssc.SkillType == 8) { break; } SkillRecordAction skillRecordAction = CustomHB426CombinePack.CreateSkillAction(battleField.guid, new List<GameNetPackBasic> { skillPack }); allSubSkills.Add((skillPack.packUID, skillRecordAction)); removePackList.Add(pack); @@ -530,9 +534,20 @@ { break; } if (ssc.SkillType == 8) { break; } SkillRecordAction skillRecordAction = combinePack.CreateSkillAction(); allSubSkills.Add((sp.packUID, skillRecordAction)); removePackList.Add(pack); if (skillRecordAction.useParentRecordPlayer) { break; } } } @@ -546,11 +561,13 @@ foreach (var (packUID, recordAction) in allSubSkills) { battleField.recordPlayer.ImmediatelyPlay(recordAction); if (recordAction.IsNeedWaiting()) if (recordAction.useParentRecordPlayer) { currentWaitingSkill.Add(recordAction); ownRecordAction.GetInnerRecordPlayer().PlayRecord(recordAction, ownRecordAction); } else { ownRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(recordAction); } } } @@ -814,12 +831,12 @@ #endif // 先调用目标受伤 DeathRecordAction recordAc = target.Hurt(hurtParam, parentRecordAction); DeathRecordAction recordAc = target.Hurt(hurtParam, ownRecordAction); if (null != recordAc) { tempDeadPackList.Remove(hurtParam.hurter.hurtObj.ObjID); battleField.recordPlayer.ImmediatelyPlay(recordAc, parentRecordAction, true); ownRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(recordAc, ownRecordAction, true); currentWaitingSkill.Add(recordAc); } @@ -909,7 +926,7 @@ // 【使用 parentRecordAction.innerRecordPlayer】 // 原因:HP刷新包是技能内部产生的,应该由当前SkillRecordAction的innerRecordPlayer管理 // 这样可以确保HP刷新与技能的生命周期绑定,ForceFinish时一并处理 PackageRegeditEx.DistributeToRecordAction(refreshPack, parentRecordAction); PackageRegeditEx.DistributeToRecordAction(refreshPack, ownRecordAction); packList.Remove(refreshPack); } } @@ -975,7 +992,7 @@ // 【使用 parentRecordAction.innerRecordPlayer】 // 原因:掉落包是技能效果的一部分,应该由当前SkillRecordAction管理 // 掉落包的分发与技能完成绑定,确保在技能ForceFinish时正确处理 PackageRegeditEx.DistributeToRecordAction(_dropPack, parentRecordAction); PackageRegeditEx.DistributeToRecordAction(_dropPack, ownRecordAction); packList.Remove(_dropPack); } @@ -1233,6 +1250,7 @@ return false; } // 检查最终完成状态 if (isFinished && moveFinished) { @@ -1243,7 +1261,7 @@ } // 如果自己内部的recora action的 inner record player还有没执行完的包 也是返回false if (parentRecordAction != null && parentRecordAction.GetInnerRecordPlayer().IsPlaying()) if (ownRecordAction != null && ownRecordAction.GetInnerRecordPlayer().IsPlaying()) { return false; } @@ -1254,16 +1272,16 @@ battleField.RemoveCastingSkill(caster.ObjID, this); // 传递parentRecordAction,让死亡技能等待当前技能完成 DeathRecordAction recordAction = battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values)); DeathRecordAction recordAction = battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values), null, ownRecordAction); if (null != recordAction) { parentRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(recordAction); ownRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(recordAction); tempDeadPackList.Clear(); return false; } } return true; return !ownRecordAction.GetInnerRecordPlayer().IsPlaying(); } return false; @@ -1286,7 +1304,7 @@ RecordAction rc = battleField.OnObjsDead(new List<BattleDeadPack>(tempDeadPackList.Values)); if (null != rc) { parentRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(rc); ownRecordAction.GetInnerRecordPlayer().ImmediatelyPlay(rc); } tempDeadPackList.Clear(); @@ -1453,11 +1471,20 @@ if (pack is CustomHB426CombinePack combinePack && combinePack.startTag.Tag.StartsWith("Skill_")) { BattleDebug.LogError("other skill casting " + combinePack.startTag.Tag); var skillRecordAction = combinePack.CreateSkillAction(); skillRecordAction.fromSkill = this; currentWaitingSkill.Add(skillRecordAction); parentRecordAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction); // 需要给真正parent播的 if (skillRecordAction.useParentRecordPlayer && skillRecordAction.parentSkillAction != null) { skillRecordAction.parentSkillAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction); } else { ownRecordAction.GetInnerRecordPlayer().PlayRecord(skillRecordAction); } return false; } else if (IsBuffPack(pack)) @@ -1490,7 +1517,7 @@ // 【使用 parentRecordAction.innerRecordPlayer】 // 原因:技能执行过程中的包(Buff、属性刷新等)是技能效果的一部分 // 应该由SkillRecordAction的innerRecordPlayer管理,确保与技能生命周期一致 PackageRegeditEx.DistributeToRecordAction(pack, parentRecordAction); PackageRegeditEx.DistributeToRecordAction(pack, ownRecordAction); } } @@ -1561,7 +1588,7 @@ // 【使用 parentRecordAction.innerRecordPlayer】 // 原因:Buff包是技能效果的核心组成部分,应该由SkillRecordAction管理 // 即使是强制分发的情况,也要保持在正确的RecordAction上下文中 PackageRegeditEx.DistributeToRecordAction(pack, parentRecordAction); PackageRegeditEx.DistributeToRecordAction(pack, ownRecordAction); } }