2024-08-17 19:43:08 +02:00
|
|
|
defmodule Example.Game do
|
2024-08-18 13:44:09 +02:00
|
|
|
require Logger
|
2024-08-28 14:52:13 +02:00
|
|
|
@behaviour Amethyst.API.Game
|
2024-08-17 19:43:08 +02:00
|
|
|
|
|
|
|
@impl true
|
2024-08-25 13:17:25 +02:00
|
|
|
def instantiate(supervisor) do
|
|
|
|
Logger.info("The supervisor for this game is at #{inspect(supervisor)}")
|
|
|
|
{:ok, %{}}
|
2024-08-17 19:43:08 +02:00
|
|
|
end
|
2024-08-18 13:44:09 +02:00
|
|
|
|
|
|
|
@impl true
|
2024-08-25 21:03:09 +02:00
|
|
|
def login(from, cfg, refs) do
|
2024-08-19 00:00:03 +02:00
|
|
|
Logger.info("Player logged in from #{inspect(from)}: #{inspect(cfg)}")
|
2024-08-25 21:03:09 +02:00
|
|
|
Logger.info("The refs for this game are #{inspect(refs)}")
|
2024-09-19 15:11:59 +02:00
|
|
|
#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
|
|
|
|
#}})
|
2024-09-04 13:13:34 +02:00
|
|
|
:accept
|
2024-08-18 13:44:09 +02:00
|
|
|
end
|
2024-09-03 19:29:19 +02:00
|
|
|
|
|
|
|
@impl true
|
2024-09-09 18:45:52 +02:00
|
|
|
def player_position(from, {x, y, z}, _refs) do
|
2024-09-03 19:29:19 +02:00
|
|
|
Logger.info("Player at #{inspect(from)} moved to #{x}, #{y}, #{z}")
|
|
|
|
:ok
|
|
|
|
end
|
2024-09-04 11:24:04 +02:00
|
|
|
|
2024-09-17 19:50:21 +02:00
|
|
|
@impl true
|
|
|
|
def accept_teleport(from, id, _state_refs) do
|
|
|
|
Logger.info("Player at #{inspect(from)} accepted teleport #{inspect(id)}")
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
|
2024-09-04 11:24:04 +02:00
|
|
|
@impl true
|
2024-09-09 18:45:52 +02:00
|
|
|
def joinable?(_refs) do
|
2024-09-04 11:24:04 +02:00
|
|
|
true
|
|
|
|
end
|
2024-08-17 19:43:08 +02:00
|
|
|
end
|