Exemplo n.º 1
0
void Scene::unlink( Object* child )
{
	switch( child->m_feature )
	{
	case Object::Feature:
		break;
	case Entity::Feature:
		removeEntity( (Entity*)child );
		break;
	case Camera::Feature:
		removeEntity( (Entity*)child );
		removeCamera( (Camera*)child );
		break;
	/*case Element::Light:
		break;*/
	default:
		MAGICAL_ASSERT( false, "Invalid!" );
		break;
	}

	for( auto itr : child->m_children )
	{
		unlink( itr );
	}
}
Exemplo n.º 2
0
void Mainscene::reset(){
    for(unsigned int i = 0; i < towers.size(); i++){
        removeEntity(towers[i]);
        delete towers[i];
        towers[i] = NULL;
    }
    towers.clear();
    for(unsigned int i = 0; i < enemies.size(); i ++){
        removeEntity(enemies[i]);
        delete enemies[i];
        enemies[i] = NULL;
    }
    enemies.clear();

    for(unsigned int i = 0; i < bullets.size(); i ++){
        removeEntity(bullets[i]);
        delete bullets[i];
        bullets[i] = NULL;
    }
    bullets.clear();

    lockedItem = NULL;
    dreamHealth = 100;
    coins = 100;

    wave = 0;
    enemiesToSpawn = 10;
    waveEnd = true;

}
Exemplo n.º 3
0
/**
 * Implementation of update. Updates the arrow.
 */
void RS_Leader::update() {

    // find and delete arrow:
	for(auto e: entities){
        if (e->rtti()==RS2::EntitySolid) {
            removeEntity(e);
            break;
        }
    }

        if (isUndone()) {
                return;
        }

    RS_Entity* fe = firstEntity();
    if (fe && fe->isAtomic()) {
        RS_Vector p1 = ((RS_AtomicEntity*)fe)->getStartpoint();
        RS_Vector p2 = ((RS_AtomicEntity*)fe)->getEndpoint();

        // first entity must be the line which gets the arrow:
        if (hasArrowHead()) {
            RS_Solid* s = new RS_Solid(this, RS_SolidData());
            s->shapeArrow(p1,
                          p2.angleTo(p1),
                          getGraphicVariableDouble("$DIMASZ", 2.5)* getGraphicVariableDouble("$DIMSCALE", 1.0));
            s->setPen(RS_Pen(RS2::FlagInvalid));
			s->setLayer(nullptr);
            RS_EntityContainer::addEntity(s);
        }
    }
    calculateBorders();
}
Exemplo n.º 4
0
bool Map::removePlayer (ClientId clientId)
{
	assert(_entityRemovalAllowed);

	for (PlayerListIter i = _playersWaitingForSpawn.begin(); i != _playersWaitingForSpawn.end(); ++i) {
		if ((*i)->getClientId() != clientId)
			continue;
		(*i)->remove();
		delete *i;
		_playersWaitingForSpawn.erase(i);
		sendPlayersList();
		return true;
	}

	for (PlayerListIter i = _players.begin(); i != _players.end(); ++i) {
		if ((*i)->getClientId() != clientId)
			continue;

		removeEntity(0, **i);
		(*i)->remove();
		delete *i;
		_players.erase(i);
		return true;
	}
	error(LOG_MAP, String::format("could not find the player with the clientId %i", clientId));
	return false;
}
Exemplo n.º 5
0
void Scene::deleteSprite(Sprite **sprite) {
    removeCollisionSprite(*sprite);
    removeSurface((*sprite)->getSurface());
    removeEntity(*sprite);
    delete *sprite;
    *sprite = NULL;
}
Exemplo n.º 6
0
/**
 * Removes invalid objects.
 * @return how many objects were removed
 */
int RS_Graphic::clean()
{
    // author: ravas

    int how_many = 0;

    foreach (RS_Entity* e, entities)
    {
        if    (e->getMin().x > e->getMax().x
            || e->getMin().y > e->getMax().y
            || e->getMin().x > RS_MAXDOUBLE
            || e->getMax().x > RS_MAXDOUBLE
            || e->getMin().x < RS_MINDOUBLE
            || e->getMax().x < RS_MINDOUBLE
            || e->getMin().y > RS_MAXDOUBLE
            || e->getMax().y > RS_MAXDOUBLE
            || e->getMin().y < RS_MINDOUBLE
            || e->getMax().y < RS_MINDOUBLE)
        {
            removeEntity(e);
            how_many += 1;
        }
    }
    return how_many;
}
/**
 * Implementation of update. Updates the arrow.
 */
void RS_Leader::update() {

    // find and delete arrow:
    for (RS_Entity* e=firstEntity(); e!=NULL; e=nextEntity()) {
        if (e->rtti()==RS2::EntitySolid) {
            removeEntity(e);
            break;
        }
    }

    if (isUndone()) {
        setVisible(false);
        return;
    }

    RS_Entity* fe = firstEntity();
    if (fe!=NULL && fe->isAtomic()) {
        RS_Vector p1 = ((RS_AtomicEntity*)fe)->getStartpoint();
        RS_Vector p2 = ((RS_AtomicEntity*)fe)->getEndpoint();

        // first entity must be the line which gets the arrow:
        if (hasArrowHead()) {
            RS_Solid* s = new RS_Solid(this, RS_SolidData());
            s->shapeArrow(p1,
                          p2.angleTo(p1),
                          getGraphicVariableDouble("$DIMASZ", 2.5));
            s->setPen(RS_Pen(RS2::FlagInvalid));
            s->setLayer(NULL);
            RS_EntityContainer::addEntity(s);
        }
    }
}
Exemplo n.º 8
0
TEST(LuaUIOperationsTest, Rotate) {
	QApplication app(argc, argv);
	LuaInterface luaInterface;
	auto L = luaInterface.luaState();

	luaInterface.hideUI(true);
	luaInterface.initLua();

	auto mdiArea = LuaIntf::Lua::getGlobal<QMdiArea*>(L, "mdiArea");

	if(mdiArea->subWindowList().count() == 0) {
		LuaIntf::LuaRef(L, "new_file")();
	}

	mdiArea->setActiveSubWindow(mdiArea->subWindowList().at(0));

	auto mdiChild = dynamic_cast<CadMdiChild*>(mdiArea->activeSubWindow()->widget());
	auto storageManager = mdiChild->storageManager();
	auto documentCanvas = mdiChild->viewer()->documentCanvas();

	lc::entity::Line_CSPtr createdEntity;
	std::vector<lc::entity::CADEntity_CSPtr> entities;

	entities = storageManager->entityContainer().asVector();

	for(auto entity : entities) {
		storageManager->removeEntity(entity);
	}

	EXPECT_EQ(0, storageManager->entityContainer().asVector().size());



	LuaIntf::LuaRef(L, "create_line")();
	LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(0, 0));
	LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(100, 100));

	EXPECT_EQ(1, storageManager->entityContainer().asVector().size()) << "Line was not created";



	documentCanvas->makeSelection(0, 0, 100, 100, false, false);
	documentCanvas->closeSelection();

	EXPECT_EQ(1, mdiChild->selection().size()) << "Entity not selected";



	LuaIntf::LuaRef(L, "rotate_selected_entities")();
	LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(0, 0));
	LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(0, 100));
	LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(100, 0));

	entities = storageManager->entityContainer().asVector();
	createdEntity = std::dynamic_pointer_cast<const lc::entity::Line>(entities.at(0));

	EXPECT_EQ(lc::geo::Coordinate(0, 0), createdEntity->start());
	EXPECT_EQ(lc::geo::Coordinate(100, -100), createdEntity->end());
}
Exemplo n.º 9
0
void EntityManager::removeAllEntities()
{
  EntityArray tmp(entities_);
  EntityArray::iterator it = tmp.begin();
  for (; it != tmp.end(); ++it) {
    removeEntity(*it);
  }
}
Exemplo n.º 10
0
//////////////////////////////////////////////////////////////////////////
// removeAllEntities
void ScnCore::removeAllEntities()
{
	for( ScnEntityListIterator It( EntityList_.begin() ); It != EntityList_.end(); ++It )
	{
		ScnEntityRef Entity( *It );
		removeEntity( Entity );
	}
}
Exemplo n.º 11
0
void IfcPPModel::removeEntity( int entity_id )
{
	auto it_find = m_map_entities.find(entity_id);
	if( it_find != m_map_entities.end() )
	{
		shared_ptr<IfcPPEntity> entity_found = it_find->second;
		removeEntity( entity_found );
	}
}
Exemplo n.º 12
0
bool Scene::removePlayer(AvatarID avatarID)
{
    auto entity = getEntityByAvatarID(avatarID);
    if (entity)
    {
        return removeEntity(entity->_state.eid);
    }
    return false;
}
Exemplo n.º 13
0
void CHUD_Radar::setSubject(ILocalEntity * entity)
{
    m_subject = entity;

    // L'entité ne peut pas être dans la liste des entités suivies
    if (isEntity(m_subject))
    {
        removeEntity(m_subject);
    }
}
Exemplo n.º 14
0
void Map::visitEntities (IEntityVisitor *visitor, const EntityType& type)
{
	if (type == EntityType::NONE || type == EntityTypes::PLAYER) {
		bool needUpdate = false;
		for (PlayerListIter i = _players.begin(); i != _players.end();) {
			Player* e = *i;
			if (visitor->visitEntity(e)) {
				debug(LOG_SERVER, String::format("remove player by visit %i: %s", e->getID(), e->getType().name.c_str()));
				removeEntity(ClientIdToClientMask(e->getClientId()), *e);
				delete *i;
				i = _players.erase(i);
				needUpdate = true;
			} else {
				++i;
			}
		}
		if (needUpdate) {
			if (_players.empty()) {
				resetCurrentMap();
				return;
			}
		}
	}

	// changing the entities list is not allowed here. Adding or removing
	// would invalidate the iterators
	for (Map::EntityListIter i = _entities.begin(); i != _entities.end();) {
		IEntity* e = *i;
		if (type.isNone() || e->getType() == type) {
			if (visitor->visitEntity(e)) {
				debug(LOG_SERVER, String::format("remove entity by visit %i: %s", e->getID(), e->getType().name.c_str()));
				removeEntity(0, *e);
				(*i)->remove();
				delete *i;
				i = _entities.erase(i);
			} else {
				++i;
			}
		} else {
			++i;
		}
	}
}
Exemplo n.º 15
0
	void GameEntitySystem::removeDeadEntities()
	{
		std::list<int>::iterator listIterator;
		for(listIterator = deadList->begin(); listIterator != deadList->end(); ++listIterator)
		{
			removeEntity((*listIterator));
		}

		deadList->clear();
	}
Exemplo n.º 16
0
void EntityEngine::removeEntity(Entity * ent, Engines & e) {
// find the pointer
	auto it = std::find(getEntities().begin(), getEntities().end(), ent);

	if (it == getEntities().end()) {
		logging::Fatal() << "Could not find entity to remove in entity list";
	} else {
		removeEntity(it, e);
	}
}
Exemplo n.º 17
0
void Level::tick()
{
	trySpawn(1);

	int tilesTickAttempts = w * h / 50;
	for (int i = 0; i < tilesTickAttempts; ++i)
	{
		int xt = random->nextInt(w);
		int yt = random->nextInt(h);
		getTile(xt, yt)->tick(this, xt, yt);
	}
	for (list<Entity*>::iterator it = entities.begin(); it != entities.end(); it++ )
	{
		Entity * e = *it;
		int xto = e->x >> 4;
		int yto = e->y >> 4;

		e->tick();

		if (e->removed)
		{
			removeEntity(xto, yto, e);
			//we should not delete player, because it will freeze on death
			//we should not delete furniture, because it is used in FurnitureItem, when taken
			if (!e->instanceOf(PLAYER) && !e->instanceOf(FURNITURE))
				delete e;
			it = entities.erase(it);
		}
		else
		{
			int xt = e->x >> 4;
			int yt = e->y >> 4;

			if (xto != xt || yto != yt)
			{
				removeEntity(xto, yto, e);
				insertEntity(xt, yt, e);
			}
		}
	}
}
Exemplo n.º 18
0
void Mainscene::removeBullet(Bullet* b){
    std::vector< Bullet* >::iterator it = bullets.begin();
    while (it != bullets.end()) {
        if ((*it)->getEntityId() == b->getEntityId()) {
            removeEntity((*it));
            delete (*it);
            (*it) = NULL;
            it = bullets.erase(it);
        } else {
            ++it;
        }
    }
}
Exemplo n.º 19
0
void Mainscene::removeCloud(SimpleEntity* e){
    std::vector< SimpleEntity* >::iterator it = clouds.begin();
    while (it != clouds.end()) {
        if ((*it)->getEntityId() == e->getEntityId()) {
            removeEntity((*it));
            delete (*it);
            (*it) = NULL;
            it = clouds.erase(it);
        }else {
            ++it;
        }
    }
}
Exemplo n.º 20
0
void Mainscene::removeEnemy(Enemy* e){

    std::vector< Enemy* >::iterator it = enemies.begin();
    while (it != enemies.end()) {
        if ((*it)->getEntityId() == e->getEntityId()) {
            removeEntity((*it));
            delete (*it);
            (*it) = NULL;
            it = enemies.erase(it);
        }else {
            ++it;
        }
    }
}
Exemplo n.º 21
0
void Mainscene::removeTwinkle(Particle* p){
    std::vector< Particle* >::iterator it = twinkles.begin();
    while (it != twinkles.end()) {
        if ((*it)->getEntityId() == p->getEntityId()) {
            removeEntity((*it));
            delete (*it);
            (*it) = NULL;
            it = twinkles.erase(it);

        }else {
            ++it;
        }
    }
}
Exemplo n.º 22
0
void Level::remove(Entity * e)
{
	entities.remove(e);
//	for (list<Entity*>::iterator it = entities.begin(); it != entities.end(); it++ )
//	{
//		if (*it == e)
//		{
//			entities.erase(it);
//			break;
//		}
//	}
	int xto = e->x >> 4;
	int yto = e->y >> 4;
	removeEntity(xto, yto, e);
}
Exemplo n.º 23
0
void Scene::update()
{
	for ( std::list<Entity*>::iterator it = _entities.begin(); it != _entities.end(); it++ )
	{
		(*it)->update();
	}

	// Deletes entities pushed into _deleteEntities list
	for ( std::list<Entity*>::iterator it = _deleteEntities.begin(); it!= _deleteEntities.end(); it++)
	{
		removeEntity( (*it) );
	}

	_deleteEntities.clear();
}
Exemplo n.º 24
0
bool Scene::removePlayerByGroupID(GroupID groupID)
{
    std::set<EntityID> removes;
    for (auto entity : _entitys)
    {
        if (entity.second->_state.etype == ENTITY_PLAYER && entity.second->_state.groupID == groupID)
        {
            removes.insert(entity.second->_state.eid);
        }
    }
    for (auto eid : removes)
    {
        removeEntity(eid);
    }
    return true;
}
Exemplo n.º 25
0
/**
 * Removes the last vertex of this polyline.
 */
void RS_Polyline::removeLastVertex() {
        RS_Entity* last = lastEntity();
        if (last!=NULL) {
                removeEntity(last);
                last = lastEntity();
                if (last!=NULL) {
                        if (last->isAtomic()) {
                                data.endpoint = ((RS_AtomicEntity*)last)->getEndpoint();
                        }
                        else {
                                RS_DEBUG->print(RS_Debug::D_WARNING,
                                        "RS_Polyline::removeLastVertex: "
                                        "polyline contains non-atomic entity");
                        }
                }
        }
}
Exemplo n.º 26
0
void gep::HavokWorld::removeCharacter(ICharacterRigidBody* character)
{
    GEP_ASSERT(character != nullptr);

    size_t index;
    for (index = 0; index < m_characters.length(); ++index)
    {
        auto& characterPtr = m_characters[index];
        if (characterPtr.get() == character)
        {
            break;
        }
    }
    GEP_ASSERT(index < m_characters.length(), "Attempt to remove character from world that does not exist there", character, index, m_characters.length());
    m_characters.removeAtIndex(index);

    removeEntity(character->getRigidBody());
}
Exemplo n.º 27
0
Scene::~Scene() {

    _vm->_screen->setSmackerDecoder(NULL);

    if (_palette) {
        removeEntity(_palette);
        delete _palette;
    }

    // Delete all entities
    for (Common::Array<Entity*>::iterator iter = _entities.begin(); iter != _entities.end(); iter++)
        delete *iter;

    // Don't delete surfaces since they always belong to an entity

    // Purge the resources after each scene
    _vm->_res->purgeResources();

}
Exemplo n.º 28
0
/**
 * Ends polyline and adds the last entity if the polyline is closed
 */
void RS_Polyline::endPolyline() {
	RS_DEBUG->print("RS_Polyline::endPolyline");

    if (isClosed()) {
		RS_DEBUG->print("RS_Polyline::endPolyline: adding closing entity");
		
        // remove old closing entity:
        if (closingEntity!=NULL) {
            removeEntity(closingEntity);
        }

        // add closing entity to the polyline:
        closingEntity = createVertex(data.startpoint, nextBulge);
        if (closingEntity!=NULL) {
            RS_EntityContainer::addEntity(closingEntity);
            //data.endpoint = data.startpoint;
        }
    }
}
Exemplo n.º 29
0
	void RenderBoxWrap::removeNode(Ogre::SceneNode* _node)
	{
		//System::Console::WriteLine("remove node {0}", gcnew System::String(_node->getName().c_str()));

		while(_node->numAttachedObjects() != 0)
		{
			Ogre::MovableObject* object = _node->getAttachedObject(0);

			removeEntity(object->getName());
		}

		while (_node->numChildren() != 0)
		{
			Ogre::SceneNode* forDelete = (Ogre::SceneNode*)_node->getChild(0);

			removeNode(forDelete);
		}

		_node->getParentSceneNode()->removeAndDestroyChild(_node->getName());
	}
Exemplo n.º 30
0
void Scene1608::upUpperFloor() {
	Scene::update();
	if (_carStatus == 1) {
		removeSurface(_klaymen->getSurface());
		removeEntity(_klaymen);
		addSprite(_asCar);
		_klaymenInCar = true;
		clearRectList();
		SetUpdateHandler(&Scene1608::upCarAtHome);
		SetMessageHandler(&Scene1608::hmCarAtHome);
		_asIdleCarLower->setVisible(false);
		_asIdleCarFull->setVisible(false);
		_asCar->setVisible(true);
		sendMessage(_asCar, 0x2009, 0);
		_asCar->handleUpdate();
		_klaymen = NULL;
		_carStatus = 0;
	}
	updateKlaymenCliprect();
}