Skip to content

Commit c9c360e

Browse files
E1intBanane9
andcommitted
Fix FlipAtUser not respecting view position
Co-authored-by: Arne Kiesewetter <banane1996@gmx.net>
1 parent 8777869 commit c9c360e

4 files changed

Lines changed: 42 additions & 0 deletions

File tree

CommunityBugFixCollection/Contributors.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ internal static class Contributors
1111

1212
public static string[] Banane9 { get; } = ["Banane9"];
1313

14+
public static string[] E1int { get; } = ["E1int"];
15+
1416
public static string[] Goat { get; } = ["goat"];
1517

1618
public static string[] LeCloutPanda { get; } = ["LeCloutPanda"];
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Elements.Core;
2+
using FrooxEngine;
3+
using HarmonyLib;
4+
using MonkeyLoader.Resonite;
5+
using System.Collections.Generic;
6+
using System.Reflection.Emit;
7+
8+
namespace CommunityBugFixCollection
9+
{
10+
[HarmonyPatchCategory(nameof(FlipAtUserView))]
11+
[HarmonyPatch(typeof(FlipAtUser), nameof(FlipAtUser.OnCommonUpdate))]
12+
internal sealed class FlipAtUserView : ResoniteMonkey<FlipAtUserView>
13+
{
14+
public override IEnumerable<string> Authors => Contributors.E1int;
15+
16+
public override bool CanBeDisabled => true;
17+
18+
private static float3 GetUserPosition(UserRoot userRoot)
19+
=> Enabled ? userRoot.ViewPosition : userRoot.HeadPosition;
20+
21+
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
22+
{
23+
var headPositionGetter = AccessTools.PropertyGetter(typeof(UserRoot), nameof(UserRoot.HeadPosition));
24+
var getUserPositionMethod = AccessTools.DeclaredMethod(typeof(FlipAtUserView), nameof(GetUserPosition));
25+
26+
foreach (var instruction in instructions)
27+
{
28+
if (instruction.Calls(headPositionGetter))
29+
{
30+
yield return new CodeInstruction(OpCodes.Call, getUserPositionMethod);
31+
continue;
32+
}
33+
34+
yield return instruction;
35+
}
36+
}
37+
}
38+
}

CommunityBugFixCollection/Locale/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"CommunityBugFixCollection.FadeContextMenuLabelOutlines.Description": "Makes the outlines of the labels of the context menu fade out like the rest of it.",
3030
"CommunityBugFixCollection.FireBrushToolDequipEvents.Description": "Fixes tools derived from BrushTool not firing OnDequipped events.",
3131
"CommunityBugFixCollection.FixMigratedItemMessages.Description": "Fixes migrated items sent as messages not spawning because they still point to the old platform.",
32+
"CommunityBugFixCollection.FlipAtUserView.Description": "Fixes FlipAtUser component by using the view position as reference instead of the head slot position.",
3233
"CommunityBugFixCollection.GammaCorrectedColorXLuminance.Description": "Fixes ColorX Luminance calculations being incorrect for non-linear color profiles.",
3334
"CommunityBugFixCollection.GroupCloudHomeTemplate.Description": "Uses the User Cloud Home template instead of the missing Group template.",
3435
"CommunityBugFixCollection.HighlightHomeWorldInInventory.Description": "Fixes the selected Home World in the Inventory not being highlighted as a favorite.",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ just disable them in the settings in the meantime.
5252
* Storage units can't be localized (and they use GB instead of GiB and so on)
5353
* https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1157
5454
* https://github.com/Yellow-Dog-Man/Locale/issues/186
55+
* FlipAtUser component does not respect view position (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1335)
5556
* ColorX From HexCode (ProtoFlux node) defaults to Linear profile (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1404)
5657
* ProtoFlux value casts from byte to other values converting incorrectly (mono / graphical client only) (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2257)
5758
* `ValueMod<Decimal>` node crashes the game when B input is set to zero or disconnected. (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2746)

0 commit comments

Comments
 (0)