using System; using System.Collections.Generic; using NUnit.Framework; using Sirenix.OdinInspector; using UnityEngine; using UnityEngine.Serialization; namespace Cielonos.MainGame.Inventory { public enum ItemType { MainWeapon, Support, Passive, Consumable } public enum ItemRarity { None, Tera, Moser, Graham, Epsilon, Aleph } [HideReferenceObjectPicker] public class ItemDescription { public string descriptionKey; public ItemDescription(string descriptionKey) { this.descriptionKey = descriptionKey; } } [CreateAssetMenu(fileName = "ContentData", menuName = "Cielonos/Items/ContentData")] public partial class ContentData : SerializedScriptableObject { [InlineButton("CreateID", "Create")] [ValueDropdown("GetAllItemTypes", IsUniqueList = true, DropdownHeight = 400)] public Type itemClass; public ItemType itemType; public ItemRarity itemRarity; [ValueDropdown("GetAllTags", IsUniqueList = true, DropdownHeight = 400)] public List tags; [ValueDropdown("GetAllInstitutions", IsUniqueList = true, DropdownHeight = 400)] public List institutions; [ReadOnly] public string displayNameKey; [ListDrawerSettings(CustomAddFunction = "AddDescription", ListElementLabelName = "descriptionKey")] public List descriptions; [FormerlySerializedAs("squareIcon")] public Sprite itemIcon; [TitleGroup("Drop Settings")] [Tooltip("掉落权重,越大越容易被随机选中。设为 0 则不会出现在随机池中。")] public float dropWeight = 1f; [Tooltip("额外的掉落设置,可以在 Roll 时传入 filter 进行更复杂的筛选逻辑。")] public Dictionary dropSettings = new Dictionary(); } public partial class ContentData { private bool IsMainWeapon => itemType == ItemType.MainWeapon; private void CreateID() { if(string.IsNullOrEmpty(itemClass?.Name)) { Debug.LogWarning("Class Name is empty. Cannot create Item ID."); return; } string className = this.itemClass.Name; displayNameKey = $"{className}_Name"; descriptions ??= new List(); } } #if UNITY_EDITOR public partial class ContentData { private List GetAllTags() { return new List { "Melee", "Ranged", "Burn", "Freeze", "Fusion", "Decay", "Shield", "Heal", "Crit", "Overload", "DoT" }; } /// /// 获取项目中所有继承自ItemBase的类的名称列表,用于编辑器下拉选择。 /// private List GetAllItemTypes() { List itemTypes = new List(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var type in assembly.GetTypes()) { if (type.IsClass && !type.IsAbstract && typeof(ItemBase).IsAssignableFrom(type)) { itemTypes.Add(type); } } } return itemTypes; } private List GetAllInstitutions() { return new List { "MilitaryIndustrialComplex", //Gun san fuku gō tai 軍産複合体 - 通用 "ShinshuManufacturing", //Shin shu sei zō 新州制造 - 机械扈从 "SkodaDynamics", //斯柯达 - 动能,爆炸 "WardenclyffeResonanceHub", //沃登克里夫 - 能量 "EuropeanOrganizationForNuclearResearch", //欧洲核子研究组织 - 核能 "DopplerLumierePhotonics", //多普勒-卢米埃尔 - 光子 "VitalisBiomass", //维塔利斯 - 生物 "Area6", //大陆技术领 第六区 - 尖端科技 "AcademyOfMagicalSciences", //魔法科学院 - 魔法 }; } private void AddDescription() { int index = descriptions.Count; string descriptionKey = $"{itemClass.Name}_Desc{index}"; descriptions.Add(new ItemDescription(descriptionKey)); } } #endif }