Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor|libdoom: Translated braindata_t into a simple C++ class name…
…d BossBrain
- Loading branch information
1 parent
0aa892f
commit ae0231c
Showing
14 changed files
with
321 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,35 +28,58 @@ | |
# error "Using jDoom headers without __JDOOM__" | ||
#endif | ||
|
||
#include "doomsday.h" | ||
#include "p_mobj.h" | ||
#include "jdoom.h" | ||
#ifdef __cplusplus | ||
#include "mapstatereader.h" | ||
#include "mapstatewriter.h" | ||
|
||
/** | ||
* Global state of boss brain. | ||
* | ||
* @ingroup libdoom | ||
*/ | ||
typedef struct bossbrain_s { | ||
int easy; | ||
int targetOn; | ||
int numTargets; | ||
int maxTargets; | ||
mobj_t **targets; | ||
} bossbrain_t; | ||
class BossBrain | ||
{ | ||
public: | ||
BossBrain(); | ||
|
||
void clearTargets(); | ||
|
||
int targetCount() const; | ||
|
||
void addTarget(struct mobj_s *mo); | ||
|
||
struct mobj_s *nextTarget(); | ||
|
||
DENG_EXTERN_C bossbrain_t bossBrain; | ||
void write(MapStateWriter *msw) const; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
danij-deng
Author
Collaborator
|
||
void read(MapStateReader *msr); | ||
|
||
private: | ||
DENG2_PRIVATE(d) | ||
}; | ||
#endif // __cplusplus | ||
|
||
// C wrapper API --------------------------------------------------------------- | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#else | ||
typedef void *BossBrain; | ||
#endif | ||
|
||
void P_BrainInitForMap(void); | ||
void P_BrainShutdown(void); | ||
void P_BrainClearTargets(void); | ||
void P_BrainWrite(Writer *writer); | ||
void P_BrainRead(Reader *reader, int mapVersion); | ||
void P_BrainAddTarget(mobj_t *mo); | ||
void BossBrain_ClearTargets(BossBrain *brain); | ||
|
||
int BossBrain_TargetCount(BossBrain const *brain); | ||
|
||
void BossBrain_AddTarget(BossBrain *brain, struct mobj_s *mo); | ||
|
||
struct mobj_s *BossBrain_NextTarget(BossBrain *brain); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
/// The One BossBrain instance. | ||
DENG_EXTERN_C BossBrain *bossBrain; | ||
|
||
#endif // LIBDOOM_PLAY_BOSSBRAIN_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Is this heading toward a de::ISerializable kind of mechanism? Meaning, something based on polymorphism where you can just write arbitrary map data objects into a writer?
I would much like to see the serialization of all of these game-side classes ultimately based on / working with the libdeng2 Writer/Reader/ISerializable classes in one way or another.