Skip to content

Commit 4b01ae0

Browse files
committed
-
1 parent cc40116 commit 4b01ae0

20 files changed

+247
-49
lines changed

src/Carnage3D.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
<ClInclude Include="Console.h" />
190190
<ClInclude Include="FileSystem.h" />
191191
<ClInclude Include="GameDefs.h" />
192-
<ClInclude Include="GameRules.h" />
192+
<ClInclude Include="GameParams.h" />
193193
<ClInclude Include="geometries.h" />
194194
<ClInclude Include="cJSON.h" />
195195
<ClInclude Include="frustum.h" />
@@ -265,7 +265,7 @@
265265
<ClCompile Include="CarnageGame.cpp" />
266266
<ClCompile Include="config_document.cpp" />
267267
<ClCompile Include="FileSystem.cpp" />
268-
<ClCompile Include="GameRules.cpp" />
268+
<ClCompile Include="GameParams.cpp" />
269269
<ClCompile Include="GpuTextureArray2D.cpp" />
270270
<ClCompile Include="GuiRenderContext.cpp" />
271271
<ClCompile Include="GuiSystem.cpp" />

src/Carnage3D.vcxproj.filters

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,6 @@
202202
<ClInclude Include="SpriteAnimation.h">
203203
<Filter>Game</Filter>
204204
</ClInclude>
205-
<ClInclude Include="GameRules.h">
206-
<Filter>Game</Filter>
207-
</ClInclude>
208205
<ClInclude Include="GameCheatsWindow.h">
209206
<Filter>Game\GUI\DebugWindows</Filter>
210207
</ClInclude>
@@ -310,6 +307,9 @@
310307
<ClInclude Include="HumanCharacterView.h">
311308
<Filter>Game</Filter>
312309
</ClInclude>
310+
<ClInclude Include="GameParams.h">
311+
<Filter>Game</Filter>
312+
</ClInclude>
313313
</ItemGroup>
314314
<ItemGroup>
315315
<ClCompile Include="stdafx.cpp">
@@ -391,9 +391,6 @@
391391
<ClCompile Include="SpriteAnimation.cpp">
392392
<Filter>Game</Filter>
393393
</ClCompile>
394-
<ClCompile Include="GameRules.cpp">
395-
<Filter>Game</Filter>
396-
</ClCompile>
397394
<ClCompile Include="GameCheatsWindow.cpp">
398395
<Filter>Game\GUI\DebugWindows</Filter>
399396
</ClCompile>
@@ -485,6 +482,9 @@
485482
<ClCompile Include="RenderView.cpp">
486483
<Filter>Game\Rendering</Filter>
487484
</ClCompile>
485+
<ClCompile Include="GameParams.cpp">
486+
<Filter>Game</Filter>
487+
</ClCompile>
488488
</ItemGroup>
489489
<ItemGroup>
490490
<None Include="..\gamedata\config\sys_config.json.default">

src/CarnageGame.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ bool CarnageGame::Initialize()
2323

2424
SetInputActionsFromConfig();
2525

26-
gGameRules.LoadDefaults();
26+
gGameParams.LoadDefaults();
2727

2828
// scan all gta1 maps
2929
std::vector<std::string> gtaMapNames;
@@ -306,6 +306,11 @@ void CarnageGame::SetupHumanCharacter(int humanIndex, Pedestrian* pedestrian)
306306
if (mHumanCharacters[humanIndex].mCharPedestrian)
307307
return;
308308

309+
if (humanIndex > 0)
310+
{
311+
pedestrian->mRemapIndex = humanIndex - 1;
312+
}
313+
309314
mHumanCharacters[humanIndex].mCharPedestrian = pedestrian;
310315
mHumanCharacters[humanIndex].mCharController.SetCharacter(pedestrian);
311316
mHumanCharacters[humanIndex].mCharView.mFollowCameraController.SetFollowTarget(pedestrian);

src/CarnageGame.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class CarnageGame final: public cxx::noncopyable
2727

2828
Timespan mGameTime;
2929

30+
cxx::randomizer mGameRand;
31+
3032
public:
3133
// Setup resources and switch to initial game state
3234
bool Initialize();

src/GameCheatsWindow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ void GameCheatsWindow::DoUI(Timespan deltaTime)
117117

118118
if (ImGui::CollapsingHeader("Ped"))
119119
{
120-
ImGui::SliderFloat("Turn speed", &gGameRules.mPedestrianTurnSpeed, 10.0f, 640.0f, "%.2f");
121-
ImGui::SliderFloat("Run speed", &gGameRules.mPedestrianRunSpeed, 0.1f, 16.0f, "%.2f");
122-
ImGui::SliderFloat("Walk speed", &gGameRules.mPedestrianWalkSpeed, 0.1f, 16.0f, "%.2f");
120+
ImGui::SliderFloat("Turn speed", &gGameParams.mPedestrianTurnSpeed, 10.0f, 640.0f, "%.2f");
121+
ImGui::SliderFloat("Run speed", &gGameParams.mPedestrianRunSpeed, 0.1f, 16.0f, "%.2f");
122+
ImGui::SliderFloat("Walk speed", &gGameParams.mPedestrianWalkSpeed, 0.1f, 16.0f, "%.2f");
123123
}
124124

125125
if (ImGui::CollapsingHeader("Graphics"))

src/GameObjectsManager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
#include "PhysicsComponents.h"
66
#include "GameMapManager.h"
77

8+
GameObjectsManager::~GameObjectsManager()
9+
{
10+
mPedestriansPool.cleanup();
11+
mCarsPool.cleanup();
12+
}
13+
814
bool GameObjectsManager::Initialize()
915
{
1016
mIDsCounter = 0;

src/GameObjectsManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class GameObjectsManager final: public cxx::noncopyable
1515
cxx::intrusive_list<Vehicle> mDeleteCarsList;
1616

1717
public:
18+
~GameObjectsManager();
19+
1820
bool Initialize();
1921
void Deinit();
2022
void UpdateFrame(Timespan deltaTime);

src/GameParams.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "stdafx.h"
2+
#include "GameParams.h"
3+
4+
GameParams gGameParams;
5+
6+
GameParams::GameParams()
7+
{
8+
LoadDefaults();
9+
}
10+
11+
void GameParams::LoadDefaults()
12+
{
13+
mPedestrianTurnSpeed = 260.0f;
14+
mPedestrianTurnSpeedSlideOnCar = 120.0f;
15+
mPedestrianSlideOnCarSpeed = MAP_BLOCK_LENGTH * 1.2f;
16+
mPedestrianWalkSpeed = MAP_BLOCK_LENGTH * 0.7f;
17+
mPedestrianRunSpeed = MAP_BLOCK_LENGTH * 1.5f;
18+
mPedestrianSpotTheCarDistance = MAP_BLOCK_LENGTH * 3.0f;
19+
mPedestrianKnockedDownTime = 3.0f;
20+
21+
// weapons time todo
22+
mWeaponsRechargeTime[eWeaponType_Fists] = 1.0f / 2.0f;
23+
mWeaponsRechargeTime[eWeaponType_Pistol] = 1.0f / 4.0f;
24+
mWeaponsRechargeTime[eWeaponType_Machinegun] = 1.0f / 4.0f;
25+
mWeaponsRechargeTime[eWeaponType_Flamethrower] = 1.0f / 4.0f;
26+
mWeaponsRechargeTime[eWeaponType_RocketLauncher] = 1.0f * 3.0f;
27+
28+
// weapons distance todo
29+
mWeaponsDistance[eWeaponType_Fists] = PHYSICS_PED_BOUNDING_SPHERE_RADIUS;
30+
mWeaponsDistance[eWeaponType_Pistol] = 1.0f;
31+
mWeaponsDistance[eWeaponType_Machinegun] = 1.0f;
32+
mWeaponsDistance[eWeaponType_Flamethrower] = 1.0f;
33+
mWeaponsDistance[eWeaponType_RocketLauncher] = 1.0f;
34+
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#pragma once
22

3+
#include "GameDefs.h"
4+
35
// defines manager that hold all game logic parameters
4-
class GameRules
6+
class GameParams
57
{
68
public:
7-
GameRules();
9+
GameParams();
810

911
// reset all rules to default values
1012
void LoadDefaults();
@@ -16,7 +18,10 @@ class GameRules
1618
float mPedestrianSlideOnCarSpeed; // in blocks per second
1719
float mPedestrianWalkSpeed; // in blocks per second
1820
float mPedestrianRunSpeed; // in blocks per second
19-
float mPedestrianSpotTheCarDistance; // max distance to detect the car
21+
float mPedestrianKnockedDownTime; // knocked down duration after the punch in face, seconds
22+
float mPedestrianSpotTheCarDistance; // max distance to detect the car
23+
float mWeaponsRechargeTime[eWeaponType_COUNT]; // weapons reload time specified in seconds
24+
float mWeaponsDistance[eWeaponType_COUNT]; // specified in blocks
2025
};
2126

22-
extern GameRules gGameRules;
27+
extern GameParams gGameParams;

src/GameRules.cpp

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)