Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SimObject.h
Go to the documentation of this file.
1 /* Project Starshatter 4.5
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: SimObject.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Simulation Object and Observer classes
13 */
14 
15 #ifndef SimObject_h
16 #define SimObject_h
17 
18 #include "Types.h"
19 #include "Physical.h"
20 #include "List.h"
21 
22 // +--------------------------------------------------------------------+
23 
24 class Sim;
25 class SimRegion;
26 class SimObject;
27 class SimObserver;
28 class Scene;
29 
30 // +--------------------------------------------------------------------+
31 
32 class SimObject : public Physical
33 {
34  friend class SimRegion;
35 
36 public:
37  static const char* TYPENAME() { return "SimObject"; }
38 
39  enum TYPES {
40  SIM_SHIP=100,
46  };
47 
48  SimObject() : region(0), objid(0), active(0), notifying(0) { }
49  SimObject(const char* n, int t=0) : Physical(n,t), region(0), objid(0), active(0), notifying(0) { }
50  virtual ~SimObject();
51 
52  virtual SimRegion* GetRegion() const { return region; }
53  virtual void SetRegion(SimRegion* rgn) { region = rgn; }
54 
55  virtual void Notify();
56  virtual void Register(SimObserver* obs);
57  virtual void Unregister(SimObserver* obs);
58 
59  virtual void Activate(Scene& scene);
60  virtual void Deactivate(Scene& scene);
61 
62  virtual DWORD GetObjID() const { return objid; }
63  virtual void SetObjID(DWORD id) { objid = id; }
64 
65  virtual bool IsHostileTo(const SimObject* o)
66  const { return false; }
67 
68 protected:
71  DWORD objid;
72  bool active;
73  bool notifying;
74 };
75 
76 // +--------------------------------------------------------------------+
77 
79 {
80 public:
81  static const char* TYPENAME() { return "SimObserver"; }
82 
83  virtual ~SimObserver();
84 
85  int operator == (const SimObserver& o) const { return this == &o; }
86 
87  virtual bool Update(SimObject* obj);
88  virtual const char* GetObserverName() const;
89 
90  virtual void Observe(SimObject* obj);
91  virtual void Ignore(SimObject* obj);
92 
93 
94 protected:
96 };
97 
98 #endif SimObject_h
99