113 lines
5.0 KiB
C#
113 lines
5.0 KiB
C#
// ─────────────────────────────────────────────────────────────────────────────
|
|
// WLEquipIcons.cs — 아이템 → 아이콘 스프라이트·색조 (#824 · 2026-10-09)
|
|
//
|
|
// 무기(부위 1) = XP Hero 무기 아이콘(그룹 → 등급 7단계 순 변형 · WLEquipGui.json weaponIcons)
|
|
// 그 외 부위 = 임시 플랫 아이콘(partIcons) + 같은 부위 안 그룹 구분용 색조(groupTints) — ComfyUI 제작분으로 교체 예정
|
|
// 소모품 = consumableIcons(골드·강화석) · 없으면 null
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace WL.Equip
|
|
{
|
|
public static class WLEquipIcons
|
|
{
|
|
static readonly Dictionary<int, int> s_groupRank = new Dictionary<int, int>(); // GroupNo → 부위 안 순번
|
|
static bool s_rankBuilt;
|
|
|
|
static void BuildRanks()
|
|
{
|
|
if (s_rankBuilt) return;
|
|
s_rankBuilt = true;
|
|
var perPart = new Dictionary<int, List<int>>();
|
|
var items = WLEquipTables.Items;
|
|
for (int i = 0; i < items.Count; i++)
|
|
{
|
|
var j = items[i];
|
|
if (!j.IsEquipment) continue;
|
|
List<int> l;
|
|
if (!perPart.TryGetValue((int)j.EquipmentType, out l)) { l = new List<int>(); perPart[(int)j.EquipmentType] = l; }
|
|
if (!l.Contains(j.GroupNo)) l.Add(j.GroupNo);
|
|
}
|
|
foreach (var kv in perPart)
|
|
{
|
|
kv.Value.Sort();
|
|
for (int i = 0; i < kv.Value.Count; i++) s_groupRank[kv.Value[i]] = i;
|
|
}
|
|
}
|
|
|
|
public static Color GroupTint(int groupNo)
|
|
{
|
|
var cfg = WLEquipGuiAssets.Config;
|
|
if (cfg.groupTints == null || cfg.groupTints.list == null || cfg.groupTints.list.Count == 0) return Color.white;
|
|
BuildRanks();
|
|
int rank;
|
|
if (!s_groupRank.TryGetValue(groupNo, out rank)) rank = 0;
|
|
var c = cfg.groupTints.list[rank % cfg.groupTints.list.Count];
|
|
if (c == null || c.Length < 3) return Color.white;
|
|
return new Color(c[0], c[1], c[2], c.Length >= 4 ? c[3] : 1f);
|
|
}
|
|
|
|
/// <summary>아이템의 아이콘. tint = 아이콘에 곱할 색(무기·소모품은 흰색).</summary>
|
|
public static Sprite For(ItemJson j, out Color tint)
|
|
{
|
|
tint = Color.white;
|
|
var cfg = WLEquipGuiAssets.Config;
|
|
if (j == null) return null;
|
|
if (j.IsEquipment)
|
|
{
|
|
int tier = 1, plus;
|
|
WLGradeTier t;
|
|
if (WLEquipGrades.TryMap(j, out t, out plus)) tier = t.tier;
|
|
if (j.EquipmentType == eFREquipmentType.Weapon)
|
|
{
|
|
List<string> list;
|
|
if (cfg.weaponIcons != null && cfg.weaponIcons.TryGetValue(j.GroupNo.ToString(), out list) && list != null && list.Count > 0)
|
|
return WLEquipGuiAssets.Get(list[Mathf.Clamp(tier - 1, 0, list.Count - 1)]);
|
|
return WLEquipGuiAssets.Get("W_Sword");
|
|
}
|
|
string pname;
|
|
if (cfg.partIcons != null && cfg.partIcons.TryGetValue(((int)j.EquipmentType).ToString(), out pname))
|
|
{
|
|
tint = GroupTint(j.GroupNo);
|
|
return WLEquipGuiAssets.Get(pname);
|
|
}
|
|
return null;
|
|
}
|
|
string cname0;
|
|
if (cfg.consumableIcons != null && cfg.consumableIcons.TryGetValue(j.Index.ToString(), out cname0)) return WLEquipGuiAssets.Get(cname0);
|
|
return null;
|
|
}
|
|
|
|
/// <summary>부위 아이콘(탭·빈 슬롯 표시용 · partIcons). 없으면 null.</summary>
|
|
public static Sprite PartIcon(eFREquipmentType t)
|
|
{
|
|
var cfg = WLEquipGuiAssets.Config;
|
|
string pname;
|
|
if (cfg.partIcons != null && cfg.partIcons.TryGetValue(((int)t).ToString(), out pname)) return WLEquipGuiAssets.Get(pname);
|
|
return null;
|
|
}
|
|
|
|
public static Sprite TierBg(int tier)
|
|
{
|
|
var t = WLEquipGuiAssets.Config.Tier(tier);
|
|
return t != null ? WLEquipGuiAssets.Get(t.bg) : null;
|
|
}
|
|
|
|
public static Sprite TierLabel(int tier)
|
|
{
|
|
var t = WLEquipGuiAssets.Config.Tier(tier);
|
|
return t != null ? WLEquipGuiAssets.Get(t.label) : null;
|
|
}
|
|
|
|
public static Color TierColor(int tier)
|
|
{
|
|
var t = WLEquipGrades.Tier(tier);
|
|
Color c;
|
|
if (t != null && !string.IsNullOrEmpty(t.color) && ColorUtility.TryParseHtmlString(t.color, out c)) return c;
|
|
return Color.white;
|
|
}
|
|
}
|
|
}
|