Class: Pathfinding::Target::Character
- Defined in:
- scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb
Class Method Summary collapse
-
.load(data)
Create new target from the given data.
Instance Method Summary collapse
-
#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.
-
#initialize(*args) ⇒ Character
constructor
A new instance of Character.
-
#reached?(x, y, z) ⇒ Boolean
Test if the target is reached at the fiveng coords.
-
#save ⇒ Array<Object>
Gather the savable data.
Constructor Details
#initialize(*args) ⇒ Character
Returns a new instance of Character.
71 72 73 74 75 76 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 71 def initialize(*args) @character = args[0] @radius = args[1] @sx = @character.x @sy = @character.y end |
Class Method Details
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
91 92 93 94 95 96 97 98 99 100 101 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 91 def check_move(x, y) if ((c = @character).x - x).abs + (c.y - y).abs > 15 if (@sx - c.x).abs + (@sy - c.y).abs > 10 @sx = c.x @sy = c.y return true end return false end return @sx != (@sx = c.x) || @sy != (@sy = c.y) end |
#reached?(x, y, z) ⇒ Boolean
Test if the target is reached at the fiveng coords
83 84 85 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 83 def reached?(x, y, z) return ((@character.x - x).abs + (@character.y - y).abs) <= @radius end |
#save ⇒ Array<Object>
Gather the savable data
105 106 107 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 105 def save return [:Character, @character.id, @radius] end |