Phase 2: customers paying in coin (CRC/CRT/CRA/PSC), taint from stolen goods
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ba0652705
commit
090a973d23
10 files changed
+149
No files matched your search
@@ -0,0 +1,78 @@
|
||||
using System.Collections.Generic;
|
||||
using Decentralized.Domain;
|
||||
|
||||
namespace Decentralized
|
||||
{
|
||||
/// <summary>
|
||||
/// 用币付款的顾客:每天排队的买家里,按派系(上层 CRC、黑市 CRT、革命派 CRA、下层 PSC)有一小部分改用币结算。
|
||||
/// 成交时在店里扣回刚入账的信用点,换成币进热钱包;赃物的款项不记销赃,改成币带污点(货值 × 赃物热度%)。
|
||||
/// </summary>
|
||||
public static class CoinCustomers
|
||||
{
|
||||
private static readonly HashSet<StoreClient> Marked = new HashSet<StoreClient>();
|
||||
private static int markDay = -1;
|
||||
|
||||
public static void Subscribe()
|
||||
{
|
||||
ModHook.OnGenerateCustomerLate += OnGenerate;
|
||||
ModHelper.AddDebugFunction(ModInfo.Id, ModInfo.Name, "Coin buyer (test)", () => Log.Guard("用币付款顾客(测试)", () =>
|
||||
{
|
||||
var c = new StoreClient
|
||||
{
|
||||
identifier = "pd_coin_test", displayName = "Coin buyer", spriteName = SpriteDict.GetRandomScavSpriteName(),
|
||||
clientFaction = "FACTION_BLACK_MARKET", useClientBudget = true, clientIntent = StoreClient.ClientIntent.BUY,
|
||||
canClientExposeFeature = ClientCanExposeFunc.BasicClientExposeCapacity,
|
||||
};
|
||||
c.SetBudget(5000);
|
||||
c.clientBuyingTagList.Add("WATER"); c.clientBuyingTagList.Add("BREVAGE");
|
||||
c.mainDialogue.SetText(c.displayName, "CRT.").SetEndAction(() => { });
|
||||
c.AddBasicDialog();
|
||||
c.CompleteClientCreation();
|
||||
Mark(c, Assets.CRT);
|
||||
PlayerStore.Instance.currentClientInstance = StoreClientInstance.CreateClientInstance(c); // 测试:直接换成这位顾客
|
||||
}));
|
||||
}
|
||||
public static void Unsubscribe() => ModHook.OnGenerateCustomerLate -= OnGenerate;
|
||||
|
||||
private static void OnGenerate(StoreClientManager manager)
|
||||
{
|
||||
if (Session.Data == null || !Unlock.IsUnlocked) return;
|
||||
Log.Guard("用币付款", () =>
|
||||
{
|
||||
int day = StoreStation.GetDayCounter();
|
||||
if (day != markDay) { Marked.Clear(); markDay = day; }
|
||||
foreach (var c in manager.clientStack)
|
||||
{
|
||||
if (c == null || c.isSecurity || Marked.Contains(c) || c.clientIntent != StoreClient.ClientIntent.BUY || c.isNoContributeToEvidence) continue;
|
||||
Marked.Add(c);
|
||||
string asset = CoinPayment.AssetFor(c.clientFaction);
|
||||
if (asset == null || !Session.Data.Rng.Chance(CoinPayment.Chance(asset))) continue;
|
||||
Mark(c, asset);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void Mark(StoreClient c, string asset)
|
||||
{
|
||||
var before = c.onItemBought;
|
||||
c.isNoContributeToEvidence = true;
|
||||
c.onItemBought = (item, cost) =>
|
||||
{
|
||||
before?.Invoke(item, cost);
|
||||
Log.Guard("用币付款成交", () => Pay(asset, item, cost));
|
||||
};
|
||||
}
|
||||
|
||||
private static void Pay(string asset, GameItem item, int cost)
|
||||
{
|
||||
var d = Session.Data;
|
||||
double price = Session.Price(asset);
|
||||
if (cost <= 0 || price <= 0) return;
|
||||
int heat = item.IsTag("STOLEN_VALUE_INT") ? item.GetTagReadonly("STOLEN_VALUE_INT").GetInt() : 0;
|
||||
ModHelper.AddCredit(-cost, false);
|
||||
double qty = CoinPayment.Receive(d.Hot, asset, cost, price, heat);
|
||||
d.CoinSalesToday += cost;
|
||||
Log.Info($"用币付款:{item.name} {cost} 信用点 → {qty:0.####} {asset},污点 +{cost * heat / 100.0:0}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user