Ares
Public Member Functions

SW_SonarPulse Class Reference

#include <src/Misc/SWTypes/SonarPulse.h>

Inheritance diagram for SW_SonarPulse:
NewSWType

List of all members.

Public Member Functions

 SW_SonarPulse ()
virtual ~SW_SonarPulse ()
virtual const char * GetTypeString ()
virtual void Initialize (SWTypeExt::ExtData *pData, SuperWeaponTypeClass *pSW)
virtual void LoadFromINI (SWTypeExt::ExtData *pData, SuperWeaponTypeClass *pSW, CCINIClass *pINI)
virtual bool Launch (SuperClass *pThis, CellStruct *pCoords, byte IsPlayer)
virtual SuperWeaponFlags::Value Flags ()

Constructor & Destructor Documentation

SW_SonarPulse::SW_SonarPulse ( ) [inline]
                                : NewSWType()
                        { };
virtual SW_SonarPulse::~SW_SonarPulse ( ) [inline, virtual]
                        { };

Member Function Documentation

SuperWeaponFlags::Value SW_SonarPulse::Flags ( ) [virtual]

Reimplemented from NewSWType.

virtual const char* SW_SonarPulse::GetTypeString ( ) [inline, virtual]

Reimplemented from NewSWType.

                        { return "SonarPulse"; }
void SW_SonarPulse::Initialize ( SWTypeExt::ExtData pData,
SuperWeaponTypeClass *  pSW 
) [virtual]
bool SW_SonarPulse::Launch ( SuperClass *  pThis,
CellStruct *  pCoords,
byte  IsPlayer 
) [virtual]

Implements NewSWType.

{
        SuperWeaponTypeClass *pType = pThis->Type;
        SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pType);

        if(!pData) {
                return false;
        }

        auto Detect = [&](ObjectClass* pObj) -> bool {
                if(TechnoClass* pTechno = generic_cast<TechnoClass*>(pObj)) {
                        // is this thing affected at all?
                        if(!pData->IsHouseAffected(pThis->Owner, pTechno->Owner)) {
                                return true;
                        }

                        if(!pData->IsTechnoAffected(pTechno)) {
                                return true;
                        }

                        // actually detect this
                        if(pTechno->CloakState) {
                                pTechno->Uncloak(1);
                                pTechno->IsSensed = 1;
                                pTechno->Cloakable = 0;
                                TechnoExt::ExtData *pExt = TechnoExt::ExtMap.Find(pTechno);
                                if(pTechno) {
                                        pExt->CloakSkipTimer.Start(pData->Sonar_Delay);
                                }
                        }
                }

                return true;
        };

        float width = pData->SW_WidthOrRange;
        int height = pData->SW_Height;

        if(width < 0) {
                // decloak everything regardless of ranges
                for(int i=0; i<TechnoClass::Array->Count; ++i) {
                        Detect(TechnoClass::Array->GetItem(i));
                }

        } else {
                // decloak everything in range
                if(Helpers::Alex::DistinctCollector<ObjectClass*> *items = new Helpers::Alex::DistinctCollector<ObjectClass*>()) {
                        Helpers::Alex::forEachObjectInRange(pCoords, width, height, items->getCollector());
                        items->forEach(Detect);
                        delete items;
                }

                // radar event only if this isn't full map sonar
                if(pData->SW_RadarEvent.Get()) {
                        RadarEventClass::Create(RADAREVENT_SUPERWEAPONLAUNCHED, *pCoords);
                }
        }

        return true;
}
void SW_SonarPulse::LoadFromINI ( SWTypeExt::ExtData pData,
SuperWeaponTypeClass *  pSW,
CCINIClass *  pINI 
) [virtual]

Reimplemented from NewSWType.

{
        const char * section = pSW->get_ID();

        if(!pINI->GetSection(section)) {
                return;
        }

        pData->Sonar_Delay = pINI->ReadInteger(section, "SonarPulse.Delay", pData->Sonar_Delay);

        // full map detection?
        if(pData->SW_WidthOrRange < 0) {
                pSW->Action = 0;
        }
}

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines