void NPC::setIdle () { debug(LOG_SERVER, String::format("idle npc %i: %s", getID(), _type.name.c_str())); setState(NPCState::NPC_IDLE); setAnimationType(getIdleAnimation()); setLinearVelocity(b2Vec2_zero); _idleTimer = 0; }
NPCBlowing::NPCBlowing (Map& map, const b2Vec2& pos, bool right, float force, float modificatorSize) : NPC(EntityTypes::NPC_BLOWING, map) { _lastDirectionRight = right; createBody(pos); const Direction dir = right ? DIRECTION_RIGHT : DIRECTION_LEFT; _modificator = new WindModificator(_map, dir, force, modificatorSize, 1.2f); // now that we have the npc body we can query the size // and configure the modificator _modificator->createBody(pos, getSize().x / 4.0f); _spriteDef = SpriteDefinition::get().getFromEntityType(_type, getIdleAnimation()); }
void NPC::onSpawn () { if (getAnimationType() == Animation::NONE) setAnimationType(getIdleAnimation()); }