-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YAGNI: Simplify asset workflow, remove reflected factories, etc. (#33)
* [WIP] Simplify Enemy spawn flow, fix race in `Resources`. * Remove `EnemySpawner`, `EnemyFactoryBuilder`. * Remove `WorldSpec`, add `AssetManifest`. Hard-code manifest in game.cpp. * Refactor asset loading into a dedicated scene. * Remove `setup()`, can be done in constructors now. * Misc cleanup.
- Loading branch information
Showing
36 changed files
with
280 additions
and
488 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/spaced/spaced/game/asset_loader.cpp → src/spaced/spaced/assets/asset_loader.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace spaced { | ||
struct AssetManifest { | ||
std::vector<std::string> textures{}; | ||
std::vector<std::string> mip_mapped_textures{}; | ||
std::vector<std::string> fonts{}; | ||
std::vector<std::string> audio_clips{}; | ||
std::vector<std::string> particle_emitters{}; | ||
}; | ||
} // namespace spaced |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <bave/core/random.hpp> | ||
#include <spaced/game/enemies/creep.hpp> | ||
#include <spaced/game/enemies/creep_factory.hpp> | ||
#include <spaced/services/resources.hpp> | ||
#include <spaced/services/styles.hpp> | ||
|
||
namespace spaced { | ||
using bave::random_in_range; | ||
using bave::Seconds; | ||
|
||
auto CreepFactory::spawn_enemy() -> std::unique_ptr<Enemy> { | ||
auto ret = std::make_unique<Creep>(get_services()); | ||
if (!m_tints.empty()) { | ||
auto const& rgbas = get_services().get<Styles>().rgbas; | ||
auto const tint_index = random_in_range(std::size_t{}, m_tints.size() - 1); | ||
ret->shape.tint = rgbas[m_tints.at(tint_index)]; | ||
} | ||
ret->health = m_initial_health; | ||
return ret; | ||
} | ||
} // namespace spaced |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
#include <djson/json.hpp> | ||
#include <spaced/game/enemy_factory.hpp> | ||
|
||
namespace spaced { | ||
class CreepFactory : public EnemyFactory { | ||
public: | ||
using EnemyFactory::EnemyFactory; | ||
|
||
[[nodiscard]] auto spawn_enemy() -> std::unique_ptr<Enemy> final; | ||
|
||
private: | ||
std::array<std::string_view, 2> m_tints{"orange", "milk"}; | ||
float m_initial_health{2.0f}; | ||
}; | ||
} // namespace spaced |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.