Initial sauer
[SauerbratenRemote.git] / src / rpggame / entities.h
blob92eea1be6cbf342b30fc65e63b7c359edbc8565b
2 enum { ETR_SPAWN = ET_GAMESPECIFIC, };
4 static const int SPAWNNAMELEN = 64;
6 struct rpgentity : extentity
8 char name[SPAWNNAMELEN];
10 rpgentity() { memset(name, 0, SPAWNNAMELEN); }
13 struct rpgentities : icliententities
15 rpgclient &cl;
16 vector<rpgentity *> ents;
17 rpgentity *lastcreated;
19 ~rpgentities() {}
20 rpgentities(rpgclient &_cl) : cl(_cl), lastcreated(NULL)
22 CCOMMAND(spawnname, "s", (rpgentities *self, char *s), { if(self->lastcreated) { s_strncpy(self->lastcreated->name, s, SPAWNNAMELEN); self->spawnfroment(*self->lastcreated); } });
25 vector<extentity *> &getents() { return (vector<extentity *> &)ents; }
27 void editent(int i) {}
29 const char *entnameinfo(entity &e) { return ((rpgentity &)e).name; }
30 const char *entname(int i)
32 static const char *entnames[] = { "none?", "light", "mapmodel", "playerstart", "envmap", "particles", "sound", "spotlight", "spawn" };
33 return i>=0 && size_t(i)<sizeof(entnames)/sizeof(entnames[0]) ? entnames[i] : "";
36 int extraentinfosize() { return SPAWNNAMELEN; }
37 void writeent(entity &e, char *buf) { memcpy(buf, ((rpgentity &)e).name, SPAWNNAMELEN); }
38 void readent (entity &e, char *buf) { memcpy(((rpgentity &)e).name, buf, SPAWNNAMELEN); }
40 float dropheight(entity &e) { return e.type==ET_MAPMODEL ? 0 : 4; }
42 void rumble(const extentity &e) { playsoundname("free/rumble", &e.o); }
43 void trigger(extentity &e) {}
45 extentity *newentity() { return new rpgentity; }
47 void fixentity(extentity &e)
49 lastcreated = (rpgentity *)&e;
50 switch(e.type)
52 case ETR_SPAWN:
53 e.attr1 = (int)cl.player1.yaw;
57 void spawnfroment(rpgentity &e)
59 cl.os.spawn(e.name);
60 cl.os.placeinworld(e.o, e.attr1);
63 void startmap()
65 lastcreated = NULL;
66 loopv(ents) if(ents[i]->type==ETR_SPAWN) spawnfroment(*ents[i]);