void Mob::onSpawn( unsigned flag ) { BaseClass::onSpawn( flag ); mBody.setSize( getSize()- Vec2f(4,4) ); mBody.setTypeMask( COL_SOILD | COL_RENDER ); mBody.setColMask( COL_BULLET | COL_SOILD | COL_TERRAIN ); getLevel()->getColManager().addBody( *this , mBody ); if ( flag & SDF_CAST_EFFECT ) spawnEffect(); }
static void updateTrap(GameObject obj) { EntityManager &em = EntityManager::instance(); TrapComponent *trap = em.getComponentForEntity<TrapComponent>(obj); if (trap->is_triggered || trap->is_destroyed) { // If the trap was already triggered or destroyed. return; } SpaceComponent *trap_space = em.getComponentForEntity<SpaceComponent>(obj); if (!trap_space || !trap_space->is_active) { // If trap isn't on map. return ; } std::vector<GameObject> entities; em.getEntitiesWithComponent<CollisionComponent>(entities); std::vector<GameObject>::iterator it = entities.begin(); for (; it != entities.end(); ++it) { if (triggersTrap(*it, obj)) { trap->is_triggered = true; trap->is_visible = true; spawnEffect(obj, *it); } } }
LuaProxy::Animation LuaProxy::spawnEffect(short effectID, double x, double y, lua_State* L) { return spawnEffect(effectID, x, y, 1.0f, L); }