mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 05:57:20 +00:00
More scene metadata
* Added the ability to specify a change to play * Added the ability to specify if a scene can play multiple times to the same player
This commit is contained in:
parent
cdc9dda3c4
commit
9954e20eac
@ -29,8 +29,6 @@ void Cinema::Play::SetupCheckForAudience() {
|
||||
void Cinema::Play::CheckForAudience() {
|
||||
auto* player = Game::entityManager->GetEntity(this->player);
|
||||
|
||||
LOG("Checking for audience");
|
||||
|
||||
if (player == nullptr) {
|
||||
CleanUp();
|
||||
|
||||
|
@ -59,6 +59,8 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
||||
// Check if the record is a fork
|
||||
auto* forkRecord = dynamic_cast<ForkRecord*>(record);
|
||||
|
||||
float delay = record->m_Delay;
|
||||
|
||||
if (forkRecord) {
|
||||
if (variables == nullptr) {
|
||||
// Skip the fork
|
||||
@ -217,7 +219,7 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
||||
auto* visibilityRecord = dynamic_cast<VisibilityRecord*>(record);
|
||||
|
||||
if (visibilityRecord) {
|
||||
if (visibilityRecord->visible) {
|
||||
if (!visibilityRecord->visible) {
|
||||
ServerPreconditions::AddExcludeFor(actor->GetObjectID(), variables->player);
|
||||
} else {
|
||||
ServerPreconditions::RemoveExcludeFor(actor->GetObjectID(), variables->player);
|
||||
@ -262,7 +264,7 @@ void Recorder::ActingDispatch(Entity* actor, size_t index, Play* variables) {
|
||||
return;
|
||||
}
|
||||
|
||||
actor->AddCallbackTimer(record->m_Delay, [this, actor, index, variables]() {
|
||||
actor->AddCallbackTimer(delay, [this, actor, index, variables]() {
|
||||
ActingDispatch(actor, index + 1, variables);
|
||||
});
|
||||
|
||||
|
@ -56,6 +56,8 @@ void Cinema::Scene::Conclude(Entity* player) {
|
||||
// Remove the player from the audience
|
||||
m_Audience.erase(player->GetObjectID());
|
||||
m_HasBeenOutside.erase(player->GetObjectID());
|
||||
|
||||
m_VisitedPlayers.emplace(player->GetObjectID());
|
||||
}
|
||||
|
||||
bool Cinema::Scene::IsPlayerInBounds(Entity* player) const {
|
||||
@ -118,6 +120,14 @@ void Cinema::Scene::AutoLoadScenesForZone(LWOMAPID zone) {
|
||||
|
||||
auto& scene = LoadFromFile(file);
|
||||
|
||||
if (scene.m_ChanceToPlay != 1.0f) {
|
||||
const auto chance = GeneralUtils::GenerateRandomNumber<float>(0.0f, 1.0f);
|
||||
|
||||
if (chance > scene.m_ChanceToPlay) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
scene.Rehearse();
|
||||
}
|
||||
}
|
||||
@ -148,6 +158,10 @@ void Cinema::Scene::CheckForShowings() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!m_Repeatable && m_VisitedPlayers.find(player->GetObjectID()) != m_VisitedPlayers.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CheckTicket(player);
|
||||
}
|
||||
|
||||
@ -307,6 +321,14 @@ Scene& Cinema::Scene::LoadFromFile(std::string file) {
|
||||
scene.m_ShowingDistance = scene.m_Bounds * 2.0f;
|
||||
}
|
||||
|
||||
if (root->Attribute("chanceToPlay")) {
|
||||
scene.m_ChanceToPlay = root->FloatAttribute("chanceToPlay");
|
||||
}
|
||||
|
||||
if (root->Attribute("repeatable")) {
|
||||
scene.m_Repeatable = root->BoolAttribute("repeatable");
|
||||
}
|
||||
|
||||
// Load accept and complete mission
|
||||
if (root->Attribute("acceptMission")) {
|
||||
scene.m_AcceptMission = root->IntAttribute("acceptMission");
|
||||
|
@ -101,6 +101,8 @@ private:
|
||||
NiPoint3 m_Center;
|
||||
float m_Bounds = 0.0f;
|
||||
float m_ShowingDistance = 0.0f;
|
||||
float m_ChanceToPlay = 1.0f;
|
||||
bool m_Repeatable = true;
|
||||
|
||||
std::vector<std::pair<PreconditionExpression, bool>> m_Preconditions;
|
||||
|
||||
@ -110,6 +112,8 @@ private:
|
||||
std::unordered_set<LWOOBJID> m_Audience;
|
||||
std::unordered_set<LWOOBJID> m_HasBeenOutside;
|
||||
|
||||
std::unordered_set<LWOOBJID> m_VisitedPlayers;
|
||||
|
||||
static std::unordered_map<std::string, Scene> m_Scenes;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user