Skip to content

Commit

Permalink
Add vehicle lights callback
Browse files Browse the repository at this point in the history
  • Loading branch information
psiberx committed Aug 18, 2024
1 parent 4bc6306 commit 1bf1dd2
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion scripts/Callback/Events/VehicleLightControlEvent.reds
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
public native class VehicleLightControlEvent extends EntityLifecycleEvent {
public native func IsEnabled() -> Bool
public native func GetLightType() -> vehicleELightType
public native func IsLightType(lightType: vehicleELightType) -> Bool
}
6 changes: 3 additions & 3 deletions src/App/Callback/Controllers/VehicleLightControlHook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class VehicleLightControlHook
, public Core::HookingAgent
{
public:
constexpr static auto EventName = Red::CName("Vehicle/ToggleLights");
constexpr static auto EventName = Red::CName("Vehicle/ToggleAuxLights");

Core::Map<Red::CName, Red::CName> GetEvents() override
{
Expand All @@ -23,12 +23,12 @@ class VehicleLightControlHook
protected:
bool OnActivateHook() override
{
return IsHooked<Raw::VehicleController::ToggleLights>() || HookAfter<Raw::VehicleController::ToggleLights>(&OnToggleLights);
return IsHooked<Raw::VehicleController::ToggleAuxLights>() || HookAfter<Raw::VehicleController::ToggleAuxLights>(&OnToggleLights);
}

bool OnDeactivateHook() override
{
return !IsHooked<Raw::VehicleController::ToggleLights>() || Unhook<Raw::VehicleController::ToggleLights>();
return !IsHooked<Raw::VehicleController::ToggleAuxLights>() || Unhook<Raw::VehicleController::ToggleAuxLights>();
}

inline static void OnToggleLights(Red::vehicleController* aController, bool aEnable, Red::vehicleELightType aLightType)
Expand Down
1 change: 0 additions & 1 deletion src/App/Callback/Events/VehicleLightControlEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ RTTI_DEFINE_CLASS(App::VehicleLightControlEvent, {
RTTI_PARENT(App::EntityLifecycleEvent);
RTTI_METHOD(IsLightType);
RTTI_GETTER(enabled);
RTTI_GETTER(lightType);
});
2 changes: 1 addition & 1 deletion src/Red/Addresses/Library.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ constexpr uint32_t ResourceSerializer_OnResourceReady = 1147149338;
constexpr uint32_t TagSystem_AssignTag = 1239092911;
constexpr uint32_t TagSystem_UnassignTag = 1875775378;

constexpr uint32_t VehicleController_ToggleLights = 3642563117;
constexpr uint32_t VehicleController_ToggleAuxLights = 1883248814;

constexpr uint32_t VehicleSystem_ToggleGarageVehicle = 3027836941;

Expand Down
4 changes: 2 additions & 2 deletions src/Red/VehicleController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Raw::VehicleController
{
constexpr auto ToggleLights = Core::RawFunc<
/* addr = */ Red::AddressLib::VehicleController_ToggleLights,
constexpr auto ToggleAuxLights = Core::RawFunc<
/* addr = */ Red::AddressLib::VehicleController_ToggleAuxLights,
/* type = */ void (*)(Red::vehicleController* aController, bool aEnable, Red::vehicleELightType aLightType)>();
}
1 change: 1 addition & 0 deletions src/pch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
#include <RED4ext/Scripting/Natives/Generated/red/TagSystem.hpp>
#include <RED4ext/Scripting/Natives/Generated/vehicle/BaseObject.hpp>
#include <RED4ext/Scripting/Natives/Generated/vehicle/Controller.hpp>
#include <RED4ext/Scripting/Natives/Generated/vehicle/ELightMode.hpp>
#include <RED4ext/Scripting/Natives/Generated/vehicle/ELightType.hpp>
#include <RED4ext/Scripting/Natives/Generated/vehicle/GarageVehicleID.hpp>
#include <RED4ext/Scripting/Natives/Generated/work/WorkEntryId.hpp>
Expand Down

0 comments on commit 1bf1dd2

Please sign in to comment.