Exemplo n.º 1
0
SensorSystemPtr TeamSensorSystem::findBestSpotter (MoverPtr contact, long* status) {

	ContactInfoPtr contactInfo = contact->getContactInfo();
	if (!contactInfo) {
		char s[256];
		sprintf(s, "TeamSensorSystem.findBestSpotter: NULL contactInfo for objClass %d partID %d team %d", contact->getObjectClass(), contact->getPartId(), contact->getTeamId());
		STOP((s));
	}
	SensorSystemPtr bestSensor = NULL;
	long bestStatus = CONTACT_NONE;
	for (long i = 0; i < MAX_SENSORS; i++)
		if (contactInfo->sensors[i] != 255) {
			SensorSystemPtr sensor = SensorManager->getSensor(i);
			if (sensor && sensor->owner && (teamId == sensor->owner->getTeamId())) {
				long status = sensor->calcContactStatus(contact);
				if (status >= bestStatus) {
					bestSensor = sensor;
					bestStatus = status;
				}
			}
		}
	if (status)
		*status = bestStatus;
	return(bestSensor);
}
Exemplo n.º 2
0
void TeamSensorSystem::removeSensor (SensorSystemPtr sensor) {

	sensor->clearContacts();
	long index = sensor->getMasterIndex();
	sensor->setMasterIndex(-1);

	sensors[index] = NULL;
	if (index < (numSensors - 1)) {
		sensors[index] = sensors[numSensors - 1];
		sensors[index]->setMasterIndex(index);
		sensors[numSensors - 1] = NULL;
	}
	numSensors--;
}
Exemplo n.º 3
0
void TeamSensorSystem::removeSensor(SensorSystemPtr sensor)
{
	sensor->clearContacts();
	int32_t index = sensor->getMasterIndex();
	sensor->setMasterIndex(-1);
	sensors[index] = nullptr;
	if(index < (numSensors - 1))
	{
		sensors[index] = sensors[numSensors - 1];
		sensors[index]->setMasterIndex(index);
		sensors[numSensors - 1] = nullptr;
	}
	numSensors--;
}
Exemplo n.º 4
0
void SensorSystemManager::removeTeamSensor (long teamId, SensorSystemPtr sensor) {

	if (teamId == -1)
		return;
	teamSensors[teamId]->removeSensor(sensor);
	sensor->setMaster(NULL);
}
Exemplo n.º 5
0
void TeamSensorSystem::addSensor(SensorSystemPtr sensor)
{
	if(numSensors == MAX_SENSORS_PER_TEAM)
		Fatal(0, " TeamSensorSystem.addSensor: too many sensors ");
	sensor->setMasterIndex(numSensors);
	sensors[numSensors++] = sensor;
}
Exemplo n.º 6
0
void SensorSystemManager::removeTeamSensor(int32_t teamId, SensorSystemPtr sensor)
{
	if(teamId == -1)
		return;
	teamSensors[teamId]->removeSensor(sensor);
	sensor->setMaster(nullptr);
}
Exemplo n.º 7
0
void SensorSystemManager::addTeamSensor (long teamId, SensorSystemPtr sensor) 
{
	if ((teamId > -1) && (teamId < Team::numTeams))
	{
		teamSensors[teamId]->addSensor(sensor);
		sensor->setMaster(teamSensors[teamId]);
	}
}