space-game001/ActiveObject.h
2025-03-02 21:51:29 +03:00

53 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "TextureManager.h"
#include "Math.h"
#include <unordered_map>
#include <memory>
namespace ZL {
struct ActiveObject {
std::string name;
std::shared_ptr<ZL::Texture> activeObjectTexturePtr;
ZL::VertexDataStruct activeObjectMesh;
ZL::VertexRenderStruct activeObjectMeshMutable;
std::shared_ptr<ZL::Texture> activeObjectScreenTexturePtr;
ZL::VertexDataStruct activeObjectScreenMesh;
ZL::VertexRenderStruct activeObjectScreenMeshMutable;
ZL::Vector3f objectPos;
bool highlighted = false;
};
class ActiveObjectManager {
public:
std::unordered_map<std::string, ActiveObject> activeObjectsEntities;
// Добавить или обновить объект в контейнере
void addActiveObject(const ActiveObject& object) {
activeObjectsEntities[object.name] = object;
}
// Найти объект по имени (возвращает указатель, nullptr — если не найден)
ActiveObject* findByName(const std::string& name) {
auto it = activeObjectsEntities.find(name);
if (it != activeObjectsEntities.end()) {
return &it->second;
}
return nullptr;
}
// Найти все объекты с нужным значением highlighted
// (возвращает список указателей на найденные объекты)
// ActiveObject.h
void removeByName(const std::string& name) {
activeObjectsEntities.erase(name);
}
};
}