Skip to content

Commit

Permalink
feat: set area on movement
Browse files Browse the repository at this point in the history
  • Loading branch information
pikdum committed Sep 12, 2024
1 parent 4625afd commit 7a41d50
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/game/movement.ex
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ defmodule ThistleTea.Game.Movement do

%{x: x0, y: y0, z: z0} = state.character.movement
%{x: x1, y: y1, z: z1} = character.movement
map = character.map

state =
if x0 != x1 and y0 != y1 and z0 != z1 do
Expand All @@ -77,11 +78,19 @@ defmodule ThistleTea.Game.Movement do
state
end

area =
case ThistleTea.Pathfinding.get_zone_and_area(map, {x1, y1, z1}) do
{_zone, area} -> area
nil -> character.area
end

character = Map.put(character, :area, area)

SpatialHash.update(
:players,
state.guid,
self(),
character.map,
map,
x1,
y1,
z1
Expand Down

0 comments on commit 7a41d50

Please sign in to comment.