The Battle for Wesnoth  1.19.5+dev
Public Member Functions | List of all members
movetype::terrain_costs Class Referenceabstract

A const-only interface for how many (movement, vision, or "jamming") points a unit needs for each hex. More...

#include <movetype.hpp>

Inheritance diagram for movetype::terrain_costs:

Public Member Functions

virtual ~terrain_costs ()=default
 
virtual int value (const t_translation::terrain_code &terrain) const =0
 Returns the value associated with the given terrain. More...
 
int cost (const t_translation::terrain_code &terrain, bool slowed=false) const
 Returns the cost associated with the given terrain. More...
 
virtual std::unique_ptr< terrain_costsmake_standalone () const =0
 Does a sufficiently deep copy so that the returned object's lifespan is independent of other objects' lifespan. More...
 
virtual void write (config &cfg, const std::string &child_name="", bool merged=true) const =0
 Writes our data to a config. More...
 

Detailed Description

A const-only interface for how many (movement, vision, or "jamming") points a unit needs for each hex.

Functions to modify the costs are exposed by the movetype instance owning this terrain_costs, so that changes to movement will cascade to the vision, etc.

Definition at line 52 of file movetype.hpp.

Constructor & Destructor Documentation

◆ ~terrain_costs()

virtual movetype::terrain_costs::~terrain_costs ( )
virtualdefault

Member Function Documentation

◆ cost()

int movetype::terrain_costs::cost ( const t_translation::terrain_code terrain,
bool  slowed = false 
) const
inline

Returns the cost associated with the given terrain.

Costs are doubled when slowed is true.

Definition at line 68 of file movetype.hpp.

References game_config::sounds::status::slowed, movetype::UNREACHABLE, and value().

Referenced by pathfind::find_routes(), movetype::jamming_cost(), movetype::movement_cost(), ai::default_recruitment::recruitment::update_average_local_cost(), and movetype::vision_cost().

◆ make_standalone()

virtual std::unique_ptr<terrain_costs> movetype::terrain_costs::make_standalone ( ) const
pure virtual

Does a sufficiently deep copy so that the returned object's lifespan is independent of other objects' lifespan.

Never returns nullptr.

Implemented in movetype::terrain_info.

◆ value()

virtual int movetype::terrain_costs::value ( const t_translation::terrain_code terrain) const
pure virtual

Returns the value associated with the given terrain.

Calculated values are cached for later queries.

Implemented in movetype::terrain_info.

Referenced by cost().

◆ write()

virtual void movetype::terrain_costs::write ( config cfg,
const std::string &  child_name = "",
bool  merged = true 
) const
pure virtual

Writes our data to a config.

Implemented in movetype::terrain_info.


The documentation for this class was generated from the following file: