The Battle for Wesnoth  1.19.7+dev
unit_creator.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
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,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /**
17  * @file
18  * Various functions related to the creation of units (recruits, recalls,
19  * and placed units).
20  */
21 
22 #pragma once
23 
24 class config;
25 class team;
26 class vconfig;
27 class game_board;
28 class unit;
29 
30 #include "map/location.hpp"
31 
33 {
34 public:
35  unit_creator(team &tm, const map_location &start_pos, game_board* board = nullptr);
36  unit_creator& allow_show(bool b);
42 
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);
49 
50 
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);
55 
56 private:
57  void post_create(const map_location &loc, const unit &new_unit, bool anim, bool fire_event);
58 
60  bool discover_;
64  bool show_;
68 
69 };
map_location loc
Definition: move.cpp:172
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
Game board class.
Definition: game_board.hpp:47
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:75
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:133
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:45
#define b