1 /* !!!! GENERATED FILE - DO NOT EDIT !!!!
2  * --------------------------------------
3  *
4  * This file is part of liblcf. Copyright (c) 2021 liblcf authors.
5  * https://github.com/EasyRPG/liblcf - https://easyrpg.org
6  *
7  * liblcf is Free/Libre Open Source Software, released under the MIT License.
8  * For the full copyright and license information, please view the COPYING
9  * file that was distributed with this source code.
10  */
11 
12 #ifndef LCF_RPG_COMMONEVENT_H
13 #define LCF_RPG_COMMONEVENT_H
14 
15 // Headers
16 #include <vector>
17 #include "lcf/dbstring.h"
18 #include "lcf/enum_tags.h"
19 #include "lcf/rpg/eventcommand.h"
20 #include "lcf/context.h"
21 #include <ostream>
22 #include <type_traits>
23 
24 /**
25  * rpg::CommonEvent class.
26  */
27 namespace lcf {
28 namespace rpg {
29 	class CommonEvent {
30 	public:
31 		enum Trigger {
32 			Trigger_automatic = 3,
33 			Trigger_parallel = 4,
34 			Trigger_call = 5
35 		};
36 
37 		int ID = 0;
38 		DBString name;
39 		int32_t trigger = 0;
40 		bool switch_flag = false;
41 		int32_t switch_id = 1;
42 		std::vector<EventCommand> event_commands;
43 	};
44 	inline std::ostream& operator<<(std::ostream& os, CommonEvent::Trigger code) {
45 		os << static_cast<std::underlying_type_t<decltype(code)>>(code);
46 		return os;
47 	}
48 
49 	inline bool operator==(const CommonEvent& l, const CommonEvent& r) {
50 		return l.name == r.name
51 		&& l.trigger == r.trigger
52 		&& l.switch_flag == r.switch_flag
53 		&& l.switch_id == r.switch_id
54 		&& l.event_commands == r.event_commands;
55 	}
56 
57 	inline bool operator!=(const CommonEvent& l, const CommonEvent& r) {
58 		return !(l == r);
59 	}
60 
61 	std::ostream& operator<<(std::ostream& os, const CommonEvent& obj);
62 
63 	template <typename F, typename ParentCtx = Context<void,void>>
64 	void ForEachString(CommonEvent& obj, const F& f, const ParentCtx* parent_ctx = nullptr) {
65 		const auto ctx1 = Context<CommonEvent, ParentCtx>{ "name", -1, &obj, parent_ctx };
66 		f(obj.name, ctx1);
67 		for (int i = 0; i < static_cast<int>(obj.event_commands.size()); ++i) {
68 			const auto ctx5 = Context<CommonEvent, ParentCtx>{ "event_commands", i, &obj, parent_ctx };
69 			ForEachString(obj.event_commands[i], f, &ctx5);
70 		}
71 		(void)obj;
72 		(void)f;
73 		(void)parent_ctx;
74 	}
75 
76 } // namespace rpg
77 } // namespace lcf
78 
79 #endif
80