Remove dict of map event replacement regions
This commit is contained in:
parent
74ab47f1e8
commit
adb720668f
|
@ -69,8 +69,7 @@ class WorldMap:
|
||||||
var blockmap_original: PoolByteArray
|
var blockmap_original: PoolByteArray
|
||||||
var block_tile_ids: PoolByteArray
|
var block_tile_ids: PoolByteArray
|
||||||
var block_pathing: PoolIntArray
|
var block_pathing: PoolIntArray
|
||||||
var event_replacements: Dictionary # Dictionary[Array[EventReplacementRegion]]
|
var event_replacements: Array # Array[int flag, EventReplacementRegion]
|
||||||
var event_replacements_ordered: Array # Array[int flag, EventReplacementRegion]
|
|
||||||
|
|
||||||
class EventReplacementRegion:
|
class EventReplacementRegion:
|
||||||
var start_y: int
|
var start_y: int
|
||||||
|
@ -135,15 +134,13 @@ class WorldMap:
|
||||||
y_offset += block_width
|
y_offset += block_width
|
||||||
|
|
||||||
func apply_event_replacements(event_flags): # Any integer array is fine
|
func apply_event_replacements(event_flags): # Any integer array is fine
|
||||||
for event_flag in event_flags:
|
for flag_and_region in self.event_replacements:
|
||||||
if self.event_replacements.has(event_flag):
|
if flag_and_region[0] in event_flags:
|
||||||
for region in self.event_replacements[event_flag]:
|
self.apply_event_region_replacement(flag_and_region[1])
|
||||||
self.apply_event_region_replacement(region)
|
|
||||||
|
|
||||||
func init_event_replacements(_data: Dictionary, buffer: StreamPeerBuffer, worldmap_event_replacements: Array):
|
func init_event_replacements(_data: Dictionary, buffer: StreamPeerBuffer, worldmap_event_replacements: Array):
|
||||||
# Turn deserialized WorldMapEventReplacement structs into EventReplacementRegions
|
# Turn deserialized WorldMapEventReplacement structs into EventReplacementRegions
|
||||||
self.event_replacements = {}
|
self.event_replacements = []
|
||||||
self.event_replacements_ordered = []
|
|
||||||
var last_event_flag: int = -1
|
var last_event_flag: int = -1
|
||||||
var last_y: int = -1
|
var last_y: int = -1
|
||||||
var region := WorldMap.EventReplacementRegion.new()
|
var region := WorldMap.EventReplacementRegion.new()
|
||||||
|
@ -159,8 +156,7 @@ class WorldMap:
|
||||||
region.start_y = y
|
region.start_y = y
|
||||||
elif last_event_flag != event_flag or last_y != y-1:
|
elif last_event_flag != event_flag or last_y != y-1:
|
||||||
# Save last region and start a new one
|
# Save last region and start a new one
|
||||||
self.event_replacements.get_or_add(last_event_flag, []).append(region)
|
self.event_replacements.append([last_event_flag, region])
|
||||||
self.event_replacements_ordered.append([last_event_flag, region])
|
|
||||||
# Start a new region
|
# Start a new region
|
||||||
region = WorldMap.EventReplacementRegion.new()
|
region = WorldMap.EventReplacementRegion.new()
|
||||||
region.start_y = y
|
region.start_y = y
|
||||||
|
@ -169,8 +165,7 @@ class WorldMap:
|
||||||
last_y = y
|
last_y = y
|
||||||
region.rows.append([x, blocks])
|
region.rows.append([x, blocks])
|
||||||
# Save final region
|
# Save final region
|
||||||
self.event_replacements.get_or_add(last_event_flag, []).append(region)
|
self.event_replacements.append([last_event_flag, region])
|
||||||
self.event_replacements_ordered.append([last_event_flag, region])
|
|
||||||
|
|
||||||
|
|
||||||
var worldmaps = [WorldMap.new(), WorldMap.new(), WorldMap.new(), WorldMap.new(), WorldMap.new()]
|
var worldmaps = [WorldMap.new(), WorldMap.new(), WorldMap.new(), WorldMap.new(), WorldMap.new()]
|
||||||
|
|
|
@ -28,10 +28,7 @@ func _create_worldmap_texture(id: int) -> void:
|
||||||
func _create_worldmap_textures() -> void:
|
func _create_worldmap_textures() -> void:
|
||||||
for id in 5:
|
for id in 5:
|
||||||
self._create_worldmap_texture(id)
|
self._create_worldmap_texture(id)
|
||||||
# for flag_block in MapLoader.worldmaps[id].event_replacements.values():
|
for flag_and_region in MapLoader.worldmaps[id].event_replacements:
|
||||||
# for region in flag_block:
|
|
||||||
# self.map_regional_replacement_lists[id].append(region)
|
|
||||||
for flag_and_region in MapLoader.worldmaps[id].event_replacements_ordered:
|
|
||||||
self.map_regional_replacement_lists[id].append(flag_and_region[1])
|
self.map_regional_replacement_lists[id].append(flag_and_region[1])
|
||||||
|
|
||||||
func _set_map(id: int) -> void:
|
func _set_map(id: int) -> void:
|
||||||
|
|
Loading…
Reference in New Issue