The Battle for Wesnoth  1.19.0-dev
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <>
4  Part of the Battle for Wesnoth Project
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
13  See the COPYING file for more details.
14 */
16 /**
17  * @file
18  * Various functions related to the creation of units (recruits, recalls,
19  * and placed units).
20  */
22 #pragma once
24 class config;
25 class team;
26 class vconfig;
27 class game_board;
28 class unit;
30 #include "map/location.hpp"
33 {
34 public:
35  unit_creator(team &tm, const map_location &start_pos, game_board* board = nullptr);
36  unit_creator& allow_show(bool b);
43  /**
44  * finds a suitable location for unit
45  * @retval map_location::null_location() if unit is to be put into recall list
46  * @retval valid on-board map location otherwise
47  */
48  map_location find_location(const config &cfg, const unit* pass_check=nullptr);
51  /**
52  * adds a unit on map without firing any events (so, usable during team construction in gamestatus)
53  */
54  void add_unit(const config &cfg, const vconfig* vcfg = nullptr);
56 private:
57  void post_create(const map_location &loc, const unit &new_unit, bool anim, bool fire_event);
60  bool discover_;
64  bool show_;
69 };
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
Game board class.
Definition: game_board.hpp:53
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:76
unit_creator & allow_invalidate(bool b)
unit_creator & allow_get_village(bool b)
unit_creator(team &tm, const map_location &start_pos, game_board *board=nullptr)
void add_unit(const config &cfg, const vconfig *vcfg=nullptr)
adds a unit on map without firing any events (so, usable during team construction in gamestatus)
map_location find_location(const config &cfg, const unit *pass_check=nullptr)
finds a suitable location for unit
unit_creator & allow_discover(bool b)
void post_create(const map_location &loc, const unit &new_unit, bool anim, bool fire_event)
unit_creator & allow_show(bool b)
unit_creator & allow_rename_side(bool b)
const map_location start_pos_
unit_creator & allow_add_to_recall(bool b)
game_board * board_
This class represents a single unit of a specific type.
Definition: unit.hpp:135
A variable-expanding proxy for the config class.
Definition: variable.hpp:45
bool fire_event(const ui_event event, const std::vector< std::pair< widget *, ui_event >> &event_chain, widget *dispatcher, widget *w, F &&... params)
Helper function for fire_event.
Encapsulates the map of the game.
Definition: location.hpp:38
#define b