Skip to content

Commit eaa7e56

Browse files
committed
small refactoring
1 parent 5d713ff commit eaa7e56

40 files changed

+846
-301
lines changed

gamedata/entities/weapons.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"base_hit_range": 4.5,
2828
"base_fire_rate": 2.3,
2929
"base_ammo_limit": 99,
30-
"base_damage": 5,
3130
"shot_sfx": 33, // sound index
3231
"hud_sprite": 30
3332
},
@@ -53,7 +52,6 @@
5352
"base_fire_rate": 16.0,
5453
"base_ammo_limit": 999,
5554
"shots_per_clip": 5,
56-
"base_damage": 5,
5755
"shot_sfx": 34, // sound index
5856
"hud_sprite": 31
5957
},
@@ -77,7 +75,6 @@
7775
"base_fire_rate": 16.0,
7876
"base_ammo_limit": 999,
7977
"shots_per_clip": 5,
80-
"base_damage": 15,
8178
"shot_sfx": 35, // sound index
8279
"hud_sprite": 33
8380
},
@@ -100,7 +97,6 @@
10097
"base_hit_range": 20.0,
10198
"base_fire_rate": 1.17,
10299
"base_ammo_limit": 99,
103-
"base_damage": 100,
104100
"shot_sfx": 36, // sound index
105101
"hud_sprite": 32
106102
}

src/BroadcastEventsManager.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "stdafx.h"
22
#include "BroadcastEventsManager.h"
33
#include "TimeManager.h"
4+
#include "CarnageGame.h"
45

56
BroadcastEventsManager gBroadcastEvents;
67

@@ -75,6 +76,12 @@ void BroadcastEventsManager::RegisterEvent(eBroadcastEvent eventType, GameObject
7576
evData.mPosition = subject->mTransform.GetPosition2();
7677
evData.mSubject = subject;
7778
evData.mCharacter = character;
79+
80+
// notify current gamestate controller
81+
if (gCarnageGame.mCurrentGamestate)
82+
{
83+
gCarnageGame.mCurrentGamestate->OnGamestateBroadcastEvent(evData);
84+
}
7885
}
7986

8087
void BroadcastEventsManager::RegisterEvent(eBroadcastEvent eventType, const glm::vec2& position, float durationTime)
@@ -102,6 +109,12 @@ void BroadcastEventsManager::RegisterEvent(eBroadcastEvent eventType, const glm:
102109
evData.mEventTimestamp = currentGameTime;
103110
evData.mEventDurationTime = durationTime;
104111
evData.mPosition = position;
112+
113+
// notify current gamestate controller
114+
if (gCarnageGame.mCurrentGamestate)
115+
{
116+
gCarnageGame.mCurrentGamestate->OnGamestateBroadcastEvent(evData);
117+
}
105118
}
106119

107120
bool BroadcastEventsManager::PeekEvent(eBroadcastEvent eventType, BroadcastEvent& outputEventData) const

src/BroadcastEventsManager.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "GameObject.h"
55
#include "Pedestrian.h"
66

7+
//////////////////////////////////////////////////////////////////////////
8+
79
// When something is happening on game map broadcast event gets fired up
810
enum eBroadcastEvent
911
{
@@ -13,10 +15,15 @@ enum eBroadcastEvent
1315
eBroadcastEvent_StealCar,
1416
eBroadcastEvent_Explosion,
1517
eBroadcastEvent_CarBurns,
18+
19+
eBroadcastEvent_StartDriveCar,
20+
eBroadcastEvent_StopDriveCar,
1621
};
1722

1823
decl_enum_strings(eBroadcastEvent);
1924

25+
//////////////////////////////////////////////////////////////////////////
26+
2027
enum eBroadcastEventSubject
2128
{
2229
eBroadcastEventSubject_None,
@@ -27,6 +34,8 @@ enum eBroadcastEventSubject
2734

2835
decl_enum_strings(eBroadcastEventSubject);
2936

37+
//////////////////////////////////////////////////////////////////////////
38+
3039
// Broadcast event data
3140
struct BroadcastEvent
3241
{
@@ -38,14 +47,16 @@ struct BroadcastEvent
3847
eBroadcastEventSubject mEventSubject;
3948

4049
float mEventTimestamp; // time when event was created
41-
float mEventDurationTime; // how long event lives
50+
float mEventDurationTime; // how long event lives, seconds
4251

4352
glm::vec2 mPosition; // position in the world where event did happen, meters
4453

4554
GameObjectHandle mSubject; // object that was affected
4655
PedestrianHandle mCharacter; // character which causes event
4756
};
4857

58+
//////////////////////////////////////////////////////////////////////////
59+
4960
// Broadcast events manager
5061
class BroadcastEventsManager final: public cxx::noncopyable
5162
{

src/Carnage3D.vcxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@
161161
<ClInclude Include="Collider.h" />
162162
<ClInclude Include="Collision.h" />
163163
<ClInclude Include="GameObjectHelpers.h" />
164+
<ClInclude Include="GameplayGamestate.h" />
165+
<ClInclude Include="GenericGamestate.h" />
166+
<ClInclude Include="MainMenuGamestate.h" />
164167
<ClInclude Include="SfxEmitter.h" />
165168
<ClInclude Include="AudioListener.h" />
166169
<ClInclude Include="AudioSource.h" />
@@ -289,6 +292,9 @@
289292
<ClCompile Include="AudioDataStream.cpp" />
290293
<ClCompile Include="Collider.cpp" />
291294
<ClCompile Include="Collision.cpp" />
295+
<ClCompile Include="GameplayGamestate.cpp" />
296+
<ClCompile Include="GenericGamestate.cpp" />
297+
<ClCompile Include="MainMenuGamestate.cpp" />
292298
<ClCompile Include="SfxEmitter.cpp" />
293299
<ClCompile Include="AudioSource.cpp" />
294300
<ClCompile Include="ConsoleVar.cpp" />

src/Carnage3D.vcxproj.filters

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
<Filter Include="Game\Particles">
7575
<UniqueIdentifier>{9702cb17-25cc-44a7-92ba-65a8c47323d6}</UniqueIdentifier>
7676
</Filter>
77+
<Filter Include="Game\GameStates">
78+
<UniqueIdentifier>{1ba8bbc1-0de7-4c68-83e9-ab609908dc23}</UniqueIdentifier>
79+
</Filter>
7780
</ItemGroup>
7881
<ItemGroup>
7982
<ClInclude Include="stdafx.h">
@@ -453,6 +456,15 @@
453456
<ClInclude Include="GameObjectHelpers.h">
454457
<Filter>Game\GameObjects</Filter>
455458
</ClInclude>
459+
<ClInclude Include="GenericGamestate.h">
460+
<Filter>Game\GameStates</Filter>
461+
</ClInclude>
462+
<ClInclude Include="GameplayGamestate.h">
463+
<Filter>Game\GameStates</Filter>
464+
</ClInclude>
465+
<ClInclude Include="MainMenuGamestate.h">
466+
<Filter>Game\GameStates</Filter>
467+
</ClInclude>
456468
</ItemGroup>
457469
<ItemGroup>
458470
<ClCompile Include="stdafx.cpp">
@@ -721,6 +733,15 @@
721733
<ClCompile Include="Collision.cpp">
722734
<Filter>Game\Physics</Filter>
723735
</ClCompile>
736+
<ClCompile Include="GenericGamestate.cpp">
737+
<Filter>Game\GameStates</Filter>
738+
</ClCompile>
739+
<ClCompile Include="GameplayGamestate.cpp">
740+
<Filter>Game\GameStates</Filter>
741+
</ClCompile>
742+
<ClCompile Include="MainMenuGamestate.cpp">
743+
<Filter>Game\GameStates</Filter>
744+
</ClCompile>
724745
</ItemGroup>
725746
<ItemGroup>
726747
<None Include="..\gamedata\config\sys_config.json.default">

0 commit comments

Comments
 (0)