asobi_zone (asobi v0.72.6)
View SourceOne spatial partition of an asobi_world_server. A gen_server that owns
the entities in its cell of the grid, ticks their simulation, applies
player input, manages interest (subscribers), and answers spatial queries
via asobi_spatial. Zones are created and reaped lazily as players move.
Summary
Functions
Drain everything this caller has already cast to the zone, reporting whether the zone is still alive rather than exiting the caller if it is not.
Functions
-spec get_subscriber_count(pid()) -> non_neg_integer().
-spec handle_call(term(), gen_server:from(), map()) -> {reply, term(), map()}.
-spec reap(pid()) -> ok.
-spec start_link(map()) -> gen_server:start_ret().
-spec sync(pid()) -> ok | zone_gone.
Drain everything this caller has already cast to the zone, reporting whether the zone is still alive rather than exiting the caller if it is not.
Callers that cast to a zone and then need the cast to have landed (the join
and crossing paths in asobi_world_server) must not use a raw
get_subscriber_count/1 for that: a zone reaped between the caller resolving
its pid and the drain exits the caller with {normal, {gen_server, call, _}},
taking the whole world down over one player's placement
(widgrensit/asobi#283). ok means every earlier cast from this process was
processed; zone_gone means the zone died and those casts were dropped.
-spec tick(pid(), non_neg_integer()) -> ok.