EventManager
Overview
Central orchestrator for event selection and dispatch. Loads standard, chained, and dated events from Resources/ folders, keeps a static registry of Regions, and opens the UI when an event is picked. Supports peeking the next event, forcing an event for a region, and certainty-weighted selection.
Serialized References
- UI:
EventPanelUI panelUI - Atoms:
FloatVariable personalityMobster,FloatVariable personalityScheming,FloatVariable personalitySubterfuge,FloatVariable eventCertainty - Events:
VoidEvent longTickEvent,VoidEvent rerollEvent,RegionEvent forceEvent,ChairmanEventEvent openEventCanvas,ChainedEventInfoEvent chainEventPooled
Static Data
static List<ChairmanEvent> eventsstatic List<Region> regionsstatic string eventDataPath = "Events\", chainEventDataPath = "ChainedEvents\", datedEventDataPath = "DatedEvents\"
Runtime State
bool storeNextEvent— whentrue, the next selected event is stored instead of shownChairmanEvent storedEvent— last stored event (for preview UI)ChairmanEvent lastEvent— to avoid immediate repeats- Pools:
List<ChainedEventInfo>,List<DatedChairmanEvent>,List<ChairmanChainEvent>
Lifecycle
- Awake():
LoadEvents(), clearstoredEvent, register handlers forlongTickEvent/rerollEvent→ProcessEvents,forceEvent→ForceEvent,chainEventPooled→PoolChainedEvent. - OnDestroy(): unregister.
- Tick():
ProcessDatedEvents()each frame/tick.
Public API
List<Region> GetRegions(),List<ChairmanEvent> GetEvents()static int GetEventIndex(ChairmanEvent e)— index withinevents(for localization keys)ChairmanEvent FindChainEvent(string title)void ProcessEvents()— main selection pipelinevoid ForceEvent(Region targetRegion)— pick and open an event for the given regionvoid RegisterRegion(Region r),void UnregisterRegion(Region r)(static)
Selection Pipeline (ProcessEvents)
- Stored event path: if
storedEvent!=null, raiseopenEventCanvaswith it and clearstoredunlessstoreNextEventremainstrue. - Chained events:
ProcessChainedEvents()may fire one immediately (probabilistic pool). - Pick a region:
SelectRandomValidRegion()among those withPresenceandControl < 1. - Filter candidates:
- Remove
lastEvent(no instant repeats). - By infrastructure: drop events whose
RequiresLab/Routeis unmet (RegionLabandRouteCount>0). - By nature: weighted by region severities × personality atoms.
- By severity: threshold against the target’s Police/Cartel/average severity.
- By effect validity:
panelUI.ValidateButtonmust pass for response 0 and 1.
- Remove
- Select one:
SelectWeightedRandomEvent()using eventCertainty:- If
eventCertainty >= 1: choose events at the maximum minSeverity per nature. - Else: compute weights
w = exp(-alpha * (severity - minSeverity))withalpha = c/(1-c), sample by cumulative weight.
- If
- Dispatch: set
TargetRegion, updatelastEvent, and either store it (if peeking) or raiseopenEventCanvas.
Chained & Dated
- ProcessChainedEvents(): rolls
poolChanceagainst pooled entries; looks up by title and raises immediately (honorsstoreNextEvent). Pool entry is removed on fire. - ProcessDatedEvents(): when
triggerDate == GameDateDisplay.CurrentDateand chance passes, finds the target region by name and raises the dated event.
Loading
- Reads JSON TextAssets from
Resources/Events,Resources/ChainedEvents, andResources/DatedEvents.ChairmanChainEventwithchainStart=truegoes into the maineventslist; others into a separate chained list.
Notes
- The personality filter method exists but is disabled by default in the pipeline.
BaseLocIDused byChairmanEventdepends on the order ofeventsat runtime—keep resource load order stable for localization.