Photon.Registry
Vehicle Registry. Keeps a live list of every Photon vehicle, and of the emergency vehicles among them, without scanning the entity list to find them.
Membership is derived from networked state, so it is maintained by
subscribing to Photon.SimpleNet.ValueChanged rather than by polling.
Neither HasPhoton nor VehicleIndex is knowable when an entity is
created — both arrive later, over the wire — so entity-creation hooks are
not a usable trigger and are deliberately not used here.
- SharedPhoton.Registry.Forget(ent)Source ☍
-
Drop an entity from every set.
Parameters
- entEntityEntity to drop.
- SharedPhoton.Registry.Rebuild()Source ☍
-
Rebuild both sets from the entity list.
The one place the registry scans, run on load and on the events that can invalidate it wholesale. Idempotent, because
GM:OnReloadedcan fire more than once for a single refresh.Also the recovery path if a membership flag ever desyncs from its list, which is why it clears flags across the entity list rather than only through the lists themselves: an entity flagged as a member of a set that does not contain it would otherwise be skipped by
Addforever. - SharedPhoton.Registry.Update(ent)Source ☍
-
Recheck which sets an entity belongs to and correct both.
Membership is recomputed from scratch every call rather than added to as values arrive. A resync sends an entity's fields in table order, so
VehicleIndexcan land beforeHasPhoton; deriving both answers together makes the result the same whichever order they turn up in.Safe to call repeatedly with no change, which it is: the client runs
Photon.SimpleNet.ValueChangedon every receipt, not only on a change.Parameters
- entEntityEntity to recheck.
Maintenance
- SharedPhoton.RegistrySource ☍
- SharedPhoton.RegistrySource ☍
- SharedPhoton.Registry.EMVsSource ☍
-
Every registered vehicle that is also an emergency vehicle. A strict subset of
Photon.Registry.Vehicles. - SharedPhoton.Registry.VehiclesSource ☍
-
Every vehicle
Photon:SetupCarhas run on.
Sets
A set of vehicles, held as a dense array plus its length.
The length is tracked rather than measured because # costs roughly as much
as a loop iteration, and these are read every frame. list stays dense from
1 to count, so #list and count agree; prefer count.