Class SlotMachineHelper
Provides a modder-facing API for interacting with slot machines without exposing game types. Handles finding slot machines, managing NPC cash, and triggering spins.
public static class SlotMachineHelper
- Inheritance
-
SlotMachineHelper
- Inherited Members
Methods
AddNPCCash(NPC, int)
Adds cash to an NPC's inventory. Tries to reuse existing cash stacks, otherwise ensures there's a spare slot (expanding the slot count if needed) and inserts a single cash item.
public static void AddNPCCash(NPC npc, int amount)
Parameters
FindNearestSlotMachine(Vector3, float)
Finds the nearest slot machine to a given position.
public static SlotMachine FindNearestSlotMachine(Vector3 position, float maxDistance)
Parameters
positionVector3The position to search from.
maxDistancefloatMaximum distance to search.
Returns
- SlotMachine
The nearest slot machine, or null if none found.
GetNPCCash(NPC)
Gets the total cash value from an NPC's inventory (cash items).
public static float GetNPCCash(NPC npc)
Parameters
npcNPCThe NPC whose cash to count.
Returns
- float
Total cash amount in dollars.
RemoveNPCCash(NPC, int)
Removes a specified amount of cash from an NPC's inventory.
public static bool RemoveNPCCash(NPC npc, int amount)
Parameters
Returns
- bool
True if the full amount was successfully removed; false otherwise.
UseSlotMachine(NPC, Vector3, int, float)
Makes an NPC use a slot machine with the specified bet amount. This handles all cash transactions, animations, and outcome determination automatically.
public static bool UseSlotMachine(NPC npc, Vector3 machinePosition, int betAmount, float maxSearchDistance = 5)
Parameters
npcNPCThe NPC that will use the slot machine.
machinePositionVector3The world position of the slot machine.
betAmountintThe amount to bet in dollars.
maxSearchDistancefloatMaximum distance to search for a slot machine from the specified position.
Returns
- bool
True if the NPC successfully started using a slot machine; false otherwise.