Class: Pathfinding::Request

Inherits:
Object show all
Defined in:
docs/01450_Systems_00003_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



2852
2853
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2852

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

Instance Attribute Details

#characterGame_Character (readonly)

The character which needs a path

Returns:



2843
2844
2845
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2843

def character
  @character
end

#need_updateBoolean (readonly)

Indicate if the request needs update or not

Returns:

  • (Boolean)


2846
2847
2848
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2846

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



2923
2924
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2923

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



2915
2916
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2915

def backtrace(tx, ty, tz)
end

#calculate_nodeObject

Calculate a node and return it if a path is found

Returns:



2908
2909
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2908

def calculate_node
end

#finished?Boolean

Indicate if the request is ended

Returns:

  • (Boolean)


2872
2873
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2872

def finished?
end

#process_result(result)

Process the result of the node calculation

Parameters:

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

    the result value



2887
2888
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2887

def process_result(result)
end

#reload?Boolean

Indicate if the request is to reload

Returns:

  • (Boolean)


2868
2869
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2868

def reload?
end

#saveArray<Object>

Gather the data ready to be saved

Returns:



2919
2920
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2919

def save
end

#searching?Boolean

Indicate if the request is search for path

Returns:

  • (Boolean)


2856
2857
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2856

def searching?
end

#send_path(path)

Make the character following the found path

Parameters:

  • path (Array<Integer>)

    The path, list of move direction



2900
2901
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2900

def send_path(path)
end

#stucked?Boolean

Detect if the character is stucked

Returns:

  • (Boolean)


2904
2905
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2904

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)


2878
2879
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2878

def update(operation_counter, is_first_update)
end

#update_reload(is_first_update)

Reload the request



2896
2897
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2896

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)


2883
2884
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2883

def update_search(operation_counter)
end

#update_wait(is_first_update)

Update the request when waiting before retrying to find path



2893
2894
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2893

def update_wait(is_first_update)
end

#update_watch(is_first_update)

Update the request when looking for obstacles



2890
2891
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2890

def update_watch(is_first_update)
end

#waiting?Boolean

Indicate if the request is watching for obstacle

Returns:

  • (Boolean)


2860
2861
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2860

def waiting?
end

#watching?Boolean

Inidicate if the request is waiting for new try

Returns:

  • (Boolean)


2864
2865
# File 'docs/01450_Systems_00003_Map_Engine.rb', line 2864

def watching?
end