#include <BNM/UserSettings/GlobalSettings.hpp>
#include <BNM/Class.hpp>
#include <BNM/Field.hpp>
#include <BNM/Method.hpp>
#include <BNM/Property.hpp>
#include <BNM/Defaults.hpp>
#include <BNM/Operators.hpp>
#include <BNM/BasicMonoStructures.hpp>
using namespace BNM::Structures;
void **PlayerConfigPtr = nullptr;
old_PlayerStart(instance);
BNM_LOG_WARN("Player's Start called twice?");
}
Player = instance;
ObjectName[instance];
PlayerConfigPtr = PlayerConfig[instance].GetPointer();
auto playerName = *PlayerConfigPtr->*ConfigName;
BNM_LOG_INFO("Player's object name: \"%s\"; Player's name: \"%s\"",
playerObjectName->
str().c_str(),
playerName->str().c_str());
auto objectToStringResult = ObjectToString[instance]();
BNM_LOG_INFO("objectToStringResult: \"%s\"", objectToStringResult->str().c_str());
}
old_PlayerUpdate(instance);
if (PlayerConfigPtr == nullptr) return;
ConfigHealth[*PlayerConfigPtr] = 99999;
ConfigCoins[*PlayerConfigPtr] = 99999;
}
void OnLoaded_Example_01() {
ObjectClass =
Class(BNM_OBFUSCATE(
"UnityEngine"), BNM_OBFUSCATE(
"Object"));
ObjectToString = ObjectClass.GetMethod(BNM_OBFUSCATE("ToString"), 0);
ObjectName = ObjectClass.GetProperty(BNM_OBFUSCATE("name"));
auto PlayerClass =
Class(BNM_OBFUSCATE(
""), BNM_OBFUSCATE(
"Player"));
auto PlayerConfigClass = PlayerClass.GetInnerClass(BNM_OBFUSCATE("Config"));
auto Update = PlayerClass.GetMethod(BNM_OBFUSCATE("Update"));
auto Start = PlayerClass.GetMethod(BNM_OBFUSCATE("Start"));
PlayerConfig = PlayerClass.GetField(BNM_OBFUSCATE("m_Config"));
ConfigName = PlayerConfigClass.GetField(BNM_OBFUSCATE("Name"));
ConfigHealth = PlayerConfigClass.GetField(BNM_OBFUSCATE("Health"));
ConfigCoins = PlayerConfigClass.GetField(BNM_OBFUSCATE("Coins"));
InvokeHook(Update, PlayerUpdate, old_PlayerUpdate);
}
constexpr DefaultTypeRef Get()
Method that helps to get il2cpp class type from C++ and BNM types.
Definition Defaults.hpp:132
Namespace that holds operators which may help with methods, events, fields and properties.
Definition Operators.hpp:13
Main BNM namespace.
Definition BasicMonoStructures.hpp:16
bool InvokeHook(const BNM::MethodBase &targetMethod, T_NEW newMet, T_OLD &oldMet)
Hook method by changing MethodInfo.
Definition MethodBase.hpp:172
Structures::Mono::String * CreateMonoString(const std::string_view &str)
Macro function for creating C# strings (BNM::Structures::Mono::String).
Class for working with il2cpp classes.
Definition Class.hpp:29
BNM::MethodBase GetMethod(const std::string_view &name, int parameters=-1) const
Get method by name and parameters count.
Typed class for working with il2cpp fields.
Definition Field.hpp:20
Typed class for working with il2cpp methods.
Definition Method.hpp:20
Typed class for working with il2cpp properties.
Definition Property.hpp:20
String type implementation.
Definition BasicMonoStructures.hpp:95
std::string str()
Convert Mono::String to std::string.
UnityEngine.Object implementation.
Definition UnityStructures.hpp:33
bool Alive() const __attribute__((always_inline))
Alias for IsValid()
Definition UnityStructures.hpp:50