mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 05:57:20 +00:00
Minor refactor
This commit is contained in:
parent
9954e20eac
commit
54060f7f40
@ -46,15 +46,15 @@ void Recorder::Act(Entity* actor, Play* variables) {
|
|||||||
LOG("Acting %d steps", m_Records.size());
|
LOG("Acting %d steps", m_Records.size());
|
||||||
|
|
||||||
// Loop through all records
|
// Loop through all records
|
||||||
ActingDispatch(actor, 0, variables);
|
ActingDispatch(actor, m_Records, 0, variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
void Recorder::ActingDispatch(Entity* actor, const std::vector<Record*>& records, size_t index, Play* variables) {
|
||||||
if (index >= m_Records.size()) {
|
if (index >= records.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* record = m_Records[index];
|
auto* record = records[index];
|
||||||
|
|
||||||
// Check if the record is a fork
|
// Check if the record is a fork
|
||||||
auto* forkRecord = dynamic_cast<ForkRecord*>(record);
|
auto* forkRecord = dynamic_cast<ForkRecord*>(record);
|
||||||
@ -64,7 +64,7 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
|||||||
if (forkRecord) {
|
if (forkRecord) {
|
||||||
if (variables == nullptr) {
|
if (variables == nullptr) {
|
||||||
// Skip the fork
|
// Skip the fork
|
||||||
ActingDispatch(actor, index + 1, variables);
|
ActingDispatch(actor, records, index + 1, variables);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,11 +86,11 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
|||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
// Find the success record
|
// Find the success record
|
||||||
for (auto i = 0; i < m_Records.size(); ++i) {
|
for (auto i = 0; i < records.size(); ++i) {
|
||||||
auto* record = m_Records[i];
|
auto* record = records[i];
|
||||||
|
|
||||||
if (record->m_Name == forkRecord->success) {
|
if (record->m_Name == forkRecord->success) {
|
||||||
ActingDispatch(actor, i, variables);
|
ActingDispatch(actor, records, i, variables);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,11 +101,11 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Find the failure record
|
// Find the failure record
|
||||||
for (auto i = 0; i < m_Records.size(); ++i) {
|
for (auto i = 0; i < records.size(); ++i) {
|
||||||
auto* record = m_Records[i];
|
auto* record = records[i];
|
||||||
|
|
||||||
if (record->m_Name == forkRecord->failure) {
|
if (record->m_Name == forkRecord->failure) {
|
||||||
ActingDispatch(actor, i, variables);
|
ActingDispatch(actor, records, i, variables);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,11 +121,11 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
|||||||
|
|
||||||
if (jumpRecord) {
|
if (jumpRecord) {
|
||||||
// Find the jump record
|
// Find the jump record
|
||||||
for (auto i = 0; i < m_Records.size(); ++i) {
|
for (auto i = 0; i < records.size(); ++i) {
|
||||||
auto* record = m_Records[i];
|
auto* record = records[i];
|
||||||
|
|
||||||
if (record->m_Name == jumpRecord->label) {
|
if (record->m_Name == jumpRecord->label) {
|
||||||
ActingDispatch(actor, i, variables);
|
ActingDispatch(actor, records, i, variables);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,13 +141,13 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
|||||||
if (setVariableRecord) {
|
if (setVariableRecord) {
|
||||||
if (variables == nullptr) {
|
if (variables == nullptr) {
|
||||||
// Skip the set variable
|
// Skip the set variable
|
||||||
ActingDispatch(actor, index + 1, variables);
|
ActingDispatch(actor, records, index + 1, variables);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
variables->variables[setVariableRecord->variable] = setVariableRecord->value;
|
variables->variables[setVariableRecord->variable] = setVariableRecord->value;
|
||||||
|
|
||||||
ActingDispatch(actor, index + 1, variables);
|
ActingDispatch(actor, records,index + 1, variables);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,38 +157,38 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
|||||||
if (barrierRecord) {
|
if (barrierRecord) {
|
||||||
if (variables == nullptr) {
|
if (variables == nullptr) {
|
||||||
// Skip the barrier
|
// Skip the barrier
|
||||||
ActingDispatch(actor, index + 1, variables);
|
ActingDispatch(actor, records, index + 1, variables);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto actionTaken = std::make_shared<bool>(false);
|
auto actionTaken = std::make_shared<bool>(false);
|
||||||
|
|
||||||
variables->SetupBarrier(barrierRecord->signal, [this, actor, index, variables, actionTaken]() {
|
variables->SetupBarrier(barrierRecord->signal, [actor, records, index, variables, actionTaken]() {
|
||||||
if (*actionTaken) {
|
if (*actionTaken) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*actionTaken = true;
|
*actionTaken = true;
|
||||||
|
|
||||||
ActingDispatch(actor, index + 1, variables);
|
ActingDispatch(actor, records, index + 1, variables);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (barrierRecord->timeout <= 0.0001f) {
|
if (barrierRecord->timeout <= 0.0001f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::entityManager->GetZoneControlEntity()->AddCallbackTimer(barrierRecord->timeout, [this, barrierRecord, actor, index, variables, actionTaken]() {
|
Game::entityManager->GetZoneControlEntity()->AddCallbackTimer(barrierRecord->timeout, [barrierRecord, records, actor, index, variables, actionTaken]() {
|
||||||
if (*actionTaken) {
|
if (*actionTaken) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*actionTaken = true;
|
*actionTaken = true;
|
||||||
|
|
||||||
for (auto i = 0; i < m_Records.size(); ++i) {
|
for (auto i = 0; i < records.size(); ++i) {
|
||||||
auto* record = m_Records[i];
|
auto* record = records[i];
|
||||||
|
|
||||||
if (record->m_Name == barrierRecord->timeoutLabel) {
|
if (record->m_Name == barrierRecord->timeoutLabel) {
|
||||||
ActingDispatch(actor, i, variables);
|
ActingDispatch(actor, records, i, variables);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,30 +232,30 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
|||||||
if (playerProximityRecord) {
|
if (playerProximityRecord) {
|
||||||
if (variables == nullptr) {
|
if (variables == nullptr) {
|
||||||
// Skip the player proximity record
|
// Skip the player proximity record
|
||||||
ActingDispatch(actor, index + 1, variables);
|
ActingDispatch(actor, records, index + 1, variables);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto actionTaken = std::make_shared<bool>(false);
|
auto actionTaken = std::make_shared<bool>(false);
|
||||||
|
|
||||||
PlayerProximityDispatch(actor, index, variables, actionTaken);
|
PlayerProximityDispatch(actor, records, index, variables, actionTaken);
|
||||||
|
|
||||||
if (playerProximityRecord->timeout <= 0.0f) {
|
if (playerProximityRecord->timeout <= 0.0f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::entityManager->GetZoneControlEntity()->AddCallbackTimer(playerProximityRecord->timeout, [this, playerProximityRecord, actor, index, variables, actionTaken]() {
|
Game::entityManager->GetZoneControlEntity()->AddCallbackTimer(playerProximityRecord->timeout, [playerProximityRecord, actor, records, index, variables, actionTaken]() {
|
||||||
if (*actionTaken) {
|
if (*actionTaken) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*actionTaken = true;
|
*actionTaken = true;
|
||||||
|
|
||||||
for (auto i = 0; i < m_Records.size(); ++i) {
|
for (auto i = 0; i < records.size(); ++i) {
|
||||||
auto* record = m_Records[i];
|
auto* record = records[i];
|
||||||
|
|
||||||
if (record->m_Name == playerProximityRecord->timeoutLabel) {
|
if (record->m_Name == playerProximityRecord->timeoutLabel) {
|
||||||
ActingDispatch(actor, i, variables);
|
ActingDispatch(actor, records, i, variables);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,15 +264,24 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
actor->AddCallbackTimer(delay, [this, actor, index, variables]() {
|
// Check if the record is a coroutine record
|
||||||
ActingDispatch(actor, index + 1, variables);
|
auto* coroutineRecord = dynamic_cast<CoroutineRecord*>(record);
|
||||||
|
|
||||||
|
if (coroutineRecord) {
|
||||||
|
actor->AddCallbackTimer(delay, [actor, coroutineRecord, index, variables]() {
|
||||||
|
ActingDispatch(actor, coroutineRecord->records, 0, variables);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
actor->AddCallbackTimer(delay, [actor, records, index, variables]() {
|
||||||
|
ActingDispatch(actor, records, index + 1, variables);
|
||||||
});
|
});
|
||||||
|
|
||||||
record->Act(actor);
|
record->Act(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cinema::Recording::Recorder::PlayerProximityDispatch(Entity* actor, size_t index, Play* variables, std::shared_ptr<bool> actionTaken) {
|
void Cinema::Recording::Recorder::PlayerProximityDispatch(Entity* actor, const std::vector<Record*>& records, size_t index, Play* variables, std::shared_ptr<bool> actionTaken) {
|
||||||
auto* record = dynamic_cast<PlayerProximityRecord*>(m_Records[index]);
|
auto* record = dynamic_cast<PlayerProximityRecord*>(records[index]);
|
||||||
auto* player = Game::entityManager->GetEntity(variables->player);
|
auto* player = Game::entityManager->GetEntity(variables->player);
|
||||||
|
|
||||||
if (player == nullptr || record == nullptr) {
|
if (player == nullptr || record == nullptr) {
|
||||||
@ -291,16 +300,78 @@ void Cinema::Recording::Recorder::PlayerProximityDispatch(Entity* actor, size_t
|
|||||||
|
|
||||||
*actionTaken = true;
|
*actionTaken = true;
|
||||||
|
|
||||||
ActingDispatch(actor, index + 1, variables);
|
ActingDispatch(actor, records, index + 1, variables);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::entityManager->GetZoneControlEntity()->AddCallbackTimer(1.0f, [this, actor, index, variables, actionTaken]() {
|
Game::entityManager->GetZoneControlEntity()->AddCallbackTimer(1.0f, [actor, records, index, variables, actionTaken]() {
|
||||||
PlayerProximityDispatch(actor, index, variables, actionTaken);
|
PlayerProximityDispatch(actor, records, index, variables, actionTaken);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cinema::Recording::Recorder::LoadRecords(tinyxml2::XMLElement* root, std::vector<Record*>& records) {
|
||||||
|
|
||||||
|
for (auto* element = root->FirstChildElement(); element; element = element->NextSiblingElement()) {
|
||||||
|
std::string name = element->Name();
|
||||||
|
|
||||||
|
if (!element->Attribute("t")) {
|
||||||
|
element->SetAttribute("t", 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the name does not end with Record, add it
|
||||||
|
if (name.find("Record") == std::string::npos) {
|
||||||
|
name += "Record";
|
||||||
|
}
|
||||||
|
|
||||||
|
Record* record = nullptr;
|
||||||
|
|
||||||
|
if (name == "MovementRecord") {
|
||||||
|
record = new MovementRecord();
|
||||||
|
} else if (name == "SpeakRecord") {
|
||||||
|
record = new SpeakRecord();
|
||||||
|
} else if (name == "AnimationRecord") {
|
||||||
|
record = new AnimationRecord();
|
||||||
|
} else if (name == "EquipRecord") {
|
||||||
|
record = new EquipRecord();
|
||||||
|
} else if (name == "UnequipRecord") {
|
||||||
|
record = new UnequipRecord();
|
||||||
|
} else if (name == "ClearEquippedRecord") {
|
||||||
|
record = new ClearEquippedRecord();
|
||||||
|
} else if (name == "ForkRecord") {
|
||||||
|
record = new ForkRecord();
|
||||||
|
} else if (name == "WaitRecord") {
|
||||||
|
record = new WaitRecord();
|
||||||
|
} else if (name == "JumpRecord") {
|
||||||
|
record = new JumpRecord();
|
||||||
|
} else if (name == "SetVariableRecord") {
|
||||||
|
record = new SetVariableRecord();
|
||||||
|
} else if (name == "BarrierRecord") {
|
||||||
|
record = new BarrierRecord();
|
||||||
|
} else if (name == "SignalRecord") {
|
||||||
|
record = new SignalRecord();
|
||||||
|
} else if (name == "ConcludeRecord") {
|
||||||
|
record = new ConcludeRecord();
|
||||||
|
} else if (name == "PlayerProximityRecord") {
|
||||||
|
record = new PlayerProximityRecord();
|
||||||
|
} else if (name == "VisibilityRecord") {
|
||||||
|
record = new VisibilityRecord();
|
||||||
|
} else if (name == "PlayEffectRecord") {
|
||||||
|
record = new PlayEffectRecord();
|
||||||
|
} else if (name == "CoroutineRecord") {
|
||||||
|
record = new CoroutineRecord();
|
||||||
|
}
|
||||||
|
|
||||||
|
record->Deserialize(element);
|
||||||
|
records.push_back(record);
|
||||||
|
|
||||||
|
if (element->Attribute("name")) {
|
||||||
|
records.back()->m_Name = element->Attribute("name");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Entity* Recorder::ActFor(Entity* actorTemplate, Entity* player, Play* variables) {
|
Entity* Recorder::ActFor(Entity* actorTemplate, Entity* player, Play* variables) {
|
||||||
EntityInfo info;
|
EntityInfo info;
|
||||||
info.lot = actorTemplate->GetLOT();
|
info.lot = actorTemplate->GetLOT();
|
||||||
@ -682,83 +753,7 @@ Recorder* Recorder::LoadFromFile(const std::string& filename) {
|
|||||||
|
|
||||||
Recorder* recorder = new Recorder();
|
Recorder* recorder = new Recorder();
|
||||||
|
|
||||||
for (auto* element = root->FirstChildElement(); element; element = element->NextSiblingElement()) {
|
LoadRecords(root, recorder->m_Records);
|
||||||
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);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "SpeakRecord") {
|
|
||||||
SpeakRecord* record = new SpeakRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "AnimationRecord") {
|
|
||||||
AnimationRecord* record = new AnimationRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "EquipRecord") {
|
|
||||||
EquipRecord* record = new EquipRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "UnequipRecord") {
|
|
||||||
UnequipRecord* record = new UnequipRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "ClearEquippedRecord") {
|
|
||||||
ClearEquippedRecord* record = new ClearEquippedRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "ForkRecord") {
|
|
||||||
ForkRecord* record = new ForkRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "WaitRecord") {
|
|
||||||
WaitRecord* record = new WaitRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "JumpRecord") {
|
|
||||||
JumpRecord* record = new JumpRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "SetVariableRecord") {
|
|
||||||
SetVariableRecord* record = new SetVariableRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "BarrierRecord") {
|
|
||||||
BarrierRecord* record = new BarrierRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "SignalRecord") {
|
|
||||||
SignalRecord* record = new SignalRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "ConcludeRecord") {
|
|
||||||
ConcludeRecord* record = new ConcludeRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "PlayerProximityRecord") {
|
|
||||||
PlayerProximityRecord* record = new PlayerProximityRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "VisibilityRecord") {
|
|
||||||
VisibilityRecord* record = new VisibilityRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
} else if (name == "PlayEffectRecord") {
|
|
||||||
PlayEffectRecord* record = new PlayEffectRecord();
|
|
||||||
record->Deserialize(element);
|
|
||||||
recorder->m_Records.push_back(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (element->Attribute("name")) {
|
|
||||||
recorder->m_Records.back()->m_Name = element->Attribute("name");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return recorder;
|
return recorder;
|
||||||
}
|
}
|
||||||
@ -1066,3 +1061,14 @@ void Cinema::Recording::PlayEffectRecord::Deserialize(tinyxml2::XMLElement* elem
|
|||||||
|
|
||||||
m_Delay = element->DoubleAttribute("t");
|
m_Delay = element->DoubleAttribute("t");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cinema::Recording::CoroutineRecord::Act(Entity* actor) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cinema::Recording::CoroutineRecord::Serialize(tinyxml2::XMLDocument& document, tinyxml2::XMLElement* parent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cinema::Recording::CoroutineRecord::Deserialize(tinyxml2::XMLElement* element) {
|
||||||
|
Recorder::LoadRecords(element, records);
|
||||||
|
}
|
||||||
|
@ -25,6 +25,54 @@ public:
|
|||||||
std::string m_Name;
|
std::string m_Name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Recorder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Recorder();
|
||||||
|
|
||||||
|
~Recorder();
|
||||||
|
|
||||||
|
void AddRecord(Record* record);
|
||||||
|
|
||||||
|
void Act(Entity* actor, Play* variables = nullptr);
|
||||||
|
|
||||||
|
Entity* ActFor(Entity* actorTemplate, Entity* player, Play* variables = nullptr);
|
||||||
|
|
||||||
|
void StopActingFor(Entity* actor, Entity* actorTemplate, LWOOBJID playerID);
|
||||||
|
|
||||||
|
bool IsRecording() const;
|
||||||
|
|
||||||
|
void SaveToFile(const std::string& filename);
|
||||||
|
|
||||||
|
float GetDuration() const;
|
||||||
|
|
||||||
|
static Recorder* LoadFromFile(const std::string& filename);
|
||||||
|
|
||||||
|
static void AddRecording(LWOOBJID actorID, Recorder* recorder);
|
||||||
|
|
||||||
|
static void StartRecording(LWOOBJID actorID);
|
||||||
|
|
||||||
|
static void StopRecording(LWOOBJID actorID);
|
||||||
|
|
||||||
|
static Recorder* GetRecorder(LWOOBJID actorID);
|
||||||
|
|
||||||
|
static void RegisterEffectForActor(LWOOBJID actorID, const int32_t& effectId);
|
||||||
|
|
||||||
|
static void LoadRecords(tinyxml2::XMLElement* root, std::vector<Record*>& records);
|
||||||
|
|
||||||
|
static void ActingDispatch(Entity* actor, const std::vector<Record*>& records, size_t index, Play* variables);
|
||||||
|
|
||||||
|
static void PlayerProximityDispatch(Entity* actor, const std::vector<Record*>& records, size_t index, Play* variables, std::shared_ptr<bool> actionTaken);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<Record*> m_Records;
|
||||||
|
|
||||||
|
bool m_IsRecording;
|
||||||
|
|
||||||
|
std::chrono::milliseconds m_StartTime;
|
||||||
|
|
||||||
|
std::chrono::milliseconds m_LastRecordTime;
|
||||||
|
};
|
||||||
|
|
||||||
class MovementRecord : public Record
|
class MovementRecord : public Record
|
||||||
{
|
{
|
||||||
@ -299,51 +347,19 @@ public:
|
|||||||
void Deserialize(tinyxml2::XMLElement* element) override;
|
void Deserialize(tinyxml2::XMLElement* element) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Recorder
|
class CoroutineRecord : public Record
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Recorder();
|
std::vector<Record*> records;
|
||||||
|
|
||||||
~Recorder();
|
CoroutineRecord() = default;
|
||||||
|
|
||||||
void AddRecord(Record* record);
|
void Act(Entity* actor) override;
|
||||||
|
|
||||||
void Act(Entity* actor, Play* variables = nullptr);
|
void Serialize(tinyxml2::XMLDocument& document, tinyxml2::XMLElement* parent) override;
|
||||||
|
|
||||||
Entity* ActFor(Entity* actorTemplate, Entity* player, Play* variables = nullptr);
|
void Deserialize(tinyxml2::XMLElement* element) override;
|
||||||
|
|
||||||
void StopActingFor(Entity* actor, Entity* actorTemplate, LWOOBJID playerID);
|
|
||||||
|
|
||||||
bool IsRecording() const;
|
|
||||||
|
|
||||||
void SaveToFile(const std::string& filename);
|
|
||||||
|
|
||||||
float GetDuration() const;
|
|
||||||
|
|
||||||
static Recorder* LoadFromFile(const std::string& filename);
|
|
||||||
|
|
||||||
static void AddRecording(LWOOBJID actorID, Recorder* recorder);
|
|
||||||
|
|
||||||
static void StartRecording(LWOOBJID actorID);
|
|
||||||
|
|
||||||
static void StopRecording(LWOOBJID actorID);
|
|
||||||
|
|
||||||
static Recorder* GetRecorder(LWOOBJID actorID);
|
|
||||||
|
|
||||||
static void RegisterEffectForActor(LWOOBJID actorID, const int32_t& effectId);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void ActingDispatch(Entity* actor, size_t index, Play* variables);
|
|
||||||
|
|
||||||
void PlayerProximityDispatch(Entity* actor, size_t index, Play* variables, std::shared_ptr<bool> actionTaken);
|
|
||||||
|
|
||||||
std::vector<Record*> m_Records;
|
|
||||||
|
|
||||||
bool m_IsRecording;
|
|
||||||
|
|
||||||
std::chrono::milliseconds m_StartTime;
|
|
||||||
|
|
||||||
std::chrono::milliseconds m_LastRecordTime;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user