00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _UCSCHED_H
00020 #define _UCSCHED_H
00021
00022 class Game_object;
00023 class Usecode_value;
00024 class Usecode_internal;
00025
00026 #include "tqueue.h"
00027
00028
00029
00030
00031 class Usecode_script : public Time_sensitive
00032 {
00033 static int count;
00034 static Usecode_script *first;
00035 Usecode_script *next, *prev;
00036 Game_object *obj;
00037 Usecode_value *code;
00038 int cnt;
00039 int i;
00040 int frame_index;
00041 bool no_halt;
00042 bool must_finish;
00043 int delay;
00044
00045 Usecode_script(Game_object *item, Usecode_value *cd, int findex,
00046 int nhalt, int del);
00047 public:
00048 Usecode_script(Game_object *o, Usecode_value *cd = 0);
00049 ~Usecode_script();
00050 void start(long delay = 1);
00051 long get_delay() const
00052 { return delay; }
00053 void halt();
00054 bool is_no_halt() const
00055 { return no_halt; }
00056 int is_activated()
00057 { return i > 0; }
00058 void add(int v1);
00059 void add(int v1, int v2);
00060 void add(int v1, const char *str);
00061 void add(int *vals, int cnt);
00062 Usecode_script& operator<<(int v)
00063 { add(v); return *this; }
00064 inline void activate_egg(Usecode_internal *usecode, Game_object *e);
00065
00066 static int get_count()
00067 { return count; }
00068
00069 static Usecode_script *find(Game_object *srch,
00070 Usecode_script *last_found = 0);
00071 static void terminate(Game_object *obj);
00072 static void clear();
00073
00074 static void purge(Tile_coord pos, int dist);
00075 virtual void handle_event(unsigned long curtime, long udata);
00076 int exec(Usecode_internal *usecode, bool finish);
00077
00078 void step(Usecode_internal *usecode, int dir);
00079
00080 int save(unsigned char *buf, int buflen);
00081 static Usecode_script *restore(Game_object *item,
00082 unsigned char *buf, int buflen);
00083 void print(std::ostream& out);
00084 };
00085
00086
00087 #endif