Skip to content

Commit

Permalink
Actor Utils (#25)
Browse files Browse the repository at this point in the history
* feat: Class `ActorUtils` declared.
  • Loading branch information
FalloutCascadia authored Dec 10, 2024
1 parent 0a2d0e4 commit 375e350
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 1 deletion.
1 change: 1 addition & 0 deletions CommonLibF4/cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(SOURCES
include/RE/Bethesda/AITimeStamp.h
include/RE/Bethesda/ActiveEffect.h
include/RE/Bethesda/Actor.h
include/RE/Bethesda/ActorUtils.h
include/RE/Bethesda/ActorValueInfo.h
include/RE/Bethesda/Archive2.h
include/RE/Bethesda/Atomic.h
Expand Down
60 changes: 60 additions & 0 deletions CommonLibF4/include/RE/Bethesda/ActorUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#pragma once

#include "RE/Bethesda/TESBoundObjects.h"

namespace RE
{
namespace ActorUtils
{
class __declspec(novtable) ArmorRatingVisitorBase
{
public:
static constexpr auto RTTI{ RTTI::ActorUtils__ArmorRatingVisitorBase };
static constexpr auto VTABLE{ VTABLE::ActorUtils__ArmorRatingVisitorBase };

ArmorRatingVisitorBase()
{
stl::emplace_vtable(this);
}

virtual bool ShouldProcess(TESBoundObject*) { return 1; }; // 00
virtual void PostPRocess(TESBoundObject*){}; // 01

Actor* actor; // 08
float rating; // 10
float armorPerks; // 14
bool checkEquipped; // 18

void ctor(const Actor* a_actor, bool a_checkEquipped)
{
using func_t = decltype(&ArmorRatingVisitorBase::ctor);
REL::Relocation<func_t> func{ REL::ID(2227205) };
return func(this, a_actor, a_checkEquipped);
}

ArmorRatingVisitorBase(const Actor* a_actor, bool a_checkEquipped)
{
ctor(a_actor, a_checkEquipped);
}

std::int64_t operator()(const BGSInventoryItem* a_item, std::uint32_t a_stackID)
{
using func_t = decltype(&ArmorRatingVisitorBase::operator());
REL::Relocation<func_t> func{ REL::ID(2227206) };
return func(this, a_item, a_stackID);
}
};
static_assert(offsetof(ArmorRatingVisitorBase, rating) == 0x10);
static_assert(sizeof(ArmorRatingVisitorBase) == 0x20);

class __declspec(novtable) ArmorRatingVisitor :
public ArmorRatingVisitorBase // 00
{
static constexpr auto RTTI{ RTTI::ActorUtils__ArmorRatingVisitor };
static constexpr auto VTABLE{ VTABLE::ActorUtils__ArmorRatingVisitor };

BSScrapArray<TESBoundObject*> foundArmor; // 20
};
static_assert(sizeof(ArmorRatingVisitor) == 0x40);
}
}
15 changes: 15 additions & 0 deletions CommonLibF4/include/RE/Bethesda/PipboyInventoryData.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "RE/Bethesda/BSTHashMap.h"
#include "RE/Bethesda/BSTList.h"
#include "RE/Bethesda/Events.h"
#include "RE/Bethesda/PipboyArray.h"
#include "RE/Bethesda/PipboyDataGroup.h"

namespace RE
Expand Down Expand Up @@ -86,6 +87,20 @@ namespace RE
return func(this, itemTypeID);
}

void PopulateItemCardInfo(const BGSInventoryItem* a_inventoryItem, const BGSInventoryItem::Stack* a_stack, PipboyObject* a_data)
{
using func_t = decltype(&PipboyInventoryData::PopulateItemCardInfo);
static REL::Relocation<func_t> func{ REL::ID(2225266) };
return func(this, a_inventoryItem, a_stack, a_data);
}

void AddItemCardInfoEntry(const BSFixedStringCS* a_string, float a_value, PipboyArray* a_itemCardSection)
{
using func_t = decltype(&PipboyInventoryData::AddItemCardInfoEntry);
static REL::Relocation<func_t> func{ REL::ID(2225267) };
return func(this, a_string, a_value, a_itemCardSection);
}

// members
PipboyObject* inventoryObject; // E8
BSTHashMap<std::uint32_t, PipboyInventoryData::ItemEntry> itemEntries; // F0
Expand Down
2 changes: 1 addition & 1 deletion CommonLibF4/include/RE/Bethesda/PipboyPrimitiveValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace RE
// members
std::uint32_t value; // 18
};
static_assert(sizeof(PipboyPrimitiveValue<bool>) == 0x20);
static_assert(sizeof(PipboyPrimitiveValue<std::uint32_t>) == 0x20);

template <>
class __declspec(novtable) PipboyPrimitiveValue<bool> : public PipboyValue
Expand Down
14 changes: 14 additions & 0 deletions CommonLibF4/include/RE/Bethesda/PipboyValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ namespace RE
virtual void SerializeChanges(BSBinarySerializer& a_serializer, bool a_fullSerialize) override; // 03
virtual SERIALIZATION_DATA_TYPE GetType() override; // 04

template <typename T>
T GetMember(const BSFixedString& a_name)
{
const auto it = memberMap.find(a_name);
return (it != memberMap.end()) ? static_cast<T>(it->second) : nullptr;
}

void AddMember(const BSFixedString* a_name, PipboyValue* a_member)
{
using func_t = decltype(&PipboyObject::AddMember);
static REL::Relocation<func_t> func{ REL::ID(2225699) };
return func(this, a_name, a_member);
}

// members
BSTHashMap<BSFixedString, PipboyValue*> memberMap; // 18
BSTSet<std::uint32_t> addedMemberIDs; // 48
Expand Down
1 change: 1 addition & 0 deletions CommonLibF4/include/RE/Fallout.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "RE/Bethesda/AITimeStamp.h"
#include "RE/Bethesda/ActiveEffect.h"
#include "RE/Bethesda/Actor.h"
#include "RE/Bethesda/ActorUtils.h"
#include "RE/Bethesda/ActorValueInfo.h"
#include "RE/Bethesda/Archive2.h"
#include "RE/Bethesda/Atomic.h"
Expand Down

0 comments on commit 375e350

Please sign in to comment.