summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2StairModule.cpp
blob: fecc568bb20f22d928ffc02347596fa05f474a67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "StdAfx.h"
#include "T2Archive.h"
#include "T2FloorInfo.h"
#include "T2People.h"
#include "T2PeopleLinkIterator.h"
#include "T2StairModule.h"
#include "T2Tenant.h"
#include "../T2TowerDoc.h"

T2StairModule::T2StairModule() {
    SetRectEmpty(&mModuleRect);
}

/*virtual*/ T2StairModule::~T2StairModule() {
}

void T2StairModule::MoverIDChanged(unsigned int moverID) {
    if (mLink1) {
        T2PeopleLinkIterator iterator((T2People *) mLink1);
        T2People *people;

        while (iterator.Next(&people)) {
            if (people)
                people->mCurrEquipID = moverID;
        }
    }
}

/*virtual*/ void T2StairModule::RemoveContents(T2TowerDoc* towerDoc) {
    T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo();

    while (mLink1) {
        T2People *thePeople = (T2People *) mLink1;
        Leave(thePeople);

        POINT theNextPt = mModuleRect.TopLeft();
        if (mDirection != kStairDirection1)
            theNextPt.y = mModuleRect.bottom - 1;

        T2Tenant *theFloor = theFloorInfo->GetFloor(theNextPt.y, theNextPt.x);
        if (theFloor)
            theFloor->Enter(thePeople);
    }
}

/*virtual*/ void T2StairModule::LoadSelf(T2Archive& archive, T2TowerDoc* towerDoc) {
    T2MoverModule::LoadSelf(archive, towerDoc);

    if (IsUsed())
        archive.ReadSRect(mModuleRect);
}

/*virtual*/ void T2StairModule::SaveSelf(T2Archive& archive) {
    T2MoverModule::SaveSelf(archive);

    if (IsUsed())
        archive.WriteSRect(mModuleRect);
}