Skip to content

Commit

Permalink
feat: complete 'TESObjectREFR` inheritance and related classes (#36)
Browse files Browse the repository at this point in the history
- Switched to using `BSTEvent` class definitions from CommonLib, this
gets rid of the unreferenced parameter error
- Added some getters and couple of functions
- `IsInSpaceship` was incorrectly defined, it is now
`GetAttachedSpaceship` (note the return parameter should be a
`NiSmartPointer` which isn't included as of yet)
  • Loading branch information
powerof3 authored Sep 13, 2023
1 parent 06eb499 commit 12fc0a5
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 61 deletions.
4 changes: 3 additions & 1 deletion CommonLibSF/include/RE/A/ActorValueOwner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ namespace RE
public:
SF_RTTI_VTABLE(ActorValueOwner);

// add
virtual ~ActorValueOwner();

// add
virtual float GetActorValue(const ActorValueInfo& a_info);
virtual float GetPermanentActorValue(const ActorValueInfo& a_info);
virtual float GetBaseActorValue(const ActorValueInfo& a_info);
Expand Down
40 changes: 24 additions & 16 deletions CommonLibSF/include/RE/B/BSTEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,45 @@

namespace RE
{
namespace detail
enum class BSEventNotifyControl : std::uint32_t
{
kContinue,
kStop
};
using EventResult = BSEventNotifyControl;

namespace BSTEventDetail
{
class SinkBase
{
public:
virtual ~SinkBase() = 0;
};
}

enum class BSEventNotifyControl : std::int32_t
{
kContinue,
kStop
};
using EventResult = BSEventNotifyControl;
class SourceBase
{
public:
virtual ~SourceBase() = 0;
};
}

template <class>
class BSTEventSource;

// 08
template <typename Event>
class BSTEventSink : public detail::SinkBase
template <class Event>
class BSTEventSink : public BSTEventDetail::SinkBase
{
public:
virtual ~BSTEventSink(){};
virtual BSEventNotifyControl ProcessEvent(const Event& a_event, [[maybe_unused]] BSTEventSource<Event>* a_source) { return EventResult::kContinue; }; // pure
~BSTEventSink() override = default; // 00

// add
virtual BSEventNotifyControl ProcessEvent(const Event& a_event, BSTEventSource<Event>* a_source) = 0; // 01
};

template <typename T>
class BSTEventSource
template <class Event>
class BSTEventSource : public BSTEventDetail::SourceBase
{
public:
// Sinks go here
~BSTEventSource() override = default; // 00
};
}
36 changes: 36 additions & 0 deletions CommonLibSF/include/RE/I/IAnimationGraphManagerHolder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

namespace RE
{
class IAnimationGraphManagerHolder
{
public:
virtual ~IAnimationGraphManagerHolder(); // 00

// add
virtual void Unk_01(); // 01
virtual void Unk_02(); // 02
virtual void Unk_03(); // 03
virtual void Unk_04(); // 04
virtual void Unk_05(); // 05
virtual void Unk_06(); // 06
virtual void Unk_07(); // 07
virtual void Unk_08(); // 08
virtual void Unk_09(); // 09
virtual void Unk_0A(); // 0A
virtual void Unk_0B(); // 0B
virtual void Unk_0C(); // 0C
virtual void Unk_0D(); // 0D
virtual void Unk_0E(); // 0E
virtual void Unk_0F(); // 0F
virtual void Unk_10(); // 10
virtual void Unk_11(); // 11
virtual void Unk_12(); // 12
virtual void Unk_13(); // 13
virtual void Unk_14(); // 14
virtual void Unk_15(); // 15
virtual void Unk_16(); // 16
virtual void Unk_17(); // 17
virtual void Unk_18(); // 18
};
}
11 changes: 11 additions & 0 deletions CommonLibSF/include/RE/I/IMovementInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

namespace RE
{
struct IMovementInterface
{
public:
virtual ~IMovementInterface(); // 00
};
static_assert(sizeof(IMovementInterface) == 0x8);
}
16 changes: 16 additions & 0 deletions CommonLibSF/include/RE/I/IPostAnimationChannelUpdateFunctor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

namespace RE
{
class IPostAnimationChannelUpdateFunctor
{
public:
SF_RTTI_VTABLE(IPostAnimationChannelUpdateFunctor);

virtual ~IPostAnimationChannelUpdateFunctor(); // 00

// add
virtual void DoPostAnimationChannelUpdate() = 0; // 01
};
static_assert(sizeof(IPostAnimationChannelUpdateFunctor) == 0x8);
}
4 changes: 2 additions & 2 deletions CommonLibSF/include/RE/N/NiPoint3.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ namespace RE
};
static_assert(sizeof(NiPoint3) == 0xC);

class alignas(0x10) NiPoint3Aligned :
class alignas(0x10) NiPoint3A :
public NiPoint3
{
public:
std::array<std::byte, 0x4> padding; // 0xC
};
static_assert(sizeof(NiPoint3Aligned) == 0x10);
static_assert(sizeof(NiPoint3A) == 0x10);
}
16 changes: 16 additions & 0 deletions CommonLibSF/include/RE/T/TESHandleForm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "RE/T/TESForm.h"

namespace RE
{
class TESHandleForm :
public TESForm
{
public:
SF_RTTI_VTABLE(TESHandleForm);

~TESHandleForm() override; // 00
};
static_assert(sizeof(TESHandleForm) == 0x38);
}
110 changes: 68 additions & 42 deletions CommonLibSF/include/RE/T/TESObjectREFR.h
Original file line number Diff line number Diff line change
@@ -1,34 +1,75 @@
#pragma once

#include "RE/B/BGSLocation.h"
#include "RE/B/BGSScene.h"
#include "RE/A/ActorValueOwner.h"
#include "RE/B/BSTEvent.h"
#include "RE/I/IAnimationGraphManagerHolder.h"
#include "RE/I/IKeywordFormBase.h"
#include "RE/I/IMovementInterface.h"
#include "RE/I/IPostAnimationChannelUpdateFunctor.h"
#include "RE/N/NiPoint3.h"
#include "RE/T/TESForm.h"
#include "RE/T/TESObjectCELL.h"
#include "RE/T/TESRace.h"
#include "RE/T/TESTopicInfo.h"
#include "RE/T/TESHandleForm.h"

namespace RE
{
class BGSLocation;
class BGSScene;
class BSAnimationGraphEvent;
class BSTransformDeltaEvent;
class TESBoundObject;
class TESObjectCELL;
class TESRace;
class TESTopicInfo;

namespace ActorValueEvents
{
struct ActorValueChangedEvent;
}

namespace BGSInventoryListEvent
{
struct Event;
}

class IMovementProcessMessageInterface :
public IMovementInterface // 00
{
public:
~IMovementProcessMessageInterface() override;

// add
virtual void Unk_01(); // 01
};
static_assert(sizeof(IMovementProcessMessageInterface) == 0x8);

struct OBJ_REFR
{
public:
// members
NiPoint3Aligned angle; // 00
NiPoint3Aligned location; // 10
TESForm* objectReference; // 20 - TESBoundObject
NiPoint3A angle; // 00
NiPoint3A location; // 10
TESBoundObject* objectReference; // 20
};
static_assert(sizeof(OBJ_REFR) == 0x30);

class TESObjectREFR : public TESForm
class TESObjectREFR :
public TESHandleForm, // 00
public BSTEventSink<BSTransformDeltaEvent>, // 38
public IMovementProcessMessageInterface, // 40
public IPostAnimationChannelUpdateFunctor, // 48
public BSTEventSink<BSAnimationGraphEvent>, // 50
public BSTEventSink<BGSInventoryListEvent::Event>, // 58
public IAnimationGraphManagerHolder, // 60
public IKeywordFormBase, // 68
public ActorValueOwner, // 70
public BSTEventSource<ActorValueEvents::ActorValueChangedEvent> // 78
{
public:
SF_RTTI_VTABLE(TESObjectREFR);
SF_FORMTYPE(REFR);

~TESObjectREFR() override; // 00

// add
// override (TESForm)
virtual void Predestroy(); // 062
virtual bool Unk_63(); // 063 - { return extraList.HasExtraData(14);};
virtual bool GetEditorLocation(NiPoint3& a_originalLocation, NiPoint3& a_originalAngle, TESForm*& a_locationFormOut); // 064 - new
Expand Down Expand Up @@ -173,7 +214,7 @@ namespace RE
virtual void Unk_EF(); // 0EF
virtual void Unk_F0(); // 0F0
virtual void Unk_F1(); // 0F1
virtual void Unk_F2(); // 0F2
virtual const char* GetDisplayFullName(); // 0F2
virtual void Unk_F3(); // 0F3
virtual void Unk_F4(); // 0F4
virtual void Unk_F5(); // 0F5
Expand Down Expand Up @@ -236,38 +277,23 @@ namespace RE
virtual void Unk_12E(); // 12E
virtual void Unk_12F(); // 12F

// the following should be inherited when decoded properly
void* BSTransformDeltaEvent; // 38
void* IMovementProcessMessageInterface; // 40
void* IPostAnimationChannelUpdateFunctor; // 48
void* BSAnimationGraphEvent; // 50
void* BGSInventoryListEvent; // 58
void* IAnimationGraphManagerHolder; // 60
void* IKeywordFormBase; // 68
void* ActorValueOwner; // 70
void* ActorValueChangedEvent; // 78

//
[[nodiscard]] bool IsInSpaceship()
{
using func_t = decltype(&TESObjectREFR::IsInSpaceship);
REL::Relocation<func_t> func{ REL::Offset(0x02B3A8D4) };
return func(this);
}
[[nodiscard]] constexpr NiPoint3A GetAngle() const { return data.angle; }
[[nodiscard]] constexpr float GetAngleX() const { return data.angle.x; }
[[nodiscard]] constexpr float GetAngleY() const { return data.angle.y; }
[[nodiscard]] constexpr float GetAngleZ() const { return data.angle.z; }

[[nodiscard]] bool IsInSpace()
{
using func_t = decltype(&TESObjectREFR::IsInSpace);
REL::Relocation<func_t> func{ REL::Offset(0x01A0E208) };
return func(this);
}
// NiPointer<TESObjectREFR>
[[nodiscard]] TESObjectREFR* GetAttachedSpaceship();

[[nodiscard]] bool HasKeyword(BGSKeyword* a_keyword)
{
using func_t = decltype(&TESObjectREFR::HasKeyword);
REL::Relocation<func_t> func{ REL::Offset(0x0139EE28) };
return func(this, a_keyword);
}
[[nodiscard]] TESBoundObject* GetBaseObject() { return data.objectReference; }
[[nodiscard]] const TESBoundObject* GetBaseObject() const { return data.objectReference; };
[[nodiscard]] constexpr NiPoint3A GetPosition() const noexcept { return data.location; }
[[nodiscard]] constexpr float GetPositionX() const noexcept { return data.location.x; }
[[nodiscard]] constexpr float GetPositionY() const noexcept { return data.location.y; }
[[nodiscard]] constexpr float GetPositionZ() const noexcept { return data.location.z; }
[[nodiscard]] bool HasKeyword(BGSKeyword* a_keyword);
[[nodiscard]] bool IsCrimeToActivate();
[[nodiscard]] bool IsInSpace();

// members
std::uint32_t unk80; // 80
Expand Down
5 changes: 5 additions & 0 deletions CommonLibSF/src/RE/I/IAnimationGraphManagerHolder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "RE/I/IAnimationGraphManagerHolder.h"
namespace RE
{
}

5 changes: 5 additions & 0 deletions CommonLibSF/src/RE/I/IMovementInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "RE/I/IMovementInterface.h"
namespace RE
{
}

5 changes: 5 additions & 0 deletions CommonLibSF/src/RE/I/IPostAnimationChannelUpdateFunctor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "RE/I/IPostAnimationChannelUpdateFunctor.h"
namespace RE
{
}

5 changes: 5 additions & 0 deletions CommonLibSF/src/RE/T/TESHandleForm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "RE/T/TESHandleForm.h"
namespace RE
{
}

31 changes: 31 additions & 0 deletions CommonLibSF/src/RE/T/TESObjectREFR.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
#include "RE/T/TESObjectREFR.h"

namespace RE
{
TESObjectREFR* TESObjectREFR::GetAttachedSpaceship()
{
using func_t = decltype(&TESObjectREFR::GetAttachedSpaceship);
REL::Relocation<func_t> func{ REL::Offset(0x02B3A8D4) };
return func(this);
}

bool TESObjectREFR::HasKeyword(BGSKeyword* a_keyword)
{
using func_t = decltype(&TESObjectREFR::HasKeyword);
REL::Relocation<func_t> func{ REL::Offset(0x0139EE28) };
return func(this, a_keyword);
}

bool TESObjectREFR::IsCrimeToActivate()
{
using func_t = decltype(&TESObjectREFR::IsCrimeToActivate);
REL::Relocation<func_t> func{ REL::Offset(0x01A0DCA0) };
return func(this);
}

bool TESObjectREFR::IsInSpace()
{
using func_t = decltype(&TESObjectREFR::IsInSpace);
REL::Relocation<func_t> func{ REL::Offset(0x01A0E208) };
return func(this);
}
}

0 comments on commit 12fc0a5

Please sign in to comment.