Skip to main content

modules/needs/needs.service

Needs service using the reactive observable system.

This service handles:

  • Server-side needs decay (hunger, thirst decrease over time)
  • Client-side vitals sampling from ped
  • Automatic bidirectional sync via observables
  • Persistence to database

Observable Architecture

  • Per-player serverOwned observables for needs (server has R/W, clients have RO)
  • Global clientOwned observable for vitals (client has R/W, server has RO per-player)

Observables are the right choice here because:

  • Hunger/thirst decay continuously on the server
  • Client needs real-time updates for HUD display
  • Values change frequently

Classes

ClassDescription
NeedsServiceNeeds service handling hunger, thirst, health, and armor.