summaryrefslogtreecommitdiff
path: root/src/koopatlas/pathmanager.h
blob: 42d94baaff90781eb91d2e5029f953a03c067ee7 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef __KOOPATLAS_PATH_MANAGER_H
#define __KOOPATLAS_PATH_MANAGER_H

//#define WM_UNLOCK_DEBUGGING
#ifdef WM_UNLOCK_DEBUGGING
#define UnlockCmdReport OSReport
#else
#define UnlockCmdReport(...)
#endif

#include "koopatlas/mapdata.h"
#include "levelinfo.h"

extern "C" void *SoundRelatedClass;
extern "C" void *MapSoundPlayer(void *SoundClass, int soundID, int unk);
extern "C" bool SpawnEffect(const char*, int, Vec*, S16Vec*, Vec*);

enum CompletionMessageType {
	CMP_MSG_NULL = 0,
	CMP_MSG_COINS = 1,
	CMP_MSG_EXITS = 2,
	CMP_MSG_WORLD = 3,
	CMP_MSG_GLOBAL_COINS_EXC_W9 = 4,
	CMP_MSG_GLOBAL_COINS = 5,
	CMP_MSG_GLOBAL_EXITS = 6,
	CMP_MSG_EVERYTHING = 7
};

class dWMPathManager_c {
	public:
		void setup();
		~dWMPathManager_c();
		void execute();

		bool canUseExit(dKPPath_s *path) {
			OSReport("Checking usability of path %p\n", path);
			if (path) OSReport("Availability: %d\n", path->isAvailable);
			return (path != 0) && (path->isAvailable);
		}

		void startMovementTo(dKPPath_s *path);
		void moveThroughPath(int pressedDir);
		void activatePoint();
		void unlockAllPaths(char type);

		void copyWorldDefToSave(const dKPWorldDef_s *world);

		dKPLayer_s *pathLayer;

		bool firstPathDone;
		bool isMoving;
		dKPNode_s *currentNode;

		HermiteKey keysX[2];
		HermiteKey keysY[3];
		float timer;
		bool isJumping;
		float moveSpeed;

		bool forcedRotation;

		int scaleAnimProgress;
		bool isScalingUp;

		nw4r::snd::SoundHandle penguinSlideSound;

		bool swimming;

		dKPPath_s *currentPath;
		bool reverseThroughPath; // direction we are going through the path

		bool mustComplainToMapCreator;

		int newlyAvailablePaths;
		int newlyAvailableNodes;

		bool panningCameraToPaths;
		bool panningCameraFromPaths;
		int unlockingAlpha; // -1 if not used
		int countdownToFadeIn;
		int waitAfterUnlock;
		int waitBeforePanBack;

		bool savingForEnding;
		bool waitingForEndingTransition;

	private:
		void unlockPaths();
		void finalisePathUnlocks();
		bool evaluateUnlockCondition(u8 *&in, SaveBlock *save, int stack);
		int cachedTotalStarCoinCount;
		int cachedUnspentStarCoinCount;

	public:
		bool shouldRequestSave;
		bool isEnteringLevel;
		bool completionMessagePending;
		int dmGladDuration;
		int completionAnimDelay;
		int completionMessageType;
		int completionMessageWorldNum;

		bool calledEnteredNode;
		int levelStartWait;
		int waitAtStart;
		bool mustPlayAfterDeathAnim;
		bool mustPlayAfterWinAnim;
		int waitAfterInitialPlayerAnim;
		bool initialLoading;

		bool checkedForMoveAfterEndLevel;
		bool afterFortressMode;

		bool doingThings();

		dLevelInfo_c::entry_s *enteredLevel;


	private:
		int camMinX, camMinY, camMaxX, camMaxY;
		int nodeStackLength;
		bool camBoundsValid;
		void visitNodeForCamCheck(dKPNode_s *node);
		void findCameraBoundsForUnlockedPaths();
		void addNodeToCameraBounds(dKPNode_s *node);
};

#endif