asobi_world behaviour (asobi v0.35.4)

View Source

Summary

Callbacks

dump_zone_state/1

(optional)
-callback dump_zone_state(ZoneState :: map()) -> map().

generate_world/2

(optional)
-callback generate_world(Seed :: integer(), Config :: map()) ->
                            {ok, ZoneStates :: #{{integer(), integer()} => term()}}.

get_state/2

(optional)
-callback get_state(PlayerId :: binary(), GameState :: term()) -> StateForPlayer :: map().

handle_input/3

-callback handle_input(PlayerId :: binary(), Input :: map(), Entities :: map()) ->
                          {ok, Entities1 :: map()} | {error, Reason :: term()}.

init/1

-callback init(Config :: map()) -> {ok, GameState :: term()}.

init_zone_state/2

(optional)
-callback init_zone_state(Config :: map(), ZoneState :: map()) -> map().

join/2

-callback join(PlayerId :: binary(), GameState :: term()) ->
                  {ok, GameState1 :: term()} | {error, Reason :: term()}.

leave/2

-callback leave(PlayerId :: binary(), GameState :: term()) -> {ok, GameState1 :: term()}.

on_phase_ended/2

(optional)
-callback on_phase_ended(PhaseName :: binary(), GameState :: term()) -> {ok, GameState1 :: term()}.

on_phase_started/2

(optional)
-callback on_phase_started(PhaseName :: binary(), GameState :: term()) -> {ok, GameState1 :: term()}.

on_world_recovered/2

(optional)
-callback on_world_recovered(Snapshots :: map(), GameState :: term()) -> {ok, GameState1 :: term()}.

on_zone_loaded/2

(optional)
-callback on_zone_loaded(Coords :: {integer(), integer()}, GameState :: term()) ->
                            {ok, ZoneState :: map(), GameState1 :: term()}.

on_zone_unloaded/2

(optional)
-callback on_zone_unloaded(Coords :: {integer(), integer()}, GameState :: term()) ->
                              {ok, GameState1 :: term()}.

phases/1

(optional)
-callback phases(Config :: map()) -> [asobi_phase:phase_def()].

post_tick/2

-callback post_tick(Tick :: non_neg_integer(), GameState :: term()) ->
                       {ok, GameState1 :: term()} |
                       {vote, VoteConfig :: map(), GameState1 :: term()} |
                       {finished, Result :: map(), GameState1 :: term()}.

spawn_position/2

-callback spawn_position(PlayerId :: binary(), GameState :: term()) -> {ok, {X :: number(), Y :: number()}}.

spawn_templates/1

(optional)
-callback spawn_templates(Config :: map()) -> #{binary() => asobi_zone_spawner:spawn_template()}.

terrain_provider/1

(optional)
-callback terrain_provider(Config :: map()) -> {Module :: module(), ProviderArgs :: map()} | none.

zone_tick/2

-callback zone_tick(Entities :: map(), ZoneState :: term()) -> {Entities1 :: map(), ZoneState1 :: term()}.