EventPanelUI

Overview

Full-screen panel to present and resolve a gameplay event for a specific Region. It loads variant images, localizes text, validates each option, supports prediction previews, applies the selected effects (with multipliers/modifiers), and optionally chains into a follow-up event. Plays appear/select/confirm SFX and closes back to the Region canvas when done. fileciteturn24file2

Serialized (Atoms & UI)

  • Labels/Images: eventTitle, eventDesc, eventSeverityText, regionName, eventImg, backgroundImg
  • Options: EventOptionUI optionA, optionB, optionC
  • Atoms (subset): money, loyalty, maxLabProduction, affinities (affinityMobster/Schemer/Subterfuge), personalities (commented out), per-parameter event multipliers/modifiers (event*CostMult, event*ProfitMult, demand modifiers), special-option flags (mobster/schemer/subterfugeSpecialOptionFree), currentRegion, navigationRoute, openRegionCanvas, discardEvent, updateUI, eventPanelClosed, showTutorialEvent, chainEventPooled fileciteturn24file2
  • Audio: SFXSingle appearSFX, selectSFX, confirmSFX
  • Helpers: PassiveEffectLibrary effectLibrary, EventPredictionUI predictionUI (fetched via GetComponent) fileciteturn24file2

Flow

  • Start(): register ClosePanel to discardEvent, disable self, cache predictionUI, and hook I2 OnLocalizeEvent. fileciteturn24file2
  • DisplayEvent(ChairmanEvent e):
    • Show panel, clear selection & predictions, set displayedEvent and its region, and update navigationRoute to sec/game/sub/gameplay/q/event.
    • Set currentRegion.Value without firing its Changed event (temporary unsubscribe). fileciteturn24file2
    • Fill title/desc/region/severity (Low/Mid/High by minSeverity) and call Localize() to swap to translated strings & keys.
    • Load random variant sprites from Resources folders:
      Event Backgrounds\{path}_Variants and Event Foregrounds\{path}_Variants. fileciteturn24file2
    • For each response (A/B/C): option.UpdateUI(response, ValidateButton(response, region)); then updateUI.Raise() and appearSFX.Play(). fileciteturn24file2
  • Localize(): swaps title/desc to displayedEvent.GetLocalizedTitle/Desc(), severity to SEVERITY_LOW/MID/HIGH, and region name to region.GetLocalizedName(). Also pushes localized response lines to options (with “selected” state). fileciteturn24file2

Validation

ValidateButton(EventResponse r, Region region) denies if any of these would go out of bounds:

  • Loyalty < 0
  • Demand would leave [0.5, 5.0]
  • Affinities < 0 and the matching *SpecialOptionFree flag is 0
    (Production/Control checks exist but are currently commented out.) fileciteturn24file2

Selection & Confirmation

  • First tap on a response → selects it, sets navigationRoute = "sec/game/sub/gameplay", calls predictionUI.UpdatePredictionsUI(...), and plays selectSFX.
  • Second tap on the same response → applies effects in order, honoring event multipliers/modifiers and clamping:
    • Money/Loyalty/Control/Severities/Demand/Affinities, plus PRODUCTION, DESTROY_ROUTE, DESTROY_LAB, and PASSIVE_EFFECT (via PassiveEffect + library).
    • Note: for Money, both signs currently use eventMoneyProfitMult (likely intentional or a TODO).
    • Demand has an extra guard so decreases can’t jump above the lower bound when a positive modifier applies. fileciteturn24file2
  • Chained events: if displayedEvent.IsChained(), resolve the next link with the chosen index, assign the same target region, and raise chainEventPooled. fileciteturn24file2
  • Finally: play confirmSFX, clear predictions, eventPanelClosed.Raise(), and ClosePanel(). fileciteturn24file2

Close & Cleanup

ClosePanel()openRegionCanvas.Raise(true) and hide self. OnDestroy() unregisters discardEvent and I2 localization hook. fileciteturn24file2