Skip to content

Commit 383d493

Browse files
committed
Merge main into branch
1 parent 0dcfe5c commit 383d493

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1290
-185
lines changed
200 KB
Loading
7.63 KB
Loading

client/src/scenes/game.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ void SceneGame::OnKeyPress(const sf::Keyboard::Key &key) {
104104
void SceneGame::LoadResources() {
105105
managers_.resources->LoadTexture("assets/sheets/player.png", "player");
106106
managers_.resources->LoadTexture("assets/sheets/enemy.png", "enemy");
107+
managers_.resources->LoadTexture("assets/sheets/enemy_pack.png", "enemy_pack");
108+
managers_.resources->LoadTexture("assets/sheets/void_eater.png", "void_eater");
107109
}
108110

109111
void SceneGame::CreatePlayerEntity() {

client/src/systems/game/texture_mapper/texture_mapper.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,17 @@ Texture TextureMapper::MapBulletType(const sdk::game::types::ProjectileType type
1616
case game::types::ProjectileType::kPlayerCommon: {
1717
return Texture{.name = "player", .scale = 3, .rect = {249, 90, 16, 4}};
1818
}
19+
case ::game::types::ProjectileType::kGrappler: {
20+
return Texture{.name = "enemy_pack", .scale = 2, .rect = {42, 719, 53, 7}};
21+
}
22+
case ::game::types::ProjectileType::kEnforcer: {
23+
return Texture{.name = "enemy_pack", .scale = 2, .rect = {412, 725, 32, 6}};
24+
}
25+
case ::game::types::ProjectileType::kVoidEater: {
26+
return Texture{.name = "enemy_pack", .scale = 2, .rect = {531, 225, 32, 32}};
27+
}
1928
default: {
20-
return Texture{.name = "player", .scale = 1.5, .rect = {300, 121, 32, 10}};
29+
return Texture{.name = "player", .scale = 2, .rect = {227, 278, 10, 8}};
2130
}
2231
}
2332
}
@@ -29,6 +38,18 @@ mew::sets::drawable::Texture TextureMapper::MapEnemyType(game::types::EnemyType
2938
case game::types::EnemyType::kPataBig: {
3039
return Texture{.name = "enemy", .scale = 3.5, .rect = {5, 6, 21, 24}};
3140
}
41+
case game::types::EnemyType::kGrappler: {
42+
return Texture{.name = "enemy_pack", .scale = 2, .rect = {78, 743, 64, 24}};
43+
}
44+
case game::types::EnemyType::kEnforcer: {
45+
return Texture{.name = "enemy_pack", .scale = 2.5, .rect = {387, 821, 71, 61}};
46+
}
47+
case game::types::EnemyType::kElectricShark: {
48+
return Texture{.name = "enemy_pack", .scale = 1.5, .rect = {674, 260, 64, 22}};
49+
}
50+
case game::types::EnemyType::kVoidEater: {
51+
return Texture{.name = "void_eater", .scale = 2.5, .rect = {22, 24, 156, 186}};
52+
}
3253
default: {
3354
return Texture{.name = "enemy", .scale = 2.5, .rect = {5, 6, 21, 24}};
3455
}

libs/game/src/types/enemies.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,12 @@ namespace rtype::sdk::game::types {
1212
enum EnemyType {
1313
kPata = 0,
1414
kPataBig,
15+
kGrappler,
16+
kEnforcer,
17+
kVoidEater,
18+
kKiller,
19+
kSuperNova,
20+
kVirus,
21+
kElectricShark
1522
};
1623
} // namespace rtype::sdk::game::types

libs/game/src/types/projectile.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ namespace rtype::sdk::game::types {
1111
/// @brief Enum of the different types of shoot
1212
enum class ProjectileType {
1313
kPlayerCommon,
14-
kEnemyCommon,
14+
kPata,
15+
kGrappler,
16+
kEnforcer,
17+
kVoidEater
1518
}; // namespace rtype::sdk::game_core::types
1619
} // namespace rtype::sdk::game::types

libs/zygarde/src/scripting/systems/execution/script_execution_system.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ void ScriptExecutionSystem::ProcessScriptPool(Registry::Const_Ptr registry,
3131
scripting::components::ScriptPool* script_pool) {
3232
std::shared_ptr<types::ScriptingContext> context =
3333
std::make_shared<types::ScriptingContext>(CreateContext(registry));
34-
auto scripts = script_pool->GetScripts();
3534

36-
for (auto& script : scripts) {
37-
script->FixedUpdate(context);
38-
HandleCollisionCallback(registry, script, context);
39-
}
35+
HandleFixedUpdateCallback(script_pool, context);
36+
HandleCollisionCallback(registry, script_pool, context);
4037
}
4138

4239
scripting::types::ScriptingContext ScriptExecutionSystem::CreateContext(
@@ -45,16 +42,29 @@ scripting::types::ScriptingContext ScriptExecutionSystem::CreateContext(
4542
}
4643

4744
void ScriptExecutionSystem::HandleCollisionCallback(
48-
Registry::Const_Ptr registry,
49-
const std::shared_ptr<scripting::components::MonoBehaviour>& script,
45+
Registry::Const_Ptr registry, scripting::components::ScriptPool* script_pool,
5046
types::ScriptingContext::ConstPtr context) const {
5147
zygarde::Entity entity = registry->EntityFromIndex(currentScriptIndex_);
5248
auto collider = registry->GetComponent<physics::components::BoxCollider2D>(entity);
5349
if (!collider.has_value() || !collider.value()) {
5450
return;
5551
}
52+
auto scripts = script_pool->GetScripts();
53+
5654
while ((*collider)->HasCollision()) {
5755
auto collision = (*collider)->GetNextCollision();
58-
script->OnCollisionEnter(context, collision);
56+
for (auto& script : scripts) {
57+
script->OnCollisionEnter(context, collision);
58+
}
59+
}
60+
}
61+
62+
void ScriptExecutionSystem::HandleFixedUpdateCallback(
63+
scripting::components::ScriptPool* script_pool,
64+
const std::shared_ptr<types::ScriptingContext>& context) {
65+
auto scripts = script_pool->GetScripts();
66+
67+
for (auto& script : scripts) {
68+
script->FixedUpdate(context);
5969
}
6070
}

libs/zygarde/src/scripting/systems/execution/script_execution_system.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,22 @@ class EXPORT_ZYGARDE_API ScriptExecutionSystem final
4848
*/
4949
void ProcessScriptPool(Registry::Const_Ptr registry, scripting::components::ScriptPool *script);
5050

51+
/**
52+
* @brief Handle a fixed update callback
53+
* @param script Script pool to process
54+
* @param context Scripting context
55+
*/
56+
static void HandleFixedUpdateCallback(scripting::components::ScriptPool *script_pool,
57+
types::ScriptingContext::ConstPtr context);
58+
5159
/**
5260
* @brief Process a script collision callbacks
5361
* @param registry Registry
54-
* @param script Script to process
62+
* @param script_pool Script pool to process
5563
* @param context Scripting context
5664
*/
5765
void HandleCollisionCallback(Registry::Const_Ptr registry,
58-
const std::shared_ptr<scripting::components::MonoBehaviour> &script,
66+
scripting::components::ScriptPool *script_pool,
5967
types::ScriptingContext::ConstPtr context) const;
6068

6169
/**
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"archetype_name": "electric_shark",
3+
"components": [
4+
{
5+
"name": "rigidbody2d",
6+
"data": {
7+
"isKinematic": false,
8+
"drag": 0
9+
}
10+
},
11+
{
12+
"name": "position"
13+
},
14+
{
15+
"name": "box_collider2d",
16+
"data": {
17+
"size": {
18+
"x": 96,
19+
"y": 33
20+
},
21+
"collisionLayers": [
22+
2
23+
],
24+
"includeLayers": [
25+
1,
26+
8
27+
]
28+
}
29+
},
30+
{
31+
"name": "tags",
32+
"data": {
33+
"tags": [
34+
"enemy",
35+
"electric_shark"
36+
]
37+
}
38+
},
39+
{
40+
"name": "script_pool",
41+
"data": [
42+
{
43+
"scriptName": "enemyDefaultScript",
44+
"customValues": {
45+
"health": 50.0,
46+
"scoreIncrease": 500,
47+
"fireRate": 0.0,
48+
"bulletArchetype": "enforcer_bullet"
49+
}
50+
},
51+
{
52+
"scriptName": "sharkMovementScript",
53+
"customValues": {
54+
"speed": 150.0,
55+
"jumpSpeed": 750.0,
56+
"jumpThreshold": 600.0,
57+
"bottomThreshold": 1000.0,
58+
"jumpChance": 0.2,
59+
"stopChance": 0.03
60+
}
61+
}
62+
]
63+
}
64+
]
65+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"archetype_name": "enforcer",
3+
"components": [
4+
{
5+
"name": "rigidbody2d",
6+
"data": {
7+
"isKinematic": false,
8+
"drag": 0
9+
}
10+
},
11+
{
12+
"name": "position"
13+
},
14+
{
15+
"name": "box_collider2d",
16+
"data": {
17+
"size": {
18+
"x": 177.5,
19+
"y": 152.5
20+
},
21+
"collisionLayers": [
22+
2
23+
],
24+
"includeLayers": [
25+
1,
26+
8
27+
]
28+
}
29+
},
30+
{
31+
"name": "tags",
32+
"data": {
33+
"tags": [
34+
"enemy",
35+
"enforcer"
36+
]
37+
}
38+
},
39+
{
40+
"name": "script_pool",
41+
"data": [
42+
{
43+
"scriptName": "enemyDefaultScript",
44+
"customValues": {
45+
"health": 300.0,
46+
"scoreIncrease": 500,
47+
"fireRate": 1.5,
48+
"bulletArchetype": "enforcer_bullet"
49+
}
50+
},
51+
{
52+
"scriptName": "straightMovementScript",
53+
"customValues": {
54+
"speed": 300.0
55+
}
56+
}
57+
]
58+
}
59+
]
60+
}

0 commit comments

Comments
 (0)