Legal services
Legal services are the game’s menu of paid services that a player can queue: clearing a crime, or unfreezing a bank account. LegalServices lists them with their price, lets your mod queue one, and tells you when one is queued or done.
LegalServices the menu, the debts and the queue
Call Actions() to list the services and their prices, and Queue(name) with a service’s Name to queue one.
public static class LegalServices
{
public static bool IsAvailable { get; }
public static event Action<LegalActionArgs> Queued;
public static event Action<LegalActionArgs> Completed;
public static List<LegalActionInfo> Actions();
public static bool HasDebt(string invoiceName);
public static bool GetDebt(string invoiceName, out int oc, out float rm);
public static bool Queue(string name);
}
| Method | Returns | What it does |
|---|---|---|
Actions() | List<LegalActionInfo> | The game’s menu of services. |
HasDebt(invoiceName) | bool | true when there is a debt for that invoice. |
GetDebt(invoiceName, out oc, out rm) | bool | Reads that debt. |
Queue(name) | bool | Queues a service by its name. |
| Property | Type | What it means |
|---|---|---|
IsAvailable | bool | true when the game’s legal services exist. |
| Event | Gives you | When it fires |
|---|---|---|
Queued | LegalActionArgs | A service was queued. |
Completed | LegalActionArgs | A queued service was done. |
LegalActionInfo one legal service
LegalServices.Actions() gives you one of these for each service. CanTrigger says whether it can be queued now, and Queued says whether it already is.
public sealed class LegalActionInfo
{
public string Name { get; }
public string InvoiceName { get; }
public LegalActionKind Kind { get; }
public string Target { get; }
public int PriceOC { get; }
public float PriceRM { get; }
public int PaymentDays { get; }
public bool CanTrigger { get; }
public bool Queued { get; }
public int RemainingSeconds { get; }
}
| Property | Type | What it means |
|---|---|---|
Name | string | The service’s name, which Queue takes. |
InvoiceName | string | The name of the invoice the service creates. |
Kind | LegalActionKind | What the service does. |
Target | string | The NPC id or bank name it is for. "" when there is none. |
PriceOC | int | The price in OC right now. 0 for a free service. |
PriceRM | float | The price in RM. |
PaymentDays | int | How many days the player has to pay. |
CanTrigger | bool | true when the service can be queued right now. |
Queued | bool | true when it is already queued. |
RemainingSeconds | int | The seconds left on its timer. -1 when it is not queued. |
LegalActionArgs what you get when a service is queued or done
Queued and Completed pass you one of these, with the service’s Name, Kind and Target.
public sealed class LegalActionArgs
{
public string Name { get; }
public LegalActionKind Kind { get; }
public string Target { get; }
}
| Property | Type | What it means |
|---|---|---|
Name | string | The service’s name. |
Kind | LegalActionKind | What the service does. |
Target | string | The NPC id or bank name it is for. |
LegalActionKind what a legal service does
LegalActionInfo.Kind holds one of these, so you can tell a crime clearance from an account unfreeze.
public enum LegalActionKind
{
None = 0,
ClearCrime = 1,
UnfreezeAccount = 2
}
| Value | Meaning |
|---|---|
None | No particular kind. |
ClearCrime | Clears a crime. |
UnfreezeAccount | Unfreezes a bank account. |
Things to know
Actionslists the game’s fixed menu of services. Each entry has its price right now, whether it can be queued now, and its queue state. An entry the game can’t work out yet is left out, and the rest are still listed. It gives an empty list when the game’s legal services are not there. (an entry is left out when its crime or money singleton is missing.)Queuequeues one service by its name, the way the game’s own queue does. It returnstruewhen the service is now in the game’s queue. (the things it needs are the singletonsTimeOfDayAzure,Achievements,InvoiceControllerandMailController.)- The price is fixed when the service is queued. The game works it out then and makes the invoice from that value. A free service is queued with no invoice, as the game does.
Queuedfires when the game adds a service to its queue, whetherQueueor the game’s own script added it.Completedfires when a queued service runs, which means the game clears the crime or unfreezes the account.Completedis raised on the next frame, not inside the game’s timer, so a handler can callQueuewithout touching the loop that runs the service.HasDebtandGetDebtread the debt the game records when a legal fee invoice expires unpaid. The debt is looked up by the invoice’s name (InvoiceName).- The game’s own resend of the debt invoice, which doubles it, is not available to mods.
Limits
Queuereturnsfalseand changes nothing when a save is loading or being written, the name is empty or unknown, the service is already queued, the game says it can’t be queued now, or something the game needs is missing.- For a paid service,
Queuealso returnsfalsewhen the game’s invoice item is missing, because the game would then make no invoice and leave the service free. Queueonly changes the game on this computer. It does not sync to other players.- If the events can’t be set up,
QueuedandCompletedstop firing, but the rest keeps working. The feature group is turned off.Actions,HasDebt,GetDebtandQueuestill work. Completeddoes not fire while a save is loading. A service queued in the old session that finishes during a load is dropped on purpose, not raised after it.