NXEngine v1.0.0.6
[NXEngine.git] / ObjManager.h
blobdc556ae5523f5533c0c1fed260fb05b89bf9938c
2 #ifndef _OBJMANAGER_H
3 #define _OBJMANAGER_H
5 namespace Objects
7 void UpdateBlockStates(void);
8 int CountType(int objtype);
10 void RunAI(void);
11 void PhysicsSim(void);
13 int IsRearTopAttack(Object *o);
15 void CullDeleted(void);
16 void DestroyAll(bool delete_player);
18 Object *FindByType(int type);
21 // synonyms
22 #define CountObjectsOfType Objects::CountType
23 #define FOREACH_OBJECT(O) for(O=firstobject; O; O=O->next)
25 // max expected objects to exist at once (for buffer allocation)
26 #define MAX_OBJECTS 1024
28 enum CreateObjectFlags
30 CF_NO_SPAWN_EVENT = 0x01, // inhibit calling OnSpawn
32 CF_DEFAULT = 0x00
35 Object *CreateObject(int x, int y, int type);
36 Object *CreateObject(int x, int y, int type, int xinertia, int yinertia, \
37 int dir=0, Object *linkedobject=NULL, uint32_t createflags=CF_DEFAULT);
40 // ObjProp definitions
41 struct ObjProp
43 // NXEngine-specific
44 int sprite;
45 int shaketime; // how long it shakes for when hit
47 uint32_t defaultnxflags;
49 // from npc.tbl
50 int initial_hp;
51 int xponkill;
52 int damage;
53 int hurt_sound, death_sound;
54 int death_smoke_amt;
56 uint32_t defaultflags;
58 // AI routines
59 struct
61 // executed every tick
62 void (*ontick)(Object *o);
63 // executed after physics sim has been done
64 void (*aftermove)(Object *o);
65 // if present, then when damage to the object causes it's hp to <= 0,
66 // this is executed instead of destroying the object or following the
67 // normal boom/spawn powerups routine.
68 void (*ondeath)(Object *o);
69 // executed when the object is first created or it's type is changed.
70 // intended for static objects which only require a small amount of
71 // initilization. This is NOT guaranteed to be only called exactly once
72 // for a given object.
73 void (*onspawn)(Object *o);
74 } ai_routines;
78 extern ObjProp objprop[OBJ_LAST];
79 extern Object *firstobject, *lastobject;
80 extern Object *lowestobject, *highestobject;
82 #endif