本文整理汇总了C++中ManagedReference::createChildObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ ManagedReference::createChildObjects方法的具体用法?C++ ManagedReference::createChildObjects怎么用?C++ ManagedReference::createChildObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManagedReference
的用法示例。
在下文中一共展示了ManagedReference::createChildObjects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadPlanetObjects
void PlanetManagerImplementation::loadPlanetObjects(LuaObject* luaObject) {
if (!luaObject->isValidTable())
return;
for (int i = 1; i <= luaObject->getTableSize(); ++i) {
lua_State* L = luaObject->getLuaState();
lua_rawgeti(L, -1, i);
LuaObject planetObject(L);
String templateFile = planetObject.getStringField("templateFile");
ManagedReference<SceneObject*> obj = ObjectManager::instance()->createObject(templateFile.hashCode(), 0, "");
if (obj != NULL) {
Locker objLocker(obj);
float x = planetObject.getFloatField("x");
float y = planetObject.getFloatField("y");
float z = planetObject.getFloatField("z");
float ox = planetObject.getFloatField("ox");
float oy = planetObject.getFloatField("oy");
float oz = planetObject.getFloatField("oz");
float ow = planetObject.getFloatField("ow");
uint64 parentID = planetObject.getLongField("parent");
if (obj->isBuildingObject()) {
BuildingObject* building = obj->asBuildingObject();
building->createCellObjects();
}
obj->initializePosition(x, z, y);
obj->setDirection(ow, ox, oy, oz);
ManagedReference<SceneObject*> parent = zone->getZoneServer()->getObject(parentID);
if (parent != NULL)
parent->transferObject(obj, -1, true);
else
zone->transferObject(obj, -1, true);
obj->createChildObjects();
}
planetObject.pop();
}
}
示例2: spawnDynamicSpawn
SceneObject* CreatureManagerImplementation::spawnDynamicSpawn(unsigned int lairTemplate, int difficulty, float x, float z, float y, float size) {
LairTemplate* lairTmpl = creatureTemplateManager->getLairTemplate(lairTemplate);
if (lairTmpl == NULL || lairTmpl->getBuildingType() != LairTemplate::NONE)
return NULL;
Vector<String>* mobiles = lairTmpl->getWeightedMobiles();
if (mobiles->size() == 0)
return NULL;
ManagedReference<TheaterObject*> theater = zoneServer->createObject(STRING_HASHCODE("object/intangible/theater/base_theater.iff"), 0).castTo<TheaterObject*>();
if (theater == NULL) {
error("error creating intangible theater");
return NULL;
}
Locker blocker(theater);
theater->initializePosition(x, z, y);
theater->setDespawnOnNoPlayersInRange(true);
ManagedReference<DynamicSpawnObserver*> dynamicObserver = new DynamicSpawnObserver();
dynamicObserver->deploy();
dynamicObserver->setLairTemplate(lairTmpl);
dynamicObserver->setDifficulty(difficulty);
dynamicObserver->setObserverType(ObserverType::LAIR);
dynamicObserver->setSize(size);
theater->registerObserver(ObserverEventType::CREATUREDESPAWNED, dynamicObserver);
theater->registerObserver(ObserverEventType::OBJECTREMOVEDFROMZONE, dynamicObserver);
zone->transferObject(theater, -1, false);
theater->createChildObjects();
dynamicObserver->spawnInitialMobiles(theater);
return theater;
}
示例3: handleObjectMenuSelect
//.........这里部分代码省略.........
player->sendSystemMessage("wrong pet template;mobileTemplate=[" + mobileTemplate + "]" );
return 1;
}
bool isVicious = petTemplate->getPvpBitmask() & CreatureFlag::AGGRESSIVE;
if (level > 10 || isVicious) {
if (!player->hasSkill("outdoors_creaturehandler_novice") || (level > maxLevelofPets)) {
player->sendSystemMessage("@pet/pet_menu:sys_lack_skill"); // You lack the skill to be able to tame that creature.
return 1;
}
if (isVicious && player->getSkillMod("tame_aggro") < 1) {
player->sendSystemMessage("@pet/pet_menu:sys_lack_skill"); // You lack the skill to be able to tame that creature.
return 1;
}
}
// All checks complete, lets setup the control device and do it.
ManagedReference<PetControlDevice*> controlDevice = (server->getZoneServer()->createObject(controlDeviceObjectTemplate.hashCode(), 1)).castTo<PetControlDevice*>();
if (controlDevice == NULL) {
player->sendSystemMessage("wrong pet control device;controlDevice=[" + controlDeviceObjectTemplate + "]" );
return 1;
}
Locker locker(controlDevice);
String templateToSpawn = creatureManager->getTemplateToSpawn(mobileTemplate.hashCode());
ManagedReference<CreatureObject*> creatureObject = creatureManager->createCreature(templateToSpawn.hashCode(), true, 0 );
if( creatureObject == NULL ) {
controlDevice->destroyObjectFromDatabase(true);
player->sendSystemMessage("wrong pet template;mobileTemplate=[" + mobileTemplate + "]" );
return 1;
}
Locker clocker(creatureObject, player);
ManagedReference<Creature*> pet = creatureObject.castTo<Creature*>();
if( pet == NULL ) {
controlDevice->destroyObjectFromDatabase(true);
creatureObject->destroyObjectFromDatabase(true);
player->sendSystemMessage("Internal Pet Deed Error #348" );
return 1;
}
ObjectManager* objectManager = server->getZoneServer()->getObjectManager();
pet->setPetDeed(_this.get());
pet->loadTemplateData( petTemplate );
pet->setCustomObjectName(StringIdManager::instance()->getStringId(*pet->getObjectName()), true);
pet->createChildObjects();
pet->setBaby(false);
// update base stats on the pet now
// We will store the deed pointer to the aiagent before serialization
// Copy color customization from deed to pet
CustomizationVariables* customVars = getCustomizationVariables();
if( customVars != NULL ){
for (int i = 0; i < customVars->size(); ++i) {
uint8 id = customVars->elementAt(i).getKey();
int16 val = customVars->elementAt(i).getValue();
String name = CustomizationIdManager::instance()->getCustomizationVariable(id);
pet->setCustomizationVariable( name, val, true );
}
}
// then this is complete
StringId s;
s.setStringId(pet->getObjectName()->getFullPath());
controlDevice->setControlledObject(pet);
controlDevice->setObjectName(s);
controlDevice->setPetType(PetManager::CREATUREPET);
controlDevice->setMaxVitality(100);
controlDevice->setVitality(100);
controlDevice->setGrowthStage(1);
controlDevice->updateStatus(1);
if (!datapad->transferObject(controlDevice, -1)) {
controlDevice->destroyObjectFromDatabase(true);
return 1;
}
datapad->broadcastObject(controlDevice, true);
controlDevice->growPet(player,true);
controlDevice->callObject(player);
//Remove the deed from it's container.
ManagedReference<SceneObject*> deedContainer = getParent().get();
if (deedContainer != NULL) {
destroyObjectFromWorld(true);
}
generated = true;
player->sendSystemMessage("@pet/pet_menu:device_added"); // "A control device has been added to your datapad."
return 0;
}
return DeedImplementation::handleObjectMenuSelect(player, selectedID);
}
示例4: handleCharacterBuilderSelectItem
//.........这里部分代码省略.........
}
} else if (templatePath == "reset_buffs") {
if (!player->isInCombat()) {
player->sendSystemMessage("Your buffs have been reset.");
player->clearBuffs(true);
ghost->setFoodFilling(0);
ghost->setDrinkFilling(0);
} else {
player->sendSystemMessage("Not within combat.");
}
} else if (templatePath.beginsWith("crafting_apron_")) {
//"object/tangible/wearables/apron/apron_chef_s01.iff"
//"object/tangible/wearables/ithorian/apron_chef_jacket_s01_ith.iff"
uint32 itemCrc = ( player->getSpecies() != CreatureObject::ITHORIAN ) ? 0x5DDC4E5D : 0x6C191FBB;
ManagedReference<WearableObject*> apron = zserv->createObject(itemCrc, 2).castTo<WearableObject*>();
if (apron == NULL) {
player->sendSystemMessage("There was an error creating the requested item. Please contact customer support with this issue.");
ghost->addSuiBox(cbSui);
player->sendMessage(cbSui->generateMessage());
error("could not create frog crafting apron");
return;
}
apron->createChildObjects();
if (apron->isWearableObject()) {
uint32 bitmask = apron->getOptionsBitmask() | OptionBitmask::YELLOW;
apron->setOptionsBitmask(bitmask, false);
UnicodeString modName = "(General)";
apron->addSkillMod(SkillModManager::WEARABLE, "general_assembly", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "general_experimentation", 25);
if(templatePath == "crafting_apron_armorsmith") {
modName = "(Armorsmith)";
apron->addSkillMod(SkillModManager::WEARABLE, "armor_assembly", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "armor_experimentation", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "armor_repair", 25);
} else if(templatePath == "crafting_apron_weaponsmith") {
modName = "(Weaponsmith)";
apron->addSkillMod(SkillModManager::WEARABLE, "weapon_assembly", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "weapon_experimentation", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "weapon_repair", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "grenade_assembly", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "grenade_experimentation", 25);
} else if(templatePath == "crafting_apron_tailor") {
modName = "(Tailor)";
apron->addSkillMod(SkillModManager::WEARABLE, "clothing_assembly", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "clothing_experimentation", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "clothing_repair", 25);
} else if(templatePath == "crafting_apron_chef") {
modName = "(Chef)";
apron->addSkillMod(SkillModManager::WEARABLE, "food_assembly", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "food_experimentation", 25);
} else if(templatePath == "crafting_apron_architect") {
modName = "(Architect)";
示例5: createCharacter
bool PlayerCreationManager::createCharacter(MessageCallback* data) {
TemplateManager* templateManager = TemplateManager::instance();
ClientCreateCharacterCallback* callback = cast<
ClientCreateCharacterCallback*>(data);
ZoneClientSession* client = data->getClient();
if (client->getCharacterCount(zoneServer.get()->getGalaxyID()) >= 10) {
ErrorMessage* errMsg = new ErrorMessage("Create Error", "You are limited to 10 characters per galaxy.", 0x0);
client->sendMessage(errMsg);
return false;
}
PlayerManager* playerManager = zoneServer.get()->getPlayerManager();
SkillManager* skillManager = SkillManager::instance();
//Get all the data and validate it.
UnicodeString characterName;
callback->getCharacterName(characterName);
//TODO: Replace this at some point?
if (!playerManager->checkPlayerName(callback))
return false;
String raceFile;
callback->getRaceFile(raceFile);
uint32 serverObjectCRC = raceFile.hashCode();
PlayerCreatureTemplate* playerTemplate =
dynamic_cast<PlayerCreatureTemplate*>(templateManager->getTemplate(
serverObjectCRC));
if (playerTemplate == NULL) {
error("Unknown player template selected: " + raceFile);
return false;
}
int raceID = playerTemplate->getRace();
String fileName = playerTemplate->getTemplateFileName();
String clientTemplate = templateManager->getTemplateFile(
playerTemplate->getClientObjectCRC());
RacialCreationData* raceData = racialCreationData.get(fileName);
if (raceData == NULL)
raceData = racialCreationData.get(0); //Just get the first race, since they tried to create a race that doesn't exist.
String profession, customization, hairTemplate, hairCustomization;
callback->getSkill(profession);
if (profession.contains("jedi"))
profession = "crafting_artisan";
callback->getCustomizationString(customization);
callback->getHairObject(hairTemplate);
callback->getHairCustomization(hairCustomization);
float height = callback->getHeight();
height = MAX(MIN(height, playerTemplate->getMaxScale()),
playerTemplate->getMinScale());
//validate biography
UnicodeString bio;
callback->getBiography(bio);
bool doTutorial = callback->getTutorialFlag();
//bool doTutorial = false;
ManagedReference<CreatureObject*> playerCreature =
zoneServer.get()->createObject(
serverObjectCRC, 2).castTo<CreatureObject*>();
if (playerCreature == NULL) {
error("Could not create player with template: " + raceFile);
return false;
}
Locker playerLocker(playerCreature);
playerCreature->createChildObjects();
playerCreature->setHeight(height);
playerCreature->setCustomObjectName(characterName, false); //TODO: Validate with Name Manager.
client->setPlayer(playerCreature);
playerCreature->setClient(client);
// Set starting cash and starting bank
playerCreature->setCashCredits(startingCash, false);
playerCreature->setBankCredits(startingBank, false);
ManagedReference<PlayerObject*> ghost = playerCreature->getPlayerObject();
if (ghost != NULL) {
//Set skillpoints before adding any skills.
ghost->setSkillPoints(skillPoints);
//.........这里部分代码省略.........
示例6: createVendor
void CreateVendorSessionImplementation::createVendor(String& name) {
ManagedReference<CreatureObject*> player = this->player.get();
Locker locker(player);
if (!VendorManager::instance()->isValidVendorName(name)) {
player->sendSystemMessage("@player_structure:obscene");
SuiInputBox* input = new SuiInputBox(player, SuiWindowType::STRUCTURE_NAME_VENDOR);
input->setCallback(new NameVendorSuiCallback(player->getZoneServer()));
input->setCancelButton(true, "@cancel");
input->setPromptTitle("@player_structure:name_t");
input->setPromptText("@player_structure:name_d");
player->sendMessage(input->generateMessage());
player->getPlayerObject()->addSuiBox(input);
return;
}
ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
if (inventory == NULL) {
cancelSession();
return;
}
ManagedReference<TangibleObject*> vendor;
try {
vendor = (player->getZoneServer()->createObject(templatePath.hashCode())).castTo<TangibleObject*>();
} catch (Exception& e) {
error(e.getMessage());
}
if (vendor == NULL) {
error("could not create vendor " + templatePath);
cancelSession();
return;
}
Locker clocker(vendor, player);
if (!vendor->isVendor()) {
error("could not create vendor " + templatePath);
vendor->destroyObjectFromDatabase(true);
cancelSession();
return;
}
vendor->createChildObjects();
if (inventory->isContainerFullRecursive()) {
player->sendSystemMessage("@player_structure:create_failed");
vendor->destroyObjectFromDatabase(true);
cancelSession();
return;
}
DataObjectComponentReference* data = vendor->getDataObjectComponent();
if(data == NULL || data->get() == NULL || !data->get()->isVendorData()) {
error("Invalid vendor, no data component: " + templatePath);
player->sendSystemMessage("@player_structure:create_failed");
vendor->destroyObjectFromDatabase(true);
cancelSession();
return;
}
VendorDataComponent* vendorData = cast<VendorDataComponent*>(data->get());
if(vendorData == NULL) {
error("Invalid vendor, no data component: " + templatePath);
player->sendSystemMessage("@player_structure:create_failed");
vendor->destroyObjectFromDatabase(true);
cancelSession();
return ;
}
vendorData->setOwnerId(player->getObjectID());
vendor->setCustomObjectName("Vendor: " + name, false);
vendor->setContainerOwnerID(player->getObjectID());
vendor->setMaxCondition(1000, false);
vendor->setConditionDamage(0, false);
if(vendor->isCreatureObject()) {
randomizeVendorLooks(cast<CreatureObject*>(vendor.get()));
}
if(!inventory->transferObject(vendor, -1, false)) {
player->sendSystemMessage("@player_structure:create_failed");
vendor->destroyObjectFromDatabase(true);
cancelSession();
return;
}
inventory->broadcastObject(vendor, true);
player->getPlayerObject()->addVendor(vendor);
player->sendSystemMessage("@player_structure:create_success");
cancelSession();
}
示例7: createLootObject
TangibleObject* LootManagerImplementation::createLootObject(LootItemTemplate* templateObject, int level, bool maxCondition) {
if(level < 1)
level = 1;
if(level > 300)
level = 300;
String directTemplateObject = templateObject->getDirectObjectTemplate();
ManagedReference<TangibleObject*> prototype = zoneServer->createObject(directTemplateObject.hashCode(), 2).castTo<TangibleObject*>();
if (prototype == NULL) {
error("could not create loot object: " + directTemplateObject);
return NULL;
}
prototype->createChildObjects();
String serial = craftingManager->generateSerial();
prototype->setSerialNumber(serial);
prototype->setJunkDealerNeeded(templateObject->getJunkDealerTypeNeeded());
float junkMinValue = templateObject->getJunkMinValue() * junkValueModifier;
float junkMaxValue = templateObject->getJunkMaxValue() * junkValueModifier;
float fJunkValue = junkMinValue+System::random(junkMaxValue-junkMinValue);
if (level>0 && templateObject->getJunkDealerTypeNeeded()>1){
fJunkValue=fJunkValue + (fJunkValue * ((float)level / 100)); // This is the loot value calculation if the item has a level
}
CraftingValues craftingValues = templateObject->getCraftingValuesCopy();
setInitialObjectStats(templateObject, &craftingValues, prototype);
setCustomObjectName(prototype, templateObject);
float excMod = 1.0;
if (System::random(legendaryChance) == legendaryChance) {
uint32 bitmask = prototype->getOptionsBitmask() | OptionBitmask::YELLOW;
UnicodeString newName = prototype->getDisplayedName() + " (Legendary)";
prototype->setCustomObjectName(newName, false);
excMod = legendaryModifier;
prototype->setOptionsBitmask(bitmask, false);
} else if (System::random(exceptionalChance) == exceptionalChance) {
uint32 bitmask = prototype->getOptionsBitmask() | OptionBitmask::YELLOW;
UnicodeString newName = prototype->getDisplayedName() + " (Exceptional)";
prototype->setCustomObjectName(newName, false);
excMod = exceptionalModifier;
prototype->setOptionsBitmask(bitmask, false);
}
String subtitle;
bool yellow = false;
for (int i = 0; i < craftingValues.getExperimentalPropertySubtitleSize(); ++i) {
subtitle = craftingValues.getExperimentalPropertySubtitle(i);
if (subtitle == "hitpoints" || subtitle == "maxrange") {
if(!(prototype->isComponent())) {
continue;
}
}
float min = craftingValues.getMinValue(subtitle);
float max = craftingValues.getMaxValue(subtitle);
if (min == max)
continue;
if (subtitle != "useCount" &&
subtitle != "quantity" &&
subtitle != "charges" &&
subtitle != "uses" &&
subtitle != "charge") {
float minMod = (max > min) ? 2000.f : -2000.f;
float maxMod = (max > min) ? 500.f : -500.f;
if (max > min && min >= 0) { // Both max and min non-negative, max is higher
min = ((min * level / minMod) + min) * excMod;
max = ((max * level / maxMod) + max) * excMod;
} else if (max > min && max <= 0) { // Both max and min are non-positive, max is higher
minMod *= -1;
maxMod *= -1;
min = ((min * level / minMod) + min) / excMod;
max = ((max * level / maxMod) + max) / excMod;
} else if (max > min) { // max is positive, min is negative
minMod *= -1;
min = ((min * level / minMod) + min) / excMod;
max = ((max * level / maxMod) + max) * excMod;
} else if (max < min && max >= 0) { // Both max and min are non-negative, min is higher
min = ((min * level / minMod) + min) / excMod;
//.........这里部分代码省略.........