forked from libxse/commonlibf4
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPowerUtils.h
More file actions
81 lines (72 loc) · 2.25 KB
/
PowerUtils.h
File metadata and controls
81 lines (72 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once
#include "RE/B/BSCRC32.h"
#include "RE/B/BSTArray.h"
#include "RE/B/BSTHashMap.h"
namespace RE
{
namespace PowerUtils
{
class GridConnection
{
public:
~GridConnection() noexcept {} // NOLINT(modernize-use-equals-default)
// members
std::uint32_t connection{ 0 }; // 0 - the powered object
std::uint32_t connector{ 0 }; // 4 - how the object is connected
};
static_assert(sizeof(GridConnection) == 0x8);
class GridSaveLoadData
{
public:
// members
std::uint32_t node{ 0 }; // 0
GridConnection connection; // 4
};
static_assert(sizeof(GridSaveLoadData) == 0xC);
class PowerGrid
{
public:
// members
BSTHashMap<std::uint32_t, BSTSet<GridConnection>*> adjacencyMap; // 00 - maps powered objects to the objects they connect to
BSTArray<GridSaveLoadData> loadGameData; // 30
std::uint32_t loadElement{ 0 }; // 48
BSTArray<std::uint32_t> currentlyPowered; // 50
float capacity{ 0.0 }; // 68
float load{ 0.0 }; // 6C
};
static_assert(sizeof(PowerGrid) == 0x70);
class TraverseConnectionsOptions
{
public:
// members
std::uint32_t ignoreMode; // 00
bool wiredOnly; // 04
bool inputsOnly; // 05
};
static_assert(sizeof(TraverseConnectionsOptions) == 0x8);
bool ItemIsPowerConnection(const TESObjectREFR* refr)
{
using func_t = decltype(&PowerUtils::ItemIsPowerConnection);
static REL::Relocation<func_t> func{ ID::PowerUtils::ItemIsPowerConnection };
return func(refr);
}
bool ItemIsPowerReceiver(const TESObjectREFR* refr)
{
using func_t = decltype(&PowerUtils::ItemIsPowerReceiver);
static REL::Relocation<func_t> func{ ID::PowerUtils::ItemIsPowerReceiver };
return func(refr);
}
}
template <>
struct BSCRC32<PowerUtils::GridConnection>
{
public:
[[nodiscard]] std::uint32_t operator()(const PowerUtils::GridConnection& a_connection) const noexcept
{
return detail::GenerateCRC32(
std::span(
reinterpret_cast<const std::uint8_t*>(std::addressof(a_connection)),
sizeof(PowerUtils::GridConnection)));
}
};
}