Horizon Official Technical Documentation
GridNotifierPredicates.hpp
Go to the documentation of this file.
1/***************************************************
2 * _ _ _ *
3 * | | | | (_) *
4 * | |_| | ___ _ __ _ _______ _ __ *
5 * | _ |/ _ \| '__| |_ / _ \| '_ \ *
6 * | | | | (_) | | | |/ / (_) | | | | *
7 * \_| |_/\___/|_| |_/___\___/|_| |_| *
8 ***************************************************
9 * This file is part of Horizon (c).
10 *
11 * Copyright (c) 2019 Sagun K. (sagunxp@gmail.com).
12 * Copyright (c) 2019 Horizon Dev Team.
13 *
14 * Base Author - Sagun K. (sagunxp@gmail.com)
15 *
16 * This library is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this library. If not, see <http://www.gnu.org/licenses/>.
28 **************************************************/
29
30#ifndef HORIZON_ZONE_GAME_MAP_GRIDNOTIFIERPREDICATES_HPP
31#define HORIZON_ZONE_GAME_MAP_GRIDNOTIFIERPREDICATES_HPP
32
35
37{
38public:
39 GUIDCheckPredicate(uint32_t guid) : _guid(guid) { }
40
41 bool operator()(std::weak_ptr<Horizon::Zone::Unit> unit)
42 {
43 return !unit.expired() && ((unit.lock())->guid() == _guid);
44 }
45
46private:
47 uint32_t _guid;
48};
49
51{
52public:
53 RangeCheckPredicate(std::weak_ptr<Horizon::Zone::Unit> source)
54 : _source(source){ }
55
56 bool operator()(std::weak_ptr<Horizon::Zone::Unit> target, uint16_t range = MAX_VIEW_RANGE)
57 {
58 return !_source.expired() && !target.expired() && _source.lock()->is_in_range_of(target.lock(), range);
59 }
60
61private:
62 std::weak_ptr<Horizon::Zone::Unit> _source;
63};
64
66{
67public:
68 AOETargetTypePredicate(int aoe_target_mask)
69 : _aoe_target_mask(aoe_target_mask){ }
70
71 bool operator()(std::weak_ptr<Horizon::Zone::Unit> target)
72 {
73 return !target.expired() && (target.lock())->is_of_type(_aoe_target_mask);
74 }
75
76private:
78};
79
81{
82public:
84 : _cell(cell){ }
85
87 {
88 return cell == _cell;
89 }
90
91private:
93};
94
95#endif /* GRIDNOTIFIERPREDICATES_HPP */
Cell cell[MAP_WIDTH][MAP_HEIGHT]
Definition: AStarTest.cpp:52
#define MAX_VIEW_RANGE
Definition: Horizon.hpp:59
Definition: GridNotifierPredicates.hpp:66
AOETargetTypePredicate(int aoe_target_mask)
Definition: GridNotifierPredicates.hpp:68
bool operator()(std::weak_ptr< Horizon::Zone::Unit > target)
Definition: GridNotifierPredicates.hpp:71
int _aoe_target_mask
Definition: GridNotifierPredicates.hpp:77
Definition: GridNotifierPredicates.hpp:81
MapCoords _cell
Definition: GridNotifierPredicates.hpp:92
CellCheckPredicate(MapCoords cell)
Definition: GridNotifierPredicates.hpp:83
bool operator()(MapCoords cell)
Definition: GridNotifierPredicates.hpp:86
Definition: GridNotifierPredicates.hpp:37
uint32_t _guid
Definition: GridNotifierPredicates.hpp:47
bool operator()(std::weak_ptr< Horizon::Zone::Unit > unit)
Definition: GridNotifierPredicates.hpp:41
GUIDCheckPredicate(uint32_t guid)
Definition: GridNotifierPredicates.hpp:39
Definition: GridNotifierPredicates.hpp:51
std::weak_ptr< Horizon::Zone::Unit > _source
Definition: GridNotifierPredicates.hpp:62
RangeCheckPredicate(std::weak_ptr< Horizon::Zone::Unit > source)
Definition: GridNotifierPredicates.hpp:53
bool operator()(std::weak_ptr< Horizon::Zone::Unit > target, uint16_t range=MAX_VIEW_RANGE)
Definition: GridNotifierPredicates.hpp:56