-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: load accuracy graphs using generic 2d graph loader
- Loading branch information
Showing
11 changed files
with
258 additions
and
30 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
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,55 @@ | ||
#include "AccuracyGraphLoader.h" | ||
|
||
#include "Parsing/Graph2D/Graph2DReader.h" | ||
|
||
#include <format> | ||
#include <iostream> | ||
|
||
namespace | ||
{ | ||
std::unique_ptr<GenericGraph2D> LoadAccuracyGraph(const IAssetLoadingManager* manager, const std::string& graphName, const std::string& subFolder) | ||
{ | ||
auto* searchPath = manager->GetAssetLoadingContext()->m_raw_search_path; | ||
const auto fileName = std::format("accuracy/{}/{}", subFolder, graphName); | ||
const auto file = searchPath->Open(fileName); | ||
if (!file.IsOpen()) | ||
{ | ||
std::cerr << std::format("Failed to open file for accuracy graph: {}/{}\n", subFolder, graphName); | ||
return nullptr; | ||
} | ||
|
||
return graph2d::Read("accuracy graph", "WEAPONACCUFILE", *file.m_stream, fileName, graphName); | ||
} | ||
} // namespace | ||
|
||
const GenericGraph2D* AccuracyGraphLoader::LoadAiVsAiGraph(const IAssetLoadingManager* manager, const std::string& graphName) | ||
{ | ||
const auto alreadyLoadedGraph = m_loaded_ai_vs_ai_graphs.find(graphName); | ||
if (alreadyLoadedGraph != m_loaded_ai_vs_ai_graphs.end()) | ||
return alreadyLoadedGraph->second.get(); | ||
|
||
auto graph = LoadAccuracyGraph(manager, graphName, "aivsai"); | ||
if (!graph) | ||
return nullptr; | ||
|
||
const auto* graphPtr = graph.get(); | ||
m_loaded_ai_vs_ai_graphs.emplace(graphName, std::move(graph)); | ||
|
||
return graphPtr; | ||
} | ||
|
||
const GenericGraph2D* AccuracyGraphLoader::LoadAiVsPlayerGraph(const IAssetLoadingManager* manager, const std::string& graphName) | ||
{ | ||
const auto alreadyLoadedGraph = m_loaded_ai_vs_player_graphs.find(graphName); | ||
if (alreadyLoadedGraph != m_loaded_ai_vs_player_graphs.end()) | ||
return alreadyLoadedGraph->second.get(); | ||
|
||
auto graph = LoadAccuracyGraph(manager, graphName, "aivsplayer"); | ||
if (!graph) | ||
return nullptr; | ||
|
||
const auto* graphPtr = graph.get(); | ||
m_loaded_ai_vs_player_graphs.emplace(graphName, std::move(graph)); | ||
|
||
return graphPtr; | ||
} |
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,17 @@ | ||
#pragma once | ||
#include "AssetLoading/IAssetLoadingManager.h" | ||
#include "AssetLoading/IZoneAssetLoaderState.h" | ||
#include "Parsing/GenericGraph2D.h" | ||
|
||
#include <memory> | ||
|
||
class AccuracyGraphLoader final : public IZoneAssetLoaderState | ||
{ | ||
public: | ||
const GenericGraph2D* LoadAiVsAiGraph(const IAssetLoadingManager* manager, const std::string& graphName); | ||
const GenericGraph2D* LoadAiVsPlayerGraph(const IAssetLoadingManager* manager, const std::string& graphName); | ||
|
||
private: | ||
std::unordered_map<std::string, std::unique_ptr<GenericGraph2D>> m_loaded_ai_vs_ai_graphs; | ||
std::unordered_map<std::string, std::unique_ptr<GenericGraph2D>> m_loaded_ai_vs_player_graphs; | ||
}; |
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
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.