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

@@ -624,7 +624,8 @@ namespace Colosseum.Editor
1f,
1f,
0,
damageEffect);
damageEffect,
allowedSkillTypes: SkillBaseType.Attack);
CreateOrUpdateGemAsset(
ChallengerGemPath,
@@ -639,7 +640,8 @@ namespace Colosseum.Editor
1f,
1.5f,
0,
tauntEffect);
tauntEffect,
allowedSkillTypes: SkillBaseType.Attack);
CreateOrUpdateGemAsset(
GuardianGemPath,
@@ -654,7 +656,8 @@ namespace Colosseum.Editor
1.5f,
1f,
0,
shieldEffect);
shieldEffect,
allowedSkillTypes: SkillBaseType.Attack);
CreateOrUpdateGemAsset(
RepeatGemPath,
@@ -669,7 +672,8 @@ namespace Colosseum.Editor
1f,
1f,
1,
null);
null,
allowedSkillTypes: SkillBaseType.Attack);
CreateOrUpdateGemAsset(
FortitudeGemPath,
@@ -718,7 +722,8 @@ namespace Colosseum.Editor
1f,
1f,
0,
edgeDamageEffect);
edgeDamageEffect,
allowedSkillTypes: SkillBaseType.Attack);
CreateOrUpdateGemAsset(
ImpactGemPath,
@@ -733,7 +738,8 @@ namespace Colosseum.Editor
1f,
1f,
0,
impactDamageEffect);
impactDamageEffect,
allowedSkillTypes: SkillBaseType.Attack);
CreateOrUpdateGemAsset(
BreachGemPath,
@@ -748,7 +754,8 @@ namespace Colosseum.Editor
1f,
1f,
0,
breachDamageEffect);
breachDamageEffect,
allowedSkillTypes: SkillBaseType.Attack);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
@@ -786,6 +793,20 @@ namespace Colosseum.Editor
SkillGemData impactGem = AssetDatabase.LoadAssetAtPath<SkillGemData>(ImpactGemPath);
SkillGemData breachGem = AssetDatabase.LoadAssetAtPath<SkillGemData>(BreachGemPath);
SetSkillBaseTypes(slashSkill, SkillBaseType.Attack);
SetSkillBaseTypes(tauntSkill, SkillBaseType.Control | SkillBaseType.Utility);
SetSkillBaseTypes(guardSkill, SkillBaseType.Defense);
SetSkillBaseTypes(dashSkill, SkillBaseType.Mobility);
SetSkillBaseTypes(ironWallSkill, SkillBaseType.Defense | SkillBaseType.Support);
SetSkillBaseTypes(pierceSkill, SkillBaseType.Attack);
SetSkillBaseTypes(gemTestSkill, SkillBaseType.Attack);
SetSkillBaseTypes(healSkill, SkillBaseType.Support);
SetSkillBaseTypes(areaHealSkill, SkillBaseType.Support);
SetSkillBaseTypes(shieldSkill, SkillBaseType.Defense | SkillBaseType.Support);
SetSkillBaseTypes(projectileSkill, SkillBaseType.Attack);
SetSkillBaseTypes(spinSkill, SkillBaseType.Attack);
SetSkillBaseTypes(evadeSkill, SkillBaseType.Mobility);
EnsureGemTestSkillSlotCount(gemTestSkill, 3);
CreateOrUpdatePresetAsset(
@@ -1314,7 +1335,10 @@ namespace Colosseum.Editor
SkillEffect triggeredEffect,
AbnormalityData[] selfAbnormalities = null,
int triggeredAbnormalityIndex = -1,
AbnormalityData[] onHitAbnormalities = null)
AbnormalityData[] onHitAbnormalities = null,
SkillBaseType allowedSkillTypes = SkillBaseType.All,
SkillGemCategory[] incompatibleCategories = null,
SkillGemData[] incompatibleGems = null)
{
SkillGemData gem = AssetDatabase.LoadAssetAtPath<SkillGemData>(assetPath);
if (gem == null)
@@ -1340,6 +1364,21 @@ namespace Colosseum.Editor
serializedGem.FindProperty("shieldMultiplier").floatValue = shieldMultiplier;
serializedGem.FindProperty("threatMultiplier").floatValue = threatMultiplier;
serializedGem.FindProperty("additionalRepeatCount").intValue = additionalRepeatCount;
serializedGem.FindProperty("allowedSkillTypes").intValue = (int)allowedSkillTypes;
SerializedProperty incompatibleCategoriesProperty = serializedGem.FindProperty("incompatibleCategories");
incompatibleCategoriesProperty.arraySize = incompatibleCategories != null ? incompatibleCategories.Length : 0;
for (int i = 0; i < incompatibleCategoriesProperty.arraySize; i++)
{
incompatibleCategoriesProperty.GetArrayElementAtIndex(i).enumValueIndex = (int)incompatibleCategories[i];
}
SerializedProperty incompatibleGemsProperty = serializedGem.FindProperty("incompatibleGems");
incompatibleGemsProperty.arraySize = incompatibleGems != null ? incompatibleGems.Length : 0;
for (int i = 0; i < incompatibleGemsProperty.arraySize; i++)
{
incompatibleGemsProperty.GetArrayElementAtIndex(i).objectReferenceValue = incompatibleGems[i];
}
SerializedProperty castStartEffectsProperty = serializedGem.FindProperty("castStartEffects");
castStartEffectsProperty.arraySize = 0;
@@ -1385,6 +1424,21 @@ namespace Colosseum.Editor
EditorUtility.SetDirty(gem);
}
private static void SetSkillBaseTypes(SkillData skill, SkillBaseType baseTypes)
{
if (skill == null)
return;
SerializedObject serializedSkill = new SerializedObject(skill);
SerializedProperty baseTypesProperty = serializedSkill.FindProperty("baseTypes");
if (baseTypesProperty == null || baseTypesProperty.intValue == (int)baseTypes)
return;
baseTypesProperty.intValue = (int)baseTypes;
serializedSkill.ApplyModifiedPropertiesWithoutUndo();
EditorUtility.SetDirty(skill);
}
private static DamageEffect CreateOrUpdateDamageEffectAsset(string assetPath, float baseDamage)
{
DamageEffect effect = AssetDatabase.LoadAssetAtPath<DamageEffect>(assetPath);

View File

@@ -432,6 +432,7 @@ namespace Colosseum.Player
skillLoadoutEntries[slotIndex] = loadoutEntry != null ? loadoutEntry.CreateCopy() : new SkillLoadoutEntry();
skillLoadoutEntries[slotIndex].EnsureGemSlotCapacity();
skillLoadoutEntries[slotIndex].SanitizeInvalidGems(true);
skillSlots[slotIndex] = skillLoadoutEntries[slotIndex].BaseSkill;
OnSkillSlotsChanged?.Invoke();
}
@@ -468,6 +469,7 @@ namespace Colosseum.Player
{
skillLoadoutEntries[i] = loadouts[i] != null ? loadouts[i].CreateCopy() : new SkillLoadoutEntry();
skillLoadoutEntries[i].EnsureGemSlotCapacity();
skillLoadoutEntries[i].SanitizeInvalidGems(true);
skillSlots[i] = skillLoadoutEntries[i].BaseSkill;
}

View File

@@ -5,6 +5,23 @@ using UnityEngine;
namespace Colosseum.Skills
{
/// <summary>
/// 젬 장착 조건에서 사용하는 기반 스킬 분류입니다.
/// 하나의 스킬이 여러 분류를 동시에 가질 수 있습니다.
/// </summary>
[Flags]
public enum SkillBaseType
{
None = 0,
Attack = 1 << 0,
Defense = 1 << 1,
Support = 1 << 2,
Control = 1 << 3,
Mobility = 1 << 4,
Utility = 1 << 5,
All = Attack | Defense | Support | Control | Mobility | Utility,
}
/// <summary>
/// 스킬 데이터. 스킬의 기본 정보와 효과 목록을 관리합니다.
/// </summary>
@@ -17,6 +34,10 @@ namespace Colosseum.Skills
[SerializeField] private string description;
[SerializeField] private Sprite icon;
[Header("기반 스킬 분류")]
[Tooltip("젬 장착 가능 조건에 사용하는 기반 스킬 분류")]
[SerializeField] private SkillBaseType baseTypes = SkillBaseType.None;
[Header("애니메이션")]
[Tooltip("기본 Animator Controller의 'Skill' 상태에 덮어씌워질 클립")]
[SerializeField] private AnimationClip skillClip;
@@ -61,6 +82,7 @@ namespace Colosseum.Skills
public string SkillName => skillName;
public string Description => description;
public Sprite Icon => icon;
public SkillBaseType BaseTypes => baseTypes;
public AnimationClip SkillClip => skillClip;
public AnimationClip EndClip => endClip;
public float AnimationSpeed => animationSpeed;

View File

@@ -65,6 +65,14 @@ namespace Colosseum.Skills
[Tooltip("젬의 주 역할 분류")]
[SerializeField] private SkillGemCategory category = SkillGemCategory.Common;
[Header("장착 제약")]
[Tooltip("장착 가능한 기반 스킬 분류입니다. None 또는 All이면 제한하지 않습니다.")]
[SerializeField] private SkillBaseType allowedSkillTypes = SkillBaseType.All;
[Tooltip("함께 장착할 수 없는 젬 분류")]
[SerializeField] private SkillGemCategory[] incompatibleCategories = Array.Empty<SkillGemCategory>();
[Tooltip("함께 장착할 수 없는 특정 젬")]
[SerializeField] private List<SkillGemData> incompatibleGems = new();
[Header("기본 수치 보정")]
[Tooltip("장착 시 마나 비용 배율")]
[Min(0f)] [SerializeField] private float manaCostMultiplier = 1f;
@@ -99,6 +107,7 @@ namespace Colosseum.Skills
public string Description => description;
public Sprite Icon => icon;
public SkillGemCategory Category => category;
public SkillBaseType AllowedSkillTypes => allowedSkillTypes;
public float ManaCostMultiplier => manaCostMultiplier;
public float CooldownMultiplier => cooldownMultiplier;
public float CastSpeedMultiplier => castSpeedMultiplier;
@@ -107,9 +116,59 @@ namespace Colosseum.Skills
public float ShieldMultiplier => shieldMultiplier;
public float ThreatMultiplier => threatMultiplier;
public int AdditionalRepeatCount => additionalRepeatCount;
public IReadOnlyList<SkillGemCategory> IncompatibleCategories => incompatibleCategories;
public IReadOnlyList<SkillGemData> IncompatibleGems => incompatibleGems;
public IReadOnlyList<SkillEffect> CastStartEffects => castStartEffects;
public IReadOnlyList<SkillGemTriggeredEffectEntry> TriggeredEffects => triggeredEffects;
public IReadOnlyList<AbnormalityData> SelfAbnormalities => selfAbnormalities;
public IReadOnlyList<SkillGemTriggeredAbnormalityEntry> OnHitAbnormalities => onHitAbnormalities;
/// <summary>
/// 지정한 기반 스킬에 이 젬을 장착할 수 있는지 확인합니다.
/// </summary>
public bool CanAttachToSkill(SkillData skill)
{
if (skill == null)
return false;
if (allowedSkillTypes == SkillBaseType.None || allowedSkillTypes == SkillBaseType.All)
return true;
return (allowedSkillTypes & skill.BaseTypes) != 0;
}
/// <summary>
/// 지정한 젬 분류와 상호 배타적인지 확인합니다.
/// </summary>
public bool IsCategoryIncompatible(SkillGemCategory otherCategory)
{
if (incompatibleCategories == null || incompatibleCategories.Length == 0)
return false;
for (int i = 0; i < incompatibleCategories.Length; i++)
{
if (incompatibleCategories[i] == otherCategory)
return true;
}
return false;
}
/// <summary>
/// 지정한 젬과 상호 배타적인지 확인합니다.
/// </summary>
public bool IsGemIncompatible(SkillGemData other)
{
if (other == null || incompatibleGems == null || incompatibleGems.Count == 0)
return false;
for (int i = 0; i < incompatibleGems.Count; i++)
{
if (incompatibleGems[i] == other)
return true;
}
return false;
}
}
}

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)