mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
Made checks of map connections go through a single method, which can be used to modify connections on the fly
This commit is contained in:
@@ -67,9 +67,7 @@ class PokemonMapFactory
|
|||||||
|
|
||||||
def getNewMap(playerX, playerY)
|
def getNewMap(playerX, playerY)
|
||||||
id = $game_map.map_id
|
id = $game_map.map_id
|
||||||
conns = MapFactoryHelper.getMapConnections
|
MapFactoryHelper.eachConnectionForMap(id) do |conn|
|
||||||
if conns[id]
|
|
||||||
conns[id].each do |conn|
|
|
||||||
mapidB = nil
|
mapidB = nil
|
||||||
newx = 0
|
newx = 0
|
||||||
newy = 0
|
newy = 0
|
||||||
@@ -88,7 +86,6 @@ class PokemonMapFactory
|
|||||||
return [getMap(mapidB), newx, newy]
|
return [getMap(mapidB), newx, newy]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -117,9 +114,7 @@ class PokemonMapFactory
|
|||||||
return if @fixup
|
return if @fixup
|
||||||
@fixup = true
|
@fixup = true
|
||||||
id = $game_map.map_id
|
id = $game_map.map_id
|
||||||
conns = MapFactoryHelper.getMapConnections
|
MapFactoryHelper.eachConnectionForMap(id) do |conn|
|
||||||
if conns[id]
|
|
||||||
conns[id].each do |conn|
|
|
||||||
if conn[0] == id
|
if conn[0] == id
|
||||||
mapA = getMap(conn[0])
|
mapA = getMap(conn[0])
|
||||||
newdispx = ((conn[4] - conn[1]) * Game_Map::REAL_RES_X) + mapA.display_x
|
newdispx = ((conn[4] - conn[1]) * Game_Map::REAL_RES_X) + mapA.display_x
|
||||||
@@ -140,7 +135,6 @@ class PokemonMapFactory
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
@fixup = false
|
@fixup = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -234,12 +228,9 @@ class PokemonMapFactory
|
|||||||
|
|
||||||
def areConnected?(mapID1, mapID2)
|
def areConnected?(mapID1, mapID2)
|
||||||
return true if mapID1 == mapID2
|
return true if mapID1 == mapID2
|
||||||
conns = MapFactoryHelper.getMapConnections
|
MapFactoryHelper.eachConnectionForMap(mapID1) do |conn|
|
||||||
if conns[mapID1]
|
|
||||||
conns[mapID1].each do |conn|
|
|
||||||
return true if conn[0] == mapID2 || conn[3] == mapID2
|
return true if conn[0] == mapID2 || conn[3] == mapID2
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -248,9 +239,7 @@ class PokemonMapFactory
|
|||||||
if thisMapID == otherMapID # Both events share the same map
|
if thisMapID == otherMapID # Both events share the same map
|
||||||
return [otherX - thisX, otherY - thisY]
|
return [otherX - thisX, otherY - thisY]
|
||||||
end
|
end
|
||||||
conns = MapFactoryHelper.getMapConnections
|
MapFactoryHelper.eachConnectionForMap(thisMapID) do |conn|
|
||||||
if conns[thisMapID]
|
|
||||||
conns[thisMapID].each do |conn|
|
|
||||||
if conn[0] == otherMapID
|
if conn[0] == otherMapID
|
||||||
posX = conn[4] - conn[1] + otherX - thisX
|
posX = conn[4] - conn[1] + otherX - thisX
|
||||||
posY = conn[5] - conn[2] + otherY - thisY
|
posY = conn[5] - conn[2] + otherY - thisY
|
||||||
@@ -261,7 +250,6 @@ class PokemonMapFactory
|
|||||||
return [posX, posY]
|
return [posX, posY]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return [0, 0]
|
return [0, 0]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -330,9 +318,7 @@ class PokemonMapFactory
|
|||||||
def getRealTilePos(mapID, x, y)
|
def getRealTilePos(mapID, x, y)
|
||||||
id = mapID
|
id = mapID
|
||||||
return [id, x, y] if getMapNoAdd(id).valid?(x, y)
|
return [id, x, y] if getMapNoAdd(id).valid?(x, y)
|
||||||
conns = MapFactoryHelper.getMapConnections
|
MapFactoryHelper.eachConnectionForMap(id) do |conn|
|
||||||
if conns[id]
|
|
||||||
conns[id].each do |conn|
|
|
||||||
if conn[0] == id
|
if conn[0] == id
|
||||||
newX = x + conn[4] - conn[1]
|
newX = x + conn[4] - conn[1]
|
||||||
newY = y + conn[5] - conn[2]
|
newY = y + conn[5] - conn[2]
|
||||||
@@ -349,7 +335,6 @@ class PokemonMapFactory
|
|||||||
return [conn[0], newX, newY]
|
return [conn[0], newX, newY]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -455,6 +440,12 @@ module MapFactoryHelper
|
|||||||
return conns[id] ? true : false
|
return conns[id] ? true : false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.eachConnectionForMap(id)
|
||||||
|
conns = MapFactoryHelper.getMapConnections
|
||||||
|
return if !conns[id]
|
||||||
|
conns[id].each { |conn| yield conn }
|
||||||
|
end
|
||||||
|
|
||||||
# Gets the height and width of the map with id
|
# Gets the height and width of the map with id
|
||||||
def self.getMapDims(id)
|
def self.getMapDims(id)
|
||||||
# Create cache if doesn't exist
|
# Create cache if doesn't exist
|
||||||
|
|||||||
Reference in New Issue
Block a user