diff --git a/cdcNative/core/NsCoreBase.h b/cdcNative/core/NsCoreBase.h new file mode 100644 index 0000000..3dc03c0 --- /dev/null +++ b/cdcNative/core/NsCoreBase.h @@ -0,0 +1,10 @@ +#pragma once +#include "cdcScript/ScriptObject.h" + +class ObjectThread; + +class NsCoreBase : public cdc::ScriptObject { + ObjectThread *m_thread = nullptr; +public: + NsCoreBase(cdc::ScriptType *ty) : cdc::ScriptObject(ty) {} +}; diff --git a/cdcNative/game/NsGameBase.h b/cdcNative/game/NsGameBase.h new file mode 100644 index 0000000..0bd288f --- /dev/null +++ b/cdcNative/game/NsGameBase.h @@ -0,0 +1,7 @@ +#pragma once +#include "cdcNative/core/NsCoreBase.h" + +class NsGameBase : public NsCoreBase { +public: + NsGameBase(cdc::ScriptType *ty) : NsCoreBase(ty) {} +}; diff --git a/cdcNative/game/NsInstance.h b/cdcNative/game/NsInstance.h new file mode 100644 index 0000000..26fa412 --- /dev/null +++ b/cdcNative/game/NsInstance.h @@ -0,0 +1,11 @@ +#pragma once +#include "cdcNative/game/NsGameBase.h" + +class Instance; + +class NsInstance : public NsGameBase { +public: + Instance *m_instance = nullptr; // 20 + + NsInstance(cdc::ScriptType *ty) : NsGameBase(ty) {} +}; diff --git a/cdcWorld/Instance.cpp b/cdcWorld/Instance.cpp index 3fb5a20..b7f9b33 100644 --- a/cdcWorld/Instance.cpp +++ b/cdcWorld/Instance.cpp @@ -1,8 +1,8 @@ #include "cdcAnim/AnimComponentV2.h" +#include "cdcNative/game/NsInstance.h" #include "cdcObjects/ObjectManager.h" #include "cdcResource/ResolveSection.h" #include "cdcResource/ScriptSection.h" -#include "cdcScript/ScriptObject.h" #include "cdcScript/ScriptType.h" #include "cdcSys/Assert.h" #include "Instance.h" @@ -78,9 +78,9 @@ bool Instance::ScriptAndUberInitCommon(uint32_t scriptTypeId, /*GCPtr<...>*/NsIn // HACK auto *scriptSection = (cdc::ScriptSection*)cdc::g_resolveSections[8]; if (auto *scriptType = scriptSection->FindScript(scriptTypeId)) { - auto *scriptObject = /*(NsInstance*)*/scriptType->CreateObject(); + auto *scriptObject = (NsInstance*)scriptType->CreateObject(); m_scriptObject = scriptObject; - // scriptObject->m_instance = this; + scriptObject->m_instance = this; return true; } return false; diff --git a/cdcWorld/Instance.h b/cdcWorld/Instance.h index 8def1ec..5bee1aa 100644 --- a/cdcWorld/Instance.h +++ b/cdcWorld/Instance.h @@ -11,7 +11,6 @@ namespace cdc { class AnimComponentV2; class IDrawable; class SceneEntity; - class ScriptObject; struct Object; } @@ -41,7 +40,7 @@ public: void *objectData; // 4C - cdc::GCPtr m_scriptObject; // 58 + cdc::GCPtr m_scriptObject; // 58 dtp::Model **modelsOverride = nullptr; // 5C uint32_t numOverrideModels = 0; // 60 cdc::SceneEntity *sceneEntity = nullptr; // 64 diff --git a/eventually_generated/game/script/_NativeScripts.cpp b/eventually_generated/game/script/_NativeScripts.cpp index 348e25e..635c93a 100644 --- a/eventually_generated/game/script/_NativeScripts.cpp +++ b/eventually_generated/game/script/_NativeScripts.cpp @@ -1,3 +1,4 @@ +#include "cdcNative/game/NsInstance.h" #include "cdcScript/cdcScript.h" #include "cdcScript/NativeScriptType.h" #include "cdcScript/ScriptManager.h" @@ -8,6 +9,31 @@ using namespace cdc; +class NsInstance_ScriptType : public NativeScriptType { +public: + NsInstance_ScriptType(); + bool InitType(ScriptType*) override; + ScriptObject *CreateObject(ScriptType *type) override; +}; + +NsInstance_ScriptType::NsInstance_ScriptType() : // line 17918 + NativeScriptType("game/script/game/game", "instance") +{ +} + +bool NsInstance_ScriptType::InitType(ScriptType *type) { // line 18205 + + NativeScriptType::InitType(type); + // TODO + + return true; +} + +ScriptObject *NsInstance_ScriptType::CreateObject(ScriptType *type) { // line 18448 + // TODO: create NeInstance too + return new NsInstance(type); +} + int32_t _NsScaleformMovieController::s_virtual = 0; class NsScaleformMovieController_ScriptType : public NativeScriptType { @@ -171,7 +197,7 @@ void Init_NativeScripts() { // line 44434 // scriptManager->RegisterNativeScriptType(new NtHostedAnimStateGraph_ScriptType()); // scriptManager->RegisterNativeScriptType(new NtHudGroup_ScriptType()); // scriptManager->RegisterNativeScriptType(new NtInputMap_ScriptType()); - // scriptManager->RegisterNativeScriptType(new NsInstance_ScriptType()); + scriptManager->RegisterNativeScriptType(new NsInstance_ScriptType()); // scriptManager->RegisterNativeScriptType(new NtInstanceRef_ScriptType()); // scriptManager->RegisterNativeScriptType(new NtInstanceStatus_ScriptType()); // scriptManager->RegisterNativeScriptType(new NtInventoryItem_ScriptType());