void SensorSystem::setShutdown (bool setting) { if (setting) { if (notShutdown) { long i = 0; while (i < numContacts) { MoverPtr mover = (MoverPtr)ObjectManager->get(contacts[i] & 0x7FFF); if (contacts[i] & VISUAL_CONTACT_FLAG) { master->removeContact(this, mover); i++; } else removeContact(i); } } // clearContacts(); notShutdown = false; } else { if (!notShutdown) for (long i = 0; i < numContacts; i++) { MoverPtr mover = (MoverPtr)ObjectManager->get(contacts[i] & 0x7FFF); if (contacts[i] & VISUAL_CONTACT_FLAG) master->addContact(this, mover, i, CONTACT_VISUAL); else master->addContact(this, mover, i, getSensorQuality()); } notShutdown = true; } }
void SensorSystem::addContact (MoverPtr mover, bool visual) { Assert(!isContact(mover), 0, " SensorSystem.addContact: already contact "); if (numContacts < MAX_CONTACTS_PER_SENSOR) { contacts[numContacts] = mover->getHandle(); if (visual) contacts[numContacts] |= VISUAL_CONTACT_FLAG; if (notShutdown) master->addContact(this, mover, numContacts, visual ? CONTACT_VISUAL : getSensorQuality()); numContacts++; } }
void SensorSystem::modifyContact(MoverPtr mover, bool visual) { int32_t contactNum = mover->getContactInfo()->getSensor(id); if(contactNum < MAX_CONTACTS_PER_SENSOR) { if(visual) contacts[contactNum] = mover->getHandle() | 0x8000; else contacts[contactNum] = mover->getHandle(); } if(notShutdown) master->modifyContact(this, mover, visual ? CONTACT_VISUAL : getSensorQuality()); }
long SensorSystem::calcContactStatus (MoverPtr mover) { if (!owner->getTeam()) return(CONTACT_NONE); if (mover->getFlag(OBJECT_FLAG_REMOVED)) { return(CONTACT_NONE); } //---------------------------------------------------------- //If object we are looking for is at the edge, NO CONTACT!! if (!Terrain::IsGameSelectTerrainPosition(mover->getPosition())) return CONTACT_NONE; //------------------------------------------------------------- // Should be properly set when active probes are implemented... long newContactStatus = CONTACT_NONE; if (!notShutdown || (range == 0.0) && !broken) { if (owner->lineOfSight(mover) && !mover->isDisabled()) newContactStatus = CONTACT_VISUAL; return(newContactStatus); } if ((masterIndex == -1) || (range < 0.0)) { return(CONTACT_NONE); } if (owner->isMover()) { MoverPtr mover = (MoverPtr)owner; if ((mover->sensor == 255) || mover->inventory[mover->sensor].disabled || broken) { return(CONTACT_NONE); } } if (mover->getFlag(OBJECT_FLAG_SENSOR) && !mover->isDisabled()) { bool moverNotContact = mover->hasNullSignature() || (mover->getEcmRange() != 0.0f); bool moverInvisible = (mover->getStatus() == OBJECT_STATUS_SHUTDOWN); if (!moverInvisible && !moverNotContact) { float distanceToMover = owner->distanceFrom(mover->getPosition()); float sensorRange = getEffectiveRange(); if (distanceToMover <= sensorRange) { //------------------------------------------- //No need to check shutdown and probe AGAIN! newContactStatus = getSensorQuality(); //--------------------------------------- // If ecm affecting me, my skill drops... // CUT, per Mitch 2/10/00 if ((ecmEffect < 1.0) && (newContactStatus > CONTACT_SENSOR_QUALITY_1)) newContactStatus--; //--------------------------------------------------- // We now we are within sensor range, check visual. float startRadius = 0.0f; if (!owner->isMover()) startRadius = owner->getAppearRadius(); if (hasLOSCapability && owner->lineOfSight(mover,startRadius)) newContactStatus = CONTACT_VISUAL; } else //Still need to check if visual!!! ECM and Lookout Towers!! { float startRadius = 0.0f; if (!owner->isMover()) startRadius = owner->getAppearRadius(); if (hasLOSCapability && owner->lineOfSight(mover,startRadius)) newContactStatus = CONTACT_VISUAL; } } else { //Target is shutdown, can ONLY be visual cause this platform has no probe. float startRadius = 0.0f; if (!owner->isMover()) startRadius = owner->getAppearRadius(); if (hasLOSCapability && owner->lineOfSight(mover,startRadius)) newContactStatus = CONTACT_VISUAL; } } //Let us know that we can see something, sensor or otherwise!! if (mover->getTeam() && (owner->getTeam() == Team::home) && mover->getTeam()->isEnemy(Team::home) && (newContactStatus != CONTACT_NONE)) { SensorSystemManager::enemyInLOS = true; } return(newContactStatus); }