using System; using System.Collections.Generic; using System.Linq; namespace Ashfall.Core { [Serializable] public class ContentEntry { public string id, name, category, description; public Family family; public int tier, floors; public bool prototypeReady; } [Serializable] public class ModuleDefinition { public string id, name, itemId, researchId, ammoId; public Family family; public int size = 1; public float mass, power, damage, range, interval; } [Serializable] public class RecipeDefinition { public string id, name, outputId; public Family family; public FacilityKind facility = FacilityKind.Workshop; public int outputAmount; public float seconds; public List inputs = new List(); } [Serializable] public class ContentCatalog { public List entries = new List(); public List modules = new List(); public List recipes = new List(); public ModuleDefinition Module(string id) => modules.Find(m => m.id == id); public RecipeDefinition Recipe(string id) => recipes.Find(r => r.id == id); public static ContentCatalog CreateDefault() { var c = new ContentCatalog(); c.Add("hero", Family.Mechanical, new[] { "ranger|游骑兵", "bulwark|堡垒卫士", "engineer|战地技师", "scout|幽光斥候" }); c.Add("hero", Family.Biological, new[] { "burrower|掘袭猎手", "tyrant|裂甲暴君", "plague|疫腺行者", "conduit|噬能先驱" }); c.Entry("form.worm", "蠕虫幼体", "form", Family.Biological).description = "虫族新角色的开局形态;撕咬、短距钻地,通过蜕变解锁成体。"; c.Add("weapon", Family.Mechanical, new[] { "rifle|突击步枪", "smg|冲锋枪", "shotgun|霰弹枪", "sniper|精确狙击枪", "machinegun|重机枪", "grenade|榴弹发射器", "flamer|火焰喷射器", "rail|磁轨步枪", "arc|电弧投射器", "plasma|等离子发射器", "rocket|制导火箭筒", "beam|熔束枪" }); c.Add("gene", Family.Biological, new[] { "scythe|刃镰前肢", "mandible|破城颚骨", "spike|骨针喷腔", "acid|腐酸喷囊", "plasma|电浆喉囊", "tail|震荡尾锤", "burrow|盾构口器", "leap|肌束弹弓", "wing|膜翼", "pull|牵引腺体", "mist|毒雾肺囊", "membrane|硬化包膜", "molt|蜕壳逃生", "metabolism|过载代谢", "carapace|反应甲壳", "leech|噬能血管", "regrowth|复生组织", "chain|连锁神经", "spore|爆裂孢囊", "catalyst|酸蚀催化", "muscle|增殖肌束", "legs|多节步足", "sense|超感触须", "harvest|采掘牙板" }); string[] functions = { "core", "generator", "reactor", "relay", "storage", "extractor", "smelter", "refinery", "fabricator", "research", "advanced_research", "weapons", "armor", "medical", "food", "garage", "hangar", "shipyard", "radar", "shield" }; string[] human = { "指挥站", "燃料发电机", "聚变反应炉", "输电节点", "智能仓库", "自动采掘井", "冶炼厂", "化工精炼厂", "精密制造机", "科研中心", "高能实验室", "枪械工坊", "动力甲整备舱", "医疗复苏舱", "合成厨房", "地面装配厂", "机库起降台", "飞行船坞", "雷达通信塔", "护盾发生器" }; string[] brood = { "源巢", "代谢心脏", "催化核囊", "神经根须节点", "储质囊", "根须汲取器", "消化池", "生化分泌池", "器官塑形池", "进化池", "祖源解析室", "攻击器官巢", "躯体蜕变室", "再生茧室", "营养菌圃", "巨兽孵育巢", "翼巢停栖台", "天穹育巢", "振动感知器", "屏障器官" }; for (int i = 0; i < functions.Length; i++) { c.Entry("facility.human." + functions[i], human[i], "facility", Family.Mechanical); c.Entry("facility.brood." + functions[i], brood[i], "facility", Family.Biological); } string[] turretsH = { "哨戒机枪塔", "火焰喷射塔", "破片霰弹塔", "狙击炮塔", "制导火箭塔", "迫击炮塔", "冷凝喷射塔", "电磁线圈塔", "近防高炮塔", "聚焦激光塔", "磁轨炮塔", "重型等离子炮台" }; string[] turretsB = { "骨针喷塔", "腐酸喷塔", "触须绞杀塔", "重棘弩塔", "爆囊投射塔", "腺体轰击塔", "黏液阻滞塔", "生物脉冲塔", "追空荚塔", "神经震荡塔", "潜伏地棘塔", "巨型溶解腺" }; for (int i = 0; i < 12; i++) { c.Entry("turret.human." + i, turretsH[i], "turret", Family.Mechanical); c.Entry("turret.brood." + i, turretsB[i], "turret", Family.Biological); } string[] vehiclesH = { "疾驰侦察车", "拓荒履带车", "碎岩攻坚坦克", "擎岳重装机甲", "蜻翼旋翼艇", "重载运输机", "雷矛武装机", "天穹方舟" }; string[] vehiclesB = { "疾爪骑兽", "囊背驮兽", "裂地攻城兽", "穴行掘进兽", "滑翔翼兽", "浮囊运载兽", "雷腺猎空兽", "万脉天巢" }; int[] decks = { 0, 1, 1, 2, 0, 2, 1, 3 }; for (int i = 0; i < 8; i++) { c.Entry("vehicle.human." + i, vehiclesH[i], "vehicle", Family.Mechanical).floors = decks[i]; c.Entry("vehicle.brood." + i, vehiclesB[i], "vehicle", Family.Biological).floors = decks[i]; } c.Add("region", Family.Mechanical, new[] { "plain|陨落平原", "marsh|腐殖湿地", "industry|铁锈工业带", "valley|黑曜热谷", "plateau|风暴高原", "rift|悬空裂隙" }); foreach (var region in c.entries.Where(e => e.category == "region").ToArray()) c.Entry("boss." + region.id.Split('.').Last(), region.name + "地区首领", "boss", Family.Biological); c.modules.Add(new ModuleDefinition { id = "mechanical.light", name = "机枪组件", itemId = "module.mechanical.light", family = Family.Mechanical, ammoId = "ammo", mass = 6, power = 3, damage = 24, range = 36, interval = .16f }); c.modules.Add(new ModuleDefinition { id = "mechanical.heavy", name = "攻坚火炮", itemId = "module.mechanical.heavy", researchId = "mechanical.weapons", family = Family.Mechanical, ammoId = "shell", size = 2, mass = 18, power = 9, damage = 150, range = 52, interval = 1.25f }); c.modules.Add(new ModuleDefinition { id = "biological.light", name = "骨针器官", itemId = "module.biological.light", family = Family.Biological, ammoId = "biomass", mass = 5, power = 3, damage = 27, range = 32, interval = .2f }); c.modules.Add(new ModuleDefinition { id = "biological.heavy", name = "腐酸重囊", itemId = "module.biological.heavy", researchId = "biological.weapons", family = Family.Biological, ammoId = "biomass", size = 2, mass = 16, power = 8, damage = 140, range = 45, interval = 1.1f }); c.RecipeEntry("ammo", "加工步枪弹药", Family.Mechanical, "ammo", 60, 3, "metal", 5); c.RecipeEntry("shell", "制造炮弹", Family.Mechanical, "shell", 12, 5, "metal", 8); c.RecipeEntry("nutrient", "培养生物质", Family.Biological, "biomass", 40, 4, "ore", 4); c.RecipeEntry("alloy", "精炼合金", Family.Mechanical, "alloy", 5, 5, "ore", 10); c.RecipeEntry("chitin", "矿化甲壳板", Family.Biological, "chitin", 5, 5, "biomass", 10); foreach (var module in c.modules) c.RecipeEntry(module.id, "制造" + module.name, module.family, module.itemId, 1, module.size == 1 ? 6 : 12, module.family == Family.Mechanical ? "metal" : "biomass", module.size == 1 ? 12 : 30); foreach (var e in c.entries) e.prototypeReady = e.id == "form.worm" || e.id == "hero.ranger" || e.id == "hero.burrower" || e.id == "weapon.rifle" || e.id == "gene.spike" || e.id == "gene.burrow" || e.id == "region.plain"; return c; } private void Add(string category, Family family, string[] values) { foreach (var row in values) { var p = row.Split('|'); Entry(category + "." + p[0], p[1], category, family); } } private ContentEntry Entry(string id, string name, string category, Family family) { var e = new ContentEntry { id = id, name = name, category = category, family = family, description = "完整内容目标;以开发状态表为准" }; entries.Add(e); return e; } private void RecipeEntry(string id, string name, Family family, string output, int amount, float seconds, string input, int cost) { recipes.Add(new RecipeDefinition { id = id, name = name, family = family, outputId = output, outputAmount = amount, seconds = seconds, inputs = new List { new ItemStack { id = input, amount = cost } } }); } public void Validate() { if (entries.Select(e => e.id).Distinct().Count() != entries.Count) throw new InvalidOperationException("Duplicate content ID."); if (modules.Any(m => m.size < 1 || m.damage <= 0 || m.interval <= 0)) throw new InvalidOperationException("Invalid module definition."); } } }