Class: Pathfinding::Target::Character_Reject
- 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_Reject
constructor
A new instance of Character_Reject.
-
#reached?(x, y, z) ⇒ Boolean
Test if the target is reached at the given coords.
-
#save ⇒ Array<Object>
Gather the savable data.
Constructor Details
#initialize(*args) ⇒ Character_Reject
Returns a new instance of Character_Reject.
118 119 120 121 122 123 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 118 def initialize(*args) @character = args[0] @radius = args[1] @sx = @character.x @sy = @character.y end |
Class Method Details
.load(data)
Create new target from the given data
158 159 160 161 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 158 def self.load(data) data[0] = (data[0] == 0 ? $game_player : $game_map.events[data[0]]) return Character_Reject.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
138 139 140 141 142 143 144 145 146 147 148 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 138 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 given coords
130 131 132 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 130 def reached?(x, y, z) return ((@character.x - x).abs + (@character.y - y).abs) > @radius end |
#save ⇒ Array<Object>
Gather the savable data
152 153 154 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00710 Pathfinding_targets.rb', line 152 def save return [:Character_Reject, @character.id, @radius] end |