Module: Pathfinding

Defined in:
docs/4_Systems_003_Map_Engine.rb

Overview

You can customize the cost of each tag in TAGS_WEIGHT.

Defined Under Namespace

Modules: TagsWeight, Target Classes: Cursor, Request

Constant Summary collapse

OPERATION_PER_FRAME =

Amount of node to calculate in one frame (OPTIMISATION)

150
OPERATION_PER_REQUEST =

Amount of node by requests in one frame (OPTIMISATION)

50
COST_RELOAD =

Cost of the reload

15
COST_WATCH =

Cost of the watch

9
COST_WAIT =

Cost of the wait

1
OBSTACLE_DETECTION_RANGE =

Obstacle detection range

9
TRY_COUNT =

Amount of try count

5
TRY_DELAY =

Number of frame before two path search when the first one fail

60
PATH_DIRS =

Directions to check

[1, 2, 3, 4]
WAITING_ROUTE =

Move route when waiting for a new path

RPG::MoveRoute.new
TAGS_WEIGHT =

Weight of the tags, the higher is the cost, the more the path will avoid it

{GameData::SystemTags::Road => 2, GameData::SystemTags::TSand => 4, GameData::SystemTags::SwampBorder => 20, GameData::SystemTags::DeepSwamp => 30, GameData::SystemTags::MachBike => 1000, GameData::SystemTags::TGrass => 20}
DEFAULT_SAVE =

Default save state

[]
PRESET_COMMANDS =

Method giving a preset command (the 5 first move commands)

Array.new(5) { |i| RPG::MoveCommand.new(i) }.method(:[])

Class Method Summary collapse

Class Method Details

.add_request(character, target, tries, tags) ⇒ Boolean

Add the request to the system list and start looking for path

Parameters:

  • character (Game_Character) —

    the character looking for a path

  • target (Game_Character, Array<Integer>) —

    character or coords to reach

  • tries (Integer) —

    the number of tries before giving up the path research. :infinity for infinite try count.

  • tags (Symbol) —

    the name of the Pathfinding::TagsWeight constant to use to calcultate the node weight

Returns:

  • (Boolean) —

    if the request is successfully submitted



3626
3627
# File 'docs/4_Systems_003_Map_Engine.rb', line 3626

def self.add_request(character, target, tries, tags)
end

.clear

CLear all the requests



3634
3635
# File 'docs/4_Systems_003_Map_Engine.rb', line 3634

def self.clear
end

.debug=(value)

Enable or disable the debug mode

Parameters:

  • value (Boolean) —

    if debug must be enabled



3653
3654
# File 'docs/4_Systems_003_Map_Engine.rb', line 3653

def self.debug=(value)
end

.debug_add(from, cursor, path)

Add a path to display

Parameters:

  • from (Game_Character) —

    the character who follow the path

  • cursor (Cursor) —

    the cursor used to calculate the path

  • path (Array<Integer>) —

    the list of moveroute command



3666
3667
# File 'docs/4_Systems_003_Map_Engine.rb', line 3666

def self.debug_add(from, cursor, path)
end

.debug_clear(from = nil)

Clear the pathfinding debug data

Parameters:

  • from (Integer, nil) (defaults to: nil) —

    the id of the caracter to clear, if nil, clear all



3657
3658
# File 'docs/4_Systems_003_Map_Engine.rb', line 3657

def self.debug_clear(from = nil)
end

.debug_update

Update the pathfinding display debug



3660
3661
# File 'docs/4_Systems_003_Map_Engine.rb', line 3660

def self.debug_update
end

.load

Load the data from the Game State



3648
3649
# File 'docs/4_Systems_003_Map_Engine.rb', line 3648

def self.load
end

.operation_per_frame=(value)

Set the number of operation per frame. By default it's 150, be careful with the performance issues.

Parameters:

  • value (Integer) —

    the new amount of operation allowed per frame



3638
3639
# File 'docs/4_Systems_003_Map_Engine.rb', line 3638

def self.operation_per_frame=(value)
end

.remove_request(character) ⇒ Boolean

Remove the request from the system list and return true if the request has been popped out.

Parameters:

Returns:

  • (Boolean) —

    if the request has been popped out



3631
3632
# File 'docs/4_Systems_003_Map_Engine.rb', line 3631

def self.remove_request(character)
end

.save ⇒ Array<Pathfinding::Request>

Create an savable array of the current requests

Returns:



3645
3646
# File 'docs/4_Systems_003_Map_Engine.rb', line 3645

def self.save
end

.update

Update the pathfinding system



3641
3642
# File 'docs/4_Systems_003_Map_Engine.rb', line 3641

def self.update
end