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



3574
3575
# File 'docs/4_Systems_003_Map_Engine.rb', line 3574

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

Instance Attribute Details

#characterGame_Character (readonly)

The character which needs a path

Returns:



3565
3566
3567
# File 'docs/4_Systems_003_Map_Engine.rb', line 3565

def character
  @character
end

#need_updateBoolean (readonly)

Indicate if the request needs update or not

Returns:

  • (Boolean)


3568
3569
3570
# File 'docs/4_Systems_003_Map_Engine.rb', line 3568

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



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

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



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

def backtrace(tx, ty, tz)
end

#calculate_nodeObject

Calculate a node and return it if a path is found

Returns:



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

def calculate_node
end

#finished?Boolean

Indicate if the request is ended

Returns:

  • (Boolean)


3594
3595
# File 'docs/4_Systems_003_Map_Engine.rb', line 3594

def finished?
end

#process_result(result)

Process the result of the node calculation

Parameters:

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

    the result value



3609
3610
# File 'docs/4_Systems_003_Map_Engine.rb', line 3609

def process_result(result)
end

#reload?Boolean

Indicate if the request is to reload

Returns:

  • (Boolean)


3590
3591
# File 'docs/4_Systems_003_Map_Engine.rb', line 3590

def reload?
end

#saveArray<Object>

Gather the data ready to be saved

Returns:



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

def save
end

#searching?Boolean

Indicate if the request is search for path

Returns:

  • (Boolean)


3578
3579
# File 'docs/4_Systems_003_Map_Engine.rb', line 3578

def searching?
end

#send_path(path)

Make the character following the found path

Parameters:

  • path (Array<Integer>)

    The path, list of move direction



3622
3623
# File 'docs/4_Systems_003_Map_Engine.rb', line 3622

def send_path(path)
end

#stucked?Boolean

Detect if the character is stucked

Returns:

  • (Boolean)


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

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)


3600
3601
# File 'docs/4_Systems_003_Map_Engine.rb', line 3600

def update(operation_counter, is_first_update)
end

#update_reload(is_first_update)

Reload the request



3618
3619
# File 'docs/4_Systems_003_Map_Engine.rb', line 3618

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)


3605
3606
# File 'docs/4_Systems_003_Map_Engine.rb', line 3605

def update_search(operation_counter)
end

#update_wait(is_first_update)

Update the request when waiting before retrying to find path



3615
3616
# File 'docs/4_Systems_003_Map_Engine.rb', line 3615

def update_wait(is_first_update)
end

#update_watch(is_first_update)

Update the request when looking for obstacles



3612
3613
# File 'docs/4_Systems_003_Map_Engine.rb', line 3612

def update_watch(is_first_update)
end

#waiting?Boolean

Indicate if the request is watching for obstacle

Returns:

  • (Boolean)


3582
3583
# File 'docs/4_Systems_003_Map_Engine.rb', line 3582

def waiting?
end

#watching?Boolean

Inidicate if the request is waiting for new try

Returns:

  • (Boolean)


3586
3587
# File 'docs/4_Systems_003_Map_Engine.rb', line 3586

def watching?
end