add NsInstance, NsGameBase and NsCoreBase

This commit is contained in:
Adam Jensen 2024-05-02 20:19:51 +01:00
parent 0966caea49
commit f25ca637aa
6 changed files with 59 additions and 6 deletions

View File

@ -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) {}
};

View File

@ -0,0 +1,7 @@
#pragma once
#include "cdcNative/core/NsCoreBase.h"
class NsGameBase : public NsCoreBase {
public:
NsGameBase(cdc::ScriptType *ty) : NsCoreBase(ty) {}
};

View File

@ -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) {}
};

View File

@ -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;

View File

@ -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<cdc::ScriptObject> m_scriptObject; // 58
cdc::GCPtr<NsInstance> m_scriptObject; // 58
dtp::Model **modelsOverride = nullptr; // 5C
uint32_t numOverrideModels = 0; // 60
cdc::SceneEntity *sceneEntity = nullptr; // 64

View File

@ -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());