Module: Util::Warp
- Defined in:
- scripts/01450 Systems/00003 Map Engine/00600 Util_Warp.rb
Overview
Module that hold a warping function
Class Method Summary collapse
-
.find_event_from(map_id, name_or_id) ⇒ Array<Integer>
Find the event coordinate in another map.
-
.setup_transition(type)
Define the transition for the warping process.
-
.to(map_id, name_or_id, transition_type = 0, offset_x: 0, offset_y: 1, direction: 0)
Warp to an event of another map (below by default).
-
.warp(map_id, x_pos, y_pos, direction)
Warp to the specified coordinate.
Class Method Details
.find_event_from(map_id, name_or_id) ⇒ Array<Integer>
Find the event coordinate in another map
47 48 49 50 51 52 53 54 55 56 |
# File 'scripts/01450 Systems/00003 Map Engine/00600 Util_Warp.rb', line 47 def find_event_from(map_id, name_or_id) $game_map.setup(map_id) if $game_map.map_id != map_id if name_or_id.is_a?(Integer) event = $game_map.events[name_or_id] else event = $game_map.events_list.find { |event| event.event.name == name_or_id } end return 0, 0 unless event return event.x, event.y end |
.setup_transition(type)
Define the transition for the warping process
22 23 24 25 26 27 28 |
# File 'scripts/01450 Systems/00003 Map Engine/00600 Util_Warp.rb', line 22 def setup_transition(type) if type < 0 $game_switches[::Yuki::Sw::WRP_Transition] = true else $game_variables[::Yuki::Var::MapTransitionID] = type end end |
.to(map_id, name_or_id, transition_type = 0, offset_x: 0, offset_y: 1, direction: 0)
Warp to an event of another map (below by default)
14 15 16 17 18 |
# File 'scripts/01450 Systems/00003 Map Engine/00600 Util_Warp.rb', line 14 def to(map_id, name_or_id, transition_type = 0, offset_x: 0, offset_y: 1, direction: 0) x, y = find_event_from(map_id, name_or_id) setup_transition(transition_type) unless transition_type == 0 warp(map_id, x + offset_x, y + offset_y, direction) end |
.warp(map_id, x_pos, y_pos, direction)
Warp to the specified coordinate
35 36 37 38 39 40 41 |
# File 'scripts/01450 Systems/00003 Map Engine/00600 Util_Warp.rb', line 35 def warp(map_id, x_pos, y_pos, direction) $game_temp.player_new_x = x_pos $game_temp.player_new_y = y_pos $game_temp.player_new_direction = direction $game_temp.player_new_map_id = map_id $game_temp.player_transferring = true end |