14. 全息电话簿联系人与拨号召唤 (RegisterPhoneContact)
玩家柜台右侧的全息电话机允许拨打 7 位通讯号码并触发专属通话对话树。NpcPhoneRegistry.cs 封装了 PhoneClientList.DialogFuncs 与 PlayerStore.Instance.PhoneClientDict 的完整绑定流程。
SDK 方法签名与防穿帮别名机制
csharp
public static void RegisterPhoneContact(
long number, // 7 位电话号码,如 2077077L
string dialogFuncId, // 唯一对话函数键名
Func<string> displayNameGetter, // 电话簿列表显示的名称委托
int cooldownDays, // 每次拨号使用服务后的冷却天数
Func<bool> isUnlockedPredicate, // 解锁条件谓词(返回 true 时自动出现在玩家电话簿中)
Func<StorePhoneClient, Dialogue> callDialogFactory, // 拨通时的对话树生成函数
params string[] clientAliases) // 关联的顾客 identifier 列表(若该顾客当前已在店门口,拨号会自动提示本人在场)代码示例:拨打 2077077 随时召唤传奇佣兵 V 进店
csharp
public const long VPhoneNumber = 2077077L;
NpcFrameworkSdk.RegisterPhoneContact(
number: VPhoneNumber,
dialogFuncId: "CyberpunkMercV_Call",
displayNameGetter: () => NpcFrameworkSdk.T("传奇佣兵 V (2077077)", "V - Afterlife Merc (2077077)"),
cooldownDays: 3,
isUnlockedPredicate: () => NpcFrameworkSdk.GetSaveInt("v_stage", 0) == 4,
callDialogFactory: CreateVPhoneDialogue,
clientAliases: new[] { "v", "v_act1_relic", "v_act2_gun_order", "v_act3_heist", "v_recurring_merc" }
);
private static Dialogue CreateVPhoneDialogue(StorePhoneClient phoneClient)
{
string vName = NpcFrameworkSdk.T("传奇佣兵 V", "V (Afterlife Merc)");
var root = new Dialogue().SetText(vName, NpcFrameworkSdk.T("喂?是我,V。有什么大买卖找我?", "Yo, it's V. Got a gig or need a drop?"));
var dlgSummon = new Dialogue().SetText("PLAYER", NpcFrameworkSdk.T("[呼叫 V 进店交易] 现在方便来店里一趟吗?", "[Call V to Store] Can you swing by the shop right now?"));
root.AddChoice(DirectoryMaster.Item("$", true), "", "", dlgSummon, () =>
{
phoneClient?.UseService(); // 进入 3 天冷却
NpcFrameworkSdk.SummonNpcNow("v_recurring_merc"); // 立即排入队首并自动唤入店门
dlgSummon.NextDialogue().SetText(vName, NpcFrameworkSdk.T("没问题,这就骑草薙摩托过去,下一声门铃见!", "You got it, choom. I'll be at your counter on the next bell!"));
}, null);
return root;
}