本文整理汇总了C++中InventoryItemRef::groupID方法的典型用法代码示例。如果您正苦于以下问题:C++ InventoryItemRef::groupID方法的具体用法?C++ InventoryItemRef::groupID怎么用?C++ InventoryItemRef::groupID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InventoryItemRef
的用法示例。
在下文中一共展示了InventoryItemRef::groupID方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InstallRig
bool ModuleManager::InstallRig(InventoryItemRef item, EVEItemFlags flag)
{
if(item->groupID() >= 773 && item->groupID() <= 786 && item->groupID() != 783)
{
_fitModule(item,flag);
return true;
}
else
SysLog::Debug("ModuleManager","%s tried to fit item %u, which is not a rig", m_Ship->GetOperator()->GetName(), item->itemID());
return false;
}
示例2: SwapSubSystem
bool ModuleManager::SwapSubSystem(InventoryItemRef item, EVEItemFlags flag)
{
if(item->groupID() >= 954 && item->groupID() <= 958)
{
_fitModule(item,flag);
return true;
}
else
SysLog::Debug("ModuleManager","%s tried to fit item %u, which is not a subsystem", m_Ship->GetOperator()->GetName(), item->itemID());
return false;
}
示例3: ActiveModule
MiningLaser::MiningLaser( InventoryItemRef item, ShipRef ship)
: ActiveModule(item, ship)
{
if (item->groupID() == EVEDB::invGroups::Gas_Cloud_Harvester)
{
m_effectString = "effects.CloudMining";
}
else
{
m_effectString = "effects.Mining";
}
}
示例4: _fitModule
bool ModuleManager::_fitModule(InventoryItemRef item, EVEItemFlags flag)
{
bool verifyFailed = false;
GenericModule * mod = ModuleFactory(item, ShipRef(m_Ship));
// Check for max turret modules allowed:
if( mod->isTurretFitted() && (m_Modules->GetFittedTurretCount() == m_Ship->GetMaxTurrentHardpoints().get_int()) )
{
//std::map<std::string, PyRep *> args;
//args["typename"] = new PyString(item->itemName().c_str());
//args["portion"] = new PyInt(item->type().portionSize());
throw PyException( MakeUserError( "NotEnoughTurretSlots" ) );
verifyFailed = true;
}
// Check for max launcher modules allowed:
if( mod->isLauncherFitted() && (m_Modules->GetFittedLauncherCount() == m_Ship->GetMaxLauncherHardpoints().get_int()) )
{
//std::map<std::string, PyRep *> args;
//args["typename"] = new PyString(item->itemName().c_str());
//args["portion"] = new PyInt(item->type().portionSize());
throw PyException( MakeUserError( "NotEnoughLauncherSlots" ) );
verifyFailed = true;
}
// Check for max modules of group allowed:
else if( mod->isMaxGroupFitLimited() && (m_Modules->GetFittedModuleCountByGroup(item->groupID()) == mod->getItem()->GetAttribute(AttrMaxGroupFitted).get_int()) )
{
//std::map<std::string, PyRep *> args;
//args["typename"] = new PyString(item->itemName().c_str());
//args["portion"] = new PyInt(item->type().portionSize());
throw PyException( MakeUserError( "CantFitTooManyByGroup" ) );
verifyFailed = true;
}
else
{
// Fit Module now that all checks have passed:
//m_Modules->AddModule(mod->flag(), mod);
m_Modules->AddModule(flag, mod);
}
if( verifyFailed )
{
delete mod;
return false;
}
else
return true;
}
示例5: canActivate
bool MiningLaser::canActivate(SystemEntity *targetEntity)
{
if(targetEntity == nullptr)
{
return false;
}
InventoryItemRef miner = getItem();
bool isIceMiner = (miner->typeID() == 16278 || miner->typeID() == 22229 || miner->typeID() == 28752);
if (isIceMiner)
{
// Only allow ice harvesters to mine ice.
if (targetEntity->Item()->groupID() != EVEDB::invGroups::Ice)
{
SysLog::Error("MiningLaser::Activate()", "ERROR: invalid target!");
throw PyException(MakeCustomError("ERROR! invalid target!"));
}
}
else if (miner->groupID() == EVEDB::invGroups::Gas_Cloud_Harvester)
{
// Gas cloud harvesters only allowed to harvest gas.
if (targetEntity->Item()->groupID() != EVEDB::invGroups::Harvestable_Cloud)
{
SysLog::Error("MiningLaser::Activate()", "ERROR: invalid target!");
throw PyException(MakeCustomError("ERROR! invalid target!"));
}
}
// Only thing left are astroid miners.
else if (targetEntity->Item()->categoryID() != EVEDB::invCategories::Asteroid)
{
// We are not targeting an asteroid.
SysLog::Error("MiningLaser::Activate()", "ERROR: invalid target!");
throw PyException(MakeCustomError("ERROR! invalid target!"));
}
// We have a valid target, are we in range?
double maxRange = miner->GetAttribute(AttrMaxRange).get_float();
double targetRange = targetEntity->DistanceTo2(m_ship->GetOperator()->GetSystemEntity());
targetRange = std::sqrt(targetRange);
targetRange -= targetEntity->GetRadius();
if (targetRange > maxRange)
{
// We are not targeting a valid target.
// TO-DO: send proper out or range response.
SysLog::Error("MiningLaser::Activate()", "ERROR: Cannot activate mining laser target out of range! (%f/%f)", targetRange, maxRange);
throw PyException(MakeCustomError("ERROR! Cannot activate mining laser target out of range! (%f/%f)", targetRange, maxRange));
}
return true;
}
示例6: SpawnAsteroid
void SpawnAsteroid( SystemManager* system, uint32 typeID, double radius, const GVector& position )
{
ItemData idata( typeID,
1,
system->GetID(),
flagAutoFit,
"", //name
position );
InventoryItemRef i = ItemFactory::SpawnItem(idata);
if (!i)
{
throw PyException(MakeCustomError("Unable to spawn item of type %u.", typeID));
}
// Calculate 1/10000th of the volume of a sphere with radius 'radius':
// (this should yield around 90,000 units of Veldspar in an asteroid with 1000.0m radius)
double volume = (1.0/100000.0) * (4.0/3.0) * M_PI * pow(radius,3);
//uint32 qty = floor((volume/(i->GetAttribute(AttrVolume).get_float())));
uint32 qty = (radius * 10) / std::sqrt(i->GetAttribute(AttrVolume).get_float());
if (i->groupID() == EVEDB::invGroups::Veldspar)
{
qty *= 2;
}
i->SetAttribute(AttrQuantity, qty);
i->SetAttribute(AttrRadius, radius);
// Create astroid srvEntity.
AsteroidEntity* new_roid = new AsteroidEntity(i, system, position);
if (new_roid != nullptr)
{
SysLog::Debug("SpawnAsteroid()", "Spawned new asteroid of radius= %fm and volume= %f m3", radius, volume);
// Add srvEntity to system.
system->AddEntity(new_roid);
}
}
示例7: ValidateAddItem
void Ship::ValidateAddItem(EVEItemFlags flag, InventoryItemRef item)
{
CharacterRef character = m_pOperator->GetChar(); // Operator assumed to be Client *
if( flag == flagDroneBay )
{
if( item->categoryID() != EVEDB::invCategories::Drone )
//Can only put drones in drone bay
throw PyException( MakeUserError( "ItemCannotBeInDroneBay" ) );
}
else if( flag == flagShipHangar )
{
if( m_pOperator->GetShip()->GetAttribute(AttrHasShipMaintenanceBay ) != 0) // Operator assumed to be Client *
// We have no ship maintenance bay
throw PyException( MakeCustomError( "%s has no ship maintenance bay.", item->itemName().c_str() ) );
if( item->categoryID() != EVEDB::invCategories::Ship )
// Only ships may be put here
throw PyException( MakeCustomError( "Only ships may be placed into ship maintenance bay." ) );
}
else if( flag == flagHangar )
{
if( m_pOperator->GetShip()->GetAttribute(AttrHasCorporateHangars ) != 0) // Operator assumed to be Client *
// We have no corporate hangars
throw PyException( MakeCustomError( "%s has no corporate hangars.", item->itemName().c_str() ) );
}
else if( flag == flagCargoHold )
{
//get all items in cargohold
EvilNumber capacityUsed(0);
std::vector<InventoryItemRef> items;
m_pOperator->GetShip()->FindByFlag(flag, items); // Operator assumed to be Client *
for(uint32 i = 0; i < items.size(); i++){
capacityUsed += items[i]->GetAttribute(AttrVolume);
}
if( capacityUsed + item->GetAttribute(AttrVolume) > m_pOperator->GetShip()->GetAttribute(AttrCapacity) ) // Operator assumed to be Client *
throw PyException( MakeCustomError( "Not enough cargo space!") );
}
else if( flag > flagLowSlot0 && flag < flagHiSlot7 )
{
if( m_pOperator->IsClient() )
if(!Skill::FitModuleSkillCheck(item, character)) // SKIP THIS SKILL CHECK if Operator is NOT Client *
throw PyException( MakeCustomError( "You do not have the required skills to fit this \n%s", item->itemName().c_str() ) );
if(!ValidateItemSpecifics(item))
throw PyException( MakeCustomError( "Your ship cannot equip this module" ) );
if(item->categoryID() == EVEDB::invCategories::Charge) {
InventoryItemRef module;
m_pOperator->GetShip()->FindSingleByFlag(flag, module); // Operator assumed to be Client *
if(module->GetAttribute(AttrChargeSize) != item->GetAttribute(AttrChargeSize) )
throw PyException( MakeCustomError( "The charge is not the correct size for this module." ) );
if(module->GetAttribute(AttrChargeGroup1) != item->groupID())
throw PyException( MakeCustomError( "Incorrect charge type for this module.") );
}
}
else if( flag > flagRigSlot0 && flag < flagRigSlot7 )
{
if( m_pOperator->IsClient() )
if(!Skill::FitModuleSkillCheck(item, character)) // SKIP THIS SKILL CHECK if Operator is NOT Client *
throw PyException( MakeCustomError( "You do not have the required skills to fit this \n%s", item->itemName().c_str() ) );
if(m_pOperator->GetShip()->GetAttribute(AttrRigSize) != item->GetAttribute(AttrRigSize)) // Operator assumed to be Client *
throw PyException( MakeCustomError( "Your ship cannot fit this size module" ) );
if( m_pOperator->GetShip()->GetAttribute(AttrUpgradeLoad) + item->GetAttribute(AttrUpgradeCost) > m_pOperator->GetShip()->GetAttribute(AttrUpgradeCapacity) ) // Operator assumed to be Client *
throw PyException( MakeCustomError( "Your ship cannot handle the extra calibration" ) );
}
else if( flag > flagSubSystem0 && flag < flagSubSystem7 )
{
if( m_pOperator->IsClient() )
if(!Skill::FitModuleSkillCheck(item, character)) // SKIP THIS SKILL CHECK if Operator is NOT Client *
throw PyException( MakeCustomError( "You do not have the required skills to fit this \n%s", item->itemName().c_str() ) );
}
}
示例8: _fitModule
bool ModuleManager::_fitModule(InventoryItemRef item, EVEItemFlags flag)
{
bool verifyFailed = false;
GenericModule * mod;
// First, check to see if this module item is already fitted, and if so, let's instruct ModuleContainer to move the module
GenericModule * existingMod = m_Modules->GetModule(item->itemID());
if( existingMod != NULL )
{
if( m_Modules->isSlotOccupied(flag) )
{
throw PyException( MakeUserError( "SlotAlreadyOccupied" ) );
verifyFailed = true;
}
m_Modules->RemoveModule( existingMod->flag() ); // Remove this module from existing slot
existingMod->getItem()->SetFlag( flag ); // Change item's flag to the NEW slot flag
m_Modules->AddModule( flag, existingMod ); // Add this module back to the container at the NEW slot location
}
else
{
mod = ModuleFactory(item, ShipRef(m_Ship));
// Set module's pointer to its owner ModuleManager's log object:
mod->setLog(m_pLog);
// Check for max turret modules allowed:
if( mod->isTurretFitted() && (m_Modules->GetFittedTurretCount() == m_Ship->GetMaxTurrentHardpoints().get_int()) )
{
//std::map<std::string, PyRep *> args;
//args["typename"] = new PyString(item->itemName().c_str());
//args["portion"] = new PyInt(item->type().portionSize());
throw PyException( MakeUserError( "NotEnoughTurretSlots" ) );
verifyFailed = true;
}
// Check for max launcher modules allowed:
if( mod->isLauncherFitted() && (m_Modules->GetFittedLauncherCount() == m_Ship->GetMaxLauncherHardpoints().get_int()) )
{
//std::map<std::string, PyRep *> args;
//args["typename"] = new PyString(item->itemName().c_str());
//args["portion"] = new PyInt(item->type().portionSize());
throw PyException( MakeUserError( "NotEnoughLauncherSlots" ) );
verifyFailed = true;
}
// Check for max modules of group allowed:
else if( mod->isMaxGroupFitLimited() && (m_Modules->GetFittedModuleCountByGroup(item->groupID()) == mod->getItem()->GetAttribute(AttrMaxGroupFitted).get_int()) )
{
//std::map<std::string, PyRep *> args;
//args["typename"] = new PyString(item->itemName().c_str());
//args["portion"] = new PyInt(item->type().portionSize());
throw PyException( MakeUserError( "CantFitTooManyByGroup" ) );
verifyFailed = true;
}
else
{
// Fit Module now that all checks have passed:
m_Modules->AddModule(flag, mod);
}
}
if( verifyFailed )
{
if( mod != NULL )
delete mod;
return false;
}
else
return true;
}
示例9: ValidateAddItem
bool Ship::ValidateAddItem(EVEItemFlags flag, InventoryItemRef item) const
{
CharacterRef character = m_pOperator->GetChar();
if( flag == flagDroneBay )
{
if (item->categoryID() != EVEDB::invCategories::Drone)
{
//Can only put drones in drone bay
throw PyException(MakeUserError("ItemCannotBeInDroneBay"));
}
}
else if( flag == flagShipHangar )
{
if (m_pOperator->GetShip()->getAttribute(AttrHasShipMaintenanceBay) != 0)
{
// We have no ship maintenance bay
throw PyException(MakeCustomError("%s has no ship maintenance bay.", item->itemName().c_str()));
}
if (item->categoryID() != EVEDB::invCategories::Ship)
{
// Only ships may be put here
throw PyException(MakeCustomError("Only ships may be placed into ship maintenance bay."));
}
}
else if( flag == flagHangar )
{
if (m_pOperator->GetShip()->getAttribute(AttrHasCorporateHangars) != 0)
{
// We have no corporate hangars
throw PyException(MakeCustomError("%s has no corporate hangars.", item->itemName().c_str()));
}
}
else if( (flag >= flagLowSlot0) && (flag <= flagHiSlot7) )
{
if (m_pOperator->IsClient())
{
// SKIP THIS SKILL CHECK if Operator is NOT Client *
if (!character->canUse(item))
{
throw PyException(MakeCustomError("You do not have the required skills to fit this \n%s", item->itemName().c_str()));
}
}
if (!ValidateItemSpecifics(item))
{
throw PyException(MakeCustomError("Your ship cannot equip this module"));
}
if(item->categoryID() == EVEDB::invCategories::Charge)
{
if( m_ModuleManager->GetModule(flag) != NULL )
{
InventoryItemRef module;
module = m_ModuleManager->GetModule(flag)->getItem();
if (module->getAttribute(AttrChargeSize) != item->getAttribute(AttrChargeSize))
throw PyException( MakeCustomError( "The charge is not the correct size for this module." ) );
if (module->getAttribute(AttrChargeGroup1) != item->groupID())
throw PyException( MakeCustomError( "Incorrect charge type for this module.") );
// NOTE: Module Manager will check for actual room to load charges and make stack splits, or reject loading altogether
}
else
{
throw PyException(MakeCustomError("Module at flag '%u' does not exist!", flag));
}
}
else
{
if (m_ModuleManager->IsSlotOccupied(flag))
{
throw PyException(MakeUserError("SlotAlreadyOccupied"));
}
}
return true;
}
else if( (flag >= flagRigSlot0) && (flag <= flagRigSlot7) )
{
if (m_pOperator->IsClient())
{
// SKIP THIS SKILL CHECK if Operator is NOT Client *
if (!character->canUse(item))
{
throw PyException(MakeCustomError("You do not have the required skills to fit this \n%s", item->itemName().c_str()));
}
}
if (m_pOperator->GetShip()->getAttribute(AttrRigSize) != item->getAttribute(AttrRigSize))
{
throw PyException(MakeCustomError("Your ship cannot fit this size module"));
}
if (m_pOperator->GetShip()->getAttribute(AttrUpgradeLoad) + item->getAttribute(AttrUpgradeCost) > m_pOperator->GetShip()->getAttribute(AttrUpgradeCapacity))
{
throw PyException(MakeCustomError("Your ship cannot handle the extra calibration"));
}
return true;
}
else if( (flag >= flagSubSystem0) && (flag <= flagSubSystem7) )
{
if (m_pOperator->IsClient())
{
// SKIP THIS SKILL CHECK if Operator is NOT Client *
if (!character->canUse(item))
//.........这里部分代码省略.........