mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-12 19:28:21 +00:00
Brought the branch up to speed
* Updated logging * Added an image to the README
This commit is contained in:
parent
3f90a4dd0b
commit
e4320d3e63
@ -29,6 +29,8 @@ void Cinema::Play::SetupCheckForAudience() {
|
||||
void Cinema::Play::CheckForAudience() {
|
||||
auto* player = Game::entityManager->GetEntity(this->player);
|
||||
|
||||
LOG("Checking for audience");
|
||||
|
||||
if (player == nullptr) {
|
||||
CleanUp();
|
||||
|
||||
@ -50,6 +52,8 @@ void Cinema::Play::CheckForAudience() {
|
||||
}
|
||||
|
||||
void Cinema::Play::CleanUp() {
|
||||
LOG("Cleaning up play with %d entities", entities.size());
|
||||
|
||||
for (const auto& entity : entities) {
|
||||
Game::entityManager->DestroyEntity(entity);
|
||||
}
|
||||
@ -66,7 +70,7 @@ void Cinema::Play::SetupBarrier(const std::string& barrier, std::function<void()
|
||||
|
||||
void Cinema::Play::SignalBarrier(const std::string& barrier) {
|
||||
if (m_Barriers.find(barrier) == m_Barriers.end()) {
|
||||
Game::logger->Log("Cinema::Play", "Barrier %s does not exist", barrier.c_str());
|
||||
LOG("Barrier %s does not exist", barrier.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ const Prefab& Prefab::LoadFromFile(std::string file) {
|
||||
|
||||
tinyxml2::XMLElement* root = doc.FirstChildElement("Prefab");
|
||||
if (!root) {
|
||||
Game::logger->Log("Prefab", "Failed to load prefab from file: %s", file.c_str());
|
||||
LOG("Failed to load prefab from file: %s", file.c_str());
|
||||
|
||||
m_Prefabs.emplace(file, prefab);
|
||||
|
||||
|
@ -14,6 +14,8 @@ Cinema works with a few concepts:
|
||||
## Play isolation
|
||||
When a play is performed to a player, it is always isolated from the rest of the players in the world. This is to ensure that the player can experience the play without being disturbed by others, and others can't be disturbed by the play. This is achieved by ghosting all NPCs and props in the play to all players except the one experiencing the play.
|
||||
|
||||
<img src="media/isolation.png" width="800">
|
||||
|
||||
## How to create a scene
|
||||
A play is created is a couple of steps:
|
||||
1. Acts out the scene in the world as how the NPCs should reenact it.
|
||||
|
@ -28,7 +28,7 @@ void Recorder::AddRecord(Record* record)
|
||||
return;
|
||||
}
|
||||
|
||||
Game::logger->Log("Recorder", "Adding record");
|
||||
LOG("Adding record");
|
||||
|
||||
const auto currentTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
|
||||
|
||||
@ -41,7 +41,7 @@ void Recorder::AddRecord(Record* record)
|
||||
}
|
||||
|
||||
void Recorder::Act(Entity* actor, Play* variables) {
|
||||
Game::logger->Log("Recorder", "Acting %d steps", m_Records.size());
|
||||
LOG("Acting %d steps", m_Records.size());
|
||||
|
||||
// Loop through all records
|
||||
ActingDispatch(actor, 0, variables);
|
||||
@ -91,7 +91,7 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
||||
}
|
||||
}
|
||||
|
||||
Game::logger->Log("Recorder", "Failed to find fork label success: %s", forkRecord->success.c_str());
|
||||
LOG("Failed to find fork label success: %s", forkRecord->success.c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
@ -106,7 +106,7 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
||||
}
|
||||
}
|
||||
|
||||
Game::logger->Log("Recorder", "Failed to find fork label failure: %s", forkRecord->failure.c_str());
|
||||
LOG("Failed to find fork label failure: %s", forkRecord->failure.c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
@ -126,7 +126,7 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
||||
}
|
||||
}
|
||||
|
||||
Game::logger->Log("Recorder", "Failed to find jump label: %s", jumpRecord->label.c_str());
|
||||
LOG("Failed to find jump label: %s", jumpRecord->label.c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
@ -631,6 +631,10 @@ Recorder* Recorder::LoadFromFile(const std::string& filename) {
|
||||
for (auto* element = root->FirstChildElement(); element; element = element->NextSiblingElement()) {
|
||||
const std::string name = element->Name();
|
||||
|
||||
if (!element->Attribute("t")) {
|
||||
element->SetAttribute("t", 0.0f);
|
||||
}
|
||||
|
||||
if (name == "MovementRecord") {
|
||||
MovementRecord* record = new MovementRecord();
|
||||
record->Deserialize(element);
|
||||
|
@ -64,6 +64,8 @@ bool Cinema::Scene::IsPlayerInBounds(Entity* player) const {
|
||||
|
||||
auto distance = NiPoint3::Distance(position, m_Center);
|
||||
|
||||
LOG("Player distance from scene: %f, with bounds %f", distance, m_Bounds);
|
||||
|
||||
// The player may be within 20% of the bounds
|
||||
return distance <= (m_Bounds * 1.2f);
|
||||
}
|
||||
@ -132,7 +134,7 @@ Play* Cinema::Scene::Act(Entity* player) {
|
||||
ServerPreconditions::AddSoloActor(entity->GetObjectID(), player->GetObjectID());
|
||||
}
|
||||
|
||||
Game::logger->Log("Scene", "Spawing object %d", entity->GetObjectID());
|
||||
LOG("Spawing object %d", entity->GetObjectID());
|
||||
}
|
||||
|
||||
for (const auto& [prefab, position] : m_Prefabs) {
|
||||
@ -143,12 +145,14 @@ Play* Cinema::Scene::Act(Entity* player) {
|
||||
if (player != nullptr) {
|
||||
for (const auto& entity : entities) {
|
||||
ServerPreconditions::AddSoloActor(entity, player->GetObjectID());
|
||||
|
||||
play->entities.emplace(entity);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& entity : entities) {
|
||||
play->entities.emplace(entity);
|
||||
}
|
||||
|
||||
Game::logger->Log("Scene", "Spawing prefab %d", instanceId);
|
||||
LOG("Spawing prefab %d", instanceId);
|
||||
}
|
||||
|
||||
for (const auto& [npc, meta] : m_NPCs) {
|
||||
@ -185,9 +189,9 @@ Play* Cinema::Scene::Act(Entity* player) {
|
||||
actor->SetVar(u"npcName", name);
|
||||
}
|
||||
|
||||
play->entities.emplace(entity->GetObjectID());
|
||||
play->entities.emplace(actor->GetObjectID());
|
||||
|
||||
Game::logger->Log("Scene", "Spawing npc %d", entity->GetObjectID());
|
||||
LOG("Spawing npc %d", entity->GetObjectID());
|
||||
}
|
||||
|
||||
if (player != nullptr) {
|
||||
@ -209,7 +213,7 @@ Scene& Cinema::Scene::LoadFromFile(std::string file) {
|
||||
|
||||
tinyxml2::XMLElement* root = doc.FirstChildElement("Scene");
|
||||
if (!root) {
|
||||
Game::logger->Log("Scene", "Failed to load scene from file: %s", file.c_str());
|
||||
LOG("Failed to load scene from file: %s", file.c_str());
|
||||
|
||||
m_Scenes.emplace(file, scene);
|
||||
|
||||
@ -271,7 +275,7 @@ Scene& Cinema::Scene::LoadFromFile(std::string file) {
|
||||
scene.AddNPC(npc, name, Recording::Recorder::LoadFromFile(act));
|
||||
}
|
||||
|
||||
Game::logger->Log("Scene", "Loaded scene from file: %s", file.c_str());
|
||||
LOG("Loaded scene from file: %s", file.c_str());
|
||||
|
||||
m_Scenes.emplace(file, scene);
|
||||
|
||||
|
BIN
dGame/dCinema/media/isolation.png
Normal file
BIN
dGame/dCinema/media/isolation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 MiB |
@ -122,13 +122,13 @@ void VanityUtilities::SpawnVanity() {
|
||||
|
||||
auto* scriptComponent = npcEntity->GetComponent<ScriptComponent>();
|
||||
|
||||
Game::logger->Log("VanityUtilities", "Script: %s", npc.m_Script.c_str());
|
||||
LOG_DEBUG("Script: %s", npc.m_Script.c_str());
|
||||
|
||||
if (scriptComponent && !npc.m_Script.empty()) {
|
||||
scriptComponent->SetScript(npc.m_Script);
|
||||
scriptComponent->SetSerialized(false);
|
||||
|
||||
Game::logger->Log("VanityUtilities", "Setting script to %s", npc.m_Script.c_str());
|
||||
LOG_DEBUG("Setting script to %s", npc.m_Script.c_str());
|
||||
|
||||
for (const auto& npc : npc.m_Flags) {
|
||||
npcEntity->SetVar<bool>(GeneralUtils::ASCIIToUTF16(npc.first), npc.second);
|
||||
@ -168,7 +168,7 @@ Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoin
|
||||
if (entity->GetVar<bool>(u"noGhosting")) entity->SetIsGhostingCandidate(false);
|
||||
|
||||
// Debug print
|
||||
Game::logger->Log("VanityUtilities", "Spawning NPC %s (%i) at %f, %f, %f", name.c_str(), lot, position.x, position.y, position.z);
|
||||
LOG_DEBUG("Spawning NPC %s (%i) at %f, %f, %f", name.c_str(), lot, position.x, position.y, position.z);
|
||||
|
||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||
|
||||
@ -188,10 +188,10 @@ Entity* VanityUtilities::SpawnNPC(LOT lot, const std::string& name, const NiPoin
|
||||
|
||||
if (scriptComponent == nullptr)
|
||||
{
|
||||
entity->AddComponent(eReplicaComponentType::SCRIPT, new ScriptComponent(entity, "", false));
|
||||
entity->AddComponent<ScriptComponent>("", false);
|
||||
}
|
||||
|
||||
Game::logger->Log("VanityUtilities", "NPC has script component? %s", (entity->GetComponent<ScriptComponent>() != nullptr) ? "true" : "false");
|
||||
LOG_DEBUG("NPC has script component? %s", (entity->GetComponent<ScriptComponent>() != nullptr) ? "true" : "false");
|
||||
|
||||
Game::entityManager->ConstructEntity(entity);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user