Skip to content

Commit 72077b7

Browse files
committed
-
1 parent be7266c commit 72077b7

22 files changed

Lines changed: 223 additions & 153 deletions

src/Carnage3D.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<ClInclude Include="Box2D_Helpers.h" />
158158
<ClInclude Include="common_utils.h" />
159159
<ClInclude Include="Convert.h" />
160+
<ClInclude Include="Decoration.h" />
160161
<ClInclude Include="GameObjectDefs.h" />
161162
<ClInclude Include="game_version.h" />
162163
<ClInclude Include="GtaFontData.h" />
@@ -249,6 +250,7 @@
249250
<ItemGroup>
250251
<ClCompile Include="AiCharacterController.cpp" />
251252
<ClCompile Include="CommonTypes.cpp" />
253+
<ClCompile Include="Decoration.cpp" />
252254
<ClCompile Include="enums_impl.cpp" />
253255
<ClCompile Include="GtaFontData.cpp" />
254256
<ClCompile Include="GameObject.cpp" />

src/Carnage3D.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@
341341
<ClInclude Include="GameObjectDefs.h">
342342
<Filter>Game\GameObjects</Filter>
343343
</ClInclude>
344+
<ClInclude Include="Decoration.h">
345+
<Filter>Game\GameObjects</Filter>
346+
</ClInclude>
344347
</ItemGroup>
345348
<ItemGroup>
346349
<ClCompile Include="stdafx.cpp">
@@ -531,6 +534,9 @@
531534
<ClCompile Include="Projectile.cpp">
532535
<Filter>Game\GameObjects</Filter>
533536
</ClCompile>
537+
<ClCompile Include="Decoration.cpp">
538+
<Filter>Game\GameObjects</Filter>
539+
</ClCompile>
534540
</ItemGroup>
535541
<ItemGroup>
536542
<None Include="..\gamedata\config\sys_config.json.default">

src/Decoration.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "stdafx.h"
2+
#include "Decoration.h"
3+
4+
Decoration::Decoration(GameObjectID id)
5+
: GameObject(eGameObjectClass_Decoration, id)
6+
{
7+
}
8+
9+
Decoration::~Decoration()
10+
{
11+
}
12+
13+
void Decoration::DrawFrame(SpriteBatch& spriteBatch)
14+
{
15+
}
16+
17+
void Decoration::UpdateFrame()
18+
{
19+
}
20+
21+
void Decoration::DrawDebug(DebugRenderer& debugRender)
22+
{
23+
}

src/Decoration.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
3+
#include "GameObject.h"
4+
5+
class Decoration final: public GameObject
6+
{
7+
friend class GameObjectsManager;
8+
9+
decl_rtti(Decoration, GameObject)
10+
11+
public:
12+
Decoration(GameObjectID id);
13+
~Decoration();
14+
15+
// override GameObject
16+
void DrawFrame(SpriteBatch& spriteBatch);
17+
void UpdateFrame();
18+
void DrawDebug(DebugRenderer& debugRender);
19+
20+
private:
21+
SpriteAnimation mAnimationState;
22+
Sprite2D mSprite;
23+
};

src/GameDefs.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@
6060

6161
#define CAR_DELTA_ANIMS_SPEED 10.0f
6262

63-
// forwards
64-
65-
class Pedestrian;
66-
class Vehicle;
67-
class Projectile;
68-
6963
// define generic gameobject information
7064
struct GameObjectStyle
7165
{

src/GameObject.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
GameObject::GameObject(eGameObjectClass objectTypeID, GameObjectID uniqueID)
66
: mObjectID(uniqueID)
77
, mObjectTypeID(objectTypeID)
8-
, mObjectsNode(this)
9-
, mDeleteObjectsNode(this)
108
{
119
if (uniqueID == GAMEOBJECT_ID_NULL ||
1210
objectTypeID == eGameObjectClass_Projectile)
@@ -23,3 +21,8 @@ void GameObject::MarkForDeletion()
2321
{
2422
gGameObjectsManager.MarkForDeletion(this);
2523
}
24+
25+
bool GameObject::IsMarkedForDeletion() const
26+
{
27+
return mMarkedForDeletion;
28+
}

src/GameObject.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
#include "GameDefs.h"
44

5-
class SpriteBatch;
65
class DebugRenderer;
76

87
// defines base class of game entity
98
class GameObject: public cxx::noncopyable
109
{
1110
friend class GameObjectsManager;
1211

12+
decl_rtti_base(GameObject)
13+
1314
public:
1415
const GameObjectID mObjectID; // its unique for all game objects except projectiles or effects, see GAMEOBJECT_ID_NULL
1516
const eGameObjectClass mObjectTypeID;
@@ -30,9 +31,11 @@ class GameObject: public cxx::noncopyable
3031
{
3132
}
3233

33-
// schedule object to despawn
34+
// schedule object to delete from game
3435
void MarkForDeletion();
3536

37+
bool IsMarkedForDeletion() const;
38+
3639
// shortcuts
3740
inline bool IsPedestrianObject() const { return mObjectTypeID == eGameObjectClass_Pedestrian; }
3841
inline bool IsProjectileObject() const { return mObjectTypeID == eGameObjectClass_Projectile; }
@@ -43,8 +46,8 @@ class GameObject: public cxx::noncopyable
4346

4447
protected:
4548
GameObject(eGameObjectClass objectTypeID, GameObjectID uniqueID);
46-
49+
4750
private:
48-
cxx::intrusive_node<GameObject> mObjectsNode; // updatable and drawable entities
49-
cxx::intrusive_node<GameObject> mDeleteObjectsNode; // to remove queue
51+
// marked object will be destroyed next game frame
52+
bool mMarkedForDeletion = false;
5053
};

src/GameObjectDefs.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#pragma once
22

3+
// forwards
4+
5+
class GameObject;
6+
class Pedestrian;
7+
class Vehicle;
8+
class Projectile;
9+
class Decoration;
10+
311
// some game objects has null identifier, they are dacals, projectiles and short-lived effects
412
#define GAMEOBJECT_ID_NULL 0
513

@@ -8,8 +16,8 @@ using GameObjectID = unsigned int; // unique id of gameobject instance in world
816
// gameobject class identifiers
917
enum eGameObjectClass
1018
{
11-
eGameObjectClass_Pedestrian,
1219
eGameObjectClass_Car,
20+
eGameObjectClass_Pedestrian,
1321
eGameObjectClass_Projectile,
1422
eGameObjectClass_Powerup,
1523
eGameObjectClass_Decoration,
@@ -27,11 +35,11 @@ enum eGameObjectFlags: unsigned int
2735

2836
decl_enum_as_flags(eGameObjectFlags);
2937

30-
// game object indices
38+
// game object type indices
3139
enum
3240
{
3341
//GameObjectIndex_
3442

3543

36-
GameObjectIndex_MAX = 102
44+
GameObjectType_MAX = 102
3745
};

0 commit comments

Comments
 (0)