- SkillGemData와 SkillLoadoutEntry를 확장해 자기 강화/적중 이상상태와 피해·회복·보호막·위협 배율을 해석하도록 정리 - SkillController와 SkillEffect 경로를 보강해 cast start 이상상태, on-hit 이상상태, 반복 시전, 출력 보정이 실제 효과에 반영되도록 연결 - 강인함/약화 테스트 젬과 자기강화/적중이상/상태복합 프리셋, 디버그 메뉴를 추가해 젬 조합 검증 경로를 보강 - 런타임에서 약화 디버프 적용, 강인함+약화 동시 적용, 파쇄/수호/도전자 보정값 해석을 확인
410 lines
13 KiB
C#
410 lines
13 KiB
C#
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using Colosseum.Abnormalities;
|
|
|
|
namespace Colosseum.Skills
|
|
{
|
|
/// <summary>
|
|
/// 단일 슬롯에서 사용할 스킬과 장착된 젬 조합입니다.
|
|
/// </summary>
|
|
[System.Serializable]
|
|
public class SkillLoadoutEntry
|
|
{
|
|
private const int DefaultGemSlotCount = 2;
|
|
|
|
[Tooltip("이 슬롯의 기반 스킬")]
|
|
[SerializeField] private SkillData baseSkill;
|
|
[Tooltip("기반 스킬에 장착된 젬")]
|
|
[SerializeField] private SkillGemData[] socketedGems = new SkillGemData[DefaultGemSlotCount];
|
|
|
|
public SkillData BaseSkill => baseSkill;
|
|
public IReadOnlyList<SkillGemData> SocketedGems => socketedGems;
|
|
|
|
public static SkillLoadoutEntry CreateTemporary(SkillData skill)
|
|
{
|
|
SkillLoadoutEntry entry = new SkillLoadoutEntry();
|
|
entry.SetBaseSkill(skill);
|
|
entry.EnsureGemSlotCapacity();
|
|
return entry;
|
|
}
|
|
|
|
public SkillLoadoutEntry CreateCopy()
|
|
{
|
|
SkillLoadoutEntry copy = new SkillLoadoutEntry();
|
|
copy.baseSkill = baseSkill;
|
|
copy.socketedGems = new SkillGemData[socketedGems != null ? socketedGems.Length : DefaultGemSlotCount];
|
|
|
|
if (socketedGems != null)
|
|
{
|
|
for (int i = 0; i < socketedGems.Length; i++)
|
|
{
|
|
copy.socketedGems[i] = socketedGems[i];
|
|
}
|
|
}
|
|
|
|
return copy;
|
|
}
|
|
|
|
public void EnsureGemSlotCapacity(int slotCount = -1)
|
|
{
|
|
if (slotCount < 0)
|
|
{
|
|
slotCount = baseSkill != null ? baseSkill.MaxGemSlotCount : DefaultGemSlotCount;
|
|
}
|
|
|
|
slotCount = Mathf.Max(0, slotCount);
|
|
if (socketedGems != null && socketedGems.Length == slotCount)
|
|
return;
|
|
|
|
SkillGemData[] resized = new SkillGemData[slotCount];
|
|
if (socketedGems != null)
|
|
{
|
|
int copyCount = Mathf.Min(socketedGems.Length, resized.Length);
|
|
for (int i = 0; i < copyCount; i++)
|
|
{
|
|
resized[i] = socketedGems[i];
|
|
}
|
|
}
|
|
|
|
socketedGems = resized;
|
|
}
|
|
|
|
public void SetBaseSkill(SkillData skill)
|
|
{
|
|
baseSkill = skill;
|
|
EnsureGemSlotCapacity();
|
|
}
|
|
|
|
public void SetGem(int slotIndex, SkillGemData gem)
|
|
{
|
|
EnsureGemSlotCapacity();
|
|
if (slotIndex < 0 || slotIndex >= socketedGems.Length)
|
|
return;
|
|
|
|
socketedGems[slotIndex] = gem;
|
|
}
|
|
|
|
public SkillGemData GetGem(int slotIndex)
|
|
{
|
|
EnsureGemSlotCapacity();
|
|
if (slotIndex < 0 || slotIndex >= socketedGems.Length)
|
|
return null;
|
|
|
|
return socketedGems[slotIndex];
|
|
}
|
|
|
|
public float GetResolvedManaCost()
|
|
{
|
|
if (baseSkill == null)
|
|
return 0f;
|
|
|
|
float resolved = baseSkill.ManaCost;
|
|
if (socketedGems == null)
|
|
return resolved;
|
|
|
|
for (int i = 0; i < socketedGems.Length; i++)
|
|
{
|
|
SkillGemData gem = socketedGems[i];
|
|
if (gem == null)
|
|
continue;
|
|
|
|
resolved *= gem.ManaCostMultiplier;
|
|
}
|
|
|
|
return resolved;
|
|
}
|
|
|
|
public float GetResolvedCooldown()
|
|
{
|
|
if (baseSkill == null)
|
|
return 0f;
|
|
|
|
float resolved = baseSkill.Cooldown;
|
|
if (socketedGems == null)
|
|
return resolved;
|
|
|
|
for (int i = 0; i < socketedGems.Length; i++)
|
|
{
|
|
SkillGemData gem = socketedGems[i];
|
|
if (gem == null)
|
|
continue;
|
|
|
|
resolved *= gem.CooldownMultiplier;
|
|
}
|
|
|
|
return resolved;
|
|
}
|
|
|
|
public float GetResolvedAnimationSpeed()
|
|
{
|
|
if (baseSkill == null)
|
|
return 0f;
|
|
|
|
float resolved = baseSkill.AnimationSpeed;
|
|
if (socketedGems == null)
|
|
return resolved;
|
|
|
|
for (int i = 0; i < socketedGems.Length; i++)
|
|
{
|
|
SkillGemData gem = socketedGems[i];
|
|
if (gem == null)
|
|
continue;
|
|
|
|
resolved *= gem.CastSpeedMultiplier;
|
|
}
|
|
|
|
return Mathf.Max(0.05f, resolved);
|
|
}
|
|
|
|
public float GetResolvedDamageMultiplier()
|
|
{
|
|
return GetResolvedScalarMultiplier(gem => gem.DamageMultiplier);
|
|
}
|
|
|
|
public float GetResolvedHealMultiplier()
|
|
{
|
|
return GetResolvedScalarMultiplier(gem => gem.HealMultiplier);
|
|
}
|
|
|
|
public float GetResolvedShieldMultiplier()
|
|
{
|
|
return GetResolvedScalarMultiplier(gem => gem.ShieldMultiplier);
|
|
}
|
|
|
|
public float GetResolvedThreatMultiplier()
|
|
{
|
|
return GetResolvedScalarMultiplier(gem => gem.ThreatMultiplier);
|
|
}
|
|
|
|
public int GetResolvedRepeatCount()
|
|
{
|
|
if (baseSkill == null)
|
|
return 0;
|
|
|
|
int resolved = 1;
|
|
if (socketedGems == null)
|
|
return resolved;
|
|
|
|
for (int i = 0; i < socketedGems.Length; i++)
|
|
{
|
|
SkillGemData gem = socketedGems[i];
|
|
if (gem == null)
|
|
continue;
|
|
|
|
resolved += gem.AdditionalRepeatCount;
|
|
}
|
|
|
|
return Mathf.Max(1, resolved);
|
|
}
|
|
|
|
public void CollectCastStartEffects(List<SkillEffect> destination)
|
|
{
|
|
if (destination == null)
|
|
return;
|
|
|
|
if (baseSkill != null && baseSkill.CastStartEffects != null)
|
|
{
|
|
for (int i = 0; i < baseSkill.CastStartEffects.Count; i++)
|
|
{
|
|
SkillEffect effect = baseSkill.CastStartEffects[i];
|
|
if (effect != null)
|
|
destination.Add(effect);
|
|
}
|
|
}
|
|
|
|
if (socketedGems == null)
|
|
return;
|
|
|
|
for (int i = 0; i < socketedGems.Length; i++)
|
|
{
|
|
SkillGemData gem = socketedGems[i];
|
|
if (gem == null || gem.CastStartEffects == null)
|
|
continue;
|
|
|
|
for (int j = 0; j < gem.CastStartEffects.Count; j++)
|
|
{
|
|
SkillEffect effect = gem.CastStartEffects[j];
|
|
if (effect != null)
|
|
destination.Add(effect);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void CollectCastStartAbnormalities(List<AbnormalityData> destination)
|
|
{
|
|
if (destination == null || socketedGems == null)
|
|
return;
|
|
|
|
for (int i = 0; i < socketedGems.Length; i++)
|
|
{
|
|
SkillGemData gem = socketedGems[i];
|
|
if (gem == null || gem.SelfAbnormalities == null)
|
|
continue;
|
|
|
|
for (int j = 0; j < gem.SelfAbnormalities.Count; j++)
|
|
{
|
|
AbnormalityData abnormality = gem.SelfAbnormalities[j];
|
|
if (abnormality != null)
|
|
destination.Add(abnormality);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void CollectTriggeredEffects(Dictionary<int, List<SkillEffect>> destination)
|
|
{
|
|
if (destination == null)
|
|
return;
|
|
|
|
if (baseSkill != null && baseSkill.Effects != null)
|
|
{
|
|
for (int i = 0; i < baseSkill.Effects.Count; i++)
|
|
{
|
|
SkillEffect effect = baseSkill.Effects[i];
|
|
if (effect == null)
|
|
continue;
|
|
|
|
AddTriggeredEffect(destination, i, effect);
|
|
}
|
|
}
|
|
|
|
if (socketedGems == null)
|
|
return;
|
|
|
|
for (int i = 0; i < socketedGems.Length; i++)
|
|
{
|
|
SkillGemData gem = socketedGems[i];
|
|
if (gem == null || gem.TriggeredEffects == null)
|
|
continue;
|
|
|
|
for (int j = 0; j < gem.TriggeredEffects.Count; j++)
|
|
{
|
|
SkillGemTriggeredEffectEntry entry = gem.TriggeredEffects[j];
|
|
if (entry == null || entry.Effects == null)
|
|
continue;
|
|
|
|
for (int k = 0; k < entry.Effects.Count; k++)
|
|
{
|
|
SkillEffect effect = entry.Effects[k];
|
|
if (effect == null)
|
|
continue;
|
|
|
|
AddTriggeredEffect(destination, entry.TriggerIndex, effect);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void CollectTriggeredAbnormalities(Dictionary<int, List<AbnormalityData>> destination)
|
|
{
|
|
if (destination == null || socketedGems == null)
|
|
return;
|
|
|
|
for (int i = 0; i < socketedGems.Length; i++)
|
|
{
|
|
SkillGemData gem = socketedGems[i];
|
|
if (gem == null || gem.OnHitAbnormalities == null)
|
|
continue;
|
|
|
|
for (int j = 0; j < gem.OnHitAbnormalities.Count; j++)
|
|
{
|
|
SkillGemTriggeredAbnormalityEntry entry = gem.OnHitAbnormalities[j];
|
|
if (entry == null || entry.Abnormalities == null)
|
|
continue;
|
|
|
|
for (int k = 0; k < entry.Abnormalities.Count; k++)
|
|
{
|
|
AbnormalityData abnormality = entry.Abnormalities[k];
|
|
if (abnormality == null)
|
|
continue;
|
|
|
|
AddTriggeredAbnormality(destination, entry.TriggerIndex, abnormality);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void AddTriggeredEffect(Dictionary<int, List<SkillEffect>> destination, int triggerIndex, SkillEffect effect)
|
|
{
|
|
if (!destination.TryGetValue(triggerIndex, out List<SkillEffect> effectList))
|
|
{
|
|
effectList = new List<SkillEffect>();
|
|
destination.Add(triggerIndex, effectList);
|
|
}
|
|
|
|
effectList.Add(effect);
|
|
}
|
|
|
|
private static void AddTriggeredAbnormality(Dictionary<int, List<AbnormalityData>> destination, int triggerIndex, AbnormalityData abnormality)
|
|
{
|
|
if (!destination.TryGetValue(triggerIndex, out List<AbnormalityData> abnormalityList))
|
|
{
|
|
abnormalityList = new List<AbnormalityData>();
|
|
destination.Add(triggerIndex, abnormalityList);
|
|
}
|
|
|
|
abnormalityList.Add(abnormality);
|
|
}
|
|
|
|
private float GetResolvedScalarMultiplier(System.Func<SkillGemData, float> selector)
|
|
{
|
|
if (baseSkill == null)
|
|
return 1f;
|
|
|
|
float resolved = 1f;
|
|
if (socketedGems == null)
|
|
return resolved;
|
|
|
|
for (int i = 0; i < socketedGems.Length; i++)
|
|
{
|
|
SkillGemData gem = socketedGems[i];
|
|
if (gem == null)
|
|
continue;
|
|
|
|
resolved *= Mathf.Max(0f, selector(gem));
|
|
}
|
|
|
|
return resolved;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 현재 시전 중인 스킬 로드아웃의 젬 보정값을 안전하게 조회하는 유틸리티입니다.
|
|
/// </summary>
|
|
public static class SkillRuntimeModifierUtility
|
|
{
|
|
public static float GetDamageMultiplier(GameObject caster)
|
|
{
|
|
return GetCurrentLoadout(caster)?.GetResolvedDamageMultiplier() ?? 1f;
|
|
}
|
|
|
|
public static float GetHealMultiplier(GameObject caster)
|
|
{
|
|
return GetCurrentLoadout(caster)?.GetResolvedHealMultiplier() ?? 1f;
|
|
}
|
|
|
|
public static float GetShieldMultiplier(GameObject caster)
|
|
{
|
|
return GetCurrentLoadout(caster)?.GetResolvedShieldMultiplier() ?? 1f;
|
|
}
|
|
|
|
public static float GetThreatMultiplier(GameObject caster)
|
|
{
|
|
return GetCurrentLoadout(caster)?.GetResolvedThreatMultiplier() ?? 1f;
|
|
}
|
|
|
|
private static SkillLoadoutEntry GetCurrentLoadout(GameObject caster)
|
|
{
|
|
if (caster == null)
|
|
return null;
|
|
|
|
SkillController skillController = caster.GetComponent<SkillController>();
|
|
if (skillController == null)
|
|
return null;
|
|
|
|
return skillController.CurrentLoadoutEntry;
|
|
}
|
|
}
|
|
}
|