amethyst/apps/example_game/lib/example/game.ex
Kodi Craft f79e0728e6
All checks were successful
Build & Test / nix-build (pull_request) Successful in 2m43s
Build & Test / nix-build (push) Successful in 2m46s
Implement callback for accept_teleport
2024-09-17 19:50:21 +02:00

35 lines
784 B
Elixir

defmodule Example.Game do
require Logger
@behaviour Amethyst.API.Game
@impl true
def instantiate(supervisor) do
Logger.info("The supervisor for this game is at #{inspect(supervisor)}")
{:ok, %{}}
end
@impl true
def login(from, cfg, refs) do
Logger.info("Player logged in from #{inspect(from)}: #{inspect(cfg)}")
Logger.info("The refs for this game are #{inspect(refs)}")
:accept
end
@impl true
def player_position(from, {x, y, z}, _refs) do
Logger.info("Player at #{inspect(from)} moved to #{x}, #{y}, #{z}")
:ok
end
@impl true
def accept_teleport(from, id, _state_refs) do
Logger.info("Player at #{inspect(from)} accepted teleport #{inspect(id)}")
:ok
end
@impl true
def joinable?(_refs) do
true
end
end