feat: 젬 장착 제약 시스템 추가

- 기반 스킬 분류를 도입하고 젬별 장착 가능 스킬 타입 조건을 추가함
- 동일 젬 중복 장착, 카테고리 상호 배타, 특정 젬 상호 배타를 로드아웃 검증에 반영함
- 테스트용 젬/스킬 자산과 디버그 생성 메뉴를 새 제약 구조에 맞게 갱신함
- Unity 재컴파일과 콘솔 확인으로 신규 컴파일 에러가 없음을 검증함
This commit is contained in:
2026-03-26 14:49:59 +09:00
parent e4710f9a29
commit 1261d4dc3c
27 changed files with 399 additions and 34 deletions

View File

@@ -44,6 +44,7 @@ namespace Colosseum.Skills
}
}
copy.SanitizeInvalidGems();
return copy;
}
@@ -56,7 +57,10 @@ namespace Colosseum.Skills
slotCount = Mathf.Max(0, slotCount);
if (socketedGems != null && socketedGems.Length == slotCount)
{
SanitizeInvalidGems();
return;
}
SkillGemData[] resized = new SkillGemData[slotCount];
if (socketedGems != null)
@@ -69,21 +73,23 @@ namespace Colosseum.Skills
}
socketedGems = resized;
SanitizeInvalidGems();
}
public void SetBaseSkill(SkillData skill)
{
baseSkill = skill;
EnsureGemSlotCapacity();
SanitizeInvalidGems();
}
public void SetGem(int slotIndex, SkillGemData gem)
{
EnsureGemSlotCapacity();
if (slotIndex < 0 || slotIndex >= socketedGems.Length)
return;
socketedGems[slotIndex] = gem;
if (!TrySetGem(slotIndex, gem, out string reason) && gem != null)
{
string skillName = baseSkill != null ? baseSkill.SkillName : "(없음)";
Debug.LogWarning($"[SkillLoadout] 젬 장착 실패 | Skill={skillName} | Slot={slotIndex} | Gem={gem.GemName} | Reason={reason}");
}
}
public SkillGemData GetGem(int slotIndex)
@@ -95,6 +101,64 @@ namespace Colosseum.Skills
return socketedGems[slotIndex];
}
/// <summary>
/// 지정한 슬롯에 젬을 장착 시도하고, 실패 이유를 반환합니다.
/// </summary>
public bool TrySetGem(int slotIndex, SkillGemData gem, out string reason)
{
reason = string.Empty;
EnsureGemSlotCapacity();
if (slotIndex < 0 || slotIndex >= socketedGems.Length)
{
reason = "유효하지 않은 젬 슬롯입니다.";
return false;
}
if (gem == null)
{
socketedGems[slotIndex] = null;
return true;
}
if (!TryValidateGemForSlot(slotIndex, gem, null, out reason))
return false;
socketedGems[slotIndex] = gem;
return true;
}
/// <summary>
/// 현재 로드아웃의 잘못된 젬 조합을 제거합니다.
/// </summary>
public void SanitizeInvalidGems(bool logWarnings = false)
{
if (socketedGems == null || socketedGems.Length == 0)
return;
List<SkillGemData> acceptedGems = new List<SkillGemData>(socketedGems.Length);
for (int i = 0; i < socketedGems.Length; i++)
{
SkillGemData gem = socketedGems[i];
if (gem == null)
continue;
if (TryValidateGemForSlot(i, gem, acceptedGems, out string reason))
{
acceptedGems.Add(gem);
continue;
}
if (logWarnings)
{
string skillName = baseSkill != null ? baseSkill.SkillName : "(없음)";
Debug.LogWarning($"[SkillLoadout] 젬 장착 제약으로 제거됨 | Skill={skillName} | Slot={i} | Gem={gem.GemName} | Reason={reason}");
}
socketedGems[i] = null;
}
}
public float GetResolvedManaCost()
{
if (baseSkill == null)
@@ -347,6 +411,78 @@ namespace Colosseum.Skills
abnormalityList.Add(abnormality);
}
private bool TryValidateGemForSlot(int slotIndex, SkillGemData gem, IReadOnlyList<SkillGemData> acceptedGems, out string reason)
{
reason = string.Empty;
if (gem == null)
return true;
if (baseSkill == null)
{
reason = "기반 스킬이 없는 슬롯에는 젬을 장착할 수 없습니다.";
return false;
}
if (!gem.CanAttachToSkill(baseSkill))
{
reason = $"기반 스킬 분류 제약을 만족하지 않습니다. Skill={baseSkill.BaseTypes}, Allowed={gem.AllowedSkillTypes}";
return false;
}
if (acceptedGems != null)
{
for (int i = 0; i < acceptedGems.Count; i++)
{
if (!TryValidateGemPair(gem, acceptedGems[i], out reason))
return false;
}
return true;
}
for (int i = 0; i < socketedGems.Length; i++)
{
if (i == slotIndex)
continue;
SkillGemData otherGem = socketedGems[i];
if (otherGem == null)
continue;
if (!TryValidateGemPair(gem, otherGem, out reason))
return false;
}
return true;
}
private static bool TryValidateGemPair(SkillGemData gem, SkillGemData otherGem, out string reason)
{
reason = string.Empty;
if (gem == null || otherGem == null)
return true;
if (gem == otherGem)
{
reason = "동일한 젬은 하나의 스킬에 여러 개 장착할 수 없습니다.";
return false;
}
if (gem.IsGemIncompatible(otherGem) || otherGem.IsGemIncompatible(gem))
{
reason = $"{gem.GemName}과 {otherGem.GemName}은 함께 장착할 수 없습니다.";
return false;
}
if (gem.IsCategoryIncompatible(otherGem.Category) || otherGem.IsCategoryIncompatible(gem.Category))
{
reason = $"{gem.Category} / {otherGem.Category} 분류 조합은 허용되지 않습니다.";
return false;
}
return true;
}
private float GetResolvedScalarMultiplier(System.Func<SkillGemData, float> selector)
{
if (baseSkill == null)