CommonLibSSE NG
ActorValueList.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/A/ActorValueInfo.h"
4 #include "RE/A/ActorValues.h"
5 
6 namespace RE
7 {
9  {
10  public:
11  [[nodiscard]] static ActorValueList* GetSingleton()
12  {
13  REL::Relocation<ActorValueList**> singleton{ RELOCATION_ID(514139, 400267) };
14  return *singleton;
15  }
16 
17  [[nodiscard]] ActorValueInfo* GetActorValue(ActorValue a_actorValue) const;
18  [[nodiscard]] ActorValue LookupActorValueByName(std::string_view a_enumName) const;
19 
20  // members
21  std::uint32_t unk00; // 00
22  std::uint32_t pad04; // 04
23  ActorValueInfo* actorValues[std::to_underlying(ActorValue::kTotal)]; // 08
24  };
25 }
26 
27 namespace std
28 {
29  [[nodiscard]] inline std::string to_string(RE::ActorValue a_actorValue)
30  {
31  const auto info = RE::ActorValueList::GetSingleton()->GetActorValue(a_actorValue);
32  return info ? info->enumName : "None";
33  }
34 }
35 
36 #ifdef __cpp_lib_format
37 template <class CharT>
38 struct std::formatter<RE::ActorValue, CharT> : formatter<std::string_view, CharT>
39 {
40  template <class FormatContext>
41  auto format(RE::ActorValue a_actorValue, FormatContext& a_ctx) const
42  {
43  const auto info = RE::ActorValueList::GetSingleton()->GetActorValue(a_actorValue);
44  return formatter<std::string_view, CharT>::format(info ? info->enumName : "None", a_ctx);
45  }
46 };
47 #endif
48 
49 #ifdef FMT_VERSION
50 template <>
51 struct fmt::formatter<RE::ActorValue>
52 {
53  template <class ParseContext>
54  constexpr auto parse(ParseContext& a_ctx)
55  {
56  return a_ctx.begin();
57  }
58 
59  template <class FormatContext>
60  auto format(const RE::ActorValue& a_actorValue, FormatContext& a_ctx)
61  {
62  const auto info = RE::ActorValueList::GetSingleton()->GetActorValue(a_actorValue);
63  return fmt::format_to(a_ctx.out(), "{}", info ? info->enumName : "None");
64  }
65 };
66 #endif
#define RELOCATION_ID(a_se, a_ae)
Definition: PCH.h:724
Definition: Relocation.h:204
Definition: ActorValueInfo.h:19
const char * enumName
Definition: ActorValueInfo.h:54
Definition: ActorValueList.h:9
ActorValue LookupActorValueByName(std::string_view a_enumName) const
std::uint32_t unk00
Definition: ActorValueList.h:21
ActorValueInfo * GetActorValue(ActorValue a_actorValue) const
static ActorValueList * GetSingleton()
Definition: ActorValueList.h:11
ActorValueInfo * actorValues[std::to_underlying(ActorValue::kTotal)]
Definition: ActorValueList.h:23
std::uint32_t pad04
Definition: ActorValueList.h:22
Definition: AbsorbEffect.h:6
ActorValue
Definition: ActorValues.h:6
string(const CharT(&)[N]) -> string< CharT, N - 1 >
Definition: ActorValueList.h:28
std::string to_string(RE::ActorValue a_actorValue)
Definition: ActorValueList.h:29