本文整理汇总了C++中DataObjectComponentReference::get方法的典型用法代码示例。如果您正苦于以下问题:C++ DataObjectComponentReference::get方法的具体用法?C++ DataObjectComponentReference::get怎么用?C++ DataObjectComponentReference::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectComponentReference
的用法示例。
在下文中一共展示了DataObjectComponentReference::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleRenameVendor
void VendorManager::handleRenameVendor(CreatureObject* player, TangibleObject* vendor, String& name) {
if (vendor == NULL)
return;
Zone* zone = vendor->getZone();
if (zone == NULL)
return;
if (!isValidVendorName(name)) {
player->sendSystemMessage("@player_structure:obscene");
promptRenameVendorTo(player, vendor);
return;
}
DataObjectComponentReference* data = vendor->getDataObjectComponent();
if(data == NULL || data->get() == NULL || !data->get()->isVendorData()) {
error("Vendor has no data component");
return;
}
VendorDataComponent* vendorData = cast<VendorDataComponent*>(data->get());
if(vendorData == NULL) {
error("Vendor has wrong data component");
return;
}
Locker _locker(vendor);
vendor->setCustomObjectName("Vendor: " + name, true);
if (vendorData->isRegistered()) {
vendorData->setRegistered(false);
zone->unregisterObjectWithPlanetaryMap(vendor);
player->sendSystemMessage("@player_structure:vendor_rename_unreg");
} else
player->sendSystemMessage("@player_structure:vendor_rename");
}
示例2: handleRegisterVendorCallback
void VendorManager::handleRegisterVendorCallback(CreatureObject* player, TangibleObject* vendor, const String& planetMapCategoryName) {
Zone* zone = vendor->getZone();
if (zone == NULL)
return;
DataObjectComponentReference* data = vendor->getDataObjectComponent();
if(data == NULL || data->get() == NULL || !data->get()->isVendorData()) {
error("Vendor has no data component");
return;
}
VendorDataComponent* vendorData = cast<VendorDataComponent*>(data->get());
if(vendorData == NULL) {
error("Vendor has wrong data component");
return;
}
if (vendorData->isEmpty()) {
player->sendSystemMessage("You cannot register an empty vendor.");
return;
}
Reference<PlanetMapCategory*> planetMapCategory = TemplateManager::instance()->getPlanetMapCategoryByName("vendor");
Reference<PlanetMapCategory*> planetMapSubCategory = TemplateManager::instance()->getPlanetMapCategoryByName("vendor_" + planetMapCategoryName);
if (planetMapCategory == NULL || planetMapSubCategory == NULL)
return;
Locker locker(vendor);
vendor->setPlanetMapCategory(planetMapCategory);
vendor->setPlanetMapSubCategory(planetMapSubCategory);
vendorData->setRegistered(true);
zone->registerObjectWithPlanetaryMap(vendor);
player->sendSystemMessage("@player_structure:register_vendor_not");
}
示例3: initDroidModules
void DroidObjectImplementation::initDroidModules(){
modules.removeAll();
ManagedReference<SceneObject*> container = getSlottedObject("crafted_components");
if(container != NULL && container->getContainerObjectsSize() > 0) {
SceneObject* satchel = container->getContainerObject(0);
if(satchel != NULL && satchel->getContainerObjectsSize() > 0) {
for (int i = 0; i < satchel->getContainerObjectsSize(); ++i) {
ManagedReference<SceneObject*> sceno = satchel->getContainerObject(i);
if( sceno == NULL ){
continue;
}
DataObjectComponentReference* data = sceno->getDataObjectComponent();
if(data == NULL || data->get() == NULL || !data->get()->isDroidModuleData() ){
continue;
}
BaseDroidModuleComponent* module = cast<BaseDroidModuleComponent*>(data->get());
if( module != NULL ){
modules.add(module);
}
}
}
}
}
示例4: destroyVendor
void VendorManager::destroyVendor(TangibleObject* vendor) {
DataObjectComponentReference* data = vendor->getDataObjectComponent();
if(data == NULL || data->get() == NULL || !data->get()->isVendorData()) {
error("Vendor has no data component");
return;
}
VendorDataComponent* vendorData = cast<VendorDataComponent*>(data->get());
if(vendorData == NULL) {
error("Vendor has wrong data component");
return;
}
ManagedReference<AuctionManager*> auctionManager = server->getZoneServer()->getAuctionManager();
if(auctionManager == NULL) {
error("null auctionManager when deleting vendor");
return;
}
ManagedReference<AuctionsMap*> auctionsMap = auctionManager->getAuctionMap();
if(auctionsMap == NULL) {
error("null auctionsMap");
return;
}
if (vendorData->isRegistered() && vendor->getZone() != NULL) {
vendor->getZone()->unregisterObjectWithPlanetaryMap(vendor);
}
Locker locker(vendor);
vendor->destroyObjectFromWorld(true);
vendor->destroyObjectFromDatabase(true);
locker.release();
auctionsMap->deleteTerminalItems(vendor);
}
示例5: notifyPositionUpdate
void MinefieldZoneComponent::notifyPositionUpdate(SceneObject* sceneObject, QuadTreeEntry* entry) const {
// if we don't have any mines, just exit
if(sceneObject->getContainerObjectsSize() == 0 )
return;
ManagedReference<SceneObject*> target = cast<SceneObject*>(entry);
if(!sceneObject->isMinefield() || target == NULL){
return;
}
DataObjectComponentReference* ref = sceneObject->getDataObjectComponent();
if(ref == NULL){
info("dataobjectcomponent is null",true);
return;
}
MinefieldDataComponent* mineData = cast<MinefieldDataComponent*>(ref->get());
if(mineData == NULL || !mineData->canExplode())
return;
try {
if (target->isPlayerCreature() && sceneObject->isInRange(target,mineData->getMaxRange())){
ManagedReference<CreatureObject*> player = cast<CreatureObject*>(entry);
if(player == NULL)
return;
ManagedReference<TangibleObject*> tano = cast<TangibleObject*>(sceneObject);
if(tano == NULL)
return;
if(!player->isAttackableBy(tano))
return;
Reference<MinefieldAttackTask*> task = new MinefieldAttackTask(sceneObject, player);
task->execute();
}
} catch (Exception& e) {
}
return;
}
示例6: notifyPositionUpdate
void DetectorZoneComponent::notifyPositionUpdate(SceneObject* sceneObject, QuadTreeEntry* entry) const {
ManagedReference<SceneObject*> target = cast<SceneObject*>(entry);
if(!sceneObject->isTangibleObject() || target == NULL){
return;
}
ManagedReference<TangibleObject*> tano = cast<TangibleObject*>(sceneObject);
DataObjectComponentReference* ref = sceneObject->getDataObjectComponent();
if(ref == NULL){
info("data is null",true);
return;
}
DetectorDataComponent* scannerData = cast<DetectorDataComponent*>(ref->get());
if(scannerData == NULL || !scannerData->canScan())
return;
if(sceneObject->isDetector() && target->isPlayerCreature() && sceneObject->isInRange(target,65)){
ManagedReference<CreatureObject*> player = cast<CreatureObject*>(entry);
if(player == NULL)
return;
ManagedReference<PlayerObject*> playerObject = player->getPlayerObject();
if(playerObject == NULL)
return;
if(tano->getFaction() != player->getFaction() && player->getFaction() != 0 ){
scannerData->updateCooldown();
PlayClientEffectLoc* explodeLoc = new PlayClientEffectLoc("clienteffect/survey_effect.cef", tano->getZone()->getZoneName(), tano->getPositionX(), tano->getPositionZ(), tano->getPositionY());
tano->broadcastMessage(explodeLoc, false);
}
}
return;
}
示例7: 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);
}
}
示例8: notifyEnter
void CityRegionImplementation::notifyEnter(SceneObject* object) {
if (object->getCityRegion().get() != _this.getReferenceUnsafeStaticCast() && object->isPlayerCreature())
currentPlayers.increment();
object->setCityRegion(_this.getReferenceUnsafeStaticCast());
if (object->isBazaarTerminal() || object->isVendor()) {
if (object->isBazaarTerminal())
bazaars.put(object->getObjectID(), cast<TangibleObject*>(object));
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 (isClientRegion())
return;
if (object->isCreatureObject()) {
CreatureObject* creature = cast<CreatureObject*>(object);
StringIdChatParameter params("city/city", "city_enter_city"); //You have entered %TT (%TO).
params.setTT(getRegionName());
UnicodeString strRank = StringIdManager::instance()->getStringId(String("@city/city:rank" + String::valueOf(cityRank)).hashCode());
if (citySpecialization.isEmpty()) {
params.setTO(strRank);
}
else {
UnicodeString citySpec = StringIdManager::instance()->getStringId(citySpecialization.hashCode());
params.setTO(strRank + ", " + citySpec);
}
creature->sendSystemMessage(params);
applySpecializationModifiers(creature);
}
if (object->isStructureObject()) {
StructureObject* structure = cast<StructureObject*>(object);
CityManager* cityManager = getZone()->getZoneServer()->getCityManager();
Locker slocker(&structureListMutex);
if (isLoaded() && !completeStructureList.contains(structure->getObjectID()) && structure->getBaseMaintenanceRate() > 0) {
cityManager->sendAddStructureMails(_this.getReferenceUnsafeStaticCast(), structure);
}
if (structure->isBuildingObject()) {
BuildingObject* building = cast<BuildingObject*>(object);
uint64 ownerID = structure->getOwnerObjectID();
ManagedReference<CreatureObject*> owner = zone->getZoneServer()->getObject(ownerID).castTo<CreatureObject*>();
if(owner != NULL && owner->isPlayerCreature() && building->isResidence() && !isCitizen(ownerID)) {
cityManager->registerCitizen(_this.getReferenceUnsafeStaticCast(), owner);
}
}
completeStructureList.put(structure->getObjectID());
if (structure->isCivicStructure() && !structure->isDecoration()) {
addStructure(structure);
} else if (structure->isCommercialStructure()) {
addCommercialStructure(structure);
}
if (registered) {
zone->registerObjectWithPlanetaryMap(structure);
}
}
if (object->isDecoration() && object->getParent().get() == NULL) {
addDecoration(object);
}
if (registered && cityMissionTerminals.contains(object)) {
zone->registerObjectWithPlanetaryMap(object);
}
if (!registered && citySkillTrainers.contains(object)) {
zone->unregisterObjectWithPlanetaryMap(object);
}
}
示例9: handleDisplayStatus
void VendorManager::handleDisplayStatus(CreatureObject* player, TangibleObject* vendor) {
if(vendor->getZone() == NULL) {
error("NULL zone in VendorManager::handleDisplayStatus");
return;
}
DataObjectComponentReference* data = vendor->getDataObjectComponent();
if(data == NULL || data->get() == NULL || !data->get()->isVendorData()) {
error("Vendor has no data component");
return;
}
VendorDataComponent* vendorData = cast<VendorDataComponent*>(data->get());
if(vendorData == NULL) {
error("Vendor has wrong data component");
return;
}
ManagedReference<SuiListBox*> statusBox = new SuiListBox(player, SuiWindowType::STRUCTURE_VENDOR_STATUS);
statusBox->setUsingObject(vendor);
statusBox->setPromptTitle("@player_structure:vendor_status");
statusBox->setPromptText("Vendor Status");
ManagedReference<CreatureObject*> owner = server->getZoneServer()->getObject(vendorData->getOwnerId()).castTo<CreatureObject*>();
String ownerName;
if (owner == NULL)
ownerName = "NULL";
else
ownerName = owner->getFirstName();
statusBox->addMenuItem("Owner: " + ownerName);
int condition = (((float)vendor->getMaxCondition() - (float)vendor->getConditionDamage()) / (float)vendor->getMaxCondition()) * 100;
statusBox->addMenuItem("Condition: " + String::valueOf(condition) + "%");
float secsRemaining = 0.f;
if( vendorData->getMaint() > 0 ){
secsRemaining = (vendorData->getMaint() / vendorData->getMaintenanceRate())*3600;
}
statusBox->addMenuItem("Maintenance Pool: " +
String::valueOf(vendorData->getMaint()) +
"cr " + getTimeString( (uint32)secsRemaining ) );
statusBox->addMenuItem("Maintenance Rate: " + String::valueOf((int)vendorData->getMaintenanceRate()) + " cr/hr");
ManagedReference<AuctionManager*> auctionManager = server->getZoneServer()->getAuctionManager();
if(auctionManager == NULL) {
error("null auction manager");
return;
}
ManagedReference<AuctionsMap*> auctionsMap = auctionManager->getAuctionMap();
if(auctionsMap == NULL) {
error("null auctionsMap");
return;
}
String planet = vendor->getZone()->getZoneName();
String region = "@planet_n:" + vendor->getZone()->getZoneName();
ManagedReference<CityRegion*> regionObject = vendor->getCityRegion();
if(regionObject != NULL)
region = regionObject->getRegionName();
TerminalListVector vendorList = auctionsMap->getVendorTerminalData(planet, region, vendor);
uint32 itemsForSaleCount = 0;
if(vendorList.size() > 0) {
Reference<TerminalItemList*> list = vendorList.get(0);
if (list != NULL) {
for (int j = 0; j < list->size(); ++j) {
ManagedReference<AuctionItem*> item = list->get(j);
if (item == NULL)
continue;
int itemSize = item->getSize();
if (itemSize > 50)
itemsForSaleCount += 50;
else if (itemSize > 0)
itemsForSaleCount += itemSize;
else
itemsForSaleCount++;
}
}
}
statusBox->addMenuItem("Number of Items For Sale: " + String::valueOf(itemsForSaleCount));
if (vendorData->isVendorSearchEnabled())
statusBox->addMenuItem("@player_structure:vendor_search_enabled");
else
statusBox->addMenuItem("@player_structure:vendor_search_disabled");
//.........这里部分代码省略.........
示例10: initializeSession
int CreateVendorSessionImplementation::initializeSession() {
ManagedReference<CreatureObject*> player = this->player.get();
if (player == NULL)
return 0;
if (player->containsActiveSession(SessionFacadeType::CREATEVENDOR)) {
player->sendSystemMessage("@player_structure:already_creating"); // You are already creating a vendor.
return 0;
}
ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
if (ghost == NULL) {
cancelSession();
return 0;
}
if (ghost->getVendorCount() >= player->getSkillMod("manage_vendor")) {
player->sendSystemMessage("@player_structure:full_vendors"); // You are already managing your maximum number of vendors. Fire someone or remove a terminal first!
cancelSession();
return 0;
}
SortedVector<unsigned long long>* ownedVendors = ghost->getOwnedVendors();
for (int i = 0; i < ownedVendors->size(); i++) {
ManagedReference<SceneObject*> vendor = player->getZoneServer()->getObject(ownedVendors->elementAt(i));
if (vendor == NULL)
continue;
DataObjectComponentReference* data = vendor->getDataObjectComponent();
if(data == NULL || data->get() == NULL || !data->get()->isVendorData())
continue;
VendorDataComponent* vendorData = cast<VendorDataComponent*>(data->get());
if(vendorData == NULL)
continue;
if (!vendorData->isInitialized()) {
player->sendSystemMessage("@player_structure:already_creating"); // You are already creating a vendor.
cancelSession();
return 0;
}
}
currentNode = VendorManager::instance()->getRootNode();
templatePath = "";
if (!currentNode->hasChildNode()) {
cancelSession();
error("Vendor Root node has no children");
return 0;
}
int hiringMod = player->getSkillMod("hiring");
suiSelectVendor = new SuiListBox(player, SuiWindowType::STRUCTURE_CREATE_VENDOR);
suiSelectVendor->setCallback(new CreateVendorSuiCallback(player->getZoneServer()));
suiSelectVendor->setCancelButton(true, "@cancel");
suiSelectVendor->setPromptTitle(currentNode->getSuiDisplay() + "t");
suiSelectVendor->setPromptText(currentNode->getSuiDisplay() + "d");
currentNode->addChildrenToListBox(suiSelectVendor, hiringMod);
player->getPlayerObject()->addSuiBox(suiSelectVendor);
player->sendMessage(suiSelectVendor->generateMessage());
player->addActiveSession(SessionFacadeType::CREATEVENDOR, _this.getReferenceUnsafeStaticCast());
return 0;
}
示例11: 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();
}
示例12: notifyPositionUpdate
void MinefieldZoneComponent::notifyPositionUpdate(SceneObject* sceneObject, QuadTreeEntry* entry) const {
ManagedReference<SceneObject*> target = cast<SceneObject*>(entry);
if(!sceneObject->isMinefield() || target == NULL){
return;
}
DataObjectComponentReference* ref = sceneObject->getDataObjectComponent();
if(ref == NULL){
info("dataobjectcomponent is null",true);
return;
}
MinefieldDataComponent* mineData = cast<MinefieldDataComponent*>(ref->get());
if (mineData == NULL)
return;
try {
if (target->isPlayerCreature()) {
ManagedReference<CreatureObject*> player = cast<CreatureObject*>(entry);
if(player == NULL)
return;
uint64 playerObjID = player->getObjectID();
ManagedReference<TangibleObject*> tano = cast<TangibleObject*>(sceneObject);
if(tano == NULL)
return;
if(!player->isAttackableBy(tano) && !mineData->hasNotifiedPlayer(playerObjID))
return;
if (sceneObject->isInRange(target, mineData->getMaxRange())) {
if (mineData->canExplode() && sceneObject->getContainerObjectsSize() > 0) {
Reference<MinefieldAttackTask*> task = new MinefieldAttackTask(sceneObject, player);
task->execute();
}
if (!mineData->hasNotifiedPlayer(playerObjID)) {
mineData->addNotifiedPlayer(playerObjID);
player->sendSystemMessage("@faction_perk:minefield_near"); //You have breached the perimeter of an enemy minefield.
}
}
else if (mineData->hasNotifiedPlayer(playerObjID)) {
player->sendSystemMessage("@faction_perk:minefield_exit"); //You have left the perimeter of an enemy minefield.
mineData->removeNotifiedPlayer(playerObjID);
}
}
} catch (Exception& e) {
}
return;
}
示例13: handleObjectMenuSelect
int DroidDeedImplementation::handleObjectMenuSelect(CreatureObject* player, byte selectedID) {
if (selectedID == 20) {
if (generated || !isASubChildOf(player))
return 1;
if (player->isInCombat() || player->isRidingMount() || player->isSwimming() || player->isDead() || player->isIncapacitated() ){
player->sendSystemMessage("@pet/pet_menu:cant_call"); // "You cannot call this pet right now."
return 1;
}
ManagedReference<SceneObject*> datapad = player->getSlottedObject("datapad");
if (datapad == NULL) {
player->sendSystemMessage("Datapad doesn't exist when trying to generate droid");
return 1;
}
// Check if this will exceed maximum number of droids allowed
ManagedReference<PlayerManager*> playerManager = player->getZoneServer()->getPlayerManager();
int droidsInDatapad = 0;
int maxStoredDroids = playerManager->getBaseStoredDroids();
for (int i = 0; i < datapad->getContainerObjectsSize(); i++) {
Reference<SceneObject*> obj = datapad->getContainerObject(i).castTo<SceneObject*>();
if (obj != NULL && obj->isPetControlDevice() ){
Reference<PetControlDevice*> petDevice = cast<PetControlDevice*>(obj.get());
if( petDevice != NULL && petDevice->getPetType() == PetManager::DROIDPET){
droidsInDatapad++;
}
}
}
if( droidsInDatapad >= maxStoredDroids){
player->sendSystemMessage("You have too many droids in your datapad");
return 1;
}
Reference<CreatureManager*> creatureManager = player->getZone()->getCreatureManager();
if( creatureManager == NULL )
return 1;
CreatureTemplateManager* creatureTemplateManager = CreatureTemplateManager::instance();
Reference<CreatureTemplate*> creatureTemplate = creatureTemplateManager->getTemplate( mobileTemplate.hashCode() );
if( creatureTemplate == NULL ){
player->sendSystemMessage("wrong droid template;mobileTemplate=[" + mobileTemplate + "]" );
return 1;
}
Reference<PetControlDevice*> controlDevice = (server->getZoneServer()->createObject(controlDeviceObjectTemplate.hashCode(), 1)).castTo<PetControlDevice*>();
if( controlDevice == NULL ){
player->sendSystemMessage("wrong droid control device template " + controlDeviceObjectTemplate);
return 1;
}
Locker locker(controlDevice);
Reference<CreatureObject*> creatureObject = creatureManager->createCreature(generatedObjectTemplate.hashCode(), true, mobileTemplate.hashCode() );
if( creatureObject == NULL ){
controlDevice->destroyObjectFromDatabase(true);
player->sendSystemMessage("wrong droid templates;mobileTemplate=[" + mobileTemplate + "];generatedObjectTemplate=[" + generatedObjectTemplate + "]" );
return 1;
}
Locker clocker(creatureObject, player);
Reference<DroidObject*> droid = creatureObject.castTo<DroidObject*>();
if( droid == NULL ) {
controlDevice->destroyObjectFromDatabase(true);
creatureObject->destroyObjectFromDatabase(true);
return 1;
}
droid->loadTemplateData( creatureTemplate );
droid->setCustomObjectName(StringIdManager::instance()->getStringId(*droid->getObjectName()), true);
// Transfer crafting components from deed to droid
ManagedReference<SceneObject*> craftingComponents = getSlottedObject("crafted_components");
if(craftingComponents != NULL) {
SceneObject* satchel = craftingComponents->getContainerObject(0);
// remove all items form satchel and add int he new items
Vector<ManagedReference<SceneObject*> > toRemove;
for (int i = 0; i < satchel->getContainerObjectsSize(); ++i) {
ManagedReference<SceneObject*> sceno = satchel->getContainerObject(i);
if (sceno != NULL) {
toRemove.add(sceno);
}
}
satchel->removeAllContainerObjects();
for(int i=0;i<toRemove.size();i++) {
SceneObject* component = toRemove.get(i);
Locker componenetLocker(component);
component->destroyObjectFromWorld(true);
}
// this will change to use stacked modules. we wont care about non droid modules as they arent needed.
String key;
ManagedReference<DroidComponent*> comp = NULL;
//.........这里部分代码省略.........
示例14: updateCraftingValues
void DroidDeedImplementation::updateCraftingValues(CraftingValues* values, bool firstUpdate) {
/*
* Values available: Range:
*
*/
String key;
ManagedReference<DroidComponent*> comp = NULL;
HashTableIterator<String, ManagedReference<DroidComponent*> > iterator = modules.iterator();
for(int i = 0; i < modules.size(); ++i) {
iterator.getNextKeyAndValue(key, comp);
if (comp) {
comp->destroyObjectFromWorld(true);
comp->destroyObjectFromDatabase(true);
}
}
modules.removeAll();
overallQuality = values->getCurrentPercentage("power_level"); // effectiveness
if (overallQuality < 0)
overallQuality = 0.1;
combatRating = values->getCurrentValue("cmbt_module");
if (combatRating < 0)
combatRating = 0;
// @TODO Add crafting values, this should adjust toHit and Speed based on droid ham, also
// we need to stack modules if they are stackable.
// walk all components and ensure we have all modules that are stackable there.
ManagedReference<ManufactureSchematic*> manufact = values->getManufactureSchematic();
for (int i = 0; i < manufact->getSlotCount(); ++i) {
// Droid Component Slots
Reference<IngredientSlot* > iSlot = manufact->getSlot(i);
if (iSlot->isComponentSlot()) {
ComponentSlot* cSlot = cast<ComponentSlot*>(iSlot.get());
ManagedReference<TangibleObject*> tano = cSlot->getPrototype();
ManagedReference<DroidComponent*> component = cast<DroidComponent*>( tano.get());
// only check modules
if (component != NULL) {
if (component->isSocketCluster()) {
// pull out the objects
ManagedReference<SceneObject*> craftingComponents = component->getSlottedObject("crafted_components");
if(craftingComponents != NULL) {
SceneObject* satchel = craftingComponents->getContainerObject(0);
for (int i = 0; i < satchel->getContainerObjectsSize(); ++i) {
ManagedReference<SceneObject*> sceno = satchel->getContainerObject(i);
if (sceno != NULL) {
// now we have the componet used in this socket item
ManagedReference<DroidComponent*> sub = cast<DroidComponent*>( sceno.get());
if (sub != NULL) {
DataObjectComponentReference* data = sub->getDataObjectComponent();
BaseDroidModuleComponent* module = NULL;
if(data != NULL && data->get() != NULL && data->get()->isDroidModuleData() ){
module = cast<BaseDroidModuleComponent*>(data->get());
}
if (module == NULL) {
continue;
}
processModule(module,sceno->getServerObjectCRC());
}
}
}
}
} else {
DataObjectComponentReference* data = component->getDataObjectComponent();
BaseDroidModuleComponent* module = NULL;
if(data != NULL && data->get() != NULL && data->get()->isDroidModuleData() ){
module = cast<BaseDroidModuleComponent*>(data->get());
}
if (module == NULL) {
continue;
}
processModule(module,tano->getServerObjectCRC());
}
}
}
}
// module stacking is completed!
}
示例15: fillObjectMenuResponse
void VendorMenuComponent::fillObjectMenuResponse(SceneObject* sceneObject,
ObjectMenuResponse* menuResponse, CreatureObject* player) {
if(!sceneObject->isVendor())
return;
if(sceneObject->isASubChildOf(player)) {
menuResponse->addRadialMenuItem(14, 3, "@ui:destroy");
return;
}
PlayerObject* playerObject = player->getPlayerObject();
if (playerObject == NULL)
return;
DataObjectComponentReference* data = sceneObject->getDataObjectComponent();
if(data == NULL || data->get() == NULL || !data->get()->isVendorData()) {
return;
}
VendorDataComponent* vendorData = cast<VendorDataComponent*>(data->get());
if(vendorData == NULL) {
return;
}
bool owner = vendorData->getOwnerId() == player->getObjectID();
if(!owner && !playerObject->isPrivileged())
return;
menuResponse->addRadialMenuItem(70, 3, "@player_structure:vendor_control");
if (!owner) {
if (vendorData->isInitialized()) {
menuResponse->addRadialMenuItemToRadialID(70, 71, 3, "@player_structure:vendor_status");
menuResponse->addRadialMenuItemToRadialID(70, 72, 3, "@player_structure:change_name");
}
return;
}
if (!vendorData->isInitialized()) {
menuResponse->addRadialMenuItemToRadialID(70, 79, 3, "@player_structure:vendor_init");
menuResponse->addRadialMenuItem(10, 3, "@ui_radial:item_pickup");
menuResponse->addRadialMenuItem(51, 1, "@ui_radial:item_rotate"); //Rotate
menuResponse->addRadialMenuItemToRadialID(51, 52, 3, "@ui_radial:item_rotate_left"); //Rotate Left
menuResponse->addRadialMenuItemToRadialID(51, 53, 3, "@ui_radial:item_rotate_right"); //Rotate Right
} else {
menuResponse->addRadialMenuItemToRadialID(70, 71, 3, "@player_structure:vendor_status");
menuResponse->addRadialMenuItemToRadialID(70, 73, 3, "@player_structure:pay_vendor_t");
menuResponse->addRadialMenuItemToRadialID(70, 74, 3, "@player_structure:withdraw_vendor_t");
if (vendorData->isVendorSearchEnabled())
menuResponse->addRadialMenuItemToRadialID(70, 75, 3, "@player_structure:disable_vendor_search");
else
menuResponse->addRadialMenuItemToRadialID(70, 75, 3, "@player_structure:enable_vendor_search");
if(player->hasSkill("crafting_merchant_advertising_03")) {
if (!vendorData->isRegistered())
menuResponse->addRadialMenuItemToRadialID(70, 76, 3, "@player_structure:register_vendor");
else
menuResponse->addRadialMenuItemToRadialID(70, 76, 3, "@player_structure:unregister_vendor");
}
if(player->hasSkill("crafting_merchant_advertising_01") && sceneObject->isCreatureObject()) {
if (!vendorData->isAdBarkingEnabled())
menuResponse->addRadialMenuItemToRadialID(70, 77, 3, "@player_structure:vendor_areabarks_on");
else
menuResponse->addRadialMenuItemToRadialID(70, 77, 3, "@player_structure:vendor_areabarks_off");
}
}
menuResponse->addRadialMenuItemToRadialID(70, 78, 3, "@player_structure:remove_vendor");
}