diff --git a/CommunityBugFixCollection/Contributors.cs b/CommunityBugFixCollection/Contributors.cs index c2b76f9..1ee776f 100644 --- a/CommunityBugFixCollection/Contributors.cs +++ b/CommunityBugFixCollection/Contributors.cs @@ -11,6 +11,8 @@ internal static class Contributors public static string[] Banane9 { get; } = ["Banane9"]; + public static string[] E1int { get; } = ["E1int"]; + public static string[] Goat { get; } = ["goat"]; public static string[] LeCloutPanda { get; } = ["LeCloutPanda"]; diff --git a/CommunityBugFixCollection/FlipAtUserView.cs b/CommunityBugFixCollection/FlipAtUserView.cs new file mode 100644 index 0000000..e3dc84c --- /dev/null +++ b/CommunityBugFixCollection/FlipAtUserView.cs @@ -0,0 +1,38 @@ +using Elements.Core; +using FrooxEngine; +using HarmonyLib; +using MonkeyLoader.Resonite; +using System.Collections.Generic; +using System.Reflection.Emit; + +namespace CommunityBugFixCollection +{ + [HarmonyPatchCategory(nameof(FlipAtUserView))] + [HarmonyPatch(typeof(FlipAtUser), nameof(FlipAtUser.OnCommonUpdate))] + internal sealed class FlipAtUserView : ResoniteMonkey + { + public override IEnumerable Authors => Contributors.E1int; + + public override bool CanBeDisabled => true; + + private static float3 GetUserPosition(UserRoot userRoot) + => Enabled ? userRoot.ViewPosition : userRoot.HeadPosition; + + private static IEnumerable Transpiler(IEnumerable instructions) + { + var headPositionGetter = AccessTools.PropertyGetter(typeof(UserRoot), nameof(UserRoot.HeadPosition)); + var getUserPositionMethod = AccessTools.DeclaredMethod(typeof(FlipAtUserView), nameof(GetUserPosition)); + + foreach (var instruction in instructions) + { + if (instruction.Calls(headPositionGetter)) + { + yield return new CodeInstruction(OpCodes.Call, getUserPositionMethod); + continue; + } + + yield return instruction; + } + } + } +} \ No newline at end of file diff --git a/CommunityBugFixCollection/Locale/en.json b/CommunityBugFixCollection/Locale/en.json index 5db0211..cd76c63 100644 --- a/CommunityBugFixCollection/Locale/en.json +++ b/CommunityBugFixCollection/Locale/en.json @@ -29,6 +29,7 @@ "CommunityBugFixCollection.FadeContextMenuLabelOutlines.Description": "Makes the outlines of the labels of the context menu fade out like the rest of it.", "CommunityBugFixCollection.FireBrushToolDequipEvents.Description": "Fixes tools derived from BrushTool not firing OnDequipped events.", "CommunityBugFixCollection.FixMigratedItemMessages.Description": "Fixes migrated items sent as messages not spawning because they still point to the old platform.", + "CommunityBugFixCollection.FlipAtUserView.Description": "Fixes FlipAtUser component by using the view position as reference instead of the head slot position.", "CommunityBugFixCollection.GammaCorrectedColorXLuminance.Description": "Fixes ColorX Luminance calculations being incorrect for non-linear color profiles.", "CommunityBugFixCollection.GroupCloudHomeTemplate.Description": "Uses the User Cloud Home template instead of the missing Group template.", "CommunityBugFixCollection.HighlightHomeWorldInInventory.Description": "Fixes the selected Home World in the Inventory not being highlighted as a favorite.", diff --git a/README.md b/README.md index 858ce7d..3fcbb82 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ just disable them in the settings in the meantime. * Storage units can't be localized (and they use GB instead of GiB and so on) * https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1157 * https://github.com/Yellow-Dog-Man/Locale/issues/186 +* FlipAtUser component does not respect view position (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1335) * ColorX From HexCode (ProtoFlux node) defaults to Linear profile (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1404) * ProtoFlux value casts from byte to other values converting incorrectly (mono / graphical client only) (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2257) * `ValueMod` node crashes the game when B input is set to zero or disconnected. (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2746)