The Battle for Wesnoth  1.19.16+dev
shroud_clearing_action.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 - 2025
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "vision.hpp"
18 #include "map/location.hpp"
19 #include "units/ptr.hpp"
20 
21 namespace actions
22 {
23 /** base class for classes that clear srhoud (move/recruit/recall) */
25 {
28  , view_info(cfg.child_or_empty("unit"))
29  {
30  }
31 
33  : route(1, loc)
34  , view_info(*u)
35  {
36  }
37 
38  typedef std::vector<map_location> route_t;
39 
40  shroud_clearing_action(const unit_const_ptr u, const route_t::const_iterator& begin, const route_t::const_iterator& end)
41  : route(begin, end)
42  , view_info(*u)
43  {
44  }
45 
46  /**
47  * The hexes occupied by the affected unit during this action.
48  * For recruits and recalls this only contains one hex.
49  */
51  /** A record of the affected unit's ability to see. */
53 
54  void write(config & cfg) const
55  {
57  view_info.write(cfg.add_child("unit"));
58  }
59 
61 };
62 }
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:157
config & add_child(std::string_view key)
Definition: config.cpp:435
const config * cfg
std::vector< map_location > read_locations(const config &cfg)
Parse x,y keys of a config into a vector of locations.
Definition: location.cpp:475
void write_locations(const std::vector< map_location > &locs, config &cfg)
Write a vector of locations into a config adding keys x=x1,x2,..,xn and y=y1,y2,.....
Definition: location.cpp:493
std::shared_ptr< const unit > unit_const_ptr
Definition: ptr.hpp:27
Class that stores the part of a unit's data that is needed for fog clearing.
Definition: vision.hpp:53
void write(config &cfg) const
Writes to a config.
Definition: vision.cpp:120
base class for classes that clear srhoud (move/recruit/recall)
shroud_clearing_action(const unit_const_ptr u, const map_location &loc)
shroud_clearing_action(const unit_const_ptr u, const route_t::const_iterator &begin, const route_t::const_iterator &end)
route_t route
The hexes occupied by the affected unit during this action.
std::vector< map_location > route_t
clearer_info view_info
A record of the affected unit's ability to see.
Encapsulates the map of the game.
Definition: location.hpp:46
Various functions implementing vision (through fog of war and shroud).