IM reference
What this page is for
Section titled “What this page is for”IM is the door to the running game. This page lists the members you reach for first, grouped by what you want to do, and each one is public in the file named beside it. The list is curated. It leaves out the members that other pages own, such as variables, the mind, messages and the full event list, so do not read a missing member as a missing feature.
For what IM is and when it throws, read the Scripting overview first.
When you come here
Section titled “When you come here”You know what you want, such as the player, a clan by name or a language switch. You need the exact member. Every row gives the signature, what it does and the file it lives in, and all files are in Runtime/Manager/ unless a row says otherwise.
The door
Section titled “The door”| Member | What it does | File |
|---|---|---|
static bool Exists |
True when a manager is running. | IM.cs |
static IntrigueManager Instance |
The running manager. Throws InvalidOperationException when there is none. |
IM.cs |
static bool DatabaseExists |
True when a manager exists and has a database. | IM.Registry.cs |
static IntrigueDatabase Database |
The database of the running manager. null without a manager. |
IM.Registry.cs |
Lookups
Section titled “Lookups”By name or ID, one thing at a time. The lookup tries the ID first, then the name as written, then the name as shown. Each returns null for no match and without a manager.
| Member | What it does | File |
|---|---|---|
static Clan GetClan(string clanNameOrID) |
One clan. | IM.Registry.cs |
static Family GetFamily(string familyNameOrId) |
One family. | IM.Registry.cs |
static Role GetRole(string roleNameOrId) |
One role. | IM.Registry.cs |
static Policy GetPolicy(string policyNameOrId) |
One policy. | IM.Registry.cs |
static Culture GetCulture(string cultureNameOrId) |
One culture. | IM.Registry.cs |
static Variable GetVariable(string), T GetVariable<T>(string), bool SetVariable<T>(string, T) |
World variables. Their page is Variables from code. | IM.Variables.cs |
Whole lists. All of them are empty without a manager.
| Member | What it does | File |
|---|---|---|
static IEnumerable<Clan> Clans |
The clans of the running game. | IM.Registry.cs |
static IReadOnlyList<Clan> ActiveClans |
The clans that are not disbanded. A kept list: reading it allocates nothing. | IM.Registry.cs |
static IEnumerable<Family> Families, Cultures, Policies, Roles, Schemes |
The families, cultures, policies, roles and scheme templates. | IM.Registry.cs |
static int GetRoles(RoleKind kind, List<Role> results) |
Fills results (cleared first) with the roles of one kind. Returns how many. |
IM.Registry.cs |
Actors have four views. All are main thread only.
| Member | What it does | File |
|---|---|---|
static IReadOnlyDictionary<string, Actor> ActorDictionary |
The registered actors by ID. Even reading the whole dictionary is main thread only. | IM.Registry.cs |
static ActorView Actors |
A snapshot in registration order. Looping over it allocates nothing, and the loop may register or remove actors. | IM.Registry.cs |
static IReadOnlyList<Actor> ActorsById |
Every actor ordered by ID, the same order on every machine and after every load. Do not keep it across frames. | IM.Registry.cs |
static int ActorCount |
How many actors are registered. | IM.Registry.cs |
There is no public lookup of an actor by name. Look up by ID in ActorDictionary, or walk Actors.
Example, not compiled. It reads two of the members above.
if (!IM.Exists) return;if (IM.ActorDictionary.TryGetValue(actorId, out var found)) Debug.Log(found.Name);var clan = IM.GetClan(clanNameOrId); // null when there is no such clanAdding and removing
Section titled “Adding and removing”These write to the world. On a machine that is not the host they are refused with one warning.
| Member | What it does | File |
|---|---|---|
static bool AddActor(Actor actor) |
Registers an actor under its ID. false when another actor holds the ID, for a null actor and without a manager. |
IM.Registry.cs |
static void DestroyActor(Actor actor) |
Removes an actor from the manager. The GameObject stays. | IM.Registry.cs |
static bool AddClan(Clan clan), AddFamily(Family), AddRole(Role), AddCulture(Culture), AddPolicy(Policy) |
Adds the thing to the running game. false for null, a duplicate, a missing ID or without a manager. |
IM.Registry.cs |
Clan.Create, Family.Create and Role.Create call the matching Add for you.
Players
Section titled “Players”The local player is the actor this machine’s human plays.
| Member | What it does | File |
|---|---|---|
static Actor Player |
The local player, or null. |
IM.Players.cs |
static IReadOnlyList<Actor> Players |
Every actor a human plays. A new list on every call. | IM.Players.cs |
static int GetPlayers(List<Actor> into) |
The same, into your list, without allocating once it has grown. | IM.Players.cs |
static int PlayerCount |
How many actors a human plays. | IM.Players.cs |
static bool IsPlayer(Actor actor) |
True when a human plays the actor, here or on another machine. | IM.Players.cs |
static bool IsLocalPlayer(Actor actor) |
True when this machine’s human plays it. | IM.Players.cs |
static bool IsRemotePlayer(Actor actor) |
True when a human on another machine plays it. | IM.Players.cs |
static void SetPlayer(Actor actor) |
Makes the actor this machine’s player. null means nobody. |
IM.Players.cs |
static bool MovePlayer(Actor from, Actor to) |
The human who plays from plays to from now on. false when nobody plays from, and on a multiplayer client. |
IM.Players.cs |
static bool IsHost |
True in a single-player game and on the host. | IM.Players.cs |
static event Action<Actor, Actor> onPlayerIsChanged |
Old and new local player. | IM.Players.cs |
static event Action<Actor, bool> onPlayersChanged |
A human started (true) or stopped playing an actor. |
IM.Players.cs |
Triggers, requirements and scheme events
Section titled “Triggers, requirements and scheme events”| Member | What it does | File |
|---|---|---|
static void Trigger(Scheme scheme, string triggerName, bool value = true) |
Fires a scheme trigger. Wait For Trigger nodes listen to it. | IM.Schemes.cs |
static event Action<Scheme, string, bool> onTrigger |
Raised when a trigger fires. | IM.Events.cs |
static bool Meets(string setNameOrId, Actor actor, Actor other = null) |
True when every requirement of the set is met. Another overload takes accomplices. | IM.Schemes.cs |
static RequirementCheck Check(string setNameOrId, Actor actor, Actor other = null) |
The same check with its reasons. Another overload takes accomplices. | IM.Schemes.cs |
static event Action<Scheme> onSchemeStarted |
A scheme started. | IM.Schemes.cs |
static event Action<Scheme, SchemeResult> onSchemeEnded |
A scheme ended with Success, Failed or None. | IM.Schemes.cs |
static event Action<Scheme, SchemeChange> onSchemeChanged |
Something about a run changed. | IM.Schemes.cs |
Meets and Check take the actor as the set’s Conspirator and other as its Target. An unknown set is not met, with one warning per name. Schemes from code shows them in use.
Signals
Section titled “Signals”| Member | What it does | File |
|---|---|---|
static void Signal(Signal signal) |
Sends a signal to onSignalReceive and every listening SignalReceiver. |
IM.Signals.cs |
static void Signal(Signal signal, Actor conspirator, Actor target, Scheme scheme = null) |
The same, with the actors and scheme that sent it. | IM.Signals.cs |
static SignalContext CurrentSignal |
The signal being handled right now. IsSet is false outside one. |
IM.Signals.cs |
static event Action<Signal> onSignalReceive |
Raised on the main thread when a signal is sent. | IM.Events.cs |
The concept is on Signals.
Language and texts
Section titled “Language and texts”| Member | What it does | File |
|---|---|---|
static string CurrentLanguage |
The language texts are read in. null without a manager. |
IM.Registry.cs |
static void ChangeLanguage(string languageKey) |
Changes the language. An unknown language logs one error and changes nothing. | IM.Localisation.cs |
const string LanguagePrefKey |
The PlayerPrefs key "IntriguesLanguage" that remembers the choice, when the manager remembers it. |
IM.Localisation.cs |
static IReadOnlyList<TextLanguage> Languages |
Every language of the game. | IM.Localisation.cs |
static TextLanguage Language |
The settings of the current language. | IM.Localisation.cs |
static string GetText(string key) |
The text as written, with tokens not filled in. A missing key gives {null:key}, or what the database’s “When a text is missing” setting says. |
IM.Localisation.cs |
static bool TryGetText(string key, out string text) |
The same without a log line; false for a missing key. |
IM.Localisation.cs |
static void ReloadTexts() |
Reads the patch files again and rebuilds the text tables. | IM.Localisation.cs |
static void AddTexts(string xml) |
Adds a patch given as a string. | IM.Localisation.cs |
static event Action<string> onLanguageChanged |
Raised after the language changed. | IM.Events.cs |
static event Action onTextsChanged |
Raised after the game’s texts were read again. | IM.Events.cs |
See Texts, tokens and pacing for the tokens and Add a language for the steps.
A look is what an actor looks like, as data.
| Member | What it does | File |
|---|---|---|
static IReadOnlyList<ActorLook> Looks |
The looks of the database’s Looks library. | IM.Looks.cs |
static ActorLook GetLook(string nameOrId) |
One look by ID or name, or null. |
IM.Looks.cs |
static ActorLook LookOf(Sprite picture) |
The look that shows a picture. | IM.Looks.cs |
static ActorLook PickLook(Actor actor, bool avoidUsed = true) |
A look that fits the actor’s culture, gender, age and state. null when none fits. |
IM.Looks.cs |
static ActorLook PickLook(Culture culture, Actor.GenderType gender, int age, bool dead = false, bool avoidUsed = true) |
A look for an actor that does not exist yet. | IM.Looks.cs |
static int FindLooks(List<ActorLook> results, params string[] tags) |
Appends the looks that have all the tags. | IM.Looks.cs |
static bool RefreshLook(Actor actor, bool refit = false) |
Gives the actor a look that fits when they have none or have outgrown theirs. | IM.Looks.cs |
All of them are main thread only.
Scenes and where actors live
Section titled “Scenes and where actors live”| Member | What it does | File |
|---|---|---|
static ActorHome ActorHome |
Scene (the default: an actor leaves the world when its scene unloads) or World (a scene left through IntrigueScenes.Unload parks its actors). |
IM.ActorHome.cs |
static ParkStatus ParkScene(Scene scene) |
Parks the actors of a scene. Call it right before your own unload. | IM.ActorHome.cs |
static event Action<Actor> onActorAway, onActorBack |
An actor was parked, or is back in its scene. | IM.ActorHome.cs |
static ReturnPose ReturnPose, static EndWorldOnSceneLoad EndWorldOnSceneLoad |
Where a parked actor’s object stands when its scene comes back, and when the parked actors leave the world. | IM.ActorHome.cs |
IntrigueScenes.Unload(string sceneName), Unload(Scene scene, out ParkStatus status) |
The same unload by scene name, or telling what the park did. | IntrigueScenes.cs |
IntrigueWorld.End() |
Ends every parked actor now. Returns how many ended; 0 on a multiplayer client. | IntrigueScenes.cs |
IntrigueScenes.Unload(Scene scene) |
Parks the scene’s actors, then unloads the scene. Returns the unload’s AsyncOperation, or null. |
IntrigueScenes.cs |
Unity has no callback before a scene unloads, and a plain SceneManager.UnloadSceneAsync destroys the actors before Intrigues hears of it. Use IntrigueScenes.Unload, or call IM.ParkScene first. The steps are in Keep actors when their scene unloads.
Age groups, deaths and the dialogue window
Section titled “Age groups, deaths and the dialogue window”| Member | What it does | File |
|---|---|---|
static IReadOnlyList<AgeGroup> AgeGroups |
The world’s age groups in start-age order. | IM.AgeGroups.cs |
static AgeGroup AgeGroupOf(int age) |
The group an age is in, or null. |
IM.AgeGroups.cs |
static int OldestAge |
The oldest age an actor can reach. | IM.AgeGroups.cs |
static event Action<Actor> onActorDeath |
Raised when any actor dies, before its roles pass on. | IM.Events.cs |
static DialogueManager DialogueManager |
The Dialogue Manager prefab the manager names. null without a manager. |
IM.Registry.cs |
Loading and the clock
Section titled “Loading and the clock”| Member | What it does | File |
|---|---|---|
static void Load(SaveData saveData) |
Rebuilds the world from a save, or for a new game when you pass null. Host only. Normally the save system calls it. |
IM.Load.cs |
static bool ReplicaReady |
True when the world is complete and can be read. | IM.Replica.cs |
static event Action onReplicaReady |
Raised when ReplicaReady becomes true. UI code may wait for it in every mode. |
IM.Replica.cs |
static int WorldSeed, static void SetWorldSeed(int seed) |
The game’s seed. 0 is refused. |
IM.World.cs |
static event Action<int> onDayPassed |
Raised at the end of every game day with the number of the day that begins. | IM.Clock.cs |
Saving and loading have their own section, starting at Saving and loading.
Do it, step by step
Section titled “Do it, step by step”To give the local player a new character at the start of a game:
- Test
IM.Exists. - Find the actor in
IM.ActorDictionaryby its ID. - Call
IM.SetPlayer(actor). - Listen to
IM.onPlayerIsChangedif your UI needs the old and the new player.
To let a living player continue as someone else, such as the heir, call IM.MovePlayer(from, to) instead. It also moves a player who sits on another machine, which SetPlayer cannot do.
How it connects
Section titled “How it connects”- Actor from code lists what you can do with the actor you found.
- Events reference lists every event of
IM. - Variables from code covers
IM.Variablesand the other variable calls.
Mistakes and messages
Section titled “Mistakes and messages”| What you see | Why | What to do |
|---|---|---|
InvalidOperationException from IM.Instance |
No manager is running. | Test IM.Exists first. |
AddActor returns false |
The ID is held already, or there is no manager. | Check the ID. A held ID gives false without a log line; an actor that fails to register on its own logs an error that names both objects. |
One warning that IM.Load was refused |
It ran on a multiplayer client. | Only the host loads a game or starts a new one. |
SetWorldSeed(0) logs a warning |
0 means no seed. | Pass any other number. |
| A scene’s actors vanished on unload | A plain Unity unload is not seen in time. | Unload with IntrigueScenes.Unload. |