Adonthell
0.4
|
00001 /* 00002 $Id: map_event.h,v 1.2 2002/08/18 19:53:17 ksterker Exp $ 00003 00004 Copyright (C) 2002 Kai Sterker <kaisterker@linuxgames.com> 00005 Part of the Adonthell Project http://adonthell.linuxgames.com 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License. 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY. 00011 00012 See the COPYING file for more details. 00013 */ 00014 00015 /** 00016 * @file map_event.h 00017 * 00018 * @author Kai Sterker 00019 * @brief Declares the different map events. 00020 */ 00021 00022 #ifndef MAP_EVENT_H__ 00023 #define MAP_EVENT_H__ 00024 00025 #include "event.h" 00026 #include "character.h" 00027 00028 /** 00029 * Baseclass for map enter/leave/action events. 00030 * The event will be launched if all the member's data matches. 00031 */ 00032 class map_event : public event 00033 { 00034 public: 00035 /** 00036 * Default constructor. 00037 */ 00038 map_event (); 00039 00040 /** 00041 * Saves the basic %event %data (such as the type or script data) 00042 * to a file. 00043 * 00044 * @param out file where to save the %event. 00045 */ 00046 void put_state (ogzstream&) const; 00047 00048 /** 00049 * Loads the basic %event %date from a file. 00050 * 00051 * @param in file to load the %event from. 00052 * @return \e true if the %event could be loaded, \e false otherwise 00053 */ 00054 bool get_state (igzstream&); 00055 00056 /** 00057 * Submap index (-1 for any). 00058 */ 00059 s_int32 submap; 00060 00061 /** 00062 * X position (-1 for any). 00063 */ 00064 s_int32 x; 00065 00066 /** 00067 * Y position (-1 for any). 00068 */ 00069 s_int32 y; 00070 00071 /** 00072 * Direction where the character is looking (-1 for any). 00073 */ 00074 s_int8 dir; 00075 00076 /** 00077 * Useless (for now). 00078 */ 00079 s_int32 map; 00080 00081 /** 00082 * Pointer to the mapcharacter that can launch this event (NULL for any). 00083 */ 00084 mapcharacter *c; 00085 00086 /** 00087 * Compare two map events for equality. 00088 * 00089 * @param evnt The map event to compare this to. 00090 * @return <b>True</b> if the two events equal, <b>false</b> otherwise. 00091 */ 00092 bool equals (const event* evnt); 00093 00094 /** 00095 * Executes the script associated with this map %event. If the 00096 * event does not repeat it is removed from the %event handler. 00097 * 00098 * @param evnt The %event that triggered this map %event. 00099 * 00100 * @return The number of times the %event needs to be repeated. 00101 */ 00102 s_int32 execute (const event* evnt); 00103 }; 00104 00105 00106 /** 00107 * To notify when a character entered a mapsquare. 00108 */ 00109 class enter_event : public map_event 00110 { 00111 public: 00112 /** 00113 * Default constructor. 00114 */ 00115 enter_event (); 00116 }; 00117 00118 00119 /** 00120 * To notify when a mapcharacter left a mapsquare. 00121 */ 00122 class leave_event : public map_event 00123 { 00124 public: 00125 /** 00126 * Default constructor. 00127 */ 00128 leave_event (); 00129 }; 00130 00131 00132 /** 00133 * To notify when a mapcharacter "act" on a square. 00134 */ 00135 class action_event : public map_event 00136 { 00137 public: 00138 /** 00139 * Default constructor. 00140 */ 00141 action_event (); 00142 }; 00143 00144 #endif // MAP_EVENT_H__