40 lines
965 B
Elixir
40 lines
965 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)}")
|
|
#send(from, {:send_packet, %{
|
|
# packet_type: :synchronize_player_position,
|
|
# x: 0.0, y: 0.0, z: 0.0, yaw: 0.0, pitch: 0.0, flags: 0x00,
|
|
# teleport_id: 0
|
|
#}})
|
|
: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
|