Many API additions
This commit is contained in:
48
src/game.c
48
src/game.c
@@ -150,13 +150,25 @@ static void contact_callback(void *data, dGeomID g1, dGeomID g2) {
|
||||
int triggerType = activate_pair(g1, g2);
|
||||
|
||||
if(e1 != ENT_ID_INVALID) {
|
||||
if(game_getcomponent(e1, physics)->dynamics & CPHYSICS_GHOST) {
|
||||
struct CPhysics *cp = game_getcomponent(e1, physics);
|
||||
if(!cp) {
|
||||
// Entity being killed
|
||||
return;
|
||||
}
|
||||
|
||||
if(cp->dynamics & CPHYSICS_GHOST) {
|
||||
ghost = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(e2 != ENT_ID_INVALID) {
|
||||
if(game_getcomponent(e2, physics)->dynamics & CPHYSICS_GHOST) {
|
||||
struct CPhysics *cp = game_getcomponent(e2, physics);
|
||||
if(!cp) {
|
||||
// Entity being killed
|
||||
return;
|
||||
}
|
||||
|
||||
if(cp->dynamics & CPHYSICS_GHOST) {
|
||||
ghost = 1;
|
||||
}
|
||||
}
|
||||
@@ -896,3 +908,35 @@ void game_cleanup() {
|
||||
|
||||
Game.contactgroup = dJointGroupCreate(0);
|
||||
}
|
||||
|
||||
void game_killentity(uint16_t eid) {
|
||||
// XXX: Go over ALL component types!
|
||||
|
||||
struct CPhysics *cp = game_getcomponent(eid, physics);
|
||||
if(cp) {
|
||||
dBodyID bid = dGeomGetBody(cp->geom);
|
||||
|
||||
dGeomDestroy(cp->geom);
|
||||
|
||||
if(bid) {
|
||||
dBodyDestroy(bid);
|
||||
}
|
||||
|
||||
game_killcomponent_ptr(cp, physics);
|
||||
}
|
||||
|
||||
struct CRender *cr = game_getcomponent(eid, render);
|
||||
if(cr) {
|
||||
if(cr->cache) {
|
||||
if(resman_rev(cr->cache)) {
|
||||
resman_unref(RESMAN_MODEL, cr->cache);
|
||||
}
|
||||
}
|
||||
|
||||
game_killcomponent_ptr(cr, render);
|
||||
}
|
||||
|
||||
game_killcomponent(eid, movement);
|
||||
game_killcomponent(eid, playerctrl);
|
||||
game_killcomponent(eid, boned);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user