本文整理汇总了C++中ZoneServer::getObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ZoneServer::getObject方法的具体用法?C++ ZoneServer::getObject怎么用?C++ ZoneServer::getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZoneServer
的用法示例。
在下文中一共展示了ZoneServer::getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
Reference<SceneObject*> PlanetManagerImplementation::loadSnapshotObject(WorldSnapshotNode* node, WorldSnapshotIff* wsiff, int& totalObjects) {
uint64 objectID = node->getObjectID();
String templateName = wsiff->getObjectTemplateName(node->getNameID());
ZoneServer* zoneServer = server->getZoneServer();
Reference<SceneObject*> object = zoneServer->getObject(objectID);
++totalObjects;
if (ConfigManager::instance()->isProgressMonitorActivated())
printf("\r\tLoading snapshot objects: [%d] / [?]\t", totalObjects);
//Object already exists, exit.
if (object != NULL)
return NULL;
Reference<SceneObject*> parentObject = zoneServer->getObject(node->getParentID());
String serverTemplate = templateName.replaceFirst("shared_", "");
Vector3 position = node->getPosition();
object = zoneServer->createClientObject(serverTemplate.hashCode(), objectID);
object->initializePosition(position.getX(), position.getZ(), position.getY());
object->setDirection(node->getDirection());
if (parentObject != NULL && parentObject->isBuildingObject() && object->isCellObject()) {
CellObject* cell = cast<CellObject*>(object.get());
BuildingObject* building = cast<BuildingObject*>(parentObject.get());
building->addCell(cell, node->getCellID());
}
if (parentObject != NULL)
parentObject->transferObject(object, -1);
else if (node->getParentID() != 0)
error("parent id " + String::valueOf(node->getParentID()));
if (parentObject == NULL) {
//object->insertToZone(zone);
Locker clocker(object);
zone->transferObject(object, -1, true);
}
//Load child nodes
for (int i = 0; i < node->getNodeCount(); ++i) {
WorldSnapshotNode* childNode = node->getNode(i);
if (childNode == NULL)
continue;
loadSnapshotObject(childNode, wsiff, totalObjects);
}
//object->createChildObjects();
return object;
}
示例2: addPlayerTargetObservers
bool BountyMissionObjectiveImplementation::addPlayerTargetObservers() {
Locker locker(&syncMutex);
ManagedReference<MissionObject* > mission = this->mission.get();
ManagedReference<CreatureObject*> owner = getPlayerOwner();
ZoneServer* zoneServer = owner->getZoneServer();
if (zoneServer != NULL) {
ManagedReference<CreatureObject*> target = zoneServer->getObject(mission->getTargetObjectId()).castTo<CreatureObject*>();
if (target != NULL) {
addObserverToCreature(ObserverEventType::PLAYERKILLED, target);
addObserverToCreature(ObserverEventType::DEFENDERADDED, target);
addObserverToCreature(ObserverEventType::DEFENDERDROPPED, target);
addObserverToCreature(ObserverEventType::PLAYERKILLED, owner);
addObserverToCreature(ObserverEventType::DEFENDERADDED, owner);
addObserverToCreature(ObserverEventType::DEFENDERDROPPED, owner);
owner->getZoneServer()->getMissionManager()->addBountyHunterToPlayerBounty(mission->getTargetObjectId(), owner->getObjectID());
//Update aggressive status on target for bh.
target->sendPvpStatusTo(owner);
return true;
}
}
return false;
}
示例3: getTargetZoneName
String BountyMissionObjectiveImplementation::getTargetZoneName() {
Locker locker(&syncMutex);
ManagedReference<MissionObject* > mission = this->mission.get();
if (isPlayerTarget()) {
uint64 targetId = mission->getTargetObjectId();
ZoneServer* zoneServer = getPlayerOwner().get()->getZoneServer();
if (zoneServer != NULL) {
ManagedReference<CreatureObject*> creature = zoneServer->getObject(targetId).castTo<CreatureObject*>();
if (creature != NULL && creature->getZone() != NULL) {
return creature->getZone()->getZoneName();
}
}
} else {
if (targetTask != NULL) {
return targetTask->getTargetZoneName();
}
}
//No target task, return dungeon1 which is not able to find.
return "dungeon1";
}
示例4: getTargetPosition
Vector3 BountyMissionObjectiveImplementation::getTargetPosition() {
Locker locker(&syncMutex);
ManagedReference<MissionObject* > mission = this->mission.get();
if (isPlayerTarget()) {
uint64 targetId = mission->getTargetObjectId();
ZoneServer* zoneServer = getPlayerOwner().get()->getZoneServer();
if (zoneServer != NULL) {
ManagedReference<CreatureObject*> creature = zoneServer->getObject(targetId).castTo<CreatureObject*>();
if (creature != NULL) {
return creature->getWorldPosition();
}
}
} else {
if (targetTask != NULL) {
return targetTask->getTargetPosition();
}
}
Vector3 empty;
return empty;
}
示例5: handlePlayerKilled
void BountyMissionObjectiveImplementation::handlePlayerKilled(ManagedObject* arg1) {
CreatureObject* killer = NULL;
killer = cast<CreatureObject*>(arg1);
ManagedReference<MissionObject* > mission = this->mission.get();
ManagedReference<CreatureObject*> owner = getPlayerOwner();
if (owner != NULL && killer != NULL) {
if (owner->getObjectID() == killer->getObjectID()) {
//Target killed by player, complete mission.
ZoneServer* zoneServer = owner->getZoneServer();
if (zoneServer != NULL) {
ManagedReference<CreatureObject*> target = zoneServer->getObject(mission->getTargetObjectId()).castTo<CreatureObject*>();
if (target != NULL) {
VisibilityManager::instance()->clearVisibility(target);
owner->getZoneServer()->getPlayerManager()->awardExperience(target, "jedi_general", -30000, true);
}
}
complete();
} else if (mission->getTargetObjectId() == killer->getObjectID() ||
(npcTarget != NULL && npcTarget->getObjectID() == killer->getObjectID())) {
//Player killed by target, fail mission.
owner->sendSystemMessage("@mission/mission_generic:failed"); // Mission failed
killer->sendSystemMessage("You have defeated a bounty hunter, ruining his mission against you!");
fail();
}
}
}
示例6: fillObjectMenuResponse
void RingObjectMenuComponent::fillObjectMenuResponse(SceneObject* sceneObject, ObjectMenuResponse* menuResponse, CreatureObject* player) const {
if (!sceneObject->isTangibleObject())
return;
WearableObject* wearable = cast<WearableObject*>(sceneObject);
if (wearable == NULL)
return;
ZoneServer* server = player->getZoneServer();
PlayerObject* ghost = player->getPlayerObject();
if (server == NULL || ghost == NULL)
return;
if (!wearable->isEquipped() && !wearable->isNoTrade()) {
if (ghost->isMarried()) {
menuResponse->addRadialMenuItem(234, 3, "@unity:mnu_divorce"); // Divorce
} else {
uint64 targetID = player->getTargetID();
ManagedReference<CreatureObject*> target = server->getObject(targetID, true).castTo<CreatureObject*>();
if (target != NULL && target->isPlayerCreature())
menuResponse->addRadialMenuItem(22, 3, "@unity:mnu_propose"); // Propose Unity
}
}
TangibleObjectMenuComponent::fillObjectMenuResponse(sceneObject, menuResponse, player);
}
示例7: handlePlayerKilled
void BountyMissionObjectiveImplementation::handlePlayerKilled(ManagedObject* arg1) {
CreatureObject* killer = NULL;
killer = cast<CreatureObject*>(arg1);
ManagedReference<MissionObject* > mission = this->mission.get();
ManagedReference<CreatureObject*> owner = getPlayerOwner();
if(mission == NULL)
return;
if (owner != NULL && killer != NULL) {
if (owner->getObjectID() == killer->getObjectID()) {
//Target killed by player, complete mission.
ZoneServer* zoneServer = owner->getZoneServer();
if (zoneServer != NULL) {
ManagedReference<CreatureObject*> target = zoneServer->getObject(mission->getTargetObjectId()).castTo<CreatureObject*>();
if (target != NULL) {
int minXpLoss = -50000;
int maxXpLoss = -500000;
VisibilityManager::instance()->clearVisibility(target);
int xpLoss = mission->getRewardCredits() * -2;
if (xpLoss > minXpLoss)
xpLoss = minXpLoss;
else if (xpLoss < maxXpLoss)
xpLoss = maxXpLoss;
owner->getZoneServer()->getPlayerManager()->awardExperience(target, "jedi_general", xpLoss, true);
StringIdChatParameter message("base_player","prose_revoke_xp");
message.setDI(xpLoss * -1);
message.setTO("exp_n", "jedi_general");
target->sendSystemMessage(message);
}
}
complete();
} else if (mission->getTargetObjectId() == killer->getObjectID() ||
(npcTarget != NULL && npcTarget->getObjectID() == killer->getObjectID())) {
//Player killed by target, fail mission.
owner->sendSystemMessage("@mission/mission_generic:failed"); // Mission failed
killer->sendSystemMessage("You have defeated a bounty hunter, ruining his mission against you!");
fail();
}
}
}
示例8: removePlayerTargetObservers
void BountyMissionObjectiveImplementation::removePlayerTargetObservers() {
Locker locker(&syncMutex);
ManagedReference<MissionObject* > mission = this->mission.get();
ManagedReference<CreatureObject*> owner = getPlayerOwner();
removeObserver(5, ObserverEventType::DEFENDERDROPPED, owner);
removeObserver(4, ObserverEventType::DEFENDERADDED, owner);
removeObserver(3, ObserverEventType::PLAYERKILLED, owner);
ZoneServer* zoneServer = owner->getZoneServer();
if (zoneServer != NULL) {
ManagedReference<CreatureObject*> target = zoneServer->getObject(mission->getTargetObjectId()).castTo<CreatureObject*>();
removeObserver(2, ObserverEventType::DEFENDERDROPPED, target);
removeObserver(1, ObserverEventType::DEFENDERADDED, target);
removeObserver(0, ObserverEventType::PLAYERKILLED, target);
}
}
示例9: useObject
int VetHarvesterDeedImplementation::useObject(CreatureObject* creature) {
ManagedReference<PlayerObject*> ghost = creature->getPlayerObject();
ZoneServer *zone = creature->getZoneServer();
if(ghost == NULL || zone == NULL)
return 0;
if (!isASubChildOf(creature))
return 0;
uint64 targetID = creature->getTargetID();
ManagedReference<TangibleObject*> targetObject = zone->getObject(targetID).castTo<TangibleObject*>();
if (targetObject == NULL || !targetObject->isHarvesterObject())
return 0;
HarvesterObject *harvester = targetObject.castTo<HarvesterObject*>();
if(harvester == NULL || !harvester->isOwnerOf(creature))
return 0;
if(harvester->isSelfPowered()) {
creature->sendSystemMessage("@veteran:harvester_already_selfpowered");
return 0;
}
StringIdChatParameter messageBody("veteran", "harvester_converted"); // Your harvester %TT has been converted to use 0 power.
messageBody.setTT(harvester);
ManagedReference<ChatManager*> cman = zone->getChatManager();
cman->sendMail("system", "@veteran:harvester_converted_subject", messageBody, creature->getFirstName());
EXECUTE_TASK_1(harvester, {
Locker locker(harvester_p);
harvester_p->setSelfPowered(true);
});
示例10: setNextPosition
int LuaAiAgent::setNextPosition(lua_State* L) {
ZoneServer* zoneServer = ServerCore::getZoneServer();
if (zoneServer == NULL)
return 0;
uint64 cellID = lua_tointeger(L, -1);
SceneObject* cell = NULL;
if (cellID != 0) {
cell = zoneServer->getObject(cellID);
if (cell != NULL && !cell->isCellObject())
cell = NULL;
}
float y = lua_tonumber(L, -2);
float z = lua_tonumber(L, -3);
float x = lua_tonumber(L, -4);
realObject->setNextPosition(x, z, y, cell);
return 0;
}
示例11: sendTo
void StructurePermissionList::sendTo(CreatureObject* creature, const String& listName) {
ZoneServer* zoneServer = creature->getZoneServer();
ReadLocker locker(&lock);
if (!idPermissionLists.contains(listName)) {
return;
}
PermissionListCreateMessage* listMsg = new PermissionListCreateMessage(listName);
SortedVector<uint64>* list = &idPermissionLists.get(listName);
Vector<uint64> invalidIDs;
for (int i = 0; i < list->size(); ++i) {
Reference<SceneObject*> object = zoneServer->getObject(list->get(i));
if (object != NULL && object->isPlayerCreature()) {
CreatureObject* player = object.castTo<CreatureObject*>();
String name = player->getFirstName();
listMsg->addName(name);
} else if (object != NULL && object->isGuildObject()) {
GuildObject* guild = object.castTo<GuildObject*>();
String name = "guild:" + guild->getGuildAbbrev();
listMsg->addName(name);
} else {
invalidIDs.add(list->get(i));
}
}
for (int i = 0; i < invalidIDs.size(); i++) {
list->drop(invalidIDs.get(i));
}
listMsg->generateMessage();
creature->sendMessage(listMsg);
}
示例12: teleport
void ZoneComponent::teleport(SceneObject* sceneObject, float newPositionX, float newPositionZ, float newPositionY, uint64 parentID) {
ZoneServer* zoneServer = sceneObject->getZoneServer();
Zone* zone = sceneObject->getZone();
if (zone == NULL)
return;
Locker locker(zone);
if (parentID != 0) {
ManagedReference<SceneObject*> newParent = zoneServer->getObject(parentID);
if (newParent == NULL || !newParent->isCellObject())
return;
if (newPositionX != sceneObject->getPositionX() || newPositionZ != sceneObject->getPositionZ() || newPositionY != sceneObject->getPositionY()) {
sceneObject->setPosition(newPositionX, newPositionZ, newPositionY);
sceneObject->updateZoneWithParent(newParent, false, false);
}
//sceneObject->info("sending data transform with parent", true);
DataTransformWithParent* pack = new DataTransformWithParent(sceneObject);
sceneObject->broadcastMessage(pack, true, false);
} else {
if (newPositionX != sceneObject->getPositionX() || newPositionZ != sceneObject->getPositionZ() || newPositionY != sceneObject->getPositionY()) {
sceneObject->setPosition(newPositionX, newPositionZ, newPositionY);
sceneObject->updateZone(false, false);
}
//sceneObject->info("sending data transform", true);
DataTransform* pack = new DataTransform(sceneObject);
sceneObject->broadcastMessage(pack, true, false);
}
}
示例13: notifyExit
void CityRegionImplementation::notifyExit(SceneObject* object) {
//pre: no 2 different city regions should ever overlap, only 2 Regions of the same city region
if (object->isTangibleObject()) {
TangibleObject* tano = cast<TangibleObject*>(object);
ManagedReference<Region*> activeRegion = tano->getActiveRegion().castTo<Region*>();
if (activeRegion != NULL) {
ManagedReference<CityRegion*> city = activeRegion->getCityRegion();
object->setCityRegion(city);
if (city == _this.getReferenceUnsafeStaticCast()) // if its the same city we wait till the object exits the last region
return;
} else {
object->setCityRegion(NULL);
}
} else {
object->setCityRegion(NULL);
}
if (object->isBazaarTerminal() || object->isVendor()) {
if (object->isBazaarTerminal())
bazaars.drop(object->getObjectID());
AuctionTerminalDataComponent* terminalData = NULL;
DataObjectComponentReference* data = object->getDataObjectComponent();
if(data != NULL && data->get() != NULL && data->get()->isAuctionTerminalData())
terminalData = cast<AuctionTerminalDataComponent*>(data->get());
if(terminalData != NULL)
terminalData->updateUID();
}
if (object->isPlayerCreature())
currentPlayers.decrement();
if (isClientRegion())
return;
if (object->isCreatureObject()) {
CreatureObject* creature = cast<CreatureObject*>(object);
StringIdChatParameter params("city/city", "city_leave_city"); //You have left %TO.
params.setTO(getRegionName());
creature->sendSystemMessage(params);
removeSpecializationModifiers(creature);
}
if (object->isStructureObject()) {
float x = object->getWorldPositionX();
float y = object->getWorldPositionY();
StructureObject* structure = cast<StructureObject*>(object);
Locker slocker(&structureListMutex);
if (structure->isBuildingObject()) {
BuildingObject* building = cast<BuildingObject*>(object);
uint64 ownerID = structure->getOwnerObjectID();
ZoneServer* zoneServer = building->getZoneServer();
if (zoneServer != NULL) {
ManagedReference<CreatureObject*> owner = zoneServer->getObject(ownerID).castTo<CreatureObject*>();
if(owner != NULL && owner->isPlayerCreature() && building->isResidence() && isCitizen(ownerID)) {
CityManager* cityManager = zoneServer->getCityManager();
cityManager->unregisterCitizen(_this.getReferenceUnsafeStaticCast(), owner);
}
}
}
completeStructureList.drop(structure->getObjectID());
if (structure->isCivicStructure()) {
removeStructure(structure);
} else if (structure->isCommercialStructure()) {
removeCommercialStructure(structure);
}
}
if (object->isDecoration() && object->getParent().get() == NULL) {
removeDecoration(object);
}
}
示例14: handleObjectMenuSelect
int DroidCustomKitObjectMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* player, byte selectedID) {
if (player == NULL)
return 0;
if (!sceneObject->isASubChildOf(player))
return 0;
if (selectedID != 20)
return TangibleObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID);
if(!sceneObject->isTangibleObject())
return 0;
ManagedReference<TangibleObject*> kitTano = cast<TangibleObject*>(sceneObject);
if(kitTano == NULL)
return 0;
uint64 targetID = player->getTargetID();
ZoneServer* server = player->getZoneServer();
if (server == NULL)
return 0;
ManagedReference<TangibleObject*> target = server->getObject(targetID, true).castTo<TangibleObject*>();
if (target == NULL || !target->isDroidObject()) {
player->sendSystemMessage("You can only use this tool to customize droids");
return 0;
}
//permission check
CreatureObject* droid = cast<CreatureObject*>(target.get());
uint64 ownerID = droid->getCreatureLinkID();
if ( ownerID != player->getObjectID()){
bool hasConsent = false;
ManagedReference<CreatureObject*> targetOwner = server->getObject(ownerID, true).castTo<CreatureObject*>();
if (targetOwner != NULL)
{
Locker crossLock(targetOwner, player);
ManagedReference<PlayerObject*> ghostOwner = targetOwner->getPlayerObject();
for (int i = 0; i < ghostOwner->getConsentListSize(); ++i) {
String entryName = ghostOwner->getConsentName(i);
if (!entryName.isEmpty()){
if (entryName == player->getFirstName().toLowerCase()){
hasConsent = true;
}
}
}
}
if (!hasConsent){
player->sendSystemMessage("You require consent to customize another player's droid");
return 0;
}
}
//end permission check
Locker clocker(droid, player);
String appearanceFilename = target->getObjectTemplate()->getAppearanceFilename();
VectorMap<String, Reference<CustomizationVariable*> > variables;
AssetCustomizationManagerTemplate::instance()->getCustomizationVariables(appearanceFilename.hashCode(), variables, false);
int numPalette = 0;
for(int i = 0; i< variables.size(); ++i)
{
String varkey = variables.elementAt(i).getKey();
if (varkey.contains("color"))
{
++numPalette;
}
}
if (numPalette == 0) {
player->sendSystemMessage("No customization options available on this droid"); // protocol droids
return 0;
}
DroidObject* painted = cast<DroidObject*>(droid);
if (painted != NULL){
painted->refreshPaint();
}
ManagedReference<SuiListBox*> frameTrimSelector = new SuiListBox(player, SuiWindowType::CUSTOMIZE_KIT);
frameTrimSelector->setUsingObject(player);
frameTrimSelector->setCallback(new CustomDroidSuiCallback(server, numPalette, kitTano));
frameTrimSelector->setUsingObject(target);
frameTrimSelector->setPromptTitle("Customize");
frameTrimSelector->setPromptText("Please select the customization action you would like to take");
frameTrimSelector->addMenuItem("Color Frame");
if (numPalette > 1 ) {
frameTrimSelector->addMenuItem("Color Trim");
}
if (numPalette > 2 ) {
frameTrimSelector->addMenuItem("Color Extra Trim");
}
frameTrimSelector->setCancelButton(true, "");
frameTrimSelector->setOkButton(true, "@ok");
//.........这里部分代码省略.........
开发者ID:Chilastra-Reborn,项目名称:Chilastra-source-code,代码行数:101,代码来源:DroidCustomKitObjectMenuComponent.cpp
示例15: handleObjectMenuSelect
int VitalityPackImplementation::handleObjectMenuSelect(CreatureObject* player, byte selectedID) {
if (player == NULL)
return 0;
if (!isASubChildOf(player))
return 0;
if (selectedID != 20)
return TangibleObjectImplementation::handleObjectMenuSelect(player, selectedID);
uint64 targetID = player->getTargetID();
ZoneServer* server = player->getZoneServer();
if (server == NULL)
return 0;
// Target must be a pet
ManagedReference<TangibleObject*> target = server->getObject(targetID, true).castTo<TangibleObject*>();
if (target == NULL || !target->isPet() ) {
player->sendSystemMessage("You can only use this to restore vitality to pets");
return 0;
}
ManagedReference<AiAgent*> pet = cast<AiAgent*>(target.get());
if( pet == NULL )
return 0;
ManagedReference<PetControlDevice*> controlDevice = pet->getControlDevice().get().castTo<PetControlDevice*>();
if( controlDevice == NULL )
return 0;
// Check pet type
Locker crossLock(controlDevice, _this.getReferenceUnsafeStaticCast() );
if( controlDevice->getPetType() == PetManager::FACTIONPET ){
player->sendSystemMessage("You cannot use this to restore vitality to that type of pet");
return 0;
}
// Check owner
uint64 ownerID = pet->getCreatureLinkID();
if ( ownerID != player->getObjectID()){
player->sendSystemMessage("You cannot revitalize another player's pet");
return 0;
}
// Check pet and player states
if( pet->isInCombat() || pet->isDead() || pet->isIncapacitated() || player->isInCombat() || player->isDead() || player->isIncapacitated()){
player->sendSystemMessage("You can't restore vitality to your pet right now");
return 0;
}
// Check that some vitality has been lost
if( controlDevice->getVitality() >= controlDevice->getMaxVitality() ){
player->sendSystemMessage("Pet is already at maximum vitality");
return 0;
}
// Calculate vitality loss
int vitalityLost = controlDevice->getMaxVitality() - controlDevice->getVitality();
int vitalityLoss = 1;
if (effectiveness < 45){
vitalityLoss += (vitalityLost / 9) + (vitalityLost / 13);
} else if (effectiveness < 75) {
vitalityLoss += (vitalityLost / 19) + (vitalityLost / 28);
} else {
vitalityLoss += (vitalityLost / 29) + (vitalityLost / 43);
}
vitalityLoss *= ((vitalityLost - 1) / effectiveness) + 1;
if( vitalityLoss >= controlDevice->getMaxVitality() ){
vitalityLoss = controlDevice->getMaxVitality() - 1;
}
// Reduce max vitality
controlDevice->setMaxVitality( controlDevice->getMaxVitality() - vitalityLoss );
// Restore vitality to new max
controlDevice->setVitality( controlDevice->getMaxVitality() );
// Use a charge
decreaseUseCount();
player->sendSystemMessage("You restore your pet to " + String::valueOf( controlDevice->getMaxVitality() ) +
" vitality but it permanently lost " + String::valueOf( vitalityLoss ) + " vitality." );
return 0;
}