Adonthell  0.4
map_event.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002 Kai Sterker <kai.sterker@gmail.com>
3  Part of the Adonthell Project <http://adonthell.nongnu.org>
4 
5  Adonthell 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 
10  Adonthell is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 /**
20  * @file map_event.h
21  *
22  * @author Kai Sterker
23  * @brief Declares the different map events.
24  */
25 
26 #ifndef MAP_EVENT_H__
27 #define MAP_EVENT_H__
28 
29 #include "event.h"
30 #include "character.h"
31 
32 /**
33  * Baseclass for map enter/leave/action events.
34  * The event will be launched if all the member's data matches.
35  */
36 class map_event : public event
37 {
38 public:
39  /**
40  * Default constructor.
41  */
42  map_event ();
43 
44  /**
45  * Saves the basic %event %data (such as the type or script data)
46  * to a file.
47  *
48  * @param out file where to save the %event.
49  */
50  void put_state (ogzstream&) const;
51 
52  /**
53  * Loads the basic %event %date from a file.
54  *
55  * @param in file to load the %event from.
56  * @return \e true if the %event could be loaded, \e false otherwise
57  */
58  bool get_state (igzstream&);
59 
60  /**
61  * Submap index (-1 for any).
62  */
64 
65  /**
66  * X position (-1 for any).
67  */
69 
70  /**
71  * Y position (-1 for any).
72  */
74 
75  /**
76  * Direction where the character is looking (-1 for any).
77  */
79 
80  /**
81  * Useless (for now).
82  */
84 
85  /**
86  * Pointer to the mapcharacter that can launch this event (NULL for any).
87  */
89 
90  /**
91  * Compare two map events for equality.
92  *
93  * @param evnt The map event to compare this to.
94  * @return <b>True</b> if the two events equal, <b>false</b> otherwise.
95  */
96  bool equals (const event* evnt);
97 
98  /**
99  * Executes the script associated with this map %event. If the
100  * event does not repeat it is removed from the %event handler.
101  *
102  * @param evnt The %event that triggered this map %event.
103  *
104  * @return The number of times the %event needs to be repeated.
105  */
106  s_int32 execute (const event* evnt);
107 };
108 
109 
110 /**
111  * To notify when a character entered a mapsquare.
112  */
113 class enter_event : public map_event
114 {
115 public:
116  /**
117  * Default constructor.
118  */
119  enter_event ();
120 };
121 
122 
123 /**
124  * To notify when a mapcharacter left a mapsquare.
125  */
126 class leave_event : public map_event
127 {
128 public:
129  /**
130  * Default constructor.
131  */
132  leave_event ();
133 };
134 
135 
136 /**
137  * To notify when a mapcharacter "act" on a square.
138  */
139 class action_event : public map_event
140 {
141 public:
142  /**
143  * Default constructor.
144  */
145  action_event ();
146 };
147 
148 #endif // MAP_EVENT_H__
Declares the character class.
Class to write data from a Gzip compressed file.
Definition: fileops.h:227
s_int8 dir
Direction where the character is looking (-1 for any).
Definition: map_event.h:78
To notify when a mapcharacter left a mapsquare.
Definition: map_event.h:126
#define s_int32
32 bits long signed integer
Definition: types.h:50
Class to read data from a Gzip compressed file.
Definition: fileops.h:135
map_event()
Default constructor.
Definition: map_event.cc:29
To notify when a mapcharacter "act" on a square.
Definition: map_event.h:139
Base class for events.
Definition: event.h:75
bool get_state(igzstream &)
Loads the basic event date from a file.
Definition: map_event.cc:88
s_int32 execute(const event *evnt)
Executes the script associated with this map event.
Definition: map_event.cc:52
To notify when a character entered a mapsquare.
Definition: map_event.h:113
Baseclass for map enter/leave/action events.
Definition: map_event.h:36
mapcharacter * c
Pointer to the mapcharacter that can launch this event (NULL for any).
Definition: map_event.h:88
s_int32 x
X position (-1 for any).
Definition: map_event.h:68
bool equals(const event *evnt)
Compare two map events for equality.
Definition: map_event.cc:36
s_int32 map
Useless (for now).
Definition: map_event.h:83
s_int32 y
Y position (-1 for any).
Definition: map_event.h:73
void put_state(ogzstream &) const
Saves the basic event data (such as the type or script data) to a file.
Definition: map_event.cc:110
Representation of characters on a landmap.
Definition: mapcharacter.h:139
Declares the event class.
s_int32 submap
Submap index (-1 for any).
Definition: map_event.h:63
#define s_int8
8 bits long signed integer
Definition: types.h:44