asobi_zone_spawner (asobi v0.35.4)

View Source

Summary

Types

respawn_rule/0

-type respawn_rule() ::
          #{strategy := timer,
            delay := non_neg_integer(),
            max_respawns => non_neg_integer() | infinity,
            jitter => non_neg_integer()}.

spawn_template/0

-type spawn_template() ::
          #{template_id := binary(),
            type := binary(),
            base_state := map(),
            persistent => boolean(),
            respawn => respawn_rule() | undefined}.

state/0

-opaque state()

Functions

deserialise(Data)

-spec deserialise(map()) -> state().

entity_removed(EntityId, Now, State)

-spec entity_removed(binary(), pos_integer(), state()) -> state().

get_spawn_count(TemplateId, _)

-spec get_spawn_count(binary(), state()) -> non_neg_integer().

get_templates(_)

-spec get_templates(state()) -> #{binary() => spawn_template()}.

info(_)

-spec info(state()) -> map().

new()

-spec new() -> state().

new(Templates)

-spec new(#{binary() => spawn_template()}) -> state().

serialise(_)

-spec serialise(state()) -> map().

set_templates(Templates, State)

-spec set_templates(#{binary() => spawn_template()}, state()) -> state().

spawn_entity(TemplateId, Pos, State)

-spec spawn_entity(binary(), {number(), number()}, state()) ->
                      {ok, {binary(), map()}, state()} | {error, unknown_template}.

spawn_entity(TemplateId, Pos, Overrides, State)

-spec spawn_entity(binary(), {number(), number()}, map(), state()) ->
                      {ok, {binary(), map()}, state()} | {error, unknown_template}.

spawn_entity(TemplateId, EntityId, Pos, Overrides, State)

-spec spawn_entity(binary(), binary(), {number(), number()}, map(), state()) ->
                      {ok, {binary(), map()}, state()} | {error, unknown_template}.

tick(Now, State)

-spec tick(pos_integer(), state()) -> {[{binary(), map(), {number(), number()}}], state()}.