trigger.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //---------------------------------------------------------------------------
  2. //
  3. // trigger.h - This file contains the class declaration for TriggerArea
  4. //
  5. //---------------------------------------------------------------------------//
  6. // Copyright (C) Microsoft Corporation. All rights reserved. //
  7. //===========================================================================//
  8. #ifndef TRIGGER_H
  9. #define TRIGGER_H
  10. #ifndef TERRAIN_H
  11. #include "terrain.h"
  12. #endif
  13. #ifndef DMOVER_H
  14. #include "dmover.h"
  15. #endif
  16. //#ifndef DSTD_H
  17. //#include "dstd.h"
  18. //#endif
  19. //---------------------------------------------------------------------------
  20. #define MAX_TRIGGER_AREAS 16
  21. typedef enum {
  22. TRIGGER_AREA_NONE,
  23. TRIGGER_AREA_MOVER,
  24. TRIGGER_AREA_TEAM,
  25. TRIGGER_AREA_GROUP,
  26. TRIGGER_AREA_COMMANDER,
  27. NUM_TRIGGER_AREA_TYPES
  28. } TriggerAreaType;
  29. typedef struct {
  30. char type;
  31. long param;
  32. long dim[4];
  33. bool hit;
  34. } TriggerArea;
  35. class TriggerAreaManager {
  36. public:
  37. TriggerArea triggerAreas[MAX_TRIGGER_AREAS];
  38. unsigned char map[MAX_MAP_CELL_WIDTH / 3][MAX_MAP_CELL_WIDTH / 3];
  39. public:
  40. void* operator new (size_t mySize);
  41. void operator delete (void* us);
  42. void init (void) {
  43. for (long i = 0; i < MAX_TRIGGER_AREAS; i++)
  44. triggerAreas[i].type = TRIGGER_AREA_NONE;
  45. for (long r = 0; r < MAX_MAP_CELL_WIDTH / 3; r++)
  46. for (long c = 0; c < MAX_MAP_CELL_WIDTH / 3; c++)
  47. map[r][c] = 0;
  48. }
  49. TriggerAreaManager (void) {
  50. init();
  51. }
  52. void destroy (void);
  53. ~TriggerAreaManager (void) {
  54. destroy();
  55. }
  56. long add (long ULrow, long ULcol, long LRrow, long LRcol, long type, long param);
  57. void remove (long areaHandle);
  58. void reset (long areaHandle);
  59. bool isHit (long areaHandle);
  60. void setHit (MoverPtr mover);
  61. };
  62. //---------------------------------------------------------------------------
  63. #endif