Skip to content

Commit

Permalink
Plugins/Lua: Add remove_all_motion_controller_states
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 31, 2024
1 parent 0655ee0 commit 94f140f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/uevr/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SOFTWARE.
#define UEVR_OUT

#define UEVR_PLUGIN_VERSION_MAJOR 2
#define UEVR_PLUGIN_VERSION_MINOR 33
#define UEVR_PLUGIN_VERSION_MINOR 34
#define UEVR_PLUGIN_VERSION_PATCH 0

#define UEVR_RENDERER_D3D11 0
Expand Down Expand Up @@ -377,6 +377,7 @@ typedef struct {
void (*set_disabled)(bool disabled);

void (*remove_motion_controller_state)(UEVR_UObjectHandle object);
void (*remove_all_motion_controller_states)();
} UEVR_UObjectHookFunctions;

typedef struct {
Expand Down
5 changes: 5 additions & 0 deletions include/uevr/API.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,11 @@ class API {
fn(obj->to_handle());
}

static void remove_all_motion_controller_states() {
static const auto fn = initialize()->remove_all_motion_controller_states;
fn();
}

struct MotionControllerState {
static consteval std::string_view internal_name() {
return "MotionControllerState";
Expand Down
7 changes: 6 additions & 1 deletion src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,10 @@ namespace uobjecthook {
UObjectHook::get()->remove_motion_controller_state(obj);
}

void remove_all_motion_controller_states() {
UObjectHook::get()->remove_all_motion_controller_states();
}

bool disabled() {
return UObjectHook::get()->is_disabled();
}
Expand Down Expand Up @@ -833,7 +837,8 @@ UEVR_UObjectHookFunctions g_uobjecthook_functions {
&g_mc_functions,
uevr::uobjecthook::disabled,
uevr::uobjecthook::set_disabled,
uevr::uobjecthook::remove_motion_controller_state
uevr::uobjecthook::remove_motion_controller_state,
uevr::uobjecthook::remove_all_motion_controller_states
};

#define FFIELDCLASS(x) ((sdk::FFieldClass*)x)
Expand Down
5 changes: 5 additions & 0 deletions src/mods/UObjectHook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ class UObjectHook : public Mod {
m_motion_controller_attached_components.erase(component);
}

void remove_all_motion_controller_states() {
std::unique_lock _{m_mutex};
m_motion_controller_attached_components.clear();
}

private:
struct StatePath;
struct PersistentState;
Expand Down

0 comments on commit 94f140f

Please sign in to comment.