hold音符补丁 备份

This commit is contained in:
FloatGaming
2026-03-03 14:07:39 +08:00
parent b8704629a3
commit 9011fa022e
36 changed files with 2721 additions and 256 deletions
+28 -141
View File
@@ -23,7 +23,6 @@ public class EffectSystem : MonoBehaviour
private readonly List<GameObject> _cachedEnemies = new List<GameObject>(8);
private readonly HashSet<int> _awaitingHitFxTargets = new HashSet<int>();
private readonly Dictionary<int, int> _pendingDamagePopupByTargetId = new Dictionary<int, int>(64);
private void Awake()
{
@@ -322,12 +321,6 @@ public class EffectSystem : MonoBehaviour
{
int before = ally.currentScore;
ally.AddScoreDirect(Mathf.CeilToInt(amount));
int delta = ally.currentScore - before;
if (delta != 0)
{
var type = delta > 0 ? iNumberPrefabController.InstantNumberType.IscorePlus : iNumberPrefabController.InstantNumberType.IscoreMinus;
iNumberPrefabController.SpawnForAllyStatic(ally.slotIndex, type, delta);
}
}
else
{
@@ -372,7 +365,7 @@ public class EffectSystem : MonoBehaviour
if (duration <= 0f)
{
enemy.SetMaxHP(enemy.maxHP + delta, false);
if (delta > 0) enemy.currentHP = Mathf.Clamp(enemy.currentHP + delta, 0, enemy.maxHP);
if (delta > 0) enemy.ModifyHP(delta);
iBudeffPrefabController.Instance?.RefreshEnemyNow(enemy);
iBudeffPrefabController.Instance?.RegisterEnemyTimedEffect(enemy, PlayerBudeffIconType.ot_maxHP_up, delta, 0f);
}
@@ -1083,18 +1076,8 @@ public class EffectSystem : MonoBehaviour
var comp = target.GetComponent<ICombatant>();
if (comp != null)
{
int beforeHP = 0;
if (targetAlly != null) beforeHP = targetAlly.currentHP;
else if (targetEnemy != null) beforeHP = targetEnemy.currentHP;
comp.ReceiveDamage(amount, source);
int afterHP = 0;
if (targetAlly != null) afterHP = targetAlly.currentHP;
else if (targetEnemy != null) afterHP = targetEnemy.currentHP;
int actualDelta = beforeHP - afterHP;
if (actualDelta != 0) QueueOrSpawnDamagePopup(target, targetAlly, targetEnemy, actualDelta);
// Use deferPopup: true for synchronization with hit fx
comp.ReceiveDamage(amount, source, true);
// Record stats if source is an ally
if (source != null && target.GetComponent<EnemyCombatant>() != null)
@@ -1124,26 +1107,8 @@ public class EffectSystem : MonoBehaviour
var comp = target.GetComponent<ICombatant>();
if (comp != null)
{
var targetAlly = target.GetComponent<AllyCombatant>();
var targetEnemy = target.GetComponent<EnemyCombatant>();
int beforeHP = 0;
if (targetAlly != null) beforeHP = targetAlly.currentHP;
else if (targetEnemy != null) beforeHP = targetEnemy.currentHP;
comp.ReceiveHeal(amount, source);
int afterHP = 0;
if (targetAlly != null) afterHP = targetAlly.currentHP;
else if (targetEnemy != null) afterHP = targetEnemy.currentHP;
int actualDelta = afterHP - beforeHP;
if (actualDelta != 0)
{
if (targetAlly != null)
iNumberPrefabController.SpawnForAllyStatic(targetAlly.slotIndex, iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
else if (targetEnemy != null)
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
}
// Use deferPopup: false for heals (usually immediate)
comp.ReceiveHeal(amount, source, false);
// Record stats if source is an ally
if (source != null)
@@ -1208,7 +1173,9 @@ public class EffectSystem : MonoBehaviour
}
}
comp.ReceiveDamage(totalAmount, source);
comp.ReceiveDamage(totalAmount, source, false);
// No need to call TriggerQueuedPopups manually as deferPopup is false
if (source != null && targetEnemy != null)
{
var ally = source.GetComponent<AllyCombatant>();
@@ -1255,19 +1222,9 @@ public class EffectSystem : MonoBehaviour
}
}
int beforeHP = 0;
if (targetAlly != null) beforeHP = targetAlly.currentHP;
else if (targetEnemy != null) beforeHP = targetEnemy.currentHP;
comp.ReceiveDamage(perTick, source);
int afterHP = 0;
if (targetAlly != null) afterHP = targetAlly.currentHP;
else if (targetEnemy != null) afterHP = targetEnemy.currentHP;
int actualDelta = beforeHP - afterHP;
if (actualDelta != 0) QueueOrSpawnDamagePopup(target, targetAlly, targetEnemy, actualDelta);
comp.ReceiveDamage(perTick, source, false);
// No need to call TriggerQueuedPopups manually as deferPopup is false
if (source != null && targetEnemy != null)
{
var ally = source.GetComponent<AllyCombatant>();
@@ -1306,21 +1263,9 @@ public class EffectSystem : MonoBehaviour
if (targetAlly != null) beforeHP = targetAlly.currentHP;
else if (targetEnemy != null) beforeHP = targetEnemy.currentHP;
comp.ReceiveHeal(totalAmount, source);
int afterHP = 0;
if (targetAlly != null) afterHP = targetAlly.currentHP;
else if (targetEnemy != null) afterHP = targetEnemy.currentHP;
int actualDelta = afterHP - beforeHP;
if (actualDelta != 0)
{
if (targetAlly != null)
iNumberPrefabController.SpawnForAllyStatic(targetAlly.slotIndex, iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
else if (targetEnemy != null)
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
}
comp.ReceiveHeal(totalAmount, source, false);
// No need to call TriggerQueuedPopups manually as deferPopup is false
// Record stats
if (source != null)
{
@@ -1339,25 +1284,9 @@ public class EffectSystem : MonoBehaviour
{
if (target == null) yield break;
int beforeHP = 0;
if (targetAllyHot != null) beforeHP = targetAllyHot.currentHP;
else if (targetEnemyHot != null) beforeHP = targetEnemyHot.currentHP;
comp.ReceiveHeal(perTick, source);
int afterHP = 0;
if (targetAllyHot != null) afterHP = targetAllyHot.currentHP;
else if (targetEnemyHot != null) afterHP = targetEnemyHot.currentHP;
int actualDelta = afterHP - beforeHP;
if (actualDelta != 0)
{
if (targetAllyHot != null)
iNumberPrefabController.SpawnForAllyStatic(targetAllyHot.slotIndex, iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
else if (targetEnemyHot != null)
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Heal, Mathf.Abs(actualDelta));
}
comp.ReceiveHeal(perTick, source, false);
// No need to call TriggerQueuedPopups manually as deferPopup is false
// Record stats
if (source != null)
{
@@ -1382,47 +1311,19 @@ public class EffectSystem : MonoBehaviour
int id = target.GetInstanceID();
if (_awaitingHitFxTargets.Contains(id)) _awaitingHitFxTargets.Remove(id);
if (!_pendingDamagePopupByTargetId.TryGetValue(id, out var signedValue) || signedValue == 0) return;
_pendingDamagePopupByTargetId.Remove(id);
var ally = target.GetComponent<AllyCombatant>();
if (ally != null)
// Trigger any queued damage/heal popups now that the hit FX is playing
var enemy = target.GetComponent<EnemyCombatant>();
if (enemy != null)
{
iNumberPrefabController.SpawnForAllyStatic(ally.slotIndex, iNumberPrefabController.InstantNumberType.Damage, signedValue);
return;
enemy.TriggerQueuedPopups();
}
if (target.GetComponent<EnemyCombatant>() != null)
else
{
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Damage, signedValue);
}
}
private void QueueOrSpawnDamagePopup(GameObject target, AllyCombatant targetAlly, EnemyCombatant targetEnemy, int actualDelta)
{
if (target == null) return;
if (actualDelta == 0) return;
int id = target.GetInstanceID();
int signedValue = -Mathf.Abs(actualDelta);
if (_awaitingHitFxTargets.Contains(id))
{
if (_pendingDamagePopupByTargetId.TryGetValue(id, out var prev))
_pendingDamagePopupByTargetId[id] = prev + signedValue;
else
_pendingDamagePopupByTargetId[id] = signedValue;
return;
}
if (targetAlly != null)
{
iNumberPrefabController.SpawnForAllyStatic(targetAlly.slotIndex, iNumberPrefabController.InstantNumberType.Damage, signedValue);
return;
}
if (targetEnemy != null)
{
iNumberPrefabController.SpawnForEnemyStatic(iNumberPrefabController.InstantNumberType.Damage, signedValue);
var ally = target.GetComponent<AllyCombatant>();
if (ally != null)
{
ally.TriggerQueuedPopups();
}
}
}
@@ -1443,14 +1344,7 @@ public class EffectSystem : MonoBehaviour
// immediate add totalAmount to mana if ally present
if (ally != null)
{
int before = ally.currentMana;
ally.ModifyMana(Mathf.CeilToInt(totalAmount), true, true);
int delta = ally.currentMana - before;
if (delta != 0)
{
var type = delta > 0 ? iNumberPrefabController.InstantNumberType.ManaPlus : iNumberPrefabController.InstantNumberType.ManaMinus;
iNumberPrefabController.SpawnForAllyStatic(ally.slotIndex, type, delta);
}
// Record stats
if (totalAmount > 0f && source != null)
{
@@ -1469,14 +1363,7 @@ public class EffectSystem : MonoBehaviour
if (target == null) yield break;
if (ally != null)
{
int before = ally.currentMana;
ally.ModifyMana(Mathf.CeilToInt(perTick), true, true);
int delta = ally.currentMana - before;
if (delta != 0)
{
var type = delta > 0 ? iNumberPrefabController.InstantNumberType.ManaPlus : iNumberPrefabController.InstantNumberType.ManaMinus;
iNumberPrefabController.SpawnForAllyStatic(ally.slotIndex, type, delta);
}
// Record stats
if (perTick > 0f && source != null)
{
@@ -1641,7 +1528,7 @@ public class EffectSystem : MonoBehaviour
{
if (enemy == null) yield break;
enemy.SetMaxHP(Mathf.Max(1, enemy.maxHP + delta), false);
if (delta > 0) enemy.currentHP = Mathf.Clamp(enemy.currentHP + delta, 0, enemy.maxHP);
if (delta > 0) enemy.ModifyHP(delta);
iBudeffPrefabController.Instance?.RefreshEnemyNow(enemy);
yield return new WaitForSeconds(duration);
if (enemy == null) yield break;