1 | /*! |
---|
2 | \file track_manager.h |
---|
3 | \brief manages all tracks defined in the world and the path the player takes |
---|
4 | |
---|
5 | it is a container for all tracks and all track-nodes. it manages the movement of |
---|
6 | the track helper-parent (that drives the player). it is responsable for calculating |
---|
7 | smooth curves etc. |
---|
8 | */ |
---|
9 | |
---|
10 | |
---|
11 | #ifndef _TRACK_MANAGER_H |
---|
12 | #define _TRACK_MANAGER_H |
---|
13 | |
---|
14 | #include "stdincl.h" |
---|
15 | |
---|
16 | |
---|
17 | //! The TrackManager handles the flow of the Players through the game. |
---|
18 | /** |
---|
19 | \todo write the methodes |
---|
20 | |
---|
21 | <b>The TrackManager works as followed:</b> \n |
---|
22 | \n |
---|
23 | <b>1. Initialize it, by setting up the Graph. You can do this by using the following Commands.</b> |
---|
24 | \li workOn(): changes the ID that will be altered through the changes. |
---|
25 | \li setType: lets you set the CurveType of the Curve we are Working on. (default is BezierCurve, set this as early as possible, for this uses resources). |
---|
26 | \li setLength(): sets the length of the current path in seconds. |
---|
27 | \li addPoint(): adds a point to the Curve. |
---|
28 | \li addHotPoint(): adds save/splitpoint.\n |
---|
29 | \li fork(): adds some interessting non-linear movments through the level (fork will force addHotPoint if not done then). |
---|
30 | \li condition(): decides under what condition a certain Path will be chosen. |
---|
31 | \li join(): joins some tracks together again. Join will set the localTime to the longest time a Path has to get to this Point) |
---|
32 | \li setSavePoint(): Sets a HotPoint into a savePoint. A Savepoint can be used as a rollbackpoint if a Player gets shot. |
---|
33 | |
---|
34 | |
---|
35 | look out: <b>SAVEPOINTS CAN NOT BE FORKS</b> (but joins), because the condition is really hard to guess if you do not give some impuls. \n |
---|
36 | \n |
---|
37 | <b> 2. Runtime knows the following: </b> |
---|
38 | \li calcPos(): returns the current position on the track |
---|
39 | \li calcDir(): returns the current Direction the track is flying on. |
---|
40 | \li tick(): makes a Step on the Path. increases localTime by dt. |
---|
41 | \li choosePath(): a Function that decides which Path we should follow. |
---|
42 | |
---|
43 | TrackManager can be handled as a StateMachine. |
---|
44 | */ |
---|
45 | class TrackManager : public BaseObject { |
---|
46 | private: |
---|
47 | //! condition for choosing a certain Path. \todo implement a useful way. |
---|
48 | struct PathCondition |
---|
49 | { |
---|
50 | |
---|
51 | }; |
---|
52 | |
---|
53 | //! A Graph, that holds the curve-structure of a Level. |
---|
54 | /** |
---|
55 | A CurveGraph is used, to Define the structure of the Track itself. |
---|
56 | It is a graph and not a tree, because paths can fork and join again. |
---|
57 | */ |
---|
58 | struct TrackElement |
---|
59 | { |
---|
60 | bool isSavePoint; //!< If the first node is a savePoint |
---|
61 | bool isFork; //!< If the first node is a Fork |
---|
62 | bool isJoined; //!< If the End of the Curve is joined. |
---|
63 | PathCondition cond; //!< The Split Condition; |
---|
64 | int ID; //!< The ID of this TrackElement |
---|
65 | float length; //!< The time usedto cross this TrackElement (curve). |
---|
66 | CurveType curveType; //!< The CurveType this will have. |
---|
67 | int nodeCount; //!< The count of points this TrackElement has. |
---|
68 | Curve* curve; //!< The Curve of this TrackElement |
---|
69 | TrackElement** children; //!< A TrackElement can have a Tree of following TrackElements. |
---|
70 | }; |
---|
71 | |
---|
72 | |
---|
73 | TrackElement* firstGraph; //!< The first Graph-element we are on. |
---|
74 | TrackElement* currentGraph; //!< The Graph-element we are working on. |
---|
75 | float localTime; //!< The time that has been passed since the traveling the Track. |
---|
76 | int trackElementCount; //!< The count of TrackElements that exist. |
---|
77 | |
---|
78 | TrackElement findTrackElementByID(int trackID); |
---|
79 | |
---|
80 | public: |
---|
81 | TrackManager (); |
---|
82 | ~TrackManager (); |
---|
83 | |
---|
84 | // Methods to change the Path (initialisation) |
---|
85 | void workOn(int trackID); |
---|
86 | void setType(CurveType curveType); |
---|
87 | void setLength(float time); |
---|
88 | void addPoint(Vector newPoint); |
---|
89 | void addHotPoint(Vector newPoint); |
---|
90 | void setSavePoint(void); |
---|
91 | void fork(int count, ...); |
---|
92 | void forkV(int count, int* trackIDs); |
---|
93 | void condition(int groupID, PathCondition cond); //!< \todo really do this!! |
---|
94 | void join(int count, ...); |
---|
95 | void joinV(int count, int* trackIDs); |
---|
96 | |
---|
97 | // Methods to calculate the position on the Path (runtime) |
---|
98 | Vector calcPos(); |
---|
99 | Vector calcDir(); |
---|
100 | void tick(float dt); |
---|
101 | void choosePath(int graphID); |
---|
102 | |
---|
103 | }; |
---|
104 | |
---|
105 | #endif /* _TRACK_MANAGER_H */ |
---|