mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +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)
|
||||
id = $game_map.map_id
|
||||
conns = MapFactoryHelper.getMapConnections
|
||||
if conns[id]
|
||||
conns[id].each do |conn|
|
||||
MapFactoryHelper.eachConnectionForMap(id) do |conn|
|
||||
mapidB = nil
|
||||
newx = 0
|
||||
newy = 0
|
||||
@@ -88,7 +86,6 @@ class PokemonMapFactory
|
||||
return [getMap(mapidB), newx, newy]
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -117,9 +114,7 @@ class PokemonMapFactory
|
||||
return if @fixup
|
||||
@fixup = true
|
||||
id = $game_map.map_id
|
||||
conns = MapFactoryHelper.getMapConnections
|
||||
if conns[id]
|
||||
conns[id].each do |conn|
|
||||
MapFactoryHelper.eachConnectionForMap(id) do |conn|
|
||||
if conn[0] == id
|
||||
mapA = getMap(conn[0])
|
||||
newdispx = ((conn[4] - conn[1]) * Game_Map::REAL_RES_X) + mapA.display_x
|
||||
@@ -140,7 +135,6 @@ class PokemonMapFactory
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@fixup = false
|
||||
end
|
||||
|
||||
@@ -234,12 +228,9 @@ class PokemonMapFactory
|
||||
|
||||
def areConnected?(mapID1, mapID2)
|
||||
return true if mapID1 == mapID2
|
||||
conns = MapFactoryHelper.getMapConnections
|
||||
if conns[mapID1]
|
||||
conns[mapID1].each do |conn|
|
||||
MapFactoryHelper.eachConnectionForMap(mapID1) do |conn|
|
||||
return true if conn[0] == mapID2 || conn[3] == mapID2
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -248,9 +239,7 @@ class PokemonMapFactory
|
||||
if thisMapID == otherMapID # Both events share the same map
|
||||
return [otherX - thisX, otherY - thisY]
|
||||
end
|
||||
conns = MapFactoryHelper.getMapConnections
|
||||
if conns[thisMapID]
|
||||
conns[thisMapID].each do |conn|
|
||||
MapFactoryHelper.eachConnectionForMap(thisMapID) do |conn|
|
||||
if conn[0] == otherMapID
|
||||
posX = conn[4] - conn[1] + otherX - thisX
|
||||
posY = conn[5] - conn[2] + otherY - thisY
|
||||
@@ -261,7 +250,6 @@ class PokemonMapFactory
|
||||
return [posX, posY]
|
||||
end
|
||||
end
|
||||
end
|
||||
return [0, 0]
|
||||
end
|
||||
|
||||
@@ -330,9 +318,7 @@ class PokemonMapFactory
|
||||
def getRealTilePos(mapID, x, y)
|
||||
id = mapID
|
||||
return [id, x, y] if getMapNoAdd(id).valid?(x, y)
|
||||
conns = MapFactoryHelper.getMapConnections
|
||||
if conns[id]
|
||||
conns[id].each do |conn|
|
||||
MapFactoryHelper.eachConnectionForMap(id) do |conn|
|
||||
if conn[0] == id
|
||||
newX = x + conn[4] - conn[1]
|
||||
newY = y + conn[5] - conn[2]
|
||||
@@ -349,7 +335,6 @@ class PokemonMapFactory
|
||||
return [conn[0], newX, newY]
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -455,6 +440,12 @@ module MapFactoryHelper
|
||||
return conns[id] ? true : false
|
||||
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
|
||||
def self.getMapDims(id)
|
||||
# Create cache if doesn't exist
|
||||
|
||||
Reference in New Issue
Block a user