@@ -9,12 +9,16 @@ class GameObject: public cxx::noncopyable
99{
1010 friend class GameObjectsManager ;
1111
12+ // add runtime information support for gameobject
1213 decl_rtti_base (GameObject)
1314
1415public:
1516 const GameObjectID mObjectID ; // its unique for all game objects except projectiles or effects, see GAMEOBJECT_ID_NULL
1617 const eGameObjectClass mObjectTypeID ;
1718
19+ // readonly
20+ eGameObjectFlags mFlags = eGameObjectFlags_None;
21+
1822public:
1923 virtual ~GameObject ();
2024
@@ -36,17 +40,40 @@ class GameObject: public cxx::noncopyable
3640
3741 bool IsMarkedForDeletion () const ;
3842
39- // shortcuts
40- inline bool IsPedestrianObject () const { return mObjectTypeID == eGameObjectClass_Pedestrian; }
41- inline bool IsProjectileObject () const { return mObjectTypeID == eGameObjectClass_Projectile; }
42- inline bool IsDecorationObject () const { return mObjectTypeID == eGameObjectClass_Decoration; }
43- inline bool IsCarObject () const { return mObjectTypeID == eGameObjectClass_Car; }
44- inline bool IsPowerupObject () const { return mObjectTypeID == eGameObjectClass_Powerup; }
45- inline bool IsObstacleObject () const { return mObjectTypeID == eGameObjectClass_Obstacle; }
43+ // Attach or detach object to other object
44+ void SetAttachedToObject (GameObject* parentObject);
45+ void SetDetached ();
46+
47+ // Inspect hierarchy
48+ bool IsAttachedToObject () const ;
49+ bool IsAttachedToObject (GameObject* parentObject) const ;
50+ bool HasAttachedObjects ();
51+
52+ // Inspect hierarchy
53+ GameObject* GetParentObject () const ;
54+ GameObject* GetAttachedObject (int index) const ;
55+
56+ // class shortcuts
57+ inline bool IsPedestrianClass () const { return mObjectTypeID == eGameObjectClass_Pedestrian; }
58+ inline bool IsProjectileClass () const { return mObjectTypeID == eGameObjectClass_Projectile; }
59+ inline bool IsDecorationClass () const { return mObjectTypeID == eGameObjectClass_Decoration; }
60+ inline bool IsVehicleClass () const { return mObjectTypeID == eGameObjectClass_Car; }
61+ inline bool IsPowerupClass () const { return mObjectTypeID == eGameObjectClass_Powerup; }
62+ inline bool IsObstacleClass () const { return mObjectTypeID == eGameObjectClass_Obstacle; }
63+
64+ // flag shortcuts
65+ inline bool IsInvisibleFlag () const { return (mFlags & eGameObjectFlags_Invisible) != 0 ; }
66+ inline bool IsCarObjectFlag () const { return (mFlags & eGameObjectFlags_CarObject) != 0 ; }
4667
4768protected:
4869 GameObject (eGameObjectClass objectTypeID, GameObjectID uniqueID);
4970
71+ protected:
72+ // todo: add attachment point and angle
73+
74+ GameObject* mParentObject = nullptr ;
75+ std::vector<GameObject*> mAttachedObjects ;
76+
5077private:
5178 // marked object will be destroyed next game frame
5279 bool mMarkedForDeletion = false ;
0 commit comments