1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
3 //
4 //    This file is part of Scorched3D.
5 //
6 //    Scorched3D 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 //
11 //    Scorched3D is distributed in the hope that it will be useful,
12 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //    GNU General Public License for more details.
15 //
16 //    You should have received a copy of the GNU General Public License along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #if !defined(__INCLUDE_LandscapeEventsh_INCLUDE__)
22 #define __INCLUDE_LandscapeEventsh_INCLUDE__
23 
24 #include <common/fixed.h>
25 #include <common/ModelID.h>
26 
27 class ScorchedContext;
28 class LandscapeCondition
29 {
30 public:
31 	virtual fixed getNextEventTime(ScorchedContext &context,
32 		int eventNumber) = 0;
33 	virtual bool fireEvent(ScorchedContext &context,
34 		fixed timeLeft, int eventNumber) = 0;
35 	virtual bool readXML(XMLNode *node) = 0;
36 
37 	static LandscapeCondition *create(const char *name);
38 };
39 
40 class LandscapeConditionGroupSize : public LandscapeCondition
41 {
42 public:
43 	int groupsize;
44 	std::string groupname;
45 
46 	virtual fixed getNextEventTime(ScorchedContext &context,
47 		int eventNumber);
48 	virtual bool fireEvent(ScorchedContext &context,
49 		fixed timeLeft, int eventNumber);
50 	virtual bool readXML(XMLNode *node);
51 };
52 
53 class LandscapeConditionTime : public LandscapeCondition
54 {
55 public:
56 	fixed mintime;
57 	fixed maxtime;
58 	bool singletimeonly;
59 
60 	virtual fixed getNextEventTime(ScorchedContext &context,
61 		int eventNumber);
62 	virtual bool fireEvent(ScorchedContext &context,
63 		fixed timeLeft, int eventNumber);
64 	virtual bool readXML(XMLNode *node);
65 };
66 
67 class LandscapeConditionRandom : public LandscapeCondition
68 {
69 public:
70 	fixed randomchance;
71 	fixed randomdelay;
72 
73 	virtual fixed getNextEventTime(ScorchedContext &context,
74 		int eventNumber);
75 	virtual bool fireEvent(ScorchedContext &context,
76 		fixed timeLeft, int eventNumber);
77 	virtual bool readXML(XMLNode *node);
78 };
79 
80 class LandscapeAction
81 {
82 public:
83 	virtual bool readXML(XMLNode *node) = 0;
84 	virtual void fireAction(ScorchedContext &context) = 0;
85 
86 	static LandscapeAction *create(const char *name);
87 };
88 
89 class LandscapeActionFireWeapon : public LandscapeAction
90 {
91 public:
92 	std::string weapon;
93 
94 	virtual void fireAction(ScorchedContext &context);
95 	virtual bool readXML(XMLNode *node);
96 };
97 
98 class LandscapeActionFireWeaponFromGroup : public LandscapeAction
99 {
100 public:
101 	std::string weapon;
102 	std::string groupname;
103 
104 	virtual void fireAction(ScorchedContext &context);
105 	virtual bool readXML(XMLNode *node);
106 };
107 
108 class LandscapeEvent
109 {
110 public:
111 	LandscapeEvent();
112 	virtual ~LandscapeEvent();
113 
114 	LandscapeCondition *condition;
115 	LandscapeAction *action;
116 
117 	virtual bool readXML(XMLNode *node);
118 };
119 
120 #endif // __INCLUDE_LandscapeEventsh_INCLUDE__
121