summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2ElevatorModule.h
blob: b79f6b166de7d00c7993f0cc8ce74671ae6e7381 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef T2DLL_T2ELEVATORMODULE_H
#define T2DLL_T2ELEVATORMODULE_H
#include "../common.h"
#include "T2MoverModule.h"

enum {
    kElevatorStatus0 = 0,
    kElevatorStatus1,
    kElevatorStatus2,
    kElevatorStatus3,
    kElevatorStatus4,
    kElevatorStatus5,
};

enum {
    // no direction set
    kElevatorDirection0 = 0,
    // moving up
    kElevatorDirection1,
    // moving down
    kElevatorDirection2
};

class AFX_CLASS_EXPORT T2ElevatorModule : public T2MoverModule {
public:
	T2ElevatorModule(int index);
	virtual ~T2ElevatorModule();
    virtual void SetUsed(BOOL used);
    virtual void Enter(T2Mover*, T2People*);
    virtual void StopAdded(T2TowerDoc*, T2Mover*, int);
    virtual void StopRemoved(T2TowerDoc*, T2Mover*, int);

	void Init(int count, int position);
	BOOL IsPtInArea(POINT, const RECT&) const;
	void Remove(T2TowerDoc*, T2Mover*);
	void MoverExpanded(T2Mover*, EEquipPos, int);
	BOOL IsStopPos(int position, ERequestUpDown upDown) const;
	BOOL IsOnStopPos(int position, ERequestUpDown upDown) const;
	BOOL IsOffStopPos(int position, ERequestUpDown upDown) const;
	void SetOnStop(int position, ERequestUpDown upDown);
	void SetOffStop(int position, ERequestUpDown upDown);
	void ClearOnStop(T2Request*);
	void ClearOffStop(T2Request*);
	void SetNextStop();
	void ChangeTurnPos();
	void StartToHomePos();
	T2Request* GetAppointRequest(T2FloorInfo*, T2Mover*);
	T2Request* GetAnyRequest(T2FloorInfo*, T2Mover*);
	void CalcUintArea(const T2Mover*, RECT&) const;
    BOOL IsPatChanged(T2Mover*);
    T2People* LeaveToDstFloor(int y);

    int GetIndex() const { return mIndex; }
    int GetHomePosition() const;
    void SetHomePosition(int v) { mHomePosition = v; }
    int GetOffsetPos() { return mOffsetPos; }
    void SetOffsetPos(int v) { mOffsetPos = v; }
    void AddOffsetPos(int v) { mOffsetPos += v; }
    int GetNextStop() const { return mNextStop; }
    int GetTopTurn() const { return mTopTurn; }
    int GetBottomTurn() const { return mBottomTurn; }

protected:
    virtual void LoadSelf(T2Archive&, T2TowerDoc*);
    virtual void SaveSelf(T2Archive&);

    void RemoveContents(T2TowerDoc*, T2Mover*, int);
    BOOL HomePosRemoved(T2Mover*, int);
    void TopTurnPosRemoved(int);
    void BottomTurnPosRemoved(int);
    void NextStopRemoved();
	void CalcUintArea(const T2Mover*, int, RECT&) const;

    int mIndex;
    int mHomePosition;
    int mOffsetPos;
    int mNextStop;
    int mRequestCount;
    int mTopTurn;
    int mBottomTurn;
    T2StopInfoArray *mStopInfoArray;
};

inline int T2ElevatorModule::GetHomePosition() const {
    int result = -1;
    if (mUsed)
        result = mHomePosition;
    return result;
}
#endif