Each Eyes Position section now has a set per body and per eye (the character's own left and right), because the face is not symmetric enough for one set to fit both eyes. The Aswid female defaults are the per-eye values dialled in on screen; Alfar and Dvergar copy their female values to both eyes. The old shared keys are dropped: they only ever existed in test builds.
129 lines
6.9 KiB
C#
129 lines
6.9 KiB
C#
using System.Collections.Generic;
|
|
using BepInEx.Configuration;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
/// <summary>
|
|
/// Hand placement for every race that hangs eyes on the face: one "Eyes Position - race"
|
|
/// section each, with a set of sliders per body and per eye. Per body because the two bodies
|
|
/// put their painted eyes in different places (PlayerFace); per eye because the face is not
|
|
/// symmetric enough for one set to fit both. Left and right are the character's own.
|
|
///
|
|
/// Every value is a delta on the placement the race's own code computes: all zeros (and size
|
|
/// 1) is the code's own placement, and the female defaults below are the corrections found in
|
|
/// game on top of it.
|
|
///
|
|
/// Local, never synced (ConfigSync): it only changes how this client draws faces.
|
|
/// </summary>
|
|
public static class EyePositionConfig
|
|
{
|
|
public const string SectionPrefix = "Eyes Position - ";
|
|
|
|
/// <summary>One eye's sliders, for one body of one race.</summary>
|
|
public sealed class Tuning
|
|
{
|
|
public ConfigEntry<float> Forward;
|
|
public ConfigEntry<float> Height;
|
|
public ConfigEntry<float> Separation;
|
|
public ConfigEntry<float> Size;
|
|
|
|
// Only bound for races whose eyes are not spheres; null elsewhere.
|
|
public ConfigEntry<float> RotationX;
|
|
public ConfigEntry<float> RotationY;
|
|
public ConfigEntry<float> RotationZ;
|
|
|
|
public float RotX => RotationX != null ? RotationX.Value : 0f;
|
|
public float RotY => RotationY != null ? RotationY.Value : 0f;
|
|
public float RotZ => RotationZ != null ? RotationZ.Value : 0f;
|
|
}
|
|
|
|
// [race] -> { male left, male right, female left, female right }
|
|
private static readonly Dictionary<string, Tuning[]> tunings = new Dictionary<string, Tuning[]>();
|
|
|
|
public static void Bind(ConfigFile config)
|
|
{
|
|
// Female defaults dialled in on screen (playtest, 2026-10-27). The male ones are
|
|
// still the code's own placement; the Sverm's helmet hides its eyes, so it keeps it.
|
|
Defaults alfar = new Defaults { Separation = 0.006f, RotX = -17.524f };
|
|
BindRace(config, AlfarConfig.RaceId, true, alfar, alfar);
|
|
|
|
BindRace(config, "Aswid", true,
|
|
new Defaults { Forward = -0.002f, Height = -0.001f, Separation = 0.003f, Size = 1.142f,
|
|
RotX = 1.298f, RotY = 0.649f },
|
|
new Defaults { Forward = -0.001f, Height = -0.001f, Separation = 0.009f, Size = 1.142f,
|
|
RotX = 1.298f, RotY = 0.649f, RotZ = -7.788f });
|
|
|
|
Defaults dvergar = new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f };
|
|
BindRace(config, DvergarConfig.RaceId, false, dvergar, dvergar);
|
|
|
|
BindRace(config, SvermConfig.RaceId, false, new Defaults(), new Defaults());
|
|
}
|
|
|
|
/// <summary>Starting values for one eye's sliders.</summary>
|
|
private sealed class Defaults
|
|
{
|
|
public float Forward, Height, Separation, RotX, RotY, RotZ;
|
|
public float Size = 1f;
|
|
}
|
|
|
|
/// <summary>
|
|
/// The sliders for one eye of the body this player is wearing right now. Side is the
|
|
/// races' own convention: negative is offset against the head frame's right axis, which is
|
|
/// the character's left eye.
|
|
/// </summary>
|
|
public static Tuning For(string race, Player player, float side)
|
|
{
|
|
if (!tunings.TryGetValue(race, out Tuning[] set)) return null;
|
|
return set[(PlayerFace.IsFemale(player) ? 2 : 0) + (side < 0f ? 0 : 1)];
|
|
}
|
|
|
|
private static void BindRace(ConfigFile config, string race, bool rotation, Defaults femaleLeft, Defaults femaleRight)
|
|
{
|
|
string section = SectionPrefix + race;
|
|
|
|
// Female first in the list, left before right: Order sorts high to low.
|
|
tunings[race] = new[]
|
|
{
|
|
BindEye(config, section, "Male", "Left", rotation, 200, new Defaults()),
|
|
BindEye(config, section, "Male", "Right", rotation, 100, new Defaults()),
|
|
BindEye(config, section, "Female", "Left", rotation, 400, femaleLeft),
|
|
BindEye(config, section, "Female", "Right", rotation, 300, femaleRight),
|
|
};
|
|
}
|
|
|
|
private static Tuning BindEye(ConfigFile config, string section, string body, string eye, bool rotation, int order, Defaults d)
|
|
{
|
|
string prefix = $"{body} {eye} Eye ";
|
|
string who = $"{body} characters, {eye.ToLowerInvariant()} eye (the character's own {eye.ToLowerInvariant()})";
|
|
Tuning t = new Tuning();
|
|
|
|
t.Forward = config.Bind(section, prefix + "Forward", d.Forward,
|
|
new ConfigDescription($"{who}: moves the eye out of (+) or into (-) the face, in metres.",
|
|
new AcceptableValueRange<float>(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 9 }));
|
|
t.Height = config.Bind(section, prefix + "Height", d.Height,
|
|
new ConfigDescription($"{who}: moves the eye up (+) or down (-), in metres.",
|
|
new AcceptableValueRange<float>(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 8 }));
|
|
t.Separation = config.Bind(section, prefix + "Separation", d.Separation,
|
|
new ConfigDescription($"{who}: moves the eye away from (+) or toward (-) the nose, in metres.",
|
|
new AcceptableValueRange<float>(-0.03f, 0.03f), new ConfigurationManagerAttributes { Order = order + 7 }));
|
|
t.Size = config.Bind(section, prefix + "Size", d.Size,
|
|
new ConfigDescription($"{who}: scales the eye. 1 is the default size.",
|
|
new AcceptableValueRange<float>(0.2f, 3f), new ConfigurationManagerAttributes { Order = order + 6 }));
|
|
|
|
if (rotation)
|
|
{
|
|
t.RotationX = config.Bind(section, prefix + "Rotation X", d.RotX,
|
|
new ConfigDescription($"{who}: tips the eye down (+) or up (-), in degrees.",
|
|
new AcceptableValueRange<float>(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 5 }));
|
|
t.RotationY = config.Bind(section, prefix + "Rotation Y", d.RotY,
|
|
new ConfigDescription($"{who}: turns the eye toward the temple (+) or the nose (-), in degrees.",
|
|
new AcceptableValueRange<float>(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 4 }));
|
|
t.RotationZ = config.Bind(section, prefix + "Rotation Z", d.RotZ,
|
|
new ConfigDescription($"{who}: raises (+) or lowers (-) the outer corner, in degrees.",
|
|
new AcceptableValueRange<float>(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 3 }));
|
|
}
|
|
|
|
return t;
|
|
}
|
|
}
|
|
}
|