Skip to content

Commit 098de6e

Browse files
committed
Add function to execute quest node
1 parent 27d5082 commit 098de6e

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

scripts/Quest/QuestsSystem.reds

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@addMethod(QuestsSystem)
2+
public native func ExecuteNode(node: ref<questNodeDefinition>)

src/App/Quest/QuestsSystemEx.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#pragma once
2+
3+
#include "Red/QuestsSystem.hpp"
4+
5+
namespace App
6+
{
7+
struct QuestsSystemEx : Red::questQuestsSystem
8+
{
9+
void ExecuteNode(const Red::Handle<Red::questNodeDefinition>& aNode)
10+
{
11+
std::unique_lock _(Raw::QuestsSystem::Mutex::Ref(this));
12+
13+
auto& rootPhaseInstance = Raw::QuestsSystem::RootPhase::Ref(this);
14+
15+
Red::QuestContext context{};
16+
Raw::QuestsSystem::CreateContext(this, &context, 1, 0, -1, -1);
17+
18+
context.phaseStack.PushBack(rootPhaseInstance);
19+
20+
Red::QuestNodeSocket inputSocket;
21+
Red::DynArray<Red::QuestNodeSocket> outputSockets;
22+
23+
Raw::QuestPhaseInstance::ExecuteNode(rootPhaseInstance, aNode, context, inputSocket, outputSockets);
24+
25+
context.phaseStack.Clear();
26+
}
27+
};
28+
}
29+
30+
RTTI_EXPAND_CLASS(Red::questQuestsSystem, App::QuestsSystemEx, {
31+
RTTI_METHOD(ExecuteNode);
32+
});

src/pch.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
#include <RED4ext/Scripting/Natives/Generated/quest/PhaseInstance.hpp>
180180
#include <RED4ext/Scripting/Natives/Generated/quest/PhaseNodeDefinition.hpp>
181181
#include <RED4ext/Scripting/Natives/Generated/quest/QuestPhaseResource.hpp>
182+
#include <RED4ext/Scripting/Natives/Generated/quest/QuestsSystem.hpp>
182183
#include <RED4ext/Scripting/Natives/Generated/quest/SetVar_NodeType.hpp>
183184
#include <RED4ext/Scripting/Natives/Generated/quest/ShowWorldNode_NodeType.hpp>
184185
#include <RED4ext/Scripting/Natives/Generated/quest/SocketDefinition.hpp>

src/rtti.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "App/Player/VehicleSystemEx.hpp"
4242
#include "App/Player/WardrobeSystemEx.hpp"
4343
#include "App/Quest/GraphSocketDefinitionEx.hpp"
44+
#include "App/Quest/QuestsSystemEx.hpp"
4445
#include "App/Reflection/Reflection.hpp"
4546
#include "App/Scripting/IScriptableEx.hpp"
4647
#include "App/Scripting/ISerializableEx.hpp"

0 commit comments

Comments
 (0)