mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-10 17:38:08 +00:00
feat: script debug info
This commit is contained in:
@@ -5,16 +5,18 @@
|
|||||||
|
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "ScriptComponent.h"
|
#include "ScriptComponent.h"
|
||||||
|
#include "GameMessages.h"
|
||||||
|
#include "Amf3.h"
|
||||||
|
|
||||||
|
ScriptComponent::ScriptComponent(Entity* parent, const std::string& scriptName, bool serialized, bool client) : Component(parent) {
|
||||||
|
using namespace GameMessages;
|
||||||
|
|
||||||
ScriptComponent::ScriptComponent(Entity* parent, std::string scriptName, bool serialized, bool client) : Component(parent) {
|
|
||||||
m_Serialized = serialized;
|
m_Serialized = serialized;
|
||||||
m_Client = client;
|
m_Client = client;
|
||||||
|
m_ScriptName = scriptName;
|
||||||
|
|
||||||
SetScript(scriptName);
|
SetScript(scriptName);
|
||||||
}
|
RegisterMsg<GetObjectReportInfo>(this, &ScriptComponent::OnGetObjectReportInfo);
|
||||||
|
|
||||||
ScriptComponent::~ScriptComponent() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
void ScriptComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||||
@@ -50,3 +52,16 @@ void ScriptComponent::SetScript(const std::string& scriptName) {
|
|||||||
// and they may also be used by other script components so DON'T delete them.
|
// and they may also be used by other script components so DON'T delete them.
|
||||||
m_Script = CppScripts::GetScript(m_Parent, scriptName);
|
m_Script = CppScripts::GetScript(m_Parent, scriptName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptComponent::OnGetObjectReportInfo(GameMessages::GameMsg& msg) {
|
||||||
|
auto& infoMsg = static_cast<GameMessages::GetObjectReportInfo&>(msg);
|
||||||
|
|
||||||
|
auto& scriptInfo = infoMsg.info->PushDebug("Script");
|
||||||
|
scriptInfo.PushDebug<AMFStringValue>("Script Name") = m_ScriptName.empty() ? "None" : m_ScriptName;
|
||||||
|
auto& networkSettings = scriptInfo.PushDebug("Network Settings");
|
||||||
|
for (const auto* const setting : m_Parent->GetNetworkSettings()) {
|
||||||
|
networkSettings.PushDebug<AMFStringValue>(GeneralUtils::UTF16ToWTF8(setting->GetKey())) = setting->GetValueAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@@ -21,8 +21,7 @@ class ScriptComponent final : public Component {
|
|||||||
public:
|
public:
|
||||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
|
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPT;
|
||||||
|
|
||||||
ScriptComponent(Entity* parent, std::string scriptName, bool serialized, bool client = false);
|
ScriptComponent(Entity* parent, const std::string& scriptName, bool serialized, bool client = false);
|
||||||
~ScriptComponent() override;
|
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||||
|
|
||||||
@@ -43,6 +42,8 @@ public:
|
|||||||
* @param scriptName the name of the script to find
|
* @param scriptName the name of the script to find
|
||||||
*/
|
*/
|
||||||
void SetScript(const std::string& scriptName);
|
void SetScript(const std::string& scriptName);
|
||||||
|
|
||||||
|
bool OnGetObjectReportInfo(GameMessages::GameMsg& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -60,6 +61,8 @@ private:
|
|||||||
* Whether or not this script is a client script
|
* Whether or not this script is a client script
|
||||||
*/
|
*/
|
||||||
bool m_Client;
|
bool m_Client;
|
||||||
|
|
||||||
|
std::string m_ScriptName;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCRIPTCOMPONENT_H
|
#endif // SCRIPTCOMPONENT_H
|
||||||
|
Reference in New Issue
Block a user