Class: Pathfinding::Target::Border

Inherits:
Object
  • Object
show all
Defined in:
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Border

Returns a new instance of Border.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 165

def initialize(*args)
  @border = args[0]
  @radius = args[1]
  case @border
  when :north
    @value = @radius + Yuki::MapLinker.get_OffsetY
  when :west
    @value = @radius + Yuki::MapLinker.get_OffsetX
  when :south
    @value = $game_map.height - @radius - 1 - Yuki::MapLinker.get_OffsetY
  when :east
    @value = $game_map.width - @radius - 1 - Yuki::MapLinker.get_OffsetX
  end
end

Class Method Details

.load(data)

Create new target from the given data

Parameters:

  • data (Array)

    saved data



215
216
217
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 215

def self.load(data)
  return Border.new(*data)
end

Instance Method Details

#check_move(x, y) ⇒ Boolean

Check if the character targetted has moved, considering the distance for optimisation and return true if the target is considered as moved

Parameters:

  • x (Integer)

    the x coordinate of the heading event

  • y (Integer)

    the y coordinate of the heading event

Returns:

  • (Boolean)


203
204
205
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 203

def check_move(x, y)
  return false
end

#reached?(x, y, z) ⇒ Boolean

Test if the target is reached at the given coords

Parameters:

  • x (Integer)

    the x coordinate to test

  • y (Integer)

    the y coordinate to test

  • z (Integer)

    the x coordinate to test

Returns:

  • (Boolean)


185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 185

def reached?(x, y, z)
  case @border
  when :north
    return y <= @value
  when :south
    return y >= @value
  when :east
    return x >= @value
  when :west
    return x <= @value
  end
  return true # Error
end

#saveArray<Object>

Gather the savable data

Returns:



209
210
211
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 209

def save
  return [:Border, @border, @radius]
end