• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ WorldObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中WorldObject的典型用法代码示例。如果您正苦于以下问题:C++ WorldObject类的具体用法?C++ WorldObject怎么用?C++ WorldObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WorldObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: switch

void Garrison::Plot::DeleteGameObject(Map* map)
{
    if (BuildingInfo.Guid.IsEmpty())
        return;

    for (ObjectGuid const& guid : BuildingInfo.Spawns)
    {
        WorldObject* object = nullptr;
        switch (guid.GetHigh())
        {
            case HighGuid::Creature:
                object = map->GetCreature(guid);
                break;
            case HighGuid::GameObject:
                object = map->GetGameObject(guid);
                break;
            default:
                continue;
        }

        if (object)
            object->AddObjectToRemoveList();
    }

    BuildingInfo.Spawns.clear();

    if (GameObject* oldBuilding = map->GetGameObject(BuildingInfo.Guid))
        oldBuilding->Delete();

    BuildingInfo.Guid.Clear();
}
开发者ID:blitztech,项目名称:TrinityCore,代码行数:31,代码来源:Garrison.cpp


示例2: MoveShips

void Sim::MoveShips()
{
	for (int i = 0; i < ARRAYSIZE(mPlayers); ++i)
	{
		for (int j = 0; j < mPlayers[i].NumShips(); ++j)
		{
			if (mPlayers[i].GetShipHasTarget(j))
			{
				WorldObject* ship = mPlayers[i].GetShip(j);
				V2 target = mPlayers[i].GetShipTarget(j);
				V2 direction = (target - ship->pos).Normalize();
				V2 delta = direction * F32(.35f);
				V2 mappos = ToMap(ship->pos + delta);
				ship->GetSpriteInstance()->SetAnimation(MapDeltaToBoatAnimation(delta));
				if (mMap.Flags(mappos) & Map::Flag_Water)
				{
					ship->pos += delta;
					if ((ship->pos - target).LengthSq() < 2)
					{
						mPlayers[i].SetShipHasTarget(j, false);
					}
				}
			}
		}
	}
}
开发者ID:sgraham,项目名称:twinisles,代码行数:26,代码来源:sim.cpp


示例3: HandleObjectUpdate

void WorldSession::HandleObjectUpdate()
{
    uint64 GUID;
    uint8 UpdateField;

    RecPckt >> GUID;
    WorldObject* pObject = ObjectHolder<WorldObject>::Find(GUID);

    while (!RecPckt.EndOfPacket())
    {
        RecPckt >> UpdateField;
        switch (UpdateField)
        {
            case UPDATE_FIELD_X:
                uint16 x;
                RecPckt >> x;
                pObject->MoveX(x);
                break;
            case UPDATE_FIELD_Y:
                uint16 y;
                RecPckt >> y;
                pObject->MoveY(y);
                break;
            default:
                break;
        }
    }
}
开发者ID:krofna,项目名称:bamboo-copter,代码行数:28,代码来源:WorldSession.cpp


示例4: CHECK_WORLDOBJECT

Corpse* Eluna::CHECK_CORPSE(lua_State* L, int narg)
{
    WorldObject* obj = CHECK_WORLDOBJECT(L, narg);
    if (!obj)
        return NULL;
    return obj->ToCorpse();
}
开发者ID:Enno92,项目名称:TC-Eluna-3.3.5a,代码行数:7,代码来源:LuaEngine.cpp


示例5: DumpWorldToSyncLog

void DumpWorldToSyncLog( char *_filename )
{
    FILE *file = fopen( _filename, "a" );
    if( !file ) return;

    fprintf( file, "\n\nBegin Final Object Positions\n" );

    for( int i = 0; i < g_app->GetWorld()->m_teams.Size(); ++i )
    {
        Team *team = g_app->GetWorld()->m_teams[i];
        for( int j = 0; j < team->m_fleets.Size(); ++j )
        {
            Fleet *fleet = team->m_fleets[j];
            char *state = fleet->LogState();
            fprintf( file, "%s\n", state );
        }
    }

    for( int i = 0; i < g_app->GetWorld()->m_objects.Size(); ++i )
    {
        if( g_app->GetWorld()->m_objects.ValidIndex(i) )
        {
            WorldObject *obj = g_app->GetWorld()->m_objects[i];
            char *state = obj->LogState();
            fprintf( file, "%s\n", state );
        }
    }

    fclose(file);
}
开发者ID:cahocachi,项目名称:DEFCON,代码行数:30,代码来源:defcon.cpp


示例6: p

bool World::move(WorldObject* const worldObject, const int direction,
				 const int maxPower, int& usedPower)
{
	Position p(0,0);
	WorldObject *object;

	WorldObjectList* list;
	if ( maxPower < usedPower)
		return false;
	p.x = worldObject->p->x;
	p.y = worldObject->p->y;

	Direction::computePosition(&p,direction);
	if (checkPosition(&p) == false ) 
		return false;

	list = world[p.x][p.y];
	list->setToFirst();
	while(object = list->getNext())
		if(!object->conditionalMovement(worldObject,direction,maxPower,usedPower))
			return false;
		if(!moveObject(worldObject,direction))
			return false;
	return true;
}
开发者ID:tomasz-kucharski,项目名称:robocode,代码行数:25,代码来源:World.cpp


示例7: WorldObject

/**
 * Adds current path to WorldObjectManager's list. Note how we copy all the local
 * to a new instance of a path world object.
 */
bool PathTool::addCurrent()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    bool returnValue = true;

    //only add path if it has more than 1 point
    if (mCurrentNumberOfPoints > 1)
    {
        WorldObject* worldObject = new WorldObject();
        worldObject->setName(mName);
        worldObject->setColor(mColor);
        worldObject->setGroup(WorldObject::PATH);

        //instantiate path renderer and associate it with world object
        PathRenderer* pathRenderer = new PathRenderer();
        for (int i = 0; i < mCurrentNumberOfPoints; i++)
        {
            pathRenderer->addPoint(mPoints[i]);
        }
        worldObject->setMeshRenderer(pathRenderer);

        //if object already exists (cannot add) perform cleanup
        if (!WorldObjectManager::getInstance()->addWorldObject(worldObject))
        {
            //note: the path renderer that we associated with this world
            //object will get deleted on the world object's destructor
            delete worldObject;
            returnValue = false;
        }
    }

    return returnValue;
}
开发者ID:hmendoza2001,项目名称:SimpleEarth,代码行数:37,代码来源:PathTool.cpp


示例8: scoreEvaluator

int ActionCover::scoreEvaluator(Actor* actor,Action* action)
{
	ActionCover* self = static_cast<ActionCover*>(action);
	Anchor* resAnchor = NULL;

	WorldObject* enemy = actor->getEnemy();
	if (!enemy)
		return 0;

	if (self->m_attackInfo && !self->m_attackInfo->coverState.empty())
	{
		//check if there is anchor hereabout
		Anchors& anchors = Anchor::getAnchors();
		for (size_t i=0; i<anchors.size(); i++)
		{
			Anchor* anchor = anchors[i];
			float distToEnemySq = (anchor->getPos() - enemy->getPos()).lengthSq();
			if (distToEnemySq < MIN_DIST_TO_ENEMY*MIN_DIST_TO_ENEMY)
				continue;

			//.todo: check conditions(i.e. reasonable distance, availability, etc)
			if (anchor->isVacant(actor))
			{
				resAnchor = anchor;
				break;
			}
		}
	}

	if (resAnchor)
		return 5;
	else
		return 0;
}
开发者ID:Duion,项目名称:GuideBot,代码行数:34,代码来源:actionFight.cpp


示例9: anchorRankEvaluator

float ActionCover::anchorRankEvaluator(Anchor* anchor)
{
	float rank = -1.f;
	if (anchor->isVacant(m_owner))
	{
		float dist = anchor->getDistSq(m_owner->getPos());

		WorldObject* enemy = m_owner->getEnemy();
		if (!enemy)
			return rank;
		float distToEnemySq = (anchor->getPos() - enemy->getPos()).lengthSq();
		if (distToEnemySq < MIN_DIST_TO_ENEMY*MIN_DIST_TO_ENEMY)
			return rank;

		if (dist < MAX_DIST_TO_ANCHOR*MAX_DIST_TO_ANCHOR)
		{
			rank = 1.f/dist;

			AnchorStatMap::iterator it = m_anchorStat.find(anchor);
			unsigned int occupancyTime = it!=m_anchorStat.end() ? it->second : 0;
			float occupancyTimeSec = (float) occupancyTime / 1000.f;
			if (m_anchor == anchor && occupancyTimeSec < 10.f)
			{
				rank += 5.f; //persistence
			}
			else if(m_anchor != anchor && occupancyTimeSec < 5.f)
			{
				rank += 5.f - occupancyTimeSec;
			}
		}
	}

	return rank;
};
开发者ID:Duion,项目名称:GuideBot,代码行数:34,代码来源:actionFight.cpp


示例10: mousePressed

	//---------------------------------------------------------------------------
	MouseEventResult SelectingObjectsWithMouse::mousePressed( const MouseEvent& _evt )
	{
		World* world = WorldManager::getSingleton().getActiveWorld();
		if(!world)
			return MouseEventResult::NOT_PROCESSED;

		Camera* camera = world->getCamera();
		SceneManagerEx* sm = world->getSceneManager();

		RaySceneQueryExPtr q = sm->createRayQueryEx(_evt.getAbsX(), _evt.getAbsY(), world->getViewportAbsCoord(), camera);
		q->setQueryTypeMask( SceneQueryMask::VOB | SceneQueryMask::INVISIBLE_IN_GAME );
		q->setMaxResults(1);
		RaySceneQueryExResult& result = q->execute();

		world->deselectAll();

		if(!result.empty())
		{
			WorldObject* worldObject = WorldObject::getFromMovableObject(result.front().movable);
			if(worldObject)
				worldObject->select();
		}

		return MouseEventResult::PROCESSED;
	}
开发者ID:raduetsya,项目名称:GothOgre,代码行数:26,代码来源:SelectingObjectsWithMouse.cpp


示例11: SetTransportData

void MoveSplineInitArgs::SetTransportData(Unit& unit)
{
    WorldObject* transport = NULL;
    ObjectGuid _transportGuid = unit.GetTransportGuid();
    switch(_transportGuid.GetHigh())
    {
        case HIGHGUID_PLAYER:
        case HIGHGUID_VEHICLE:
            transport = unit.GetMap()->GetUnit(_transportGuid);
            break;
        case HIGHGUID_MO_TRANSPORT:
            transport = unit.GetMap()->GetTransport(_transportGuid);
            break;
        case HIGHGUID_TRANSPORT:
            transport = unit.GetMap()->GetGameObject(_transportGuid);
            break;
    }

    if (!transport)
    {
        ERROR_LOG("MoveSplineInitArgs: Unsupported transport %s for %s", _transportGuid.GetString().c_str(), unit.GetObjectGuid().GetString().c_str());
        return;
    }
    else
        DEBUG_LOG("MoveSplineInitArgs: Set transport %s for %s", _transportGuid.GetString().c_str(), unit.GetObjectGuid().GetString().c_str());

    transportGuid = _transportGuid.GetRawValue();
    transportSeat = unit.GetTransSeat();
    transportPos = Location(transport->GetPositionX(), transport->GetPositionY(), transport->GetPositionZ(), transport->GetOrientation());
}
开发者ID:Calixa,项目名称:murlocs_434,代码行数:30,代码来源:MoveSpline.cpp


示例12: GetOwner

// Update the global position of a passenger
void TransportBase::UpdateGlobalPositionOf(ObjectGuid const& passengerGuid, Position const& pos) const
{
    WorldObject* passenger = GetOwner()->GetMap()->GetWorldObject(passengerGuid);

    if (!passenger)
        return;

    Position g = CalculateGlobalPositionOf(pos);

    switch(passenger->GetTypeId())
    {
        case TYPEID_GAMEOBJECT:
        case TYPEID_DYNAMICOBJECT:
            m_owner->GetMap()->Relocation((GameObject*)passenger, g);
            break;
        case TYPEID_UNIT:
            m_owner->GetMap()->Relocation((Creature*)passenger, g);
            // If passenger is vehicle
            if (((Unit*)passenger)->IsVehicle())
                ((Unit*)passenger)->GetVehicleKit()->UpdateGlobalPositions();
            break;
        case TYPEID_PLAYER:
            m_owner->GetMap()->Relocation((Player*)passenger, g);
            // If passenger is vehicle
            if (((Unit*)passenger)->IsVehicle())
                ((Unit*)passenger)->GetVehicleKit()->UpdateGlobalPositions();
            break;
        case TYPEID_CORPSE:
        // TODO - add corpse relocation
        default:
            break;
    }
}
开发者ID:BACKUPLIB,项目名称:Infinity_MaNGOS,代码行数:34,代码来源:TransportSystem.cpp


示例13: Vector

void ClusterBomb::explode()
{
#ifdef DEBUG
//  printf("ClusterBomb just exploded!\n");
#endif
  WorldObject * wo;
  float angle = 6.28318 / BOMB_PIECES;
  Vector a = Vector(1, 0, 0);
  Vector b = Vector(0, 0, 1);
  Vector c = Vector(0, .1, 0);
  float mag = global::factory->getBlueprint(type).getSize().mag() / 4;
  Vector off;
  for (int i = 0; i < BOMB_PIECES; i++)
  {
    wo = new WorldObject(0, 0, DUMMY_SPHERE);
    off = a * mag * sin(i * angle) + b * mag * cos(i * angle) + c;
    wo->setPosition(position + off);
    wo->setVelocity(velocity + off);
    networkManager->network->getPhysicsPtr()->insertWorldObject(wo);
    wo = new WorldObject(0, 0, DUMMY_SPHERE);
    off = a * mag * cos(i * angle) + b * mag * sin(i * angle) - c;
    wo->setPosition(position + off);
    wo->setVelocity(velocity + off);
    networkManager->network->getPhysicsPtr()->insertWorldObject(wo);
  }
}
开发者ID:cgibson,项目名称:2cities,代码行数:26,代码来源:ClusterBomb.cpp


示例14: massiveDamage

void World::massiveDamage(const Vec2 &pos, int range, int damage)
{
    // Пробегаем по всем объектам.
    for ( std::list< WorldObject* >::iterator it = items.begin();
          it != items.end();
          ++it )
    {

        // Нас интересуют пони.
        if ( ( *it )->isTargetable() )
        {
            WorldObject* unit = *it;

            // Интересуют только живые пони.
            if ( !unit->isDead() )
            {
                // Находим расстояние до этого пони.
                double distance = unit->getPos().distance(pos);

                // Если зацепили пони.
                if ( distance < range )
                {
                    unit->hit( static_cast< int > ( damage ) );
                }
            }
        }
    }
}
开发者ID:vladimirgamalian,项目名称:neopedersia,代码行数:28,代码来源:World.cpp


示例15:

WorldObject *World::getNearestTarget(const Vec2 &pos, int range)
{
    double minRange = 100000000;
    WorldObject *target = nullptr;

    for (std::list<WorldObject *>::iterator it = items.begin();
         it != items.end();
         ++it)
    {
        WorldObject *unit = *it;

        if (!unit->isTargetable())
            continue;

        if (unit->isDead())
            continue;

        double distance = pos.distance(unit->getPos());
        if (distance < range)
        {
            if (distance < minRange)
            {
                minRange = distance;
                target = unit;
            }
        }
    }

    return target;
}
开发者ID:vladimirgamalian,项目名称:neopedersia,代码行数:30,代码来源:World.cpp


示例16: HandleMmapTestArea

    static bool HandleMmapTestArea(ChatHandler* handler, char const* /*args*/)
    {
        float radius = 40.0f;
        WorldObject* object = handler->GetSession()->GetPlayer();

        // Get Creatures
        std::list<Creature*> creatureList;
        Trinity::AnyUnitInObjectRangeCheck go_check(object, radius);
        Trinity::CreatureListSearcher<Trinity::AnyUnitInObjectRangeCheck> go_search(object, creatureList, go_check);
        Cell::VisitGridObjects(object, go_search, radius);

        if (!creatureList.empty())
        {
            handler->PSendSysMessage("Found %zu Creatures.", creatureList.size());

            uint32 paths = 0;
            uint32 uStartTime = getMSTime();

            float gx, gy, gz;
            object->GetPosition(gx, gy, gz);
            for (std::list<Creature*>::iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr)
            {
                PathGenerator path(*itr);
                path.CalculatePath(gx, gy, gz);
                ++paths;
            }

            uint32 uPathLoadTime = getMSTimeDiff(uStartTime, getMSTime());
            handler->PSendSysMessage("Generated %i paths in %i ms", paths, uPathLoadTime);
        }
        else
            handler->PSendSysMessage("No creatures in %f yard range.", radius);

        return true;
    }
开发者ID:090809,项目名称:TrinityCore,代码行数:35,代码来源:cs_mmaps.cpp


示例17: boardComputer

float FighterFightTask::angleToTarget() {
    WorldObject* worldObject = boardComputer()->worldObject();
    glm::vec3 shipDirection = glm::vec3(0, 0, -1);
    glm::vec3 targetDirection = glm::inverse(worldObject->transform().orientation()) * safeNormalize(m_primaryTarget->transform().position() - worldObject->transform().position(), glm::vec3(0, 0, 1));
    float angle = GeometryHelper::angleBetween(shipDirection, targetDirection);
    return glm::degrees(angle);
}
开发者ID:voxelinc,项目名称:voxellancer,代码行数:7,代码来源:fighterfighttask.cpp


示例18: draw

void Symmetry::draw(ShaderProgram*  shader) {
	for (Map::iterator it = originalObjects->begin(); it != originalObjects->end(); ++it) {
		WorldObject * wo = it->second;
		//wo->setPosTrans(transform());
		wo->draw(shader);
		//wo->setPosTrans(glm::mat4(1.0f));
	}
}
开发者ID:pedroth,项目名称:AVT,代码行数:8,代码来源:Symmetry.cpp


示例19: while

void Transport::UnloadStaticPassengers()
{
    while (!_staticPassengers.empty())
    {
        WorldObject* obj = *_staticPassengers.begin();
        obj->AddObjectToRemoveList();   // also removes from _staticPassengers
    }
}
开发者ID:Caydan,项目名称:WoWSCore548,代码行数:8,代码来源:Transport.cpp


示例20: applyLights

/**
  Walk recursively through a node and switch on all lights.

  \param node World object to search for lights
 */
void GLRenderInstance::applyLights(WorldObject& node)
{
  double M[16];
  int idx=0;

  WorldObject::ChildIterator it;
  for(it=node.childsBegin(); it!=node.childsEnd(); it++)
  {
    glPushMatrix();
    // Set the local transformation
    it->second->localTransform().toList(M);
    glMultMatrixd(M);

    // Check if the object is a light source...
    LightSource* lgt = dynamic_cast<LightSource*>(it->second.get());
    if (lgt!=0)
    {
      // Is it a point light?
      GLPointLight* pntlgt = dynamic_cast<GLPointLight*>(lgt);
      if (pntlgt!=0)
      {
        if (pntlgt->enabled.getValue())
        {
          pntlgt->applyGL(idx);
          glEnable(GL_LIGHT0+idx);
          idx++;
        }
      }
      // Is it a spot light?
      GLSpotLight* spotlgt = dynamic_cast<GLSpotLight*>(lgt);
      if (spotlgt!=0)
      {
        if (spotlgt->enabled.getValue())
        {
          spotlgt->applyGL(idx);
          glEnable(GL_LIGHT0+idx);
          idx++;
        }
      }
      // Is it a distant light?
      GLDistantLight* dstlgt = dynamic_cast<GLDistantLight*>(lgt);
      if (dstlgt!=0)
      {
        if (dstlgt->enabled.getValue())
        {
          dstlgt->applyGL(idx);
          glEnable(GL_LIGHT0+idx);
          idx++;
        }
      }
    }

    // Search the children for lights
    applyLights(*(it->second));
    glPopMatrix();
  }
}
开发者ID:behnam,项目名称:cgkit,代码行数:62,代码来源:glrenderer.cpp



注:本文中的WorldObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WorldPacket类代码示例发布时间:2022-05-31
下一篇:
C++ WorldModel类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap