diff --git a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/CoreUObject/UObject.cs b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/CoreUObject/UObject.cs
index 53f97af..abb56d4 100644
--- a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/CoreUObject/UObject.cs
+++ b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/CoreUObject/UObject.cs
@@ -684,6 +684,11 @@ internal virtual void SetupInputComponentInternal()
// This is eventually implemented in injected classes
}
+ internal virtual void UpdateRotationInternal(float DeltaTime)
+ {
+ // This is eventually implemented in injected classes
+ }
+
///
/// Looks for a given function name
///
diff --git a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/InjectedClasses/Engine/ActorComponent_Injected.cs b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/InjectedClasses/Engine/ActorComponent_Injected.cs
index 62d37aa..38ebe26 100644
--- a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/InjectedClasses/Engine/ActorComponent_Injected.cs
+++ b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/InjectedClasses/Engine/ActorComponent_Injected.cs
@@ -7,6 +7,12 @@ namespace UnrealEngine.Engine
{
public partial class UActorComponent : UObject
{
+ private CachedUObject worldCached;
+ public UWorld World
+ {
+ get { return worldCached.Update(Native_UActorComponent.GetWorld(Address)); }
+ }
+
static int PrimaryComponentTick_Offset;
///
/// Main tick function for the Actor
diff --git a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/InjectedClasses/Engine/PlayerController_Injected.cs b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/InjectedClasses/Engine/PlayerController_Injected.cs
index 3738f52..d495c59 100644
--- a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/InjectedClasses/Engine/PlayerController_Injected.cs
+++ b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/InjectedClasses/Engine/PlayerController_Injected.cs
@@ -7,12 +7,32 @@ namespace UnrealEngine.Engine
{
public partial class APlayerController : AController
{
+ public FRotator RotationInput
+ {
+ get
+ {
+ CheckDestroyed();
+ return Native_APlayerController.Get_RotationInput(this.Address);
+ }
+ set
+ {
+ CheckDestroyed();
+ Native_APlayerController.Set_RotationInput(this.Address, ref value);
+ }
+ }
+
private VTableHacks.CachedFunctionRedirect setupInputComponentRedirect;
internal override void SetupInputComponentInternal()
{
SetupInputComponent();
}
+ private VTableHacks.CachedFunctionRedirect updateRotationRedirect;
+ internal override void UpdateRotationInternal(float DeltaTime)
+ {
+ UpdateRotation(DeltaTime);
+ }
+
///
/// Allows the PlayerController to set up custom input bindings.
///
@@ -22,5 +42,16 @@ protected virtual void SetupInputComponent()
.Resolve(VTableHacks.PlayerControllerSetupInputComponent, this)
.Invoke(Address);
}
+
+ ///
+ /// Updates the rotation of player, based on ControlRotation after RotationInput has been applied.
+ /// This may then be modified by the PlayerCamera, and is passed to Pawn->FaceRotation().
+ ///
+ public virtual void UpdateRotation(float DeltaTime)
+ {
+ updateRotationRedirect
+ .Resolve(VTableHacks.PlayerControllerUpdateRotation, this)
+ .Invoke(Address, DeltaTime);
+ }
}
}
diff --git a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_APlayerController.cs b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_APlayerController.cs
new file mode 100644
index 0000000..8a6dd14
--- /dev/null
+++ b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_APlayerController.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+#pragma warning disable 649 // Field is never assigned
+
+namespace UnrealEngine.Runtime.Native
+{
+ public static class Native_APlayerController
+ {
+ public delegate FRotator Del_Get_RotationInput(IntPtr instance);
+ public delegate void Del_Set_RotationInput(IntPtr instance, ref FRotator RotationInput);
+
+ public static Del_Get_RotationInput Get_RotationInput;
+ public static Del_Set_RotationInput Set_RotationInput;
+ }
+}
diff --git a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_UActorComponent.cs b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_UActorComponent.cs
index 9c572d3..7f7a4bc 100644
--- a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_UActorComponent.cs
+++ b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_UActorComponent.cs
@@ -12,10 +12,12 @@ public static class Native_UActorComponent
public delegate void Del_RegisterComponent(IntPtr instance);
public delegate void Del_ReregisterComponent(IntPtr instance);
public delegate void Del_UnregisterComponent(IntPtr instance);
+ public delegate IntPtr Del_GetWorld(IntPtr instance);
public static Del_RegisterComponent RegisterComponent;
public static Del_ReregisterComponent ReregisterComponent;
public static Del_UnregisterComponent UnregisterComponent;
+ public static Del_GetWorld GetWorld;
}
}
diff --git a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_VTableHacks.cs b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_VTableHacks.cs
index 63c17ad..5900934 100644
--- a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_VTableHacks.cs
+++ b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/Native/Native_VTableHacks.cs
@@ -18,6 +18,7 @@ static class Native_VTableHacks
public delegate void Del_CallOriginal_ActorComponentBeginPlay(IntPtr originalFunc, IntPtr obj);
public delegate void Del_CallOriginal_ActorComponentEndPlay(IntPtr originalFunc, IntPtr obj, byte endPlayReason);
public delegate void Del_CallOriginal_PlayerControllerSetupInputComponent(IntPtr originalFunc, IntPtr obj);
+ public delegate void Del_CallOriginal_PlayerControllerUpdateRotation(IntPtr originalFunc, IntPtr obj, float deltaTime);
public static Del_Set_VTableCallback Set_VTableCallback;
public static Del_CallOriginal_GetLifetimeReplicatedProps CallOriginal_GetLifetimeReplicatedProps;
diff --git a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/VTableHacks.cs b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/VTableHacks.cs
index 8133868..b5a59e3 100644
--- a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/VTableHacks.cs
+++ b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/VTableHacks.cs
@@ -27,6 +27,7 @@ private static void AddVTableRedirects()
ActorComponentBeginPlay = AddVTableRedirect(actorComponentClass, "DummyActorComponentBeginPlay", new BeginPlayDel(OnActorComponentBeginPlay));
ActorComponentEndPlay = AddVTableRedirect(actorComponentClass, "DummyActorComponentEndPlay", new EndPlayDel(OnActorComponentEndPlay));
PlayerControllerSetupInputComponent = AddVTableRedirect(playerControllerClass, "DummyPlayerControllerSetupInputComponent", new PlayerControllerSetupInputComponentDel(OnPlayerControllerSetupInputComponent));
+ PlayerControllerUpdateRotation = AddVTableRedirect(playerControllerClass, "DummyPlayerControllerUpdateRotation", new PlayerControllerUpdateRotationDel(OnPlayerControllerUpdateRotation));
}
private static void LogCallbackException(string functionName, Exception e)
@@ -147,6 +148,23 @@ private static void OnPlayerControllerSetupInputComponent(IntPtr address)
}
}
+ public static FunctionRedirect PlayerControllerUpdateRotation { get; private set; }
+ delegate void PlayerControllerUpdateRotationDel(IntPtr address, float deltaTime);
+ [UnmanagedFunctionPointer(CallingConvention.ThisCall)]
+ public delegate void PlayerControllerUpdateRotationDel_ThisCall(IntPtr address, float deltaTime);
+ private static void OnPlayerControllerUpdateRotation(IntPtr address, float deltaTime)
+ {
+ try
+ {
+ UObject obj = GCHelper.Find(address);
+ obj.UpdateRotationInternal(deltaTime);
+ }
+ catch (Exception e)
+ {
+ LogCallbackException(nameof(OnPlayerControllerUpdateRotation), e);
+ }
+ }
+
////////////////////////////////////////////////////////////////////////////////////////
// Add vtable redirects above this line
////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/UnrealEngine.Runtime.csproj b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/UnrealEngine.Runtime.csproj
index cbbe8e6..026f39b 100644
--- a/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/UnrealEngine.Runtime.csproj
+++ b/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/UnrealEngine.Runtime.csproj
@@ -210,6 +210,7 @@
+
diff --git a/Source/USharp/Private/ExportedFunctions/Export_APlayerController.h b/Source/USharp/Private/ExportedFunctions/Export_APlayerController.h
new file mode 100644
index 0000000..b705e1a
--- /dev/null
+++ b/Source/USharp/Private/ExportedFunctions/Export_APlayerController.h
@@ -0,0 +1,15 @@
+CSEXPORT FRotator CSCONV Export_APlayerController_Get_RotationInput(APlayerController* instance)
+{
+ return instance->RotationInput;
+}
+
+CSEXPORT void CSCONV Export_APlayerController_Set_RotationInput(APlayerController* instance, const FRotator& RotationInput)
+{
+ instance->RotationInput = RotationInput;
+}
+
+CSEXPORT void CSCONV Export_APlayerController(RegisterFunc registerFunc)
+{
+ REGISTER_FUNC(Export_APlayerController_Get_RotationInput);
+ REGISTER_FUNC(Export_APlayerController_Set_RotationInput);
+}
\ No newline at end of file
diff --git a/Source/USharp/Private/ExportedFunctions/Export_UActorComponent.h b/Source/USharp/Private/ExportedFunctions/Export_UActorComponent.h
index 40bae67..954eea5 100644
--- a/Source/USharp/Private/ExportedFunctions/Export_UActorComponent.h
+++ b/Source/USharp/Private/ExportedFunctions/Export_UActorComponent.h
@@ -13,9 +13,15 @@ CSEXPORT void CSCONV Export_UActorComponent_UnregisterComponent(UActorComponent*
instance->UnregisterComponent();
}
+CSEXPORT UWorld* CSCONV Export_UActorComponent_GetWorld(UActorComponent* instance)
+{
+ return instance->GetWorld();
+}
+
CSEXPORT void CSCONV Export_UActorComponent(RegisterFunc registerFunc)
{
REGISTER_FUNC(Export_UActorComponent_RegisterComponent);
REGISTER_FUNC(Export_UActorComponent_ReregisterComponent);
REGISTER_FUNC(Export_UActorComponent_UnregisterComponent);
+ REGISTER_FUNC(Export_UActorComponent_GetWorld);
}
\ No newline at end of file
diff --git a/Source/USharp/Private/ExportedFunctions/ExportedFunctions.h b/Source/USharp/Private/ExportedFunctions/ExportedFunctions.h
index f6dbff7..45b84b3 100644
--- a/Source/USharp/Private/ExportedFunctions/ExportedFunctions.h
+++ b/Source/USharp/Private/ExportedFunctions/ExportedFunctions.h
@@ -49,6 +49,7 @@
#include "Export_UGameInstance.h"
#include "Export_ULevel.h"
#include "Export_AActor.h"
+#include "Export_APlayerController.h"
#include "Export_UActorComponent.h"
#include "Export_USceneComponent.h"
#include "Export_UMaterialInstanceDynamic.h"
@@ -207,6 +208,7 @@ CSEXPORT void CSCONV RegisterFunctions(RegisterFunc registerFunc)
Export_UGameInstance(registerFunc);
Export_ULevel(registerFunc);
Export_AActor(registerFunc);
+ Export_APlayerController(registerFunc);
Export_UActorComponent(registerFunc);
Export_USceneComponent(registerFunc);
Export_UMaterialInstanceDynamic(registerFunc);
diff --git a/Source/USharp/Private/ExportedFunctions/Internal/Export_VTableHacks.h b/Source/USharp/Private/ExportedFunctions/Internal/Export_VTableHacks.h
index 549070c..5aeac85 100644
--- a/Source/USharp/Private/ExportedFunctions/Internal/Export_VTableHacks.h
+++ b/Source/USharp/Private/ExportedFunctions/Internal/Export_VTableHacks.h
@@ -7,6 +7,7 @@ ActorEndPlayCallbackSig ActorEndPlayCallback = nullptr;
ActorComponentBeginPlayCallbackSig ActorComponentBeginPlayCallback = nullptr;
ActorComponentEndPlayCallbackSig ActorComponentEndPlayCallback = nullptr;
PlayerControllerSetupInputComponentCallbackSig PlayerControllerSetupInputComponentCallback = nullptr;
+PlayerControllerUpdateRotationCallbackSig PlayerControllerUpdateRotationCallback = nullptr;
TMap DummyNames;
CSEXPORT void CSCONV Export_VTableHacks_Set_VTableCallback(const FString& DummyName, void* Callback)
@@ -21,6 +22,7 @@ CSEXPORT void CSCONV Export_VTableHacks_Set_VTableCallback(const FString& DummyN
DummyNames.Add(TEXT("DummyActorComponentBeginPlay"), (void**)&ActorComponentBeginPlayCallback);
DummyNames.Add(TEXT("DummyActorComponentEndPlay"), (void**)&ActorComponentEndPlayCallback);
DummyNames.Add(TEXT("DummyPlayerControllerSetupInputComponent"), (void**)&PlayerControllerSetupInputComponentCallback);
+ DummyNames.Add(TEXT("DummyPlayerControllerUpdateRotation"), (void**)&PlayerControllerUpdateRotationCallback);
}
void*** Element = DummyNames.Find(DummyName);
@@ -73,6 +75,12 @@ CSEXPORT void CSCONV Export_VTableHacks_CallOriginal_PlayerControllerSetupInputC
(Obj->*Func)();
}
+typedef void (UObject::*PlayerControllerUpdateRotationFunc)(float DeltaTime);
+CSEXPORT void CSCONV Export_VTableHacks_CallOriginal_PlayerControllerUpdateRotation(PlayerControllerUpdateRotationFunc Func, UObject* Obj, float DeltaTime)
+{
+ (Obj->*Func)(DeltaTime);
+}
+
CSEXPORT void CSCONV Export_VTableHacks(RegisterFunc registerFunc)
{
REGISTER_FUNC(Export_VTableHacks_Set_VTableCallback);
@@ -83,4 +91,5 @@ CSEXPORT void CSCONV Export_VTableHacks(RegisterFunc registerFunc)
REGISTER_FUNC(Export_VTableHacks_CallOriginal_ActorComponentBeginPlay);
REGISTER_FUNC(Export_VTableHacks_CallOriginal_ActorComponentEndPlay);
REGISTER_FUNC(Export_VTableHacks_CallOriginal_PlayerControllerSetupInputComponent);
+ REGISTER_FUNC(Export_VTableHacks_CallOriginal_PlayerControllerUpdateRotation);
}
\ No newline at end of file
diff --git a/Source/USharp/Private/VTableHacks.h b/Source/USharp/Private/VTableHacks.h
index ffcedd7..3d0be0b 100644
--- a/Source/USharp/Private/VTableHacks.h
+++ b/Source/USharp/Private/VTableHacks.h
@@ -350,4 +350,44 @@ class USHARP_API ADummyPlayerControllerSetupInputComponent3 : public ADummyPlaye
{
FMsg::Logf("", 0, FName(TEXT("USharp")), ELogVerbosity::Log, TEXT("ADummyPlayerControllerSetupInputComponent3-SetupInputComponent"));
}
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// APlayerController::UpdateRotation
+/////////////////////////////////////////////////////////////////////////////
+
+typedef void(CSCONV *PlayerControllerUpdateRotationCallbackSig)(APlayerController* Obj, float DeltaTime);
+extern PlayerControllerUpdateRotationCallbackSig PlayerControllerUpdateRotationCallback;
+
+UCLASS(NotBlueprintable, NotBlueprintType)
+class USHARP_API ADummyPlayerControllerUpdateRotation1 : public APlayerController
+{
+ GENERATED_BODY()
+
+protected:
+ virtual void UpdateRotation(float DeltaTime) override
+ {
+ if (PlayerControllerUpdateRotationCallback != nullptr)
+ {
+ PlayerControllerUpdateRotationCallback(this, DeltaTime);
+ }
+ }
+};
+
+UCLASS(NotBlueprintable, NotBlueprintType)
+class USHARP_API ADummyPlayerControllerUpdateRotation2 : public ADummyPlayerControllerUpdateRotation1
+{
+ GENERATED_BODY()
+};
+
+UCLASS(NotBlueprintable, NotBlueprintType)
+class USHARP_API ADummyPlayerControllerUpdateRotation3 : public ADummyPlayerControllerUpdateRotation2
+{
+ GENERATED_BODY()
+
+protected:
+ virtual void UpdateRotation(float DeltaTime) override
+ {
+ FMsg::Logf("", 0, FName(TEXT("USharp")), ELogVerbosity::Log, TEXT("ADummyPlayerControllerUpdateRotation3-UpdateRotation"));
+ }
};
\ No newline at end of file