2021-04-10 17:14:41 +02:00
|
|
|
local PlayerMap = Object:extend()
|
2021-04-21 19:06:38 +02:00
|
|
|
local defTransitions = require "core.modules.transitions"
|
2021-04-10 17:14:41 +02:00
|
|
|
|
|
|
|
function PlayerMap:initMap()
|
|
|
|
self.previousMap = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
function PlayerMap:updateCurrentMap()
|
|
|
|
local currentMap = self.world.map:getMapAtPoint(self.x, self.y)
|
|
|
|
if (currentMap ~= nil) then
|
|
|
|
if (self.previousMap ~= currentMap.id) then
|
|
|
|
self.previousMap = currentMap.id
|
|
|
|
self.scene:updateCurrentMap(currentMap)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-21 19:06:38 +02:00
|
|
|
function PlayerMap:updateOutsideMap()
|
|
|
|
if ((self.x > self.world.map.w + 8) or (self.x < -8) or (self.y > self.world.map.h + 16) or (self.y < -8))
|
|
|
|
and (self.world.map.data.exitTo ~= nil) then
|
|
|
|
local arguments = self.world.map.data.exitTo
|
|
|
|
core.screen:startTransition(defTransitions.default, defTransitions.default,
|
|
|
|
function() self.world:teleport(arguments.area, arguments.x, arguments.y, arguments.charDir) end,
|
|
|
|
0, 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-10 17:14:41 +02:00
|
|
|
return PlayerMap
|