本文整理汇总了C++中plKey类的典型用法代码示例。如果您正苦于以下问题:C++ plKey类的具体用法?C++ plKey怎么用?C++ plKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了plKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EatKey
virtual bool EatKey(const plKey& key)
{
uint32_t count = plCommonObjLib::GetNumLibs();
for (uint32_t i = 0; i < count; i++)
{
plCommonObjLib* lib = plCommonObjLib::GetLib(i);
if (lib->IsInteresting(key))
{
// Lib wants this guy, so load the object and add it
// Note: we want to switch to passive mode here, so any keys read in
// will NOT force a load on whichever page those keys belong to. Otherwise,
// we'd have to load that entire page and ref all the objects all over
// again and I just really don't want to do that...
plResMgrSettings::Get().SetPassiveKeyRead(true);
hsKeyedObject* object = key->VerifyLoaded();
plResMgrSettings::Get().SetPassiveKeyRead(false);
lib->AddObject(object);
break;
}
}
return true;
}
示例2: GetRefCount
bool plPluginResManager::NukeKeyAndObject(plKey& objectKey)
{
class plPublicRefKey : public plKeyImp
{
public:
uint16_t GetRefCount() const { return fRefCount; }
};
plKeyImp* keyData = (plKeyImp*)objectKey;
// Check the ref count on the object. Nobody should have a ref to it
// except the key
hsKeyedObject* object = objectKey->ObjectIsLoaded();
if (object != nil)
{
if (keyData->GetActiveRefs())
// Somebody still has a ref to this object, so we can't nuke it
return false;
}
// Nobody has a ref to the object, so we're clear to nuke
keyData->SetObjectPtr(nil);
// Check the key. The refcount should be 1 at this point, for the copy
// we're holding in this function. Nobody else should be holding the key
// now that the object is gone.
if (((plPublicRefKey*)keyData)->GetRefCount() > 1)
return false;
// Nuke out the key as well
objectKey = nil;
// All done!
return true;
}
示例3: UpdateDetectorsInScene
void plSimulationMgr::UpdateDetectorsInScene(plKey world, plKey avatar, hsPoint3& pos, bool entering)
{
// search thru the actors in a scene looking for convex hull detectors and see if the avatar is inside it
// ... and then send appropiate collision message if needed
NxScene* scene = GetScene(world);
plSceneObject* avObj = plSceneObject::ConvertNoRef(avatar->ObjectIsLoaded());
const plCoordinateInterface* ci = avObj->GetCoordinateInterface();
hsPoint3 soPos = ci->GetWorldPos();
if (scene)
{
uint32_t numActors = scene->getNbActors();
NxActor** actors = scene->getActors();
for (int i = 0; i < numActors; i++)
{
plPXPhysical* physical = (plPXPhysical*)actors[i]->userData;
if (physical && physical->DoDetectorHullWorkaround())
{
if ( physical->IsObjectInsideHull(pos) )
{
physical->SetInsideConvexHull(entering);
// we are entering this world... say we entered this detector
ISendCollisionMsg(physical->GetObjectKey(), avatar, entering);
}
}
}
}
}
示例4: ICheckSubworlds
// check to make sure that the avatar and the exclude region are in the same subworld
bool plExcludeRegionModifier::ICheckSubworlds(plKey avatar)
{
plSceneObject* avObj = plSceneObject::ConvertNoRef(avatar->GetObjectPtr());
if (avObj)
{
// get the avatar modifier
const plArmatureMod *avMod = (plArmatureMod*)avObj->GetModifierByType(plArmatureMod::Index());
if (avMod)
{
// get the avatar controller
plPhysicalControllerCore* avController = avMod->GetController();
if (avController)
{
// get physical of the detector region
plPhysical* phys = GetPhysical(GetTarget());
if (phys)
{
// are they in the same subworld?
if ( phys->GetWorldKey() == avController->GetSubworld() )
return true;
else
return false;
}
}
}
}
return false;
}
示例5: IFindClosestSafePoint
int plExcludeRegionModifier::IFindClosestSafePoint(plKey avatar)
{
float closestDist = 0.f;
int closestIdx = -1;
plSceneObject* avObj = plSceneObject::ConvertNoRef(avatar->GetObjectPtr());
if (!avObj)
return -1;
hsVector3 avPos;
avObj->GetCoordinateInterface()->GetLocalToWorld().GetTranslate(&avPos);
for (int i = 0; i < fSafePoints.size(); i++)
{
plSceneObject* safeObj = plSceneObject::ConvertNoRef(fSafePoints[i]->GetObjectPtr());
hsVector3 safePos;
safeObj->GetCoordinateInterface()->GetLocalToWorld().GetTranslate(&safePos);
float dist = (safePos - avPos).Magnitude();
if (dist < closestDist || closestIdx == -1)
{
closestDist = dist;
closestIdx = i;
}
}
return closestIdx;
}
示例6: ISendNetMsg
//
// write to net msg and send to server
//
void plSDLModifier::ISendNetMsg(plStateDataRecord*& state, plKey senderKey, uint32_t sendFlags)
{
hsAssert(senderKey, "nil senderKey?");
plSynchedObject* sobj = plSynchedObject::ConvertNoRef(senderKey->ObjectIsLoaded());
if (sobj && (sobj->IsInSDLVolatileList(GetSDLName())))
state->SetFlags(state->GetFlags() | plStateDataRecord::kVolatile);
bool dirtyOnly = (sendFlags & plSynchedObject::kForceFullSend) == 0;
bool broadcast = (sendFlags & plSynchedObject::kBCastToClients) != 0;
int writeOptions=0;
// if (dirtyOnly)
writeOptions |= plSDL::kDirtyOnly;
if (broadcast)
writeOptions |= plSDL::kBroadcast;
writeOptions |= plSDL::kTimeStampOnRead;
// send to server
plNetMsgSDLState* msg = state->PrepNetMsg(0, writeOptions);
msg->SetNetProtocol(kNetProtocolCli2Game);
msg->ObjectInfo()->SetUoid(senderKey->GetUoid());
if (sendFlags & plSynchedObject::kNewState)
msg->SetBit(plNetMessage::kNewSDLState);
if (sendFlags & plSynchedObject::kUseRelevanceRegions)
msg->SetBit(plNetMessage::kUseRelevanceRegions);
if (sendFlags & plSynchedObject::kDontPersistOnServer)
msg->SetPersistOnServer(false);
if (sendFlags & plSynchedObject::kIsAvatarState)
msg->SetIsAvatarState(true);
if (broadcast && plNetClientApp::GetInstance())
{
msg->SetPlayerID(plNetClientApp::GetInstance()->GetPlayerID());
}
plNetClientApp::GetInstance()->SendMsg(msg);
msg->UnRef();
fSentOrRecvdState = true;
}
示例7: MakeCCRInvisible
//
// a remote ccr is turning [in]visible
//
void plNetClientMgr::MakeCCRInvisible(plKey avKey, int level)
{
if (!avKey)
{
ErrorMsg("Failed to make remote CCR Invisible, nil avatar key");
return;
}
if (level<0)
{
ErrorMsg("Failed to make remote CCR Invisible, negative level");
return;
}
if (!avKey->ObjectIsLoaded() || !avKey->ObjectIsLoaded()->IsFinal())
{
hsAssert(false, "avatar not loaded or final");
return;
}
plAvatarStealthModeMsg *msg = new plAvatarStealthModeMsg();
msg->SetSender(avKey);
msg->fLevel = level;
if (GetCCRLevel()<level) // I'm a lower level than him, so he's invisible to me
msg->fMode = plAvatarStealthModeMsg::kStealthCloaked;
else
{
// he's visible to me
if (AmCCR() && level > 0)
msg->fMode = plAvatarStealthModeMsg::kStealthCloakedButSeen; // draw as semi-invis
else
msg->fMode = plAvatarStealthModeMsg::kStealthVisible;
}
DebugMsg("Handled MakeCCRInvisible - sending stealth msg");;
// This fxn is called when avatar SDL state is received from the server,
// so this msg will inherit the 'non-local' status of the parent sdl msg.
// That means that the avatar linkSound won't receive it, since the linkSound
// is set as localOnly.
// So, terminate the remote cascade and start a new (local) cascade.
msg->SetBCastFlag(plMessage::kNetStartCascade);
msg->Send();
}
示例8: IResMgrProgressBarCallback
//============================================================================
void plNCAgeJoiner::IResMgrProgressBarCallback (plKey key) {
#ifndef PLASMA_EXTERNAL_RELEASE
if (s_instance)
s_instance->progressBar->SetStatusText(key->GetName());
#endif
if (s_instance)
s_instance->progressBar->Increment(1);
}
示例9: AddLooseEnd
void plPluginResManager::AddLooseEnd(plKey key)
{
if( key )
{
key->RefObject();
fLooseEnds.Append(key);
}
}
示例10: IsInteresting
virtual bool IsInteresting( const plKey &objectKey )
{
if( objectKey->GetUoid().GetClassType() == plCubicEnvironmap::Index() ||
objectKey->GetUoid().GetClassType() == plMipmap::Index() )
{
return true;
}
return false;
}
示例11:
plPhysicsSoundMgr::CollidePair::CollidePair(const plKey& firstPhys, const plKey& secondPhys, const hsPoint3& point, const hsVector3& normal)
{
// To simplify searching and sorting, all pairs are set up with the pointer value of the
// first element greater than the pointer value of the second.
if (firstPhys->GetObjectPtr() < secondPhys->GetObjectPtr())
{
this->firstPhysKey = secondPhys;
this->secondPhysKey = firstPhys;
}
else
{
this->firstPhysKey = firstPhys;
this->secondPhysKey = secondPhys;
}
this->point = point;
this->normalForce = normal;
}
示例12: ISaveOrLoad
//
// save or load a key. return the key.
//
const plKey plSynchedValueBase::ISaveOrLoad(const plKey key, bool32 save, hsStream* stream, hsResMgr* mgr)
{
if (save)
{
if (key)
{
stream->WriteByte(1);
// I need to write a key to MY stream...
#if 0 // DEBUG
plStringBuffer<char> buf = key->GetName()->ToIso8859_1();
stream->WriteLE32(buf.GetSize());
stream->Write(buf.GetSize(), buf.GetData());
#endif
key->GetUoid().Write(stream);
}
else
{
stream->WriteByte(0);
}
return key;
}
else
{
int32_t has=stream->ReadByte();
if (has)
{
// read a key from MY stream
#if 0 // DEBUG
int32_t len = stream->ReadLE32();
char tmp[256];
hsAssert(len<256, "key name overflow");
stream->Read(len, tmp);
#endif
plUoid uoid;
uoid.Read(stream);
return mgr->FindKey(uoid);
}
else
return (nil);
}
return nil;
}
示例13: pfKIListPlayerItem
pfKIListPlayerItem( plKey key, bool inRange = false ) : pfGUIListText(), fPlayerKey( key )
{
static char str[ 256 ];
if( key == nil )
SetText( "<Everyone>" );
else
{
const char *name = plNetClientMgr::GetInstance()->GetPlayerName( key );
if( inRange )
{
sprintf( str, ">%s<", name != nil ? name : key->GetName() );
SetText( str );
}
else
SetText( name != nil ? name : key->GetName() );
}
ISetJustify( true );
}
示例14: SetTarget
void plAvTaskSeek::SetTarget(plKey target)
{
hsAssert(target, "Bad key to seek task");
if(target)
{
fSeekObject = plSceneObject::ConvertNoRef(target->ObjectIsLoaded());
}
else
{
fSeekObject = nil;
}
}
示例15: KeyedObjectProc
void plPageOptimizer::KeyedObjectProc(plKey key)
{
plString keyName = key->GetName();
const char* className = plFactory::GetNameOfClass(key->GetUoid().GetClassType());
// For now, ignore any key that isn't in the location we're looking at. That means stuff like textures.
if (fInstance->fLoc != key->GetUoid().GetLocation())
return;
KeySet& loadedKeys = fInstance->fLoadedKeys;
KeyVec& loadOrder = fInstance->fKeyLoadOrder;
KeySet::iterator it = loadedKeys.lower_bound(key);
if (it != loadedKeys.end() && *it == key)
{
printf("Keyed object %s(%s) loaded more than once\n", keyName.c_str(), className);
}
else
{
loadedKeys.insert(it, key);
loadOrder.push_back(key);
}
}