mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 06:27:24 +00:00
Resolved some comments
This commit is contained in:
parent
32cbd18e6b
commit
17a62d95e0
@ -6,7 +6,7 @@
|
||||
|
||||
using namespace Cinema;
|
||||
|
||||
void Cinema::Play::Conclude() {
|
||||
void Play::Conclude() {
|
||||
auto* player = Game::entityManager->GetEntity(this->player);
|
||||
|
||||
if (player == nullptr) {
|
||||
@ -16,7 +16,7 @@ void Cinema::Play::Conclude() {
|
||||
scene->Conclude(player);
|
||||
}
|
||||
|
||||
void Cinema::Play::SetupCheckForAudience() {
|
||||
void Play::SetupCheckForAudience() {
|
||||
if (m_CheckForAudience) {
|
||||
return;
|
||||
}
|
||||
@ -26,7 +26,7 @@ void Cinema::Play::SetupCheckForAudience() {
|
||||
CheckForAudience();
|
||||
}
|
||||
|
||||
void Cinema::Play::CheckForAudience() {
|
||||
void Play::CheckForAudience() {
|
||||
auto* player = Game::entityManager->GetEntity(this->player);
|
||||
|
||||
if (player == nullptr) {
|
||||
@ -51,13 +51,13 @@ void Cinema::Play::CheckForAudience() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Still don't care
|
||||
// As the scene isn't associated with a specifc objects, we'll use the zone control entity to setup a callback.
|
||||
Game::entityManager->GetZoneControlEntity()->AddCallbackTimer(1.0f, [this]() {
|
||||
CheckForAudience();
|
||||
});
|
||||
}
|
||||
|
||||
void Cinema::Play::CleanUp() {
|
||||
void Play::CleanUp() {
|
||||
LOG("Cleaning up play with %d entities", entities.size());
|
||||
|
||||
for (const auto& entity : entities) {
|
||||
@ -65,25 +65,23 @@ void Cinema::Play::CleanUp() {
|
||||
}
|
||||
}
|
||||
|
||||
void Cinema::Play::SetupBarrier(const std::string& barrier, std::function<void()> callback) {
|
||||
void Play::SetupBarrier(const std::string& barrier, const std::function<void()>& callback) {
|
||||
// Add the callback to the barrier
|
||||
if (m_Barriers.find(barrier) == m_Barriers.end()) {
|
||||
m_Barriers[barrier] = std::vector<std::function<void()>>();
|
||||
}
|
||||
|
||||
m_Barriers[barrier].push_back(callback);
|
||||
}
|
||||
|
||||
void Cinema::Play::SignalBarrier(const std::string& barrier) {
|
||||
if (m_Barriers.find(barrier) == m_Barriers.end()) {
|
||||
void Play::SignalBarrier(const std::string& barrier) {
|
||||
const auto& it = m_Barriers.find(barrier);
|
||||
|
||||
if (it == m_Barriers.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& callback : m_Barriers[barrier]) {
|
||||
for (const auto& callback : it->second) {
|
||||
callback();
|
||||
}
|
||||
|
||||
m_Barriers.erase(barrier);
|
||||
m_Barriers.erase(it);
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
* @param barrier The name of the barrier.
|
||||
* @param callback The callback to call when the barrier is signaled.
|
||||
*/
|
||||
void SetupBarrier(const std::string& barrier, std::function<void()> callback);
|
||||
void SetupBarrier(const std::string& barrier, const std::function<void()>& callback);
|
||||
|
||||
/**
|
||||
* @brief Signal a barrier.
|
||||
|
@ -9,13 +9,31 @@
|
||||
|
||||
using namespace Cinema;
|
||||
|
||||
std::unordered_map<std::string, Prefab> Prefab::m_Prefabs;
|
||||
std::unordered_map<size_t, Prefab::Instance> Prefab::m_Instances;
|
||||
struct PrefabInstance
|
||||
{
|
||||
std::vector<LWOOBJID> m_Entities;
|
||||
};
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
std::unordered_map<std::string, Prefab> m_Prefabs;
|
||||
std::unordered_map<size_t, PrefabInstance> m_Instances;
|
||||
|
||||
float m_AngleToRadians = 0.0174532925f;
|
||||
}
|
||||
|
||||
size_t Prefab::AddObject(LOT lot, NiPoint3 position, NiQuaternion rotation, float scale) {
|
||||
const auto id = ObjectIDManager::GenerateRandomObjectID();
|
||||
|
||||
m_Pieces.emplace(id, Prefab::Piece { lot, position, rotation, scale, {} });
|
||||
m_Pieces.emplace(id, Prefab::Piece {
|
||||
lot,
|
||||
position,
|
||||
rotation,
|
||||
scale,
|
||||
std::vector<int32_t>()
|
||||
});
|
||||
|
||||
return id;
|
||||
}
|
||||
@ -55,9 +73,9 @@ const Prefab& Prefab::LoadFromFile(std::string file) {
|
||||
// Check if the qx attribute exists, if so the rotation is a quaternion, otherwise it's a vector
|
||||
if (!element->Attribute("qx")) {
|
||||
rotation = NiQuaternion::FromEulerAngles( {
|
||||
element->FloatAttribute("rx") * 0.0174532925f,
|
||||
element->FloatAttribute("ry") * 0.0174532925f,
|
||||
element->FloatAttribute("rz") * 0.0174532925f
|
||||
element->FloatAttribute("rx") * m_AngleToRadians,
|
||||
element->FloatAttribute("ry") * m_AngleToRadians,
|
||||
element->FloatAttribute("rz") * m_AngleToRadians
|
||||
} );
|
||||
}
|
||||
else {
|
||||
@ -141,7 +159,7 @@ size_t Prefab::Instantiate(NiPoint3 position, float scale) const {
|
||||
// Generate random name
|
||||
std::string effectName = "Effect_";
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
effectName += std::to_string(rand() % 10);
|
||||
effectName += std::to_string(GeneralUtils::GenerateRandomNumber<size_t>(0, 10));
|
||||
}
|
||||
|
||||
renderComponent->PlayEffect(effect, u"create", effectName);
|
||||
@ -152,7 +170,7 @@ size_t Prefab::Instantiate(NiPoint3 position, float scale) const {
|
||||
Game::entityManager->ConstructEntity(entity);
|
||||
}
|
||||
|
||||
m_Instances.emplace(id, Prefab::Instance { entities });
|
||||
m_Instances.emplace(id, PrefabInstance { entities });
|
||||
|
||||
return id;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ class Prefab
|
||||
public:
|
||||
Prefab() = default;
|
||||
|
||||
~Prefab() = default;
|
||||
|
||||
/**
|
||||
* @brief Adds an object to the prefab.
|
||||
*
|
||||
@ -87,8 +89,6 @@ public:
|
||||
static void DestroyInstance(size_t instanceID);
|
||||
|
||||
|
||||
~Prefab() = default;
|
||||
|
||||
private:
|
||||
struct Piece
|
||||
{
|
||||
@ -99,16 +99,7 @@ private:
|
||||
std::vector<int32_t> m_Effects;
|
||||
};
|
||||
|
||||
struct Instance
|
||||
{
|
||||
std::vector<LWOOBJID> m_Entities;
|
||||
};
|
||||
|
||||
std::unordered_map<size_t, Piece> m_Pieces;
|
||||
|
||||
static std::unordered_map<std::string, Prefab> m_Prefabs;
|
||||
|
||||
static std::unordered_map<size_t, Instance> m_Instances;
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user