PresenceParticleSpawner

File name may appear as PresenceParticleSystem.cs but the class is PresenceParticleSpawner.

Overview

UI particle system for presence/feedback effects. It has two channels:

  1. Money particles — pooled images that drift upward and fade.
  2. Severity/Control one-shots — instantiated images for Police/Cartel increase/decrease, Control gains, and personality-driven effects (tokens/loyalty/notoriety/capture).

While any severity particle is active, money particles are temporarily blocked, ensuring important feedback remains readable.

Atoms & Settings

  • BoolVariable paused
  • IntVariable selectedPersonality
  • FloatVariable notorietyProgress
  • Spawn area / interval, max pooled money particles.
  • Movement: starting vertical velocity, vertical acceleration, horizontal Perlin noise (horizontalNoise, noiseTimeScale).
  • Lifetime: deathDelay (hold) + deathTime (fade).
  • Severity multipliers to scale lifetime & movement (applied only to severity one-shots).
  • useUnscaledTime for frame-rate independent timing (UI-safe).
  • forceKillGrace to hard-kill stragglers.

Prefabs

  • moneyPrefab, policeIncreasePrefab, cartelIncreasePrefab, policeDecreasePrefab, cartelDecreasePrefab, loyaltyPrefab, notorietyPrefab, capturePrefab, tokensPrefab.

Money Flow (pooled)

  • Pool initialized on Awake() with maxParticles.
  • OnEnable() immediately schedules the spawn loop.
  • Spawn() schedules itself again after a random delay in [spawnIntervalRange.x, spawnIntervalRange.y] (only counts while not paused and not money-blocked).
  • Each pooled particle:
    • Drifts up with acceleration and horizontal noise.
    • Fades after deathDelay until deathTime is reached.
    • Returns to pool (and can be force-killed after a safety timeout).

Severity & Control (one-shot)

  • OnPoliceSeverityChange(region, isPolice, hasIncreased): spawns the matching icon near the region and runs the one-shot routine (scaled by severity multipliers).
  • OnControlChange(): picks a prefab by current personality:
    • MobstertokensPrefab
    • SchemernotorietyPrefab (or capturePrefab when notorietyProgress >= 1)
    • SubterfugeloyaltyPrefab
  • SpawnRewardBubbleOneShot(RewardBubble bubble): clones the bubble’s icon sprite as a one-shot particle for consistent visuals.

Money Gating

  • _activeSeverityCount > 0 or a brief cooldown after the last severity effect prevents money spawns.
  • When the last severity particle ends, money is unblocked after a small randomized delay.

Spawn Points

  • Random valid Region (Presence or full Control) → its Node.visualAnchor offset by a random vector within spawnArea.

Disable/Reset

  • On disable: stops all coroutines, hides pooled items, destroys one-shots, and clears internal counters/sets.

Notes

  • Uses unscaled time for consistent UI behavior across pause states.
  • Designed to be lightweight: pooling for money, instancing only for salient effects.