本文整理汇总了C++中Agent::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ Agent::getType方法的具体用法?C++ Agent::getType怎么用?C++ Agent::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agent
的用法示例。
在下文中一共展示了Agent::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addOrUpdateAgent
Agent* AgentList::addOrUpdateAgent(sockaddr* publicSocket, sockaddr* localSocket, char agentType, uint16_t agentId) {
AgentList::iterator agent = end();
if (publicSocket) {
for (agent = begin(); agent != end(); agent++) {
if (agent->matches(publicSocket, localSocket, agentType)) {
// we already have this agent, stop checking
break;
}
}
}
if (agent == end()) {
// we didn't have this agent, so add them
Agent* newAgent = new Agent(publicSocket, localSocket, agentType, agentId);
if (socketMatch(publicSocket, localSocket)) {
// likely debugging scenario with two agents on local network
// set the agent active right away
newAgent->activatePublicSocket();
}
if (newAgent->getType() == AGENT_TYPE_VOXEL_SERVER ||
newAgent->getType() == AGENT_TYPE_AVATAR_MIXER ||
newAgent->getType() == AGENT_TYPE_AUDIO_MIXER) {
// this is currently the cheat we use to talk directly to our test servers on EC2
// to be removed when we have a proper identification strategy
newAgent->activatePublicSocket();
}
addAgentToList(newAgent);
return newAgent;
} else {
if (agent->getType() == AGENT_TYPE_AUDIO_MIXER ||
agent->getType() == AGENT_TYPE_VOXEL_SERVER) {
// until the Audio class also uses our agentList, we need to update
// the lastRecvTimeUsecs for the audio mixer so it doesn't get killed and re-added continously
agent->setLastHeardMicrostamp(usecTimestampNow());
}
// we had this agent already, do nothing for now
return &*agent;
}
}
示例2:
int Grid1D::getNumCooperators(){
list<Agent*> ags;
int count = 0;
Agent* a = NULL;
set<Agent*>::iterator i;
for (i = agents.begin(); i != agents.end(); ++i) {
a = *i;
if ((a->getType()) == COOP){
count++;
}
}
return count;
}
示例3: clone
void Agent::clone(Agent b){
type = b.getType();
decompositionTime = b.decompositionTime;
decomposed = b.decomposed;
shooted = b.shooted;
lifeTime = b.lifeTime;
infected = b.infected;
gender = b.gender;
age = b.age;
hasAGun = b.hasAGun;
infectionTime = b.infectionTime;
yearTime = b.yearTime;
deadByConversion = b.deadByConversion;
naturalDead = b.naturalDead;
lifeExpectancy = b.lifeExpectancy;
numBabies = b.numBabies;
}