Skip to main content

Raindome

Overview

This component implements a global rain-protection dome around an entity, which dynamically shields nearby entities (typically players) from rain when active. It operates in two modes: client-side updates to reflect networked radius changes and server-side (master sim) logic to manage entity inclusion/exclusion, registration of active dome sizes, and radius-based spatial queries.

Dependencies & Tags

  • Components: Relies on rainimmunity component being added to affected entities.
  • Tags added on enable: "raindome" (on the dome entity itself), "inspectable" (for entity search).
  • Tags excluded in search: "INLIMBO".
  • Network Variables: raindome._activeradius (synced float, triggers _activeradiusdirty event).
  • Global Support Functions: GetRainDomesAtXZ, IsUnderRainDomeAtXZ use TheSim:FindEntities with "raindome" tag.

Properties

PropertyTypeDefault ValueDescription
radiusnumber16 (server only)The configured radius of the dome. Only settable on master sim.
enabledbooleanfalse (server only)Whether the dome is currently active. Only modified on master sim.
_activeradiusnet_float0The actual radius used by the dome (0 when disabled). Synced to clients.
_lastactiveradiusnumber0 (client only)Tracks previous active radius on client for cleanup during updates.

Main Functions

SetRadius(radius)

  • Description: Sets the configured radius of the dome (server only). Does not immediately update active radius or覆盖; requires Enable() to apply.
  • Parameters: radius (number) — New radius value.

Enable()

  • Description: Activates the dome: sets active radius to the configured radius, registers it globally, starts updating target list, and adds the "raindome" tag.
  • Parameters: None.

Disable()

  • Description: Deactivates the dome: sets active radius to 0, unregisters it globally, stops updating, and removes the "raindome" tag. Also removes rain immunity from previously affected entities.
  • Parameters: None.

SetActiveRadius_Internal(new, old)

  • Description: Core internal helper used by Enable/Disable. Handles global dome size registration/unregistration, adding/removing tags, starting/stopping updates, and managing the list of affected entities.
  • Parameters:
    new (number) — New active radius (0 to disable).
    old (number) — Previous active radius.

GetActiveRadius()

  • Description: Returns the current active radius (including 0 when disabled), matching _activeradius.
  • Parameters: None.

OnUpdate(dt)

  • Description: Periodically scans entities within configured radius and grants rain immunity to them (by calling rainimmunity:AddSource). Also updates the refresh delay based on target wakefulness.
  • Parameters: dt (number) — Delta time since last frame.

Events & Listeners

  • Listen: inst:ListenForEvent("_activeradiusdirty", OnActiveRadiusDirty) — Client-side; triggers global registration/unregistration of active dome size when radius syncs.
  • Push (implicit via network): _activeradiusdirty — Fired by network framework when _activeradius changes (not manually called here).
  • Push (global cleanup): _unreg_active_dome_size and _reg_active_dome_size — Internal helpers, not events, used by OnActiveRadiusDirty and OnRemoveEntity.