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