Class: Pathfinding::Request

Inherits:
Object show all
Defined in:
docs/4_Systems_003_Map_Engine.rb

Overview


Class that describe a pathfinding request A request has three caracteristics :

- Character : the character summonning the request
- Target : the target to reach
- Priority : The priority of the request between others

Algorithm steps 1st step : Initialization Creation of the variables (#initialize) 2nde step: Search Calculate NODES_PER_FRAME nodes per frame to optimize the process (#update_search) Nodes are calculated in #calculate_node with A* algorithm Once a path is found, or all possibilies are studied, the request start watching 3rd step : Watch The Request look for obstacles on the path and restart the search (reload) if there is one

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(character, target, tries, tags) ⇒ Request

Create the request

Parameters:

  • character (Game_Character) —

    the character to give a path

  • target (Target) —

    the target data

  • tries (Integer, Symbol) —

    the amount of tries allowed before fail, use :infinity to have unlimited tries

  • tags (Symbol) —

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



3696
3697
# File 'docs/4_Systems_003_Map_Engine.rb', line 3696

def initialize(character, target, tries, tags)
end

Instance Attribute Details

#character ⇒ Game_Character (readonly)

The character which needs a path

Returns:



3687
3688
3689
# File 'docs/4_Systems_003_Map_Engine.rb', line 3687

def character
  @character
end

#need_update ⇒ Boolean (readonly)

Indicate if the request needs update or not

Returns:

  • (Boolean)


3690
3691
3692
# File 'docs/4_Systems_003_Map_Engine.rb', line 3690

def need_update
  @need_update
end

Class Method Details

.load(data)

(Class method) Load the requests from the given argument

Parameters:

  • data (Array<Object>) —

    the data generated by the save method



3767
3768
# File 'docs/4_Systems_003_Map_Engine.rb', line 3767

def self.load(data)
end

Instance Method Details

#backtrace(tx, ty, tz) ⇒ Array<Integer>

Calculate the path from the given node

Parameters:

  • tx (Integer) —

    target x?

  • ty (Integer) —

    target y?

  • tz (Integer) —

    target z?

Returns:

  • (Array<Integer>) —

    the path



3759
3760
# File 'docs/4_Systems_003_Map_Engine.rb', line 3759

def backtrace(tx, ty, tz)
end

#calculate_node ⇒ Object

Calculate a node and return it if a path is found

Returns:



3752
3753
# File 'docs/4_Systems_003_Map_Engine.rb', line 3752

def calculate_node
end

#finished? ⇒ Boolean

Indicate if the request is ended

Returns:

  • (Boolean)


3716
3717
# File 'docs/4_Systems_003_Map_Engine.rb', line 3716

def finished?
end

#process_result(result)

Process the result of the node calculation

Parameters:

  • result (Array<Integer>, nil, Symbol) —

    the result value



3731
3732
# File 'docs/4_Systems_003_Map_Engine.rb', line 3731

def process_result(result)
end

#reload? ⇒ Boolean

Indicate if the request is to reload

Returns:

  • (Boolean)


3712
3713
# File 'docs/4_Systems_003_Map_Engine.rb', line 3712

def reload?
end

#save ⇒ Array<Object>

Gather the data ready to be saved

Returns:



3763
3764
# File 'docs/4_Systems_003_Map_Engine.rb', line 3763

def save
end

#searching? ⇒ Boolean

Indicate if the request is search for path

Returns:

  • (Boolean)


3700
3701
# File 'docs/4_Systems_003_Map_Engine.rb', line 3700

def searching?
end

#send_path(path)

Make the character following the found path

Parameters:

  • path (Array<Integer>) —

    The path, list of move direction



3744
3745
# File 'docs/4_Systems_003_Map_Engine.rb', line 3744

def send_path(path)
end

#stucked? ⇒ Boolean

Detect if the character is stucked

Returns:

  • (Boolean)


3748
3749
# File 'docs/4_Systems_003_Map_Engine.rb', line 3748

def stucked?
end

#update(operation_counter, is_first_update) ⇒ Integer

Update the requests and return the number of performed actions

Parameters:

  • operation_counter (Integer) —

    the amount of operation left

  • is_first_update (Boolean) —

    indicate if it's the first update of the frame

Returns:

  • (Integer)


3722
3723
# File 'docs/4_Systems_003_Map_Engine.rb', line 3722

def update(operation_counter, is_first_update)
end

#update_reload(is_first_update)

Reload the request



3740
3741
# File 'docs/4_Systems_003_Map_Engine.rb', line 3740

def update_reload(is_first_update)
end

#update_search(operation_counter) ⇒ Integer

Update the request search and return the new remaining node count

Parameters:

  • operation_counter (Integer) —

    the amount of node per frame remaining

Returns:

  • (Integer)


3727
3728
# File 'docs/4_Systems_003_Map_Engine.rb', line 3727

def update_search(operation_counter)
end

#update_wait(is_first_update)

Update the request when waiting before retrying to find path



3737
3738
# File 'docs/4_Systems_003_Map_Engine.rb', line 3737

def update_wait(is_first_update)
end

#update_watch(is_first_update)

Update the request when looking for obstacles



3734
3735
# File 'docs/4_Systems_003_Map_Engine.rb', line 3734

def update_watch(is_first_update)
end

#waiting? ⇒ Boolean

Indicate if the request is watching for obstacle

Returns:

  • (Boolean)


3704
3705
# File 'docs/4_Systems_003_Map_Engine.rb', line 3704

def waiting?
end

#watching? ⇒ Boolean

Inidicate if the request is waiting for new try

Returns:

  • (Boolean)


3708
3709
# File 'docs/4_Systems_003_Map_Engine.rb', line 3708

def watching?
end