class Game_Map
alias init_20140728 initialize
def initialize
init_20140728
@moved_events = {}
@removed_events = {}
end
# default_proc 不能存档简直忧伤……
def get_moved_events(map_id)
@moved_events[map_id] ||= {}
end
def get_removed_events(map_id)
@removed_events[map_id] ||= {}
end
def setup_events
@events = {}
@map.events.each do |i, event|
unless get_removed_events(@map_id)[i]
@events[i] = Game_Event.new(@map_id, event)
end
end
get_moved_events(@map_id).each do |i, (x, y, direction, event)|
@events[i] = event = Game_Event.new(@map_id, event)
event.moveto(x, y)
event.set_direction(direction)
end
@common_events = parallel_common_events.collect do |common_event|
Game_CommonEvent.new(common_event.id)
end
refresh_tile_events
end
end
class Game_Event
def moveto_new_map(map_id, x, y, direction = nil)
if map_id == @map_id
moveto(x, y)
set_direction(direction) if direction
return
end
$game_map.get_moved_events(@map_id).delete(@id)
$game_map.get_removed_events(@map_id)[@id] = true
new_map = load_data(sprintf("Data/Map%03d.rvdata2", map_id))
size = new_map.width * new_map.height
begin
@event.id = @id = size + rand(0xffff) + @id # just a random number big enough
end while $game_map.get_moved_events(map_id).key?(@id)
$game_map.get_moved_events(map_id)[@id] =
[x, y, (direction || @direction), @event]
$game_map.get_removed_events(map_id).delete(@id)
end
end