Phones
What it is
This API reads the phone book, the numbers the player can dial. Calls are on Phone lines.
Reference
Phones the phone book
Call All() to list the numbers the player can dial. Pass one of those numbers to PhoneLines.Ring or PhoneLines.StartCall.
public static class Phones
{
public static List<PhoneContact> All();
}
| Method | Returns | What it does |
|---|---|---|
All() | List<PhoneContact> | Every number the player can dial. |
PhoneContact one phone entry
Phones.All() gives you one of these for each number. Number is the number to pass to PhoneLines.Ring or PhoneLines.StartCall, and Network says which networks it is on. (It is built from the game’s PhoneNumber phone book entries.)
public sealed class PhoneContact
{
public string Id { get; }
public string Number { get; }
public PhoneNetwork Network { get; }
public float AnswerChance { get; }
}
| Property | Type | What it means |
|---|---|---|
Id | string | The entry’s internal name. |
Number | string | The digits to dial, where * is 10 and # is 11. |
Network | PhoneNetwork | Which network the number is on. A number can be on more than one. |
AnswerChance | float | The chance someone picks up, from 0 (never) to 1 (always). |
PhoneNetwork which networks a number is on
These are the values of PhoneContact.Network and PhoneLineInfo.Network. It is a set of flags, so a number can be on more than one network. (It mirrors the game’s PhoneNumber.Network.)
[Flags]
public enum PhoneNetwork
{
None = 0,
Obenseuer = 1,
Outside = 2,
Wasteland = 4
}
| Value | Meaning |
|---|---|
None | The number is on no network. |
Obenseuer | A phone in Obenseuer. |
Outside | A phone outside Obenseuer. |
Wasteland | A phone in the wasteland. |
Putting it together
Logs Obenseuer numbers with their answer chance.
using ObenseuerCore;
[ModInfo("example.phonebook", "Phone Book", "0.1.0")]
[ModDependency("obenseuer.moddingframework", "0.11.0")]
public sealed class PhoneBook : FrameworkMod
{
protected override void OnLoad()
{
Events.WhenReady(() =>
{
foreach (PhoneContact contact in Phones.All())
{
if (!contact.Network.HasFlag(PhoneNetwork.Obenseuer)) continue;
int percent = (int)(contact.AnswerChance * 100);
Log.Info(contact.Id + ": dial " + contact.Number + ", picks up " + percent + "% of the time");
}
});
}
}
| Step | What it does |
|---|---|
contact.Network.HasFlag(PhoneNetwork.Obenseuer) | Keeps only the numbers on the Obenseuer network. |
contact.AnswerChance * 100 | Turns the chance into a percentage. |
Things to know
- Hidden entries and entries with no digits are left out of
All(). - Off-network numbers get an “outside the network” reply, with no answer roll.
Limits
- The framework has no call to add a number. The game’s phone book is a static list (
PhoneNumberDatabase.database) that it fills once at start and never saves, so a number a mod adds itself lasts until the game closes and must be added again at each launch.
Details
Target: Obenseuer 0.5.08 (buildid 25969064), Unity 6000.0.77f1 Mono, BepInEx 6 Unity.Mono (be.788, the tested build) or BepInEx 5 (5.4.23 or later). Logs go to BepInEx\logs\obenseuer.moddingframework.npcs.log.
When you can call it
- Call from the main thread, not a thread you started.
- Safe at any time; empty reads return
0,false,nullor an empty list.
Under the hood
How the framework reads the game, for modders who want to dig deeper.
PhoneNumberDatabase.databasefills from the game’sResourcesfolder at start.notIndexedand emptynumberarrays are skipped.network.HasFlag(number.network)is checked beforeAnswerChanceis rolled.Phone.additionalNumbersis set in the Unity editor. No save code touches the book.