Class: Pathfinding::Target::Coords

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) ⇒ Coords

Returns a new instance of Coords.



30
31
32
33
34
35
36
37
38
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 30

def initialize(*args)
  coords = args[0]
  @x = coords[0] + Yuki::MapLinker.get_OffsetX
  @y = coords[1] + Yuki::MapLinker.get_OffsetY
  @z = coords[2]
  @radius = args[1]
  @original_x = coords[0]
  @original_y = coords[1] # Prevent bug from MapLinker Enable/Disable
end

Class Method Details

.load(data)

Create new target from the given data

Parameters:

  • data (Array)

    saved data



65
66
67
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 65

def self.load(data)
  return Coords.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)


53
54
55
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 53

def check_move(x, y)
  false
end

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

Test if the target is reached at the fiveng 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)


45
46
47
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 45

def reached?(x, y, z)
  return ((@x - x).abs + (@y - y).abs) <= @radius
end

#saveArray<Object>

Gather the savable data

Returns:



59
60
61
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 59

def save
  return [:Coords, [@original_x, @original_y, @z], @radius]
end