Ares
Public Member Functions | Protected Attributes

PsychicDominatorStateMachine Class Reference

#include <src/Misc/SWTypes.h>

Inheritance diagram for PsychicDominatorStateMachine:
SWStateMachine

List of all members.

Public Member Functions

 PsychicDominatorStateMachine (CellStruct XY, SuperClass *pSuper, NewSWType *pSWType)
virtual void Update ()

Protected Attributes

int Deferment

Constructor & Destructor Documentation

PsychicDominatorStateMachine::PsychicDominatorStateMachine ( CellStruct  XY,
SuperClass *  pSuper,
NewSWType pSWType 
) [inline]
                        : SWStateMachine(MAXINT32, XY, pSuper, pSWType) {
                                PsyDom::Status(PsychicDominatorStatus::FirstAnim);

                                // the initial deferment
                                SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pSuper->Type);
                                this->Deferment = pData->SW_Deferment.Get();

                                // make the game happy
                                PsyDom::Owner(pSuper->Owner);
                                PsyDom::Coords(XY);
                                PsyDom::Anim(NULL);
                };

Member Function Documentation

void PsychicDominatorStateMachine::Update ( ) [virtual]

Reimplemented from SWStateMachine.

                                          {
        // waiting. lurking in the shadows.
        if(this->Deferment > 0) {
                if(--this->Deferment) {
                        return;
                }
        }

        SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(this->Super->Type);

        switch(PsyDom::Status()) {
        case PsychicDominatorStatus::FirstAnim:
                {
                        // here are the contents of PsyDom::Start().
                        CoordStruct coords;
                        CellClass *pTarget = MapClass::Instance->GetCellAt(&this->Coords);
                        pTarget->GetCoords(&coords);
                        coords.Z += pData->Dominator_FirstAnimHeight;

                        AnimClass* pAnim = NULL;
                        if(pData->Dominator_FirstAnim.Get()) {
                                GAME_ALLOC(AnimClass, pAnim, pData->Dominator_FirstAnim, &coords);
                        }
                        PsyDom::Anim(pAnim);
                
                        if(pData->SW_ActivationSound.Get()) {
                                VocClass::PlayAt(pData->SW_ActivationSound, &coords, NULL);
                        }

                        if(*pData->Message_Activate) {
                                pData->PrintMessage(pData->Message_Activate, this->Super->Owner);
                        }
                        
                        PsyDom::Status(PsychicDominatorStatus::Fire);

                        // most likely LightUpdateTimer
                        ScenarioClass::Instance->Timer4.Start(1);
                        ScenarioClass::UpdateLighting();

                        return;
                }
        case PsychicDominatorStatus::Fire:
                {
                        // wait for some percentage of the first anim to be
                        // played until we strike.
                        AnimClass* pAnim = PsyDom::Anim();
                        if(pAnim) {
                                int currentFrame = pAnim->CurrentFrame;
                                short frameCount = pAnim->Type->GetImage()->Frames;
                                if(frameCount * pData->Dominator_FireAtPercentage * 0.01 > currentFrame) {
                                        return;
                                }
                        }

                        PsyDom::Fire();

                        PsyDom::Status(PsychicDominatorStatus::SecondAnim);
                        return;
                }
        case PsychicDominatorStatus::SecondAnim:
                {
                        // wait for the second animation to finish. (there may be up to
                        // 10 frames still to be played.)
                        AnimClass* pAnim = PsyDom::Anim();
                        if(pAnim) {
                                int currentFrame = pAnim->CurrentFrame;
                                short frameCount = pAnim->Type->GetImage()->Frames;

                                if(frameCount - currentFrame > 10) {
                                        return;
                                }
                        }

                        PsyDom::Status(PsychicDominatorStatus::Reset);
                        return;
                }
        case PsychicDominatorStatus::Reset:
                {
                        // wait for the last frame... WTF? 
                        AnimClass* pAnim = PsyDom::Anim();
                        if(pAnim) {
                                int currentFrame = pAnim->CurrentFrame;
                                short frameCount = pAnim->Type->GetImage()->Frames;

                                if(frameCount - currentFrame > 1) {
                                        return;
                                }
                        }

                        PsyDom::Status(PsychicDominatorStatus::Over);

                        CellStruct nullCell;
                        nullCell.X = 0;
                        nullCell.Y = 0;

                        PsyDom::Coords(nullCell);
                        PsyDom::Anim(NULL);
                        ScenarioClass::UpdateLighting();

                        return;
                }
        case PsychicDominatorStatus::Over:
                {
                        // wait for the light to go away.
                        if(ScenarioClass::Instance->AmbientCurrent != ScenarioClass::Instance->AmbientTarget) {
                                return;
                        }

                        // clean up
                        SW_PsychicDominator::CurrentPsyDom = NULL;
                        PsyDom::Status(PsychicDominatorStatus::Inactive);
                        ScenarioClass::UpdateLighting();
                        this->Clock.TimeLeft = 0;
                }
        }
}

Member Data Documentation


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