PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
objective_ops.h
1#pragma once
2
3#include "pixelbullet/scene/objective_types.h"
4
5#include <optional>
6#include <string_view>
7
8namespace pixelbullet
9{
10inline void NormalizeObjectiveAsset(ObjectiveAsset& asset)
11{
12 (void)asset;
13}
14
15[[nodiscard]] inline std::optional<std::size_t> FindObjectiveStageIndex(const ObjectiveAsset& asset,
16 const std::string_view stage_id)
17{
18 for (std::size_t index = 0; index < asset.stages.size(); ++index)
19 {
20 if (asset.stages[index].id == stage_id)
21 {
22 return index;
23 }
24 }
25
26 return std::nullopt;
27}
28
29[[nodiscard]] inline const ObjectiveStage* FindObjectiveStage(const ObjectiveAsset& asset, const std::string_view stage_id)
30{
31 const auto index = FindObjectiveStageIndex(asset, stage_id);
32 return index ? &asset.stages[*index] : nullptr;
33}
34
35[[nodiscard]] inline ObjectiveStage* FindObjectiveStage(ObjectiveAsset& asset, const std::string_view stage_id)
36{
37 const auto index = FindObjectiveStageIndex(asset, stage_id);
38 return index ? &asset.stages[*index] : nullptr;
39}
40} // namespace pixelbullet
Definition objective_types.h:19
Definition objective_types.h:9