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

C++ Thing类代码示例

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

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



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

示例1: popNumber

int NpcScriptInterface::luagetDistanceTo(lua_State *L)
{
	//getDistanceTo(uid)
	uint32_t uid = popNumber(L);

	ScriptEnviroment* env = getScriptEnv();

	Npc* npc = env->getNpc();
	Thing* thing = env->getThingByUID(uid);
	if(thing && npc){
		Position thing_pos = thing->getPosition();
		Position npc_pos = npc->getPosition();
		if(npc_pos.z != thing_pos.z){
			lua_pushnumber(L, -1);
		}
		else{
			int32_t dist = std::max(std::abs(npc_pos.x - thing_pos.x), std::abs(npc_pos.y - thing_pos.y));
			lua_pushnumber(L, dist);
		}
	}
	else{
		reportErrorFunc(getErrorDesc(LUA_ERROR_THING_NOT_FOUND));
		lua_pushnil(L);
	}

	return 1;
}
开发者ID:cp1337,项目名称:devland,代码行数:27,代码来源:npc.cpp


示例2: getNextPosition

void Commands::removeThing(Player* player, const std::string& cmd, const std::string& param)
{
	Position pos = player->getPosition();
	pos = getNextPosition(player->direction, pos);
	Tile* removeTile = g_game.getMap()->getTile(pos);
	if (!removeTile) {
		player->sendTextMessage(MSG_STATUS_SMALL, "Tile not found.");
		g_game.addMagicEffect(pos, NM_ME_POFF);
		return;
	}

	Thing* thing = removeTile->getTopVisibleThing(player);
	if (!thing) {
		player->sendTextMessage(MSG_STATUS_SMALL, "Object not found.");
		g_game.addMagicEffect(pos, NM_ME_POFF);
		return;
	}

	if (Creature* creature = thing->getCreature()) {
		g_game.removeCreature(creature, true);
	} else {
		Item* item = thing->getItem();
		if (item) {
			if (item->isGroundTile()) {
				player->sendTextMessage(MSG_STATUS_SMALL, "You may not remove a ground tile.");
				g_game.addMagicEffect(pos, NM_ME_POFF);
				return;
			}

			g_game.internalRemoveItem(item, std::max<int32_t>(1, std::min<int32_t>(atoi(param.c_str()), item->getItemCount())));
			g_game.addMagicEffect(pos, NM_ME_MAGIC_BLOOD);
		}
	}
}
开发者ID:KnightLogini,项目名称:forgottenserver,代码行数:34,代码来源:commands.cpp


示例3: getScriptEnv

int NpcScriptInterface::luagetDistanceTo(lua_State* L)
{
    //getDistanceTo(uid)
    ScriptEnvironment* env = getScriptEnv();

    Npc* npc = env->getNpc();
    if (!npc) {
        reportErrorFunc(getErrorDesc(LUA_ERROR_THING_NOT_FOUND));
        lua_pushnil(L);
        return 1;
    }

    uint32_t uid = getNumber<uint32_t>(L, -1);

    Thing* thing = env->getThingByUID(uid);
    if (!thing) {
        reportErrorFunc(getErrorDesc(LUA_ERROR_THING_NOT_FOUND));
        lua_pushnil(L);
        return 1;
    }

    const Position& thingPos = thing->getPosition();
    const Position& npcPos = npc->getPosition();
    if (npcPos.z != thingPos.z) {
        lua_pushnumber(L, -1);
    } else {
        int32_t dist = std::max<int32_t>(Position::getDistanceX(npcPos, thingPos), Position::getDistanceY(npcPos, thingPos));
        lua_pushnumber(L, dist);
    }
    return 1;
}
开发者ID:marksamman,项目名称:forgottenserver,代码行数:31,代码来源:npc.cpp


示例4: collect_garbage

void WebThings::collect_garbage()
{
    if (stale_count) {
        // mark all nodes reachable from the roots
        for (Thing *t = things; t; t = (Thing *)t->next)
            t->reachable(gc_phase);
/*
        for (Proxy *proxy = proxies; proxy; proxy = (Proxy *)proxy->next) {
            reachable(proxy->properties);
            reachable(proxy->proxies);
        }
*/

        // now sweep through the nodes reachable from the stale list
        // and delete the ones that aren't reachable from the roots
        for (unsigned int i = 0; i < stale_count; ++i) {
            JSON *json = get_json(stale[i]);
        
            if (!json->marked(gc_phase)) {
                json->sweep(gc_phase);
                for (unsigned int j = i; j < stale_count - 1; ++j)
                    stale[j] = stale[j+1];
                --stale_count;
            }
        }
        
        gc_phase = !gc_phase;
        JSON::set_gc_phase(gc_phase); // to ensure new nodes are marked correctly
    }
}
开发者ID:w3c,项目名称:wot-arduino,代码行数:30,代码来源:WebThings.cpp


示例5: main

// -------------------------------------------------------------
//  Main Program
// -------------------------------------------------------------
int
main(int argc, char **argv)
{
  Thing thing;
  thing.message();
  return 0;
}
开发者ID:Anastien,项目名称:GridPACK,代码行数:10,代码来源:thingc.cpp


示例6: getEvent

uint32_t MoveEvents::onCreatureMove(Creature* creature, Tile* tile, bool isIn)
{
	MoveEvent_t eventType;
	if(isIn){
		eventType = MOVE_EVENT_STEP_IN;
	}
	else{
		eventType = MOVE_EVENT_STEP_OUT;
	}

	uint32_t ret = 1;
	MoveEvent* moveEvent = getEvent(tile, eventType);
	if(moveEvent){
		ret = ret & moveEvent->fireStepEvent(creature, NULL, tile->getPosition());
	}

	int32_t j = tile->__getLastIndex();
	Item* tileItem = NULL;
	for(int32_t i = tile->__getFirstIndex(); i < j; ++i){
		Thing* thing = tile->__getThing(i);
		if(thing && (tileItem = thing->getItem())){
			moveEvent = getEvent(tileItem, eventType);
			if(moveEvent){
				ret = ret & moveEvent->fireStepEvent(creature, tileItem, tile->getPosition());
			}
		}
	}
	return ret;
}
开发者ID:WeDontGiveAF,项目名称:OOServer,代码行数:29,代码来源:movement.cpp


示例7: menuWindow

void Kernel::handleMotionNotify(XMotionEvent *event) {

    Menu *menu = menuWindow(event->window);
    if (menu) {
        menu->handleMotionNotify(event);
    }

    Bar *bar = barWindow(event->window);
    if (bar) {
        bar->handleMotionNotify(event);
        return;
    }

    Thing *thing = thingWindow(event->window);
    if (thing) {
        if (!thing->isFocused() && isSloppyMode_) {
            Workspace *workspace = focusedMonitor()->focused();
            workspace->focus(thing, false);
        }
        thing->handleMotionNotify(event);
    }

    // focusses the monitor if multihead
    isRootWindow(event->root);
}
开发者ID:edmondas,项目名称:ncwm,代码行数:25,代码来源:kernel.cpp


示例8: getEvent

uint32_t MoveEvents::onCreatureMove(Creature* creature, const Tile* tile, bool isIn)
{
	MoveEvent_t eventType;

	if (isIn) {
		eventType = MOVE_EVENT_STEP_IN;
	} else {
		eventType = MOVE_EVENT_STEP_OUT;
	}

	Position pos = tile->getPosition();

	uint32_t ret = 1;

	MoveEvent* moveEvent = getEvent(tile, eventType);
	if (moveEvent) {
		ret = ret & moveEvent->fireStepEvent(creature, nullptr, pos);
	}

	for (int32_t i = tile->__getFirstIndex(), j = tile->__getLastIndex(); i < j; ++i) {
		Thing* thing = tile->__getThing(i);
		if (thing) {
			Item* tileItem = thing->getItem();
			if (tileItem) {
				moveEvent = getEvent(tileItem, eventType);
				if (moveEvent) {
					ret = ret & moveEvent->fireStepEvent(creature, tileItem, pos);
				}
			}
		}
	}

	return ret;
}
开发者ID:AhmedWaly,项目名称:forgottenserver,代码行数:34,代码来源:movement.cpp


示例9: lua_gettop

   int LuaThing::getAliases(lua_State *L) {

      int n = lua_gettop(L);

      if (1 != n) {
         return luaL_error(L, "takes no arguments");
      }

      Thing *t = checkThing(L, -1);

      if (0 == t) {
         return luaL_error(L, "not a Thing!");
      }

      LuaArray luaAliases;
      vector<string> aliases = t->getAliases();

      for (vector<string>::const_iterator i = aliases.begin(); i != aliases.end(); i++) {

         LuaValue v;

         v.type = LUA_TYPE_STRING;
         v.value = *i;

         luaAliases.insert(luaAliases.end(), v);
      }

      LuaState::pushArray(L, luaAliases);
      return 1;
   }
开发者ID:Ockin,项目名称:trogdor-pp,代码行数:30,代码来源:luathing.cpp


示例10: getEvent

uint32_t MoveEvents::onCreatureMove(Creature* creature, const Tile* tile, const Position& fromPos, MoveEvent_t eventType)
{
	const Position& pos = tile->getPosition();

	uint32_t ret = 1;

	MoveEvent* moveEvent = getEvent(tile, eventType);
	if (moveEvent) {
		ret &= moveEvent->fireStepEvent(creature, nullptr, pos, fromPos);
	}

	for (size_t i = tile->getFirstIndex(), j = tile->getLastIndex(); i < j; ++i) {
		Thing* thing = tile->getThing(i);
		if (!thing) {
			continue;
		}

		Item* tileItem = thing->getItem();
		if (!tileItem) {
			continue;
		}

		moveEvent = getEvent(tileItem, eventType);
		if (moveEvent) {
			ret &= moveEvent->fireStepEvent(creature, tileItem, pos, fromPos);
		}
	}
	return ret;
}
开发者ID:ricardosohn,项目名称:forgottenserver,代码行数:29,代码来源:movement.cpp


示例11: MultiLockUnsafeThread

void * MultiLockUnsafeThread( void * p )
{

    const unsigned int value = reinterpret_cast< unsigned int >( p );
    Thing * thing = nullptr;
    unsigned int jj = 0;
    unsigned int tests = 0;
    unsigned int fails = 0;
    unsigned int randomIndex = 0;
    try
    {
        for ( unsigned int ii = 0; ii < thingCount; ++ii )
        {
            for ( jj = 0; jj < thingCount; ++jj )
            {
                thing = const_cast< Thing * >( Thing::GetFromPool( jj ) );
                assert( nullptr != thing );
                thing->SetValue( value );
            }
            ::GoToSleep( 2 );

            if ( WillRedoSingleTests() )
            {
                SingleThreadSimpleTest();
                SingleThreadReentrantTest();
                SingleThreadSimpleMultiLockTest();
                SingleThreadComplexMultiLockTest( false );
                SingleThreadExceptionTest();
            }

            thing = const_cast< Thing * >( Thing::GetFromPool( ii ) );
            assert( nullptr != thing );
            thing->Print( value, ii, 7 );
            randomIndex = ( ::rand() % thingCount );
            thing = const_cast< Thing * >( Thing::GetFromPool( randomIndex ) );
            assert( nullptr != thing );
            thing->Print( value, ii, 7 );

            for ( jj = 0; jj < thingCount; ++jj )
            {
                thing = const_cast< Thing * >( Thing::GetFromPool( jj ) );
                assert( nullptr != thing );
                if ( thing->GetValue() != value )
                    fails++;
                tests++;
            }

            ::GoToSleep( 2 );
        }
    }
    catch ( ... )
    {
        assert( false );
    }

    TestResults::GetIt()->SetResult( value, tests, fails );

    return nullptr;
}
开发者ID:AFialkovskiy,项目名称:loki-lib,代码行数:59,代码来源:MultiThreadTests.cpp


示例12: getParent

Container* Container::getParentContainer()
{
	Thing* thing = getParent();
	if (!thing) {
		return nullptr;
	}
	return thing->getContainer();
}
开发者ID:otland,项目名称:forgottenserver,代码行数:8,代码来源:container.cpp


示例13: getParent

Container* Container::getParentContainer()
{
	Thing* thing = getParent();
	if (thing) {
		return thing->getContainer();
	}
	return NULL;
}
开发者ID:Remoq7,项目名称:forgottenserver,代码行数:8,代码来源:container.cpp


示例14: getTilePosition

Cylinder* Tile::__queryDestination(int32_t& index, const Thing* thing, Item** destItem,
	uint32_t& flags)
{
	Tile* destTile = NULL;
	*destItem = NULL;

	if(floorChangeDown()){
		int dx = getTilePosition().x;
		int dy = getTilePosition().y;
		int dz = getTilePosition().z + 1;
		Tile* downTile = g_game.getTile(dx, dy, dz);

		if(downTile){
			if(downTile->floorChange(NORTH))
				dy += 1;
			if(downTile->floorChange(SOUTH))
				dy -= 1;
			if(downTile->floorChange(EAST))
				dx -= 1;
			if(downTile->floorChange(WEST))
				dx += 1;
			destTile = g_game.getTile(dx, dy, dz);
		}
	}
	else if(floorChange()){
		int dx = getTilePosition().x;
		int dy = getTilePosition().y;
		int dz = getTilePosition().z - 1;

		if(floorChange(NORTH))
			dy -= 1;
		if(floorChange(SOUTH))
			dy += 1;
		if(floorChange(EAST))
			dx += 1;
		if(floorChange(WEST))
			dx -= 1;
		destTile = g_game.getTile(dx, dy, dz);
	}


	if(destTile == NULL){
		destTile = this;
	}
	else{
		flags |= FLAG_NOLIMIT; //Will ignore that there is blocking items/creatures
	}

	if(destTile){
		Thing* destThing = destTile->getTopDownItem();
		if(destThing)
			*destItem = destThing->getItem();
	}

	return destTile;
}
开发者ID:angeliker,项目名称:OTHire,代码行数:56,代码来源:tile.cpp


示例15: collidesWith

bool Thing::collidesWith(Thing &thing)
{
	if(this->hp == 0 || thing.hp == 0)
		return false;
	
	return this->_collissionCheck(
		this->x, this->y, this->x + this->width(), this->y + this->height(),
		thing.x, thing.y, thing.x + thing.width(), thing.y + thing.height()
	);
}
开发者ID:uppfinnarn,项目名称:simple-psp-game,代码行数:10,代码来源:Thing.cpp


示例16: MultiLockRandomUnsafeThread

void * MultiLockRandomUnsafeThread( void * p )
{
    const unsigned int value = reinterpret_cast< unsigned int >( p );
    unsigned int testCount = 0;
    unsigned int failCount = 0;
    Thing * thing = nullptr;
    UnsafeThingPool pool;

    unsigned int jj = 0;
    unsigned int place = 0;
    try
    {
        for ( unsigned int ii = 0; ii < thingCount; ++ii )
        {

            pool.clear();
            pool.reserve( thingCount );
            for ( place = 0; place < thingCount; ++place )
            {
                place += ::rand() % 3;
                if ( thingCount <= place )
                    break;
                thing = const_cast< Thing * >( Thing::GetFromPool( place ) );
                assert( nullptr != thing );
                pool.push_back( thing );
            }
            const unsigned int poolCount = pool.size();

            for ( jj = 0; jj < poolCount; ++jj )
            {
                thing = pool[ jj ];
                assert( nullptr != thing );
                thing->SetValue( value );
            }
            ::GoToSleep( 3 );

            for ( jj = 0; jj < poolCount; ++jj )
            {
                thing = pool[ jj ];
                assert( nullptr != thing );
                if ( thing->GetValue() != value )
                    failCount++;
                testCount++;
            }
        }
    }
    catch ( ... )
    {
        assert( false );
    }

    TestResults::GetIt()->SetResult( value, testCount, failCount );

    return nullptr;
}
开发者ID:AFialkovskiy,项目名称:loki-lib,代码行数:55,代码来源:MultiThreadTests.cpp


示例17: switch

int Structure::Place(Cell *targ)  {
  int alt=-100000, malt = 0;
  if(stgr[struct_type][material][2][0][0] == NULL)  return 0;
  switch(struct_type)  {
    case(STRUCT_RAMP):
    case(STRUCT_WALL):  {
      if(targ->Terrain() ==TERRAIN_LOWWATER || targ->Terrain() ==TERRAIN_WATER
	|| targ->Terrain() == TERRAIN_OCEAN) return 0;
      }break;
    case(STRUCT_BRIDGE):  {
      int ctr;
      flying = 1;
      for(ctr=0; ctr<12 && alt<=-100000; ctr+=2)  {
	Thing *tmpt = targ->Next(ctr)->Inside(0);
	while(tmpt != NULL)  {
	  if(tmpt->Type() == THING_STRUCT &&
		((Structure*)tmpt)->StructType() == STRUCT_BRIDGE)  {
	    alt = ((Structure*)tmpt)->altitude;
//	    printf("Set relative bridge alt to %d.\r\n", alt);
	    }
	  tmpt = tmpt->Inside(0);
	  }
	}
      if(alt <= -100000 && targ->Terrain() !=TERRAIN_LOWWATER
		&& targ->Terrain() !=TERRAIN_WATER
		&& targ->Terrain() != TERRAIN_OCEAN)  {
	Thing *tmpt = targ;
	while(tmpt->Inside(0) != NULL)  tmpt = tmpt->Inside(0);
	if(tmpt->Type() == THING_CELL || tmpt->Type() == THING_STRUCT)  {
	  alt = tmpt->Height();
	  break;
	  }
	return 0;
	}
      if(alt <= -100000) return 0;
      }break;
    }
  if(alt <= -100000) alt = targ->Height();
  else malt = alt-targ->Height();
  if(malt < 0) return 0;

//  printf("Attempting to claim for struct!\r\n");
  if(!(targ->Claim(this, alt, height, 0, malt)))  return 0;
//  printf("Attempting to enter for struct!\r\n");
  if(!(targ->Enter(this, alt, height, 0, malt)))  {
    targ->UnClaim(this);
    return 0;
    }
//  printf("Success!\r\n");
  targ->UnClaim(this);
  location[0] = targ;
  Changed[thingnum] = 1;
  if(struct_type == STRUCT_BRIDGE)  {
    altitude = alt;
//    printf("Placing Struct at altitude %d\r\n", altitude);
    }
  InitNeighbors();
  return 1;
  }
开发者ID:steaphangreene,项目名称:dg2,代码行数:59,代码来源:struct.cpp


示例18: Thing

Thing* Thing::create(ThingType type)
{
	Thing* thing = new Thing(type);
	if(thing && thing->init())
	{
		thing->autorelease();
		return thing;
	}
	CC_SAFE_DELETE(thing);
	return nullptr;
}
开发者ID:wuhuilin5,项目名称:Brave,代码行数:11,代码来源:Thing.cpp


示例19: execute

   void LookAction::execute(Player *player, Command *command, Game *game) {

      string object = command->getDirectObject();

      if (object.length() == 0) {
         object = command->getIndirectObject();
      }

      if (object.length() == 0) {
         player->getLocation()->observe(player, true, true);
      }

      else {

         Place *location = player->getLocation();

         // Note: I can't use list.merge(), because ObjectList and ThingList are
         // of different types :'(
         ThingList items;

         // consider matching inventory items, if there are any
         ObjectListCItPair invItems = player->getInventoryObjectsByName(object);
         for (ObjectListCIt i = invItems.begin; i != invItems.end; i++) {
               items.push_front(*i);
         }

         // also consider matching items in the room, if there are any
         ThingListCItPair roomItems = location->getThingsByName(object);
         for (ThingListCIt i = roomItems.begin; i != roomItems.end; i++) {
            items.push_front(*i);
         }

         if (0 == items.size()) {
            player->out("display") << "There is no " << object << " here!" << endl;
            return;
         }

         ThingListCItPair itemsIt;
         itemsIt.begin = items.begin();
         itemsIt.end   = items.end();

         try {
            Thing *thing =
               Entity::clarifyEntity<ThingListCItPair, ThingListCIt, Thing *>(itemsIt,
               player);
            thing->observe(player, true, true);
         }

         catch (string name) {
            player->out("display") << "There is no " << name << " here!" << endl;
         }
      }
   }
开发者ID:Ockin,项目名称:trogdor-pp,代码行数:53,代码来源:actions.cpp


示例20: RebuildCounts

void Container::RebuildCounts() {

    Thing *t;
    for (unsigned int i = 0 ; i < capacity ; i++ ) {
        containeritemdata_t *c = (containeritemdata_t*)objects[i]->GetCustomData();
        if (c->container->GetItem(c->elementid) && (t = c->container->GetItem(c->elementid))->IsStackable()) {
            char tmp[20];
            sprintf(tmp, "%dx", t->GetCount());
            objects[i]->SetCaption(tmp);
        } else objects[i]->SetCaption("");
    }
}
开发者ID:ivucica,项目名称:theoutcast,代码行数:12,代码来源:container.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ThingPtr类代码示例发布时间:2022-05-31
下一篇:
C++ ThermoPhase类代码示例发布时间: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