本文整理汇总了C++中DataObjectComponentReference类的典型用法代码示例。如果您正苦于以下问题:C++ DataObjectComponentReference类的具体用法?C++ DataObjectComponentReference怎么用?C++ DataObjectComponentReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataObjectComponentReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notifyPositionUpdate
void MinefieldZoneComponent::notifyPositionUpdate(SceneObject* sceneObject, QuadTreeEntry* entry) {
// 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;
}
示例2: fillAttributeList
void DroidDeedImplementation::fillAttributeList(AttributeListMessage* alm, CreatureObject* object) {
DeedImplementation::fillAttributeList(alm, object);
// @TODO Add attributes
// Deed needs to show a few important bits
// 1.) HAM
int maxHam = DroidMechanics::determineHam(overallQuality,species);
alm->insertAttribute("challenge_level", level);
alm->insertAttribute("creature_health", maxHam);
alm->insertAttribute("creature_action", maxHam);
alm->insertAttribute("creature_mind", maxHam);
if(combatRating > 0 || (species == DroidObject::DZ70 || species == DroidObject::PROBOT) ) {
StringBuffer attdisplayValue;
float attackSpeed = DroidMechanics::determineSpeed(species,maxHam);
float chanceHit = DroidMechanics::determineHit(species,maxHam);
// do we have a combat module installed?
float damageMin = DroidMechanics::determineMinDamage(species,combatRating);
float damageMax = DroidMechanics::determineMaxDamage(species,combatRating);
attdisplayValue << Math::getPrecision(attackSpeed, 2);
StringBuffer hitdisplayValue;
hitdisplayValue << Math::getPrecision(chanceHit, 2);
alm->insertAttribute("creature_attack", attdisplayValue);
alm->insertAttribute("creature_tohit", hitdisplayValue);
alm->insertAttribute("creature_damage", String::valueOf(damageMin) + " - " + String::valueOf(damageMax));
}
// hit and speed?
// if object is the master
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) {
DataObjectComponentReference* data = comp->getDataObjectComponent();
BaseDroidModuleComponent* module = NULL;
if(data != NULL && data->get() != NULL && data->get()->isDroidModuleData() ){
module = cast<BaseDroidModuleComponent*>(data->get());
}
if (module == NULL) {
continue;
}
module->fillAttributeList(alm,object);
}
}
}
示例3: promptRenameVendorTo
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");
}
示例4: 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");
}
示例5: 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;
}
示例6: getSlottedObject
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);
}
}
}
}
}
示例7: 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);
}
示例8: error
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");
//.........这里部分代码省略.........
示例9: cancelSession
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;
}
示例10: locker
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();
}
示例11: 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");
}
示例12: locker
//.........这里部分代码省略.........
}
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;
HashTableIterator<String, ManagedReference<DroidComponent*> > iterator = modules.iterator();
droid->setResists(0);
droid->setHitChance(0);
for(int i = 0; i < modules.size(); ++i) {
iterator.getNextKeyAndValue(key, comp);
if (comp) {
satchel->transferObject(comp, -1, false);
DataObjectComponentReference* data = comp->getDataObjectComponent();
BaseDroidModuleComponent* module = NULL;
if(data != NULL && data->get() != NULL && data->get()->isDroidModuleData()) {
module = cast<BaseDroidModuleComponent*>(data->get());
module->initialize(droid);
}
}
}
droid->transferObject(craftingComponents, 4, false);
craftingComponents->setSendToClient(false);
}
// Copy color customization from deed to droid
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);
if( name.contains( "color" ) ){
droid->setCustomizationVariable( name, val, true );
}
}
droid->refreshPaint();
}
StringId s;
s.setStringId(droid->getObjectName()->getFullPath());
controlDevice->setObjectName(s);
controlDevice->setPetType(PetManager::DROIDPET);
controlDevice->setMaxVitality(100);
controlDevice->setVitality(100);
droid->createChildObjects();
示例13: processModule
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!
}
示例14: 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);
}
}
示例15: 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;
}