The Battle for Wesnoth  1.19.6+dev
Public Member Functions | Protected Attributes | List of all members
editor::editor_action_unit Class Reference

place a new unit on the map More...

#include <action_unit.hpp>

Inheritance diagram for editor::editor_action_unit:

Public Member Functions

 editor_action_unit (map_location loc, const unit &u)
 
std::unique_ptr< editor_actionclone () const override
 Action cloning. More...
 
std::unique_ptr< editor_actionperform (map_context &mc) const override
 Perform the action, returning an undo action that, when performed, shall reverse any effects of this action. More...
 
void perform_without_undo (map_context &mc) const override
 Perform the action without creating an undo action. More...
 
const std::string & get_name () const override
 
- Public Member Functions inherited from editor::editor_action_location
 editor_action_location (map_location loc)
 
- Public Member Functions inherited from editor::editor_action
 editor_action ()
 
virtual ~editor_action ()
 
virtual int action_count () const
 
virtual std::string get_description () const
 A textual description of the action. More...
 
int get_id () const
 Debugging aid. More...
 

Protected Attributes

unit_ptr u_
 
- Protected Attributes inherited from editor::editor_action_location
map_location loc_
 

Additional Inherited Members

- Static Public Member Functions inherited from editor::editor_action
static int get_instance_count ()
 Debugging aid. More...
 

Detailed Description

place a new unit on the map

Definition at line 38 of file action_unit.hpp.

Constructor & Destructor Documentation

◆ editor_action_unit()

editor::editor_action_unit::editor_action_unit ( map_location  loc,
const unit u 
)
inline

Definition at line 41 of file action_unit.hpp.

Member Function Documentation

◆ clone()

std::unique_ptr<editor_action> editor::editor_action_unit::clone ( ) const
overridevirtual

Action cloning.

Implements editor::editor_action.

◆ get_name()

const std::string& editor::editor_action_unit::get_name ( ) const
overridevirtual
Returns
a short name of this action type, defaults to unknown

Reimplemented from editor::editor_action_location.

◆ perform()

std::unique_ptr< editor_action > editor::editor_action_unit::perform ( map_context mc) const
overridevirtual

Perform the action, returning an undo action that, when performed, shall reverse any effects of this action.

The undo action object is owned by the caller. Default behavior is to create a whole-map undo, call the perform_without_undo function and return the undo object.

Reimplemented from editor::editor_action.

Definition at line 35 of file action_unit.cpp.

References loc_.

◆ perform_without_undo()

void editor::editor_action_unit::perform_without_undo ( map_context ) const
overridevirtual

Perform the action without creating an undo action.

Implements editor::editor_action.

Definition at line 42 of file action_unit.cpp.

References unit_map::add(), editor::map_context::add_changed_location(), unit_map::find(), editor::editor_action_location::loc_, u_, and editor::map_context::units().

Member Data Documentation

◆ u_

unit_ptr editor::editor_action_unit::u_
protected

Definition at line 53 of file action_unit.hpp.

Referenced by perform_without_undo().


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