BruceOfTheBow / BruceComfyMods

Player mods made for Comfy Valheim
GNU General Public License v3.0
2 stars 4 forks source link

NoMap feature request - Default rotation adjustment #29

Closed weiler-git closed 4 hours ago

weiler-git commented 4 hours ago

when playing NoMap, part of the challenge is to figure what direction you are going in, reseting axis rotation with Gizmo makes it pretty easy to figure out.

I tested a way to go around this by modifying your repo. basically using this method:

public float GetPlayerYAngel()
{
    if (Player.m_localPlayer == null) return 0f;

    float baseAngle = GetAngle(); // This represents the angle step (e.g., 180f / SnapDivisions)
    float playerY = Player.m_localPlayer.transform.eulerAngles.y; // Get player's Y rotation in degrees (0 to 360)

    // Calculate the closest multiplier for the given base angle
    float multiplier = Mathf.Round(playerY / baseAngle);

    // Return the closest angle
    return baseAngle * multiplier;
}

then at all methods to reset axis or all rotations:

_eulerAngles = Vector3.zero;
    _eulerAngles.y = GetPlayerYAngel();
    _gizmos.SetLocalRotation(_eulerAngles);

this sets resets the Y axis to the closest angle wherever the player face, so it cannot be used to determin north.

added also this in player patches:

[HarmonyPostfix]
[HarmonyPatch(nameof(Player.Awake))]
static void AwakePostfix(Player __instance)
{
    if (Player.m_localPlayer == null) return;

    if (Player.m_localPlayer == __instance)
    {
        RotationManager.ResetRotation();
    }
}

to set initial rotation to players direction too. so if you try to restart game, you wont have y = 0

If this could be added as an option (with server locked config sync), that would be really great.

redseiko commented 4 hours ago

Feel free to fork the mod and publish your own version. It's a bit too much complexity and overhead for a niche use case (especially with config sync) that I consider it out of scope for this mod.

weiler-git commented 4 hours ago

Ok, thank you