Remove dict of map event replacement regions

This commit is contained in:
Luke Hubmayer-Werner 2024-07-05 20:05:55 +09:30
parent 74ab47f1e8
commit adb720668f
2 changed files with 8 additions and 16 deletions

View File

@ -69,8 +69,7 @@ class WorldMap:
var blockmap_original: PoolByteArray
var block_tile_ids: PoolByteArray
var block_pathing: PoolIntArray
var event_replacements: Dictionary # Dictionary[Array[EventReplacementRegion]]
var event_replacements_ordered: Array # Array[int flag, EventReplacementRegion]
var event_replacements: Array # Array[int flag, EventReplacementRegion]
class EventReplacementRegion:
var start_y: int
@ -135,15 +134,13 @@ class WorldMap:
y_offset += block_width
func apply_event_replacements(event_flags): # Any integer array is fine
for event_flag in event_flags:
if self.event_replacements.has(event_flag):
for region in self.event_replacements[event_flag]:
self.apply_event_region_replacement(region)
for flag_and_region in self.event_replacements:
if flag_and_region[0] in event_flags:
self.apply_event_region_replacement(flag_and_region[1])
func init_event_replacements(_data: Dictionary, buffer: StreamPeerBuffer, worldmap_event_replacements: Array):
# Turn deserialized WorldMapEventReplacement structs into EventReplacementRegions
self.event_replacements = {}
self.event_replacements_ordered = []
self.event_replacements = []
var last_event_flag: int = -1
var last_y: int = -1
var region := WorldMap.EventReplacementRegion.new()
@ -159,8 +156,7 @@ class WorldMap:
region.start_y = y
elif last_event_flag != event_flag or last_y != y-1:
# Save last region and start a new one
self.event_replacements.get_or_add(last_event_flag, []).append(region)
self.event_replacements_ordered.append([last_event_flag, region])
self.event_replacements.append([last_event_flag, region])
# Start a new region
region = WorldMap.EventReplacementRegion.new()
region.start_y = y
@ -169,8 +165,7 @@ class WorldMap:
last_y = y
region.rows.append([x, blocks])
# Save final region
self.event_replacements.get_or_add(last_event_flag, []).append(region)
self.event_replacements_ordered.append([last_event_flag, region])
self.event_replacements.append([last_event_flag, region])
var worldmaps = [WorldMap.new(), WorldMap.new(), WorldMap.new(), WorldMap.new(), WorldMap.new()]

View File

@ -28,10 +28,7 @@ func _create_worldmap_texture(id: int) -> void:
func _create_worldmap_textures() -> void:
for id in 5:
self._create_worldmap_texture(id)
# for flag_block in MapLoader.worldmaps[id].event_replacements.values():
# for region in flag_block:
# self.map_regional_replacement_lists[id].append(region)
for flag_and_region in MapLoader.worldmaps[id].event_replacements_ordered:
for flag_and_region in MapLoader.worldmaps[id].event_replacements:
self.map_regional_replacement_lists[id].append(flag_and_region[1])
func _set_map(id: int) -> void: