TraitManager

Overview

Loads ChairmanTrait assets from Resources/Traits\ and grants/withdraws their effects automatically when the player’s affinity tokens change. Each trait belongs to one personality track — Mobster, Schemer, or Subterfuge — and becomes obtained when floor(tokens) >= requiredTokens. Effects are applied to Unity Atoms on obtain and reverted when the threshold is no longer met. The manager also raises UI and analytics events on changes.

Serialized Atoms & Events

Global UI / notifications

  • FloatEvent affinityMobsterChanged, FloatEvent affinitySchemerChanged, FloatEvent affinitySubterfugeChanged — triggers for re‑evaluating traits when affinities change.
  • VoidEvent updateTraitUI — raised after any change so UI can refresh.
  • ChairmanTraitEvent traitObtained, ChairmanTraitEvent traitLost — fire once per trait toggle.

Mobster modifiers

  • FloatVariable labRefund, FloatVariable routeRefund — building & route refund multipliers.
  • FloatVariable loyaltyLossThreshold
  • FloatVariable eventMoneyProfitMult, FloatVariable eventMoneyCostMult
  • FloatVariable buildingCostMult
  • FloatVariable eventLoyaltyProfitMult, FloatVariable eventLoyaltyCostMult
  • FloatVariable mobsterSpecialOptionFree

Schemer modifiers

  • FloatVariable policeSeverityGainPerTickMult, FloatVariable policeSeverityLossPerTickMult
  • FloatVariable eventDemandCostModifier, FloatVariable eventDemandProfitModifier
  • FloatVariable eventPoliceSeverityCostModifier, FloatVariable eventPoliceSeverityProfitModifier
  • FloatVariable notorietyGainMult, FloatVariable captureGainMult
  • FloatVariable schemerSpecialOptionFree

Subterfuge modifiers

  • FloatVariable cartelSeverityGainPerTickMult, FloatVariable cartelSeverityLossPerTickMult
  • FloatVariable eventControlCostModifier, FloatVariable eventControlProfitModifier
  • FloatVariable eventCartelSeverityCostModifier, FloatVariable eventCartelSeverityProfitModifier
  • FloatVariable controlGainPerTickMult, FloatVariable controlLossPerTickMult
  • FloatVariable subterfugeSpecialOptionFree

Data Source

  • Resources/Traits\ is scanned on boot and each TextAsset is parsed as a ChairmanTrait JSON object.

Lifecycle

  • AwakeLoadTraits() clears and repopulates per‑track lists.
  • Start → register handlers to affinity*Changed events.
  • OnDestroy → (implicit) unregister calls would go here if needed.

Affinity Change Handling

For each track:

  1. Compute affinity = floor(_affinity).
  2. For every trait in that track:
    • If affinity >= requiredTokens and not yet obtained → ApplyEffect, set obtained=true, raise traitObtained.
    • Else if the opposite → RevertEffect, set obtained=false, raise traitLost.
  3. Raise updateTraitUI.

Effect Mapping

When applying (or reverting), each ChairmanTraitEffect.Parameter adjusts a specific Atom:

Parameter Affected Atom(s)
BUILDING_REFUND_MULT labRefund, routeRefund
EVENT_MONEY_PROFIT_MULT eventMoneyProfitMult
LOYALTY_LOSS_THRESHOLD loyaltyLossThreshold
EVENT_LOYALTY_COST_MULT eventLoyaltyCostMult
BUILDING_COST_MULT buildingCostMult
EVENT_MONEY_COST_MULT eventMoneyCostMult
EVENT_LOYALTY_PROFIT_MULT eventLoyaltyProfitMult
MOBSTER_SPECIAL_OPTION_FREE mobsterSpecialOptionFree
POLICE_SEVERITY_GAINPERTICK_MULT policeSeverityGainPerTickMult
EVENT_DEMAND_COST_MODIFIER eventDemandCostModifier
POLICE_SEVERITY_LOSSPERTICK_MULT policeSeverityLossPerTickMult
EVENT_POLICESEVERITY_COST_MULT eventPoliceSeverityCostModifier
NOTORIETY_GAIN_MULT notorietyGainMult
EVENT_POLICESEVERITY_PROFIT_MULT eventPoliceSeverityProfitModifier
CAPTURE_GAIN_MULT captureGainMult
EVENT_DEMAND_PROFIT_MODIFIER eventDemandProfitModifier
SCHEMER_SPECIAL_OPTION_FREE schemerSpecialOptionFree
CARTEL_SEVERITY_GAINPERTICK_MULT cartelSeverityGainPerTickMult
EVENT_CONTROL_COST_MULT eventControlCostModifier
CARTEL_SEVERITY_LOSSPERTICK_MULT cartelSeverityLossPerTickMult
EVENT_CARTELSEVERITY_COST_MULT eventCartelSeverityCostModifier
CONTROL_LOSSPERTICK_MULT controlLossPerTickMult
EVENT_CARTELSEVERITY_PROFIT_MULT eventCartelSeverityProfitModifier
CONTROL_GAIN_MULT controlGainPerTickMult
EVENT_CONTROL_PROFIT_MULT eventControlProfitModifier
SUBTERFUGE_SPECIAL_OPTION_FREE subterfugeSpecialOptionFree

Static API

public static List<ChairmanTrait> GetTraitList(GameManager.ChairmanPersonalities p);
// Returns the internal list for the given personality (Mobster, Schemer, Subterfuge).

Notes & Quirks

  • Traits are keyed by required token thresholds using floor(affinity); fractional progress doesn’t trigger early.
  • Known quirk: in the current code, reverting EVENT_LOYALTY_PROFIT_MULT subtracts from eventMoneyProfitMult instead of eventLoyaltyProfitMult. Verify before shipping progression tuning.