Cards: 3x2 front/back sprites, appearance overlays, flip via the Toggle menu
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
No files matched your search
@@ -15,6 +15,14 @@ namespace Decentralized
|
||||
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, "Dr. Jackson stock (test)", () =>
|
||||
{
|
||||
EmporiumEntry.Instance.ClearFrontInv();
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Decentralized
|
||||
public const string FakeTag = "PD_FAKE_OF";
|
||||
public const string RefurbTag = "PD_REFURBISHED";
|
||||
public const string DeadTag = "PD_DEAD";
|
||||
public const string LookTag = "PD_LOOK", BackTag = "PD_BACK";
|
||||
|
||||
public static Action OpenTerminal;
|
||||
|
||||
@@ -68,14 +69,32 @@ namespace Decentralized
|
||||
private static GameItem CreateGpu(HardwareSpec spec)
|
||||
{
|
||||
var item = ItemDirectory.CreateEmptyItem(GpuId(spec.Model));
|
||||
item.SetSpriteAndShapeFromMod(ModInfo.Id, spec.Brand == Hardware.Probidia ? "gpu_probidia" : "gpu_pmd");
|
||||
item.SetGameItemType("ELECTRONIC");
|
||||
item.onLoaded = Refresh;
|
||||
// 右键"切换"翻面;外观差异用叠加图画在同一张底图上
|
||||
item.EnableTag(ToggleAppearanceHelper.TOGGLE_APPEARANCE_TAG);
|
||||
item.mayToggleSlotItemFunc = (_, _, _) => true;
|
||||
item.canToggleSlotItemFunc = (_, _, _) => true;
|
||||
item.onToggleSlotItemFunc = (toggled, _, _) => Log.Guard("显卡翻面", () =>
|
||||
{
|
||||
if (toggled.IsTag(BackTag)) toggled.ModifyTag(BackTag, t => t.Disable()); else toggled.EnableTag(BackTag);
|
||||
Refresh(toggled);
|
||||
});
|
||||
item.getItemSpriteModifierForItemFunc = Overlays;
|
||||
ModHelper.SetSource(item, ModInfo.Id, ModInfo.Name);
|
||||
Refresh(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
/// <summary>按给定的状态造一张卡(二手卡、假卡):写入标签并生成外观。</summary>
|
||||
public static GameItem NewCard(string model, double health, string fakeOf, Rng rng)
|
||||
{
|
||||
var item = ModHelper.SpawnItem(GpuId(model));
|
||||
var u = new Unit { Model = model, FakeOf = fakeOf, Health = health, Look = CardLook.Generate(rng, health, fakeOf != null) };
|
||||
Store(item, u);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static Unit ToUnit(GameItem item)
|
||||
{
|
||||
string model = item.identifier.Substring(GpuPrefix.Length);
|
||||
@@ -85,6 +104,7 @@ namespace Decentralized
|
||||
if (item.IsTag(FakeTag)) u.FakeOf = item.GetTagReadonly(FakeTag).GetString();
|
||||
u.Refurbished = item.IsTag(RefurbTag);
|
||||
u.Dead = item.IsTag(DeadTag);
|
||||
if (item.IsTag(LookTag)) u.Look = CardLook.Decode(item.GetTagReadonly(LookTag).GetString());
|
||||
return u;
|
||||
}
|
||||
|
||||
@@ -94,6 +114,7 @@ namespace Decentralized
|
||||
if (u.FakeOf != null) item.ModifyTag(FakeTag, s => s.Enable().SetString(u.FakeOf));
|
||||
if (u.Refurbished) item.EnableTag(RefurbTag);
|
||||
if (u.Dead) item.EnableTag(DeadTag);
|
||||
item.ModifyTag(LookTag, s => s.Enable().SetString(u.Look.Encode()));
|
||||
Refresh(item);
|
||||
}
|
||||
|
||||
@@ -107,12 +128,48 @@ namespace Decentralized
|
||||
item.name = L.T("item.gpu.burnt.name", label.Brand, DisplayModel(label.Model));
|
||||
item.shortDescription = L.T("item.gpu.burnt.desc");
|
||||
item.unitValue = Math.Max(1, label.Price / 20);
|
||||
item.SetSpriteAndShapeFromMod(ModInfo.Id, "gpu_burnt");
|
||||
item.SetSpriteAndShapeFromMod(ModInfo.Id, item.IsTag(BackTag) ? "gpu_burnt_b" : "gpu_burnt_f");
|
||||
return;
|
||||
}
|
||||
item.SetSpriteAndShapeFromMod(ModInfo.Id, (label.Brand == Hardware.Probidia ? "gpu_probidia" : "gpu_pmd") + (item.IsTag(BackTag) ? "_b" : "_f"));
|
||||
item.name = L.T("item.gpu.name", label.Brand, DisplayModel(label.Model));
|
||||
item.shortDescription = L.T("item.gpu.desc", Fmt.Num(label.DisplayHash), Fmt.Num(label.Kj), Mathf.RoundToInt((float)u.Health));
|
||||
item.unitValue = Math.Max(1, (long)Math.Round(label.Price * u.Health / 100));
|
||||
item.unitValue = CardValue.True(u);
|
||||
}
|
||||
|
||||
private static Sprite ModSprite(string key)
|
||||
{
|
||||
var mod = ModLoader.Mods.Find(m => m.Manifest.ID.Equals(ModInfo.Id));
|
||||
return mod != null && mod.Sprites.TryGetValue(key, out var sprite) ? sprite : null;
|
||||
}
|
||||
|
||||
/// <summary>外观叠加图:正面三个维度,背面丝印与贴纸;烧毁的卡不叠。</summary>
|
||||
private static List<ItemSpriteModifier> Overlays(GameItem item)
|
||||
{
|
||||
var list = new List<ItemSpriteModifier>();
|
||||
if (item.IsTag(DeadTag)) return list;
|
||||
var u = ToUnit(item);
|
||||
var keys = new List<string>();
|
||||
if (!item.IsTag(BackTag))
|
||||
{
|
||||
if (u.Look.Fan > 0) keys.Add("gpu_ov_fan" + u.Look.Fan);
|
||||
if (u.Look.Fingers > 0) keys.Add("gpu_ov_fin" + u.Look.Fingers);
|
||||
if (u.Look.Bracket > 0) keys.Add("gpu_ov_brk" + u.Look.Bracket);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 丝印:0 标称型号;1 印的是真实芯片型号;2 标称型号但字歪(重印过)
|
||||
string model = u.Look.Print == 1 && u.FakeOf != null ? u.FakeOf : u.Model;
|
||||
keys.Add((u.Look.Print == 2 ? "gpu_ov_txs_" : "gpu_ov_txt_") + model.ToLowerInvariant());
|
||||
if (u.Look.Sticker > 0) keys.Add("gpu_ov_stk" + u.Look.Sticker);
|
||||
}
|
||||
int priority = 0;
|
||||
foreach (var k in keys)
|
||||
{
|
||||
var sprite = ModSprite(k);
|
||||
if (sprite != null) list.Add(new ItemSpriteModifier(sprite, Vector2.zero, 0, false, priority++, false, Color.white));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// ---------- 矿架 ----------
|
||||
@@ -126,7 +183,7 @@ namespace Decentralized
|
||||
var battery = new GameSlotInventory();
|
||||
var upgrade = new GameSlotInventory();
|
||||
var modules = new GameGridInventory(MachineHelper.DEFAULT_MODULE_BAY_CONFIG, 7);
|
||||
// 显卡每张 2×2 格:一列 2 格宽的格子,每个槽两行;未解锁的行不可放
|
||||
// 显卡每张 3×2 格:3 格宽的格子,每张卡 3×2 格,每个槽两行;未解锁的行不可放
|
||||
var cards = new GameGridInventory(RigSlots.Shape(RigSlots.Base), RigSlots.CellWidth);
|
||||
var window = MachineHelper.CreateMachineryWindow(true,
|
||||
MachineHelper.PowerPanel(battery),
|
||||
|
||||
|
Before Width: | Height: | Size: 375 B |
|
After Width: | Height: | Size: 256 B |
|
After Width: | Height: | Size: 390 B |
|
After Width: | Height: | Size: 118 B |
|
After Width: | Height: | Size: 108 B |
|
After Width: | Height: | Size: 155 B |
|
After Width: | Height: | Size: 116 B |
|
After Width: | Height: | Size: 129 B |
|
After Width: | Height: | Size: 126 B |
|
After Width: | Height: | Size: 133 B |
|
After Width: | Height: | Size: 116 B |
|
After Width: | Height: | Size: 155 B |
|
After Width: | Height: | Size: 150 B |
|
After Width: | Height: | Size: 162 B |
|
After Width: | Height: | Size: 156 B |
|
After Width: | Height: | Size: 154 B |
|
After Width: | Height: | Size: 154 B |
|
After Width: | Height: | Size: 153 B |
|
After Width: | Height: | Size: 164 B |
|
After Width: | Height: | Size: 153 B |
|
After Width: | Height: | Size: 149 B |
|
After Width: | Height: | Size: 141 B |
|
After Width: | Height: | Size: 144 B |
|
After Width: | Height: | Size: 145 B |
|
After Width: | Height: | Size: 144 B |
|
After Width: | Height: | Size: 146 B |
|
After Width: | Height: | Size: 144 B |
|
After Width: | Height: | Size: 153 B |
|
After Width: | Height: | Size: 144 B |
|
Before Width: | Height: | Size: 329 B |
|
After Width: | Height: | Size: 235 B |
|
After Width: | Height: | Size: 354 B |
|
Before Width: | Height: | Size: 328 B |
|
After Width: | Height: | Size: 237 B |
|
After Width: | Height: | Size: 353 B |