using System.Collections.Generic; using System.Linq; using UnityEngine; using Decentralized.Domain; namespace Decentralized { /// /// 杰克逊博士进货时(夜间去他店里,或他每周来本店摆摊)加上挖矿设备。用游戏给 mod 的进货钩子和他自己的上架函数, /// 价格是物品价值加上他的加价(难度规则与夜间事件决定)。加入 Web3 治理社区之后才上货。 /// public static class DealerStock { public static void Subscribe() { ModHook.OnPlaceInventorInventoryItemLate += OnPlace; // 开发者模式(F9)里的测试入口:像到了杰克逊店里一样,清空并扩大柜台后上货 ModHelper.AddDebugFunction(ModInfo.Id, ModInfo.Name, "Give rig x3 (test)", () => { for (int i = 0; i < 3; i++) Items.Give(ModHelper.SpawnItem(Items.Rig)); }); ModHelper.AddDebugFunction(ModInfo.Id, ModInfo.Name, "Used cards x4 (test)", () => { var rng = Session.Data.Rng; Items.Give(Items.NewCard("RZX80Ti", 40, null, rng)); Items.Give(Items.NewCard("RZX80Ti", 70, "RZX60", rng)); Items.Give(Items.NewCard("RZ6800", 30, "RZ580", rng)); Items.Give(Items.NewCard("RZ7900", 90, "RZ470", rng)); }); ModHelper.AddDebugFunction(ModInfo.Id, ModInfo.Name, "Dump inspection UI (test)", () => Log.Guard("检视界面结构", () => { var sb = new System.Text.StringBuilder("\n"); void Walk(Transform t, int depth) { var rt = t as RectTransform; var img = t.GetComponent(); sb.AppendLine($"{new string(' ', depth * 2)}{t.name} active={t.gameObject.activeSelf} pos={t.localPosition} size={(rt != null ? rt.sizeDelta.ToString() : "-")} scale={t.localScale}{(img != null ? " img=" + (img.sprite != null ? img.sprite.name : "null") : "")}"); if (depth < 5) foreach (Transform c in t) Walk(c, depth + 1); } var m = InspectionUIManager.Instance; var ci = PlayerStore.Instance.currentClientInstance; sb.AppendLine("当前顾客:" + (ci == null ? "无" : ci.GetClientBlueprint().identifier + " 意图 " + ci.GetClientBlueprint().clientIntent)); sb.AppendLine("检视物品:" + (m.currentInspectingItem?.identifier ?? "无") + " APPRAISAL=" + (m.currentInspectingItem?.IsTag("APPRAISAL_ITEM") ?? false)); Walk(m.panel.transform, 0); Log.Info(sb.ToString()); })); ModHelper.AddDebugFunction(ModInfo.Id, ModInfo.Name, "Dr. Jackson stock (test)", () => { EmporiumEntry.Instance.ClearFrontInv(); EmporiumEntry.Instance.ExpandFrontCounterGrid(); StoreClientList.PlaceInventorInventory(); }); } public static void Unsubscribe() { ModHook.OnPlaceInventorInventoryItemLate -= OnPlace; ModHelper.RemoveDebugFunctions(ModInfo.Id); } private static void OnPlace(List owned) { if (Session.Data == null || !Unlock.IsUnlocked) return; Log.Guard("杰克逊博士上货", () => { bool ownsRig = owned != null && owned.Any(i => i.identifier == Items.Rig); bool special = AfterhourEvents.IsActive("special_stock"); var placed = new List(); foreach (var kind in Dealer.Stock(StoreStation.GetDayCounter(), ownsRig, special, Session.Data.Rng)) { var item = ModHelper.SpawnItem(kind == Dealer.Rig ? Items.Rig : Items.GpuId(kind)); bool ok = PlayerStore.Instance.TryAddDirectSellingItemToTable(item); placed.Add(ok ? $"{kind}#{item.uniqueId}" : kind + "(柜台已满)"); } Log.Info("杰克逊博士上货:" + string.Join(",", placed)); }); } } }