本文整理汇总了C++中ManagedReference::addOwnedStructure方法的典型用法代码示例。如果您正苦于以下问题:C++ ManagedReference::addOwnedStructure方法的具体用法?C++ ManagedReference::addOwnedStructure怎么用?C++ ManagedReference::addOwnedStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManagedReference
的用法示例。
在下文中一共展示了ManagedReference::addOwnedStructure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: completeSession
int PlaceStructureSessionImplementation::completeSession() {
if (constructionBarricade != NULL)
constructionBarricade->destroyObjectFromWorld(true);
String serverTemplatePath = deedObject->getGeneratedObjectTemplate();
StructureManager* structureManager = StructureManager::instance();
ManagedReference<StructureObject*> structureObject = structureManager->placeStructure(creatureObject, serverTemplatePath, positionX, positionY, directionAngle);
removeTemporaryNoBuildZone();
if (structureObject == NULL) {
ManagedReference<SceneObject*> inventory = creatureObject->getSlottedObject("inventory");
if (inventory != NULL)
inventory->transferObject(deedObject, -1, true);
return cancelSession();
}
structureObject->setDeedObjectID(deedObject->getObjectID());
deedObject->notifyStructurePlaced(creatureObject, structureObject);
ManagedReference<PlayerObject*> ghost = creatureObject->getPlayerObject();
if (ghost != NULL) {
ghost->addOwnedStructure(structureObject);
//Create Waypoint
ManagedReference<WaypointObject*> waypointObject = ( zone->getZoneServer()->createObject(String("object/waypoint/world_waypoint_blue.iff").hashCode(), 1)).castTo<WaypointObject*>();
waypointObject->setCustomObjectName(structureObject->getDisplayedName(), false);
waypointObject->setActive(true);
waypointObject->setPosition(positionX, 0, positionY);
waypointObject->setPlanetCRC(zone->getZoneCRC());
ghost->addWaypoint(waypointObject, false, true);
//Create an email.
ManagedReference<ChatManager*> chatManager = zone->getZoneServer()->getChatManager();
if (chatManager != NULL) {
UnicodeString subject = "@player_structure:construction_complete_subject";
StringIdChatParameter emailBody("@player_structure:construction_complete");
emailBody.setTO(structureObject->getObjectName());
emailBody.setDI(ghost->getLotsRemaining());
chatManager->sendMail("@player_structure:construction_complete_sender", subject, emailBody, creatureObject->getFirstName(), waypointObject);
}
if (structureObject->isBuildingObject() && !structureObject->isGCWBase()) {
BuildingObject* building = cast<BuildingObject*>(structureObject.get());
building->setCustomObjectName(creatureObject->getFirstName() + "'s House", true); //Set the house sign.
}
}
return cancelSession(); //Canceling the session just removes the session from the player's map.
}
示例2: placeStructure
StructureObject* StructureManager::placeStructure(CreatureObject* creature,
const String& structureTemplatePath, float x, float y, int angle, int persistenceLevel) {
ManagedReference<Zone*> zone = creature->getZone();
if (zone == NULL)
return NULL;
TerrainManager* terrainManager =
zone->getPlanetManager()->getTerrainManager();
SharedStructureObjectTemplate* serverTemplate =
dynamic_cast<SharedStructureObjectTemplate*>(templateManager->getTemplate(
structureTemplatePath.hashCode()));
if (serverTemplate == NULL) {
info("server template is null");
return NULL;
}
float z = zone->getHeight(x, y);
float floraRadius = serverTemplate->getClearFloraRadius();
bool snapToTerrain = serverTemplate->getSnapToTerrain();
Reference<StructureFootprint*> structureFootprint =
serverTemplate->getStructureFootprint();
float w0 = -5; //Along the x axis.
float l0 = -5; //Along the y axis.
float l1 = 5;
float w1 = 5;
float zIncreaseWhenNoAvailableFootprint = 0.f; //TODO: remove this when it has been verified that all buildings have astructure footprint.
if (structureFootprint != NULL) {
//If the angle is odd, then swap them.
getStructureFootprint(serverTemplate, angle, l0, w0, l1, w1);
} else {
if (!serverTemplate->isCampStructureTemplate())
warning(
"Structure with template '" + structureTemplatePath
+ "' has no structure footprint.");
zIncreaseWhenNoAvailableFootprint = 5.f;
}
if (floraRadius > 0 && !snapToTerrain)
z = terrainManager->getHighestHeight(x + w0, y + l0, x + w1, y + l1, 1)
+ zIncreaseWhenNoAvailableFootprint;
String strDatabase = "playerstructures";
bool bIsFactionBuilding = (serverTemplate->getGameObjectType()
== SceneObjectType::FACTIONBUILDING);
if (bIsFactionBuilding || serverTemplate->getGameObjectType() == SceneObjectType::TURRET) {
strDatabase = "playerstructures";
}
ManagedReference<SceneObject*> obj =
ObjectManager::instance()->createObject(
structureTemplatePath.hashCode(), persistenceLevel, strDatabase);
if (obj == NULL || !obj->isStructureObject()) {
if (obj != NULL) {
Locker locker(obj);
obj->destroyObjectFromDatabase(true);
}
error(
"Failed to create structure with template: "
+ structureTemplatePath);
return NULL;
}
StructureObject* structureObject = cast<StructureObject*>(obj.get());
Locker sLocker(structureObject);
structureObject->grantPermission("ADMIN", creature->getObjectID());
structureObject->setOwner(creature->getObjectID());
ManagedReference<PlayerObject*> ghost = creature->getPlayerObject();
if (ghost != NULL) {
ghost->addOwnedStructure(structureObject);
}
if(structureObject->isTurret() || structureObject->isMinefield()){
structureObject->setFaction(creature->getFaction());
}
BuildingObject* buildingObject = NULL;
if (structureObject->isBuildingObject()) {
buildingObject = cast<BuildingObject*>(structureObject);
if (buildingObject != NULL)
buildingObject->createCellObjects();
}
structureObject->setPublicStructure(serverTemplate->isPublicStructure());
structureObject->initializePosition(x, z, y);
structureObject->rotate(angle);
//.........这里部分代码省略.........