本文整理汇总了C++中CGameObject::ID方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameObject::ID方法的具体用法?C++ CGameObject::ID怎么用?C++ CGameObject::ID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameObject
的用法示例。
在下文中一共展示了CGameObject::ID方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
u32 CLevel::Objects_net_Save (NET_Packet* _Packet, u32 start, u32 max_object_size)
{
NET_Packet& Packet = *_Packet;
u32 position;
for (; start<Objects.o_count(); start++) {
CObject *_P = Objects.o_get_by_iterator(start);
CGameObject *P = smart_cast<CGameObject*>(_P);
// Msg ("save:iterating:%d:%s",P->ID(),*P->cName());
if (P && !P->getDestroy() && P->net_SaveRelevant()) {
Packet.w_u16 (u16(P->ID()) );
Packet.w_chunk_open16 (position);
// Msg ("save:saving:%d:%s",P->ID(),*P->cName());
P->net_Save (Packet);
#ifdef DEBUG
u32 size = u32 (Packet.w_tell()-position)-sizeof(u16);
// Msg ("save:saved:%d bytes:%d:%s",size,P->ID(),*P->cName());
if (size>=65536) {
Debug.fatal (DEBUG_INFO,"Object [%s][%d] exceed network-data limit\n size=%d, Pend=%d, Pstart=%d",
*P->cName(), P->ID(), size, Packet.w_tell(), position);
}
#endif
Packet.w_chunk_close16 (position);
// if (0==(--count))
// break;
if (max_object_size > (NET_PacketSizeLimit - Packet.w_tell()))
break;
}
}
return ++start;
}
示例2: Affect
void CRadioactiveZone::Affect(SZoneObjectInfo* O)
{
// вермя срабатывания не чаще, чем заданный период
if(m_dwDeltaTime < m_dwPeriod) return;
//. m_dwDeltaTime = 0;
CGameObject *GO = O->object;
if(GO)
{
Fvector pos;
XFORM().transform_tiny(pos,CFORM()->getSphere().P);
#ifdef DEBUG
char pow[255];
sprintf(pow, "zone hit. %.3f", Power(GO->Position().distance_to(pos)));
if(bDebug) Msg("%s %s", *GO->cName(), pow);
#endif
Fvector dir;
dir.set(0,0,0);
Fvector position_in_bone_space;
float power = (GameID() == GAME_SINGLE) ? Power(GO->Position().distance_to(pos)) : 0.0f;
float impulse = 0.f;
if(power > EPS)
{
//. m_dwDeltaTime = 0;
position_in_bone_space.set(0.f,0.f,0.f);
CreateHit(GO->ID(),ID(),dir,power,BI_NONE,position_in_bone_space,impulse,ALife::eHitTypeRadiation);
}
}
}
示例3:
void CPurchaseList::process (const CGameObject &owner, const shared_str &name, const u32 &count, const float &probability)
{
VERIFY3 (count,"Invalid count for section in the purchase list",*name);
VERIFY3 (!fis_zero(probability,EPS_S),"Invalid probability for section in the purchase list",*name);
const Fvector &position = owner.Position();
const u32 &level_vertex_id = owner.ai_location().level_vertex_id();
const ALife::_OBJECT_ID &id = owner.ID();
CRandom random((u32)(CPU::QPC() & u32(-1)));
u32 j = 0;
for (u32 i=0; i<count; ++i) {
if (random.randF() > probability)
continue;
++j;
Level().spawn_item (*name,position,level_vertex_id,id,false);
}
DEFICITS::const_iterator I = m_deficits.find(name);
VERIFY3 (I == m_deficits.end(),"Duplicate section in the purchase list",*name);
m_deficits.insert (
std::make_pair(
name,
(float)count*probability
/
_max((float)j,min_deficit_factor)
)
);
}
示例4: OnBuyMenu_Ok
void game_cl_CaptureTheArtefact::OnBuyMenu_Ok()
{
#ifdef DEBUG
Msg("* CTA: Buy menu OK...");
#endif // #ifdef DEBUG
typedef CUIGameCTA::BuyMenuItemsCollection TBuyCol;
VERIFY2(m_game_ui, "game ui not initialized");
CUIGameCTA::BuyMenuItemsCollection toBuyItemsCollection;
s32 moneyDif = 0;
m_game_ui->GetPurchaseItems(toBuyItemsCollection, moneyDif);
R_ASSERT(local_player);
if (local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD))
{
if (InWarmUp())
{
buy_amount = 0;
} else
{
buy_amount = moneyDif;
}
UpdateMoneyIndicator();
}
CGameObject* pPlayer = smart_cast<CGameObject*>(Level().CurrentEntity());
VERIFY(pPlayer);
NET_Packet P;
pPlayer->u_EventGen(P, GE_GAME_EVENT, pPlayer->ID());
P.w_u16(GAME_EVENT_PLAYER_BUY_FINISHED);
if (InWarmUp())
{
P.w_s32(0);
} else
{
P.w_s32(moneyDif);
}
P.w_u16(static_cast<u16>(toBuyItemsCollection.size()));
TBuyCol::const_iterator bie = toBuyItemsCollection.end();
for (TBuyCol::const_iterator toBuyIter = toBuyItemsCollection.begin();
toBuyIter != bie; ++toBuyIter)
{
P.w_u8(toBuyIter->first);
P.w_u8(toBuyIter->second);
}
pPlayer->u_EventSend(P);
if (local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD))
{
u_EventGen(P, GE_GAME_EVENT, local_player->GameID);
P.w_u16(GAME_EVENT_PLAYER_BUYMENU_CLOSE);
u_EventSend(P);
}
set_buy_menu_not_ready();
}
示例5: Level
void game_cl_ArtefactHunt::OnBuySpawnMenu_Ok ()
{
CObject* curr = Level().CurrentEntity();
if (!curr) return;
CGameObject* GO = smart_cast<CGameObject*>(curr);
NET_Packet P;
GO->u_EventGen (P,GE_GAME_EVENT,GO->ID() );
P.w_u16(GAME_EVENT_PLAYER_BUY_SPAWN);
GO->u_EventSend (P);
};
示例6:
void CActor::LostPdaContact (CInventoryOwner* pInvOwner)
{
CGameObject* GO = smart_cast<CGameObject*>(pInvOwner);
if (GO){
for(int t = ALife::eRelationTypeFriend; t<ALife::eRelationTypeLast; ++t){
ALife::ERelationType tt = (ALife::ERelationType)t;
Level().MapManager().RemoveMapLocation(RELATION_REGISTRY().GetSpotName(tt), GO->ID());
}
Level().MapManager().RemoveMapLocation("deadbody_location", GO->ID());
};
if( HUD().GetUI() ){
CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
if(pGameSP){
pGameSP->PdaMenu->PdaContentsChanged (pda_section::contacts);
}
}
}
示例7: Level
void CActor::LostPdaContact (CInventoryOwner* pInvOwner)
{
CGameObject* GO = smart_cast<CGameObject*>(pInvOwner);
if (GO) {
for(int t = ALife::eRelationTypeFriend; t<ALife::eRelationTypeLast; ++t) {
ALife::ERelationType tt = (ALife::ERelationType)t;
Level().MapManager().RemoveMapLocation(RELATION_REGISTRY().GetSpotName(tt), GO->ID());
}
Level().MapManager().RemoveMapLocation("deadbody_location", GO->ID());
};
}
示例8: net_Relcase
void CCustomZone::net_Relcase(CObject* O)
{
CGameObject* GO = smart_cast<CGameObject*>(O);
OBJECT_INFO_VEC_IT it = std::find(m_ObjectInfoMap.begin(),m_ObjectInfoMap.end(), GO);
if(it!=m_ObjectInfoMap.end())
{
exit_Zone (*it);
m_ObjectInfoMap.erase (it);
}
if(GO->ID()==m_owner_id) m_owner_id = u32(-1);
if(m_actor_effector && m_actor_effector->m_pActor && m_actor_effector->m_pActor->ID() == GO->ID())
m_actor_effector->Stop();
inherited::net_Relcase(O);
}
示例9: inventory
void CInventoryOwner::sell_useless_items ()
{
CGameObject *object = smart_cast<CGameObject*>(this);
TIItemContainer::iterator I = inventory().m_all.begin();
TIItemContainer::iterator E = inventory().m_all.end();
for ( ; I != E; ++I) {
if ( smart_cast<CBolt*>( *I ) )
{
continue;
}
CPda* pda = smart_cast<CPda*>( *I );
if ( pda )
{
if (pda->GetOriginalOwnerID() == object->ID())
{
continue;
}
}
(*I)->SetDropManual(FALSE);
(*I)->object().DestroyObject();
}
}
示例10: ActorUse
void CActor::ActorUse()
{
if (m_holder)
{
CGameObject* GO = smart_cast<CGameObject*>(m_holder);
NET_Packet P;
CGameObject::u_EventGen (P, GEG_PLAYER_DETACH_HOLDER, ID());
P.w_u16 (GO->ID());
CGameObject::u_EventSend (P);
return;
}
if(character_physics_support()->movement()->PHCapture())
character_physics_support()->movement()->PHReleaseObject();
if(m_pUsableObject && NULL==m_pObjectWeLookingAt->cast_inventory_item())
{
m_pUsableObject->use(this);
}
if ( m_pInvBoxWeLookingAt && m_pInvBoxWeLookingAt->nonscript_usable() )
{
CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI());
if ( pGameSP ) //single
{
if ( !m_pInvBoxWeLookingAt->closed() )
{
pGameSP->StartCarBody( this, m_pInvBoxWeLookingAt );
}
}
return;
}
if(!m_pUsableObject||m_pUsableObject->nonscript_usable())
{
if(m_pPersonWeLookingAt)
{
CEntityAlive* pEntityAliveWeLookingAt =
smart_cast<CEntityAlive*>(m_pPersonWeLookingAt);
VERIFY(pEntityAliveWeLookingAt);
if (IsGameTypeSingle())
{
if(pEntityAliveWeLookingAt->g_Alive())
{
TryToTalk();
}else
{
//только если находимся в режиме single
CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI());
if ( pGameSP )
{
if ( !m_pPersonWeLookingAt->deadbody_closed_status() )
{
if(pEntityAliveWeLookingAt->AlreadyDie() &&
pEntityAliveWeLookingAt->GetLevelDeathTime()+3000 < Device.dwTimeGlobal)
// 99.9% dead
pGameSP->StartCarBody(this, m_pPersonWeLookingAt );
}
}
}
}
}
collide::rq_result& RQ = HUD().GetCurrentRayQuery();
CPhysicsShellHolder* object = smart_cast<CPhysicsShellHolder*>(RQ.O);
u16 element = BI_NONE;
if(object)
element = (u16)RQ.element;
if(object && Level().IR_GetKeyState(DIK_LSHIFT))
{
bool b_allow = !!pSettings->line_exist("ph_capture_visuals",object->cNameVisual());
if(b_allow && !character_physics_support()->movement()->PHCapture())
{
character_physics_support()->movement()->PHCaptureObject( object, element );
}
}
else
{
if (object && smart_cast<CHolderCustom*>(object))
{
NET_Packet P;
CGameObject::u_EventGen (P, GEG_PLAYER_ATTACH_HOLDER, ID());
P.w_u16 (object->ID());
CGameObject::u_EventSend (P);
return;
}
}
}
}
示例11: Level
void CActor::OnEvent (NET_Packet& P, u16 type)
{
inherited::OnEvent (P,type);
CInventoryOwner::OnEvent (P,type);
u16 id;
switch (type)
{
case GE_TRADE_BUY:
case GE_OWNERSHIP_TAKE:
{
P.r_u16 (id);
CObject* O = Level().Objects.net_Find (id);
if (!O)
{
Msg("! Error: No object to take/buy [%d]", id);
break;
}
CGameObject* _GO = smart_cast<CGameObject*>(O);
CFoodItem* pFood = smart_cast<CFoodItem*>(O);
if(pFood)
#if defined(INV_NEW_SLOTS_SYSTEM)
if (pFood->m_eItemPlace != eItemPlaceSlot)
#endif
pFood->m_eItemPlace = eItemPlaceRuck;
if( inventory().CanTakeItem(smart_cast<CInventoryItem*>(_GO)) )
{
O->H_SetParent(smart_cast<CObject*>(this));
inventory().Take(_GO, false, true);
CUIGameSP* pGameSP = NULL;
CUI* ui = HUD().GetUI();
if( ui&&ui->UIGame() )
{
pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
if (Level().CurrentViewEntity() == this)
HUD().GetUI()->UIGame()->ReInitShownUI();
};
//добавить отсоединенный аддон в инвентарь
if(pGameSP)
{
if(pGameSP->MainInputReceiver() == pGameSP->InventoryMenu)
{
pGameSP->InventoryMenu->AddItemToBag(smart_cast<CInventoryItem*>(O));
}
}
SelectBestWeapon(O);
}
else
{
NET_Packet P;
u_EventGen(P,GE_OWNERSHIP_REJECT,ID());
P.w_u16(u16(O->ID()));
u_EventSend(P);
}
}
break;
case GE_TRADE_SELL:
case GE_OWNERSHIP_REJECT:
{
P.r_u16 (id);
CObject* O = Level().Objects.net_Find (id);
if (!O)
{
Msg("! Error: No object to reject/sell [%d]", id);
break;
}
bool just_before_destroy = !P.r_eof() && P.r_u8();
O->SetTmpPreDestroy (just_before_destroy);
if (inventory().DropItem(smart_cast<CGameObject*>(O)) && !O->getDestroy())
{
O->H_SetParent(0,just_before_destroy);
//. feel_touch_deny(O,2000);
Level().m_feel_deny.feel_touch_deny(O, 1000);
}
SelectBestWeapon(O);
if (Level().CurrentViewEntity() == this && HUD().GetUI() && HUD().GetUI()->UIGame())
HUD().GetUI()->UIGame()->ReInitShownUI();
}
break;
case GE_INV_ACTION:
{
s32 cmd;
P.r_s32 (cmd);
u32 flags;
P.r_u32 (flags);
s32 ZoomRndSeed = P.r_s32();
s32 ShotRndSeed = P.r_s32();
if (flags & CMD_START)
{
//.........这里部分代码省略.........
示例12: OnEvent
void CActor::OnEvent(NET_Packet& P, u16 type)
{
inherited::OnEvent (P,type);
CInventoryOwner::OnEvent (P,type);
u16 id;
switch (type)
{
case GE_TRADE_BUY:
case GE_OWNERSHIP_TAKE:
{
P.r_u16 (id);
CObject* Obj = Level().Objects.net_Find (id);
// R_ASSERT2( Obj, make_string("GE_OWNERSHIP_TAKE: Object not found. object_id = [%d]", id).c_str() );
VERIFY2 ( Obj, make_string("GE_OWNERSHIP_TAKE: Object not found. object_id = [%d]", id).c_str() );
if ( !Obj ) {
Msg ( "! GE_OWNERSHIP_TAKE: Object not found. object_id = [%d]", id );
break;
}
CGameObject* _GO = smart_cast<CGameObject*>(Obj);
if (!IsGameTypeSingle() && !g_Alive())
{
Msg("! WARNING: dead player [%d][%s] can't take items [%d][%s]",
ID(), Name(), _GO->ID(), _GO->cNameSect().c_str());
break;
}
if( inventory().CanTakeItem(smart_cast<CInventoryItem*>(_GO)) )
{
Obj->H_SetParent (smart_cast<CObject*>(this));
#ifdef MP_LOGGING
string64 act;
xr_strcpy( act, (type == GE_TRADE_BUY)? "buys" : "takes" );
Msg("--- Actor [%d][%s] %s [%d][%s]", ID(), Name(), act, _GO->ID(), _GO->cNameSect().c_str());
#endif // MP_LOGGING
inventory().Take (_GO, false, true);
SelectBestWeapon(Obj);
}
else
{
if (IsGameTypeSingle())
{
NET_Packet P;
u_EventGen (P,GE_OWNERSHIP_REJECT,ID());
P.w_u16 (u16(Obj->ID()));
u_EventSend (P);
} else
{
Msg("! ERROR: Actor [%d][%s] tries to drop on take [%d][%s]", ID(), Name(), _GO->ID(), _GO->cNameSect().c_str());
}
}
}
break;
case GE_TRADE_SELL:
case GE_OWNERSHIP_REJECT:
{
P.r_u16 (id);
CObject* Obj = Level().Objects.net_Find (id);
// R_ASSERT2( Obj, make_string("GE_OWNERSHIP_REJECT: Object not found, id = %d", id).c_str() );
VERIFY2 ( Obj, make_string("GE_OWNERSHIP_REJECT: Object not found, id = %d", id).c_str() );
if ( !Obj ) {
Msg ( "! GE_OWNERSHIP_REJECT: Object not found, id = %d", id );
break;
}
bool just_before_destroy = !P.r_eof() && P.r_u8();
bool dont_create_shell = (type==GE_TRADE_SELL) || just_before_destroy;
Obj->SetTmpPreDestroy (just_before_destroy);
CGameObject * GO = smart_cast<CGameObject*>(Obj);
#ifdef MP_LOGGING
string64 act;
xr_strcpy( act, (type == GE_TRADE_SELL)? "sells" : "rejects" );
Msg("--- Actor [%d][%s] %s [%d][%s]", ID(), Name(), act, GO->ID(), GO->cNameSect().c_str());
#endif // MP_LOGGING
VERIFY( GO->H_Parent() );
if ( !GO->H_Parent() )
{
Msg("! ERROR: Actor [%d][%s] tries to reject item [%d][%s] that has no parent",
ID(), Name(), GO->ID(), GO->cNameSect().c_str());
break;
}
VERIFY2( GO->H_Parent()->ID() == ID(),
make_string("actor [%d][%s] tries to drop not own object [%d][%s]",
ID(), Name(), GO->ID(), GO->cNameSect().c_str() ).c_str() );
if ( GO->H_Parent()->ID() != ID() )
{
CActor* real_parent = smart_cast<CActor*>(GO->H_Parent());
Msg("! ERROR: Actor [%d][%s] tries to drop not own item [%d][%s], his parent is [%d][%s]",
ID(), Name(), GO->ID(), GO->cNameSect().c_str(), real_parent->ID(), real_parent->Name());
//.........这里部分代码省略.........
示例13: ActorUse
void CActor::ActorUse()
{
//mstate_real = 0;
PickupModeOn();
if (m_holder)
{
CGameObject* GO = smart_cast<CGameObject*>(m_holder);
NET_Packet P;
CGameObject::u_EventGen (P, GEG_PLAYER_DETACH_HOLDER, ID());
P.w_u32 (GO->ID());
CGameObject::u_EventSend (P);
return;
}
if(character_physics_support()->movement()->PHCapture())
character_physics_support()->movement()->PHReleaseObject();
if(m_pUsableObject)m_pUsableObject->use(this);
if(m_pInvBoxWeLookingAt && m_pInvBoxWeLookingAt->nonscript_usable())
{
CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
if(pGameSP) pGameSP->StartCarBody(this, m_pInvBoxWeLookingAt );
return;
}
if(!m_pUsableObject||m_pUsableObject->nonscript_usable())
{
if(m_pPersonWeLookingAt)
{
CEntityAlive* pEntityAliveWeLookingAt =
smart_cast<CEntityAlive*>(m_pPersonWeLookingAt);
VERIFY(pEntityAliveWeLookingAt);
if (GameID()==GAME_SINGLE)
{
if(pEntityAliveWeLookingAt->g_Alive())
{
TryToTalk();
}
//обыск трупа
else if(!Level().IR_GetKeyState(DIK_LSHIFT))
{
//только если находимся в режиме single
CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
if(pGameSP)pGameSP->StartCarBody(this, m_pPersonWeLookingAt );
}
}
}
collide::rq_result& RQ = HUD().GetCurrentRayQuery();
CPhysicsShellHolder* object = smart_cast<CPhysicsShellHolder*>(RQ.O);
u16 element = BI_NONE;
if(object)
element = (u16)RQ.element;
if(object && Level().IR_GetKeyState(DIK_LSHIFT))
{
bool b_allow = !!pSettings->line_exist("ph_capture_visuals",object->cNameVisual());
if(b_allow && !character_physics_support()->movement()->PHCapture())
{
character_physics_support()->movement()->PHCaptureObject(object,element);
}
}
else
{
if (object && smart_cast<CHolderCustom*>(object))
{
NET_Packet P;
CGameObject::u_EventGen (P, GEG_PLAYER_ATTACH_HOLDER, ID());
P.w_u32 (object->ID());
CGameObject::u_EventSend (P);
return;
}
}
}
}