本文整理汇总了C++中AiAgent::getFactionString方法的典型用法代码示例。如果您正苦于以下问题:C++ AiAgent::getFactionString方法的具体用法?C++ AiAgent::getFactionString怎么用?C++ AiAgent::getFactionString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AiAgent
的用法示例。
在下文中一共展示了AiAgent::getFactionString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canAddObject
int FactionRecruiterContainerComponent::canAddObject(SceneObject* sceneObject, SceneObject* object, int containmentType, String& errorDescription) {
if (sceneObject == object) {
return TransferErrorCode::CANTADDTOITSELF;
}
if (!sceneObject->isAiAgent()) {
return TransferErrorCode::INVALIDTYPE;
}
AiAgent* recruiter = cast<AiAgent*>(sceneObject);
String recruiterFaction = recruiter->getFactionString().toLowerCase();
if (recruiterFaction != "imperial" && recruiterFaction != "rebel") {
return TransferErrorCode::INVALIDTYPE;
}
CreatureObject* player = object->getParentRecursively(SceneObjectType::PLAYERCREATURE).get().castTo<CreatureObject*>();
if (player == NULL) {
return TransferErrorCode::MUSTBEINPLAYERINVENTORY;
}
if (object->getObjectTemplate()->getFullTemplateString() == "object/tangible/encoded_disk/message_assembled_base.iff") {
CoaMessageDataComponent* data = object->getDataObjectComponent()->castTo<CoaMessageDataComponent*>();
if (data != NULL) {
String faction = data->getFaction().toLowerCase();
if (faction == "imperial" || faction == "rebel") {
return TransferErrorCode::SUCCESS;
}
}
}
return TransferErrorCode::INVALIDTYPE;
}
示例2: transferObject
bool FactionRecruiterContainerComponent::transferObject(SceneObject* sceneObject, SceneObject* object, int containmentType, bool notifyClient, bool allowOverflow) {
CoaMessageDataComponent* data = object->getDataObjectComponent()->castTo<CoaMessageDataComponent*>();
if (data == NULL) {
return false;
}
CreatureObject* player = object->getParentRecursively(SceneObjectType::PLAYERCREATURE).get().castTo<CreatureObject*>();
if (player == NULL) {
return false;
}
ZoneServer* zoneServer = player->getZoneServer();
PlayerObject* ghost = player->getPlayerObject();
if (zoneServer == NULL || ghost == NULL) {
return false;
}
if (!sceneObject->isAiAgent()) {
return false;
}
AiAgent* recruiter = cast<AiAgent*>(sceneObject);
String recruiterFaction = recruiter->getFactionString().toLowerCase();
bool hasBadge = ghost->hasBadge(Badge::EVENT_PROJECT_DEAD_EYE_1);
String faction = data->getFaction().toLowerCase();
StringBuffer response;
response << "@encoded_disk/message_fragment:response_event";
if (faction == "rebel") {
response << "reb1_";
} else if (faction == "imperial") {
response << "imp1_";
}
response << recruiterFaction;
ChatManager* chatManager = zoneServer->getChatManager();
if (chatManager == NULL) {
return false;
}
Locker locker(recruiter);
chatManager->broadcastMessage(recruiter,response.toString(), 0, 0, 0);
object->destroyObjectFromWorld(true);
object->destroyObjectFromDatabase();
int credits = System::random(500) + 500;
player->sendSystemMessage("You receive " + String::valueOf(credits) + " credits.");
player->addCashCredits(credits, true);
if (!hasBadge) {
ghost->awardBadge(Badge::EVENT_PROJECT_DEAD_EYE_1);
ghost->increaseFactionStanding(recruiterFaction, 500);
}
return true;
}