feat(debug): Debug config section; debug key rebindable and off by default; Log Form Hits moved from Fenrir; dead Skeleton F8 helpers removed
Requested by Dagaz.
This commit is contained in:
parent
b431bb9d1f
commit
0668d59a9b
6 changed files with 40 additions and 103 deletions
32
JotunnModStub/DebugConfig.cs
Normal file
32
JotunnModStub/DebugConfig.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using BepInEx.Configuration;
|
||||||
|
|
||||||
|
namespace RacesOfValheim
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The mod-wide debug switches, in one "Debug" section rather than one per race. Bound last
|
||||||
|
/// from RacesOfValheim.Awake(), so Configuration Manager lists the section at the bottom.
|
||||||
|
///
|
||||||
|
/// Every entry stays local (never synced from the server): ConfigSync leaves KeyboardShortcut
|
||||||
|
/// entries and any key containing "debug" alone, so keep "Debug" in the key names.
|
||||||
|
/// </summary>
|
||||||
|
public static class DebugConfig
|
||||||
|
{
|
||||||
|
public static ConfigEntry<bool> EnableDebugKey;
|
||||||
|
public static ConfigEntry<KeyboardShortcut> DebugKey;
|
||||||
|
public static ConfigEntry<bool> LogFormHits;
|
||||||
|
|
||||||
|
public static void Bind(ConfigFile config)
|
||||||
|
{
|
||||||
|
const string section = "Debug";
|
||||||
|
EnableDebugKey = config.Bind(section, "Debug: Enable Debug Key", false,
|
||||||
|
new ConfigDescription("Turns on the debug key below. Leave it off unless you are sending a bug report."));
|
||||||
|
DebugKey = config.Bind(section, "Debug Key", new KeyboardShortcut(KeyCode.F8),
|
||||||
|
new ConfigDescription("Toggles the melee reach readout (top left and log) and writes what the Alfar drones and the camera's target are doing to the log."));
|
||||||
|
// Was "Fenrir - Debug" / "Debug: Log Form Hits" until v1.6.10. It covers the Skadi,
|
||||||
|
// Sverm and Trol forms too (FormMelee.LogHit), so it moved here.
|
||||||
|
LogFormHits = config.Bind(section, "Debug: Log Form Hits", false,
|
||||||
|
new ConfigDescription("Writes one log line per form claw, bite or swing: what was in reach, what it hit, and why anything was skipped. For bug reports about attacks that do no damage."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -100,9 +100,6 @@ namespace RacesOfValheim
|
||||||
public static ConfigEntry<float> UlvAttackRadius;
|
public static ConfigEntry<float> UlvAttackRadius;
|
||||||
public static ConfigEntry<float> UlvPushForce;
|
public static ConfigEntry<float> UlvPushForce;
|
||||||
|
|
||||||
// ─── Debug ─────────────────────────────────────────────────────────────
|
|
||||||
public static ConfigEntry<bool> DebugFormHits;
|
|
||||||
|
|
||||||
// ─── Appearance (per player, never synced) ──────────────────────────────
|
// ─── Appearance (per player, never synced) ──────────────────────────────
|
||||||
public static ConfigEntry<bool> ReadyMessage;
|
public static ConfigEntry<bool> ReadyMessage;
|
||||||
public static ConfigEntry<bool> EyeGlow;
|
public static ConfigEntry<bool> EyeGlow;
|
||||||
|
|
@ -268,10 +265,6 @@ namespace RacesOfValheim
|
||||||
// Tried at 1.2 in game: the orange was too strong. 0.9 checked and kept.
|
// Tried at 1.2 in game: the orange was too strong. 0.9 checked and kept.
|
||||||
EyeReadyStrength = config.Bind(appearance, "Eye Ready Strength", 0.9f,
|
EyeReadyStrength = config.Bind(appearance, "Eye Ready Strength", 0.9f,
|
||||||
new ConfigDescription("Glow at night while a form is ready.", new AcceptableValueRange<float>(0f, 3f)));
|
new ConfigDescription("Glow at night while a form is ready.", new AcceptableValueRange<float>(0f, 3f)));
|
||||||
|
|
||||||
// "debug" in the key keeps it local - see ConfigSync.
|
|
||||||
DebugFormHits = config.Bind("Fenrir - Debug", "Debug: Log Form Hits", false,
|
|
||||||
new ConfigDescription("Writes one log line per claw or bite: what was in reach, what it hit, and why anything was skipped. For bug reports about attacks that do no damage."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -342,7 +342,7 @@ namespace RacesOfValheim
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LogMiss(string form, Collider hit, string reason)
|
public static void LogMiss(string form, Collider hit, string reason)
|
||||||
{
|
{
|
||||||
if (!FenrirConfig.DebugFormHits.Value) return;
|
if (!DebugConfig.LogFormHits.Value) return;
|
||||||
Jotunn.Logger.LogInfo($"[FenrirForm] {form} swing skipped '{hit.name}' (layer {LayerMask.LayerToName(hit.gameObject.layer)}): {reason}.");
|
Jotunn.Logger.LogInfo($"[FenrirForm] {form} swing skipped '{hit.name}' (layer {LayerMask.LayerToName(hit.gameObject.layer)}): {reason}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -436,14 +436,14 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
public static void LogHit(string form, IDestructible target, float damage)
|
public static void LogHit(string form, IDestructible target, float damage)
|
||||||
{
|
{
|
||||||
if (!FenrirConfig.DebugFormHits.Value) return;
|
if (!DebugConfig.LogFormHits.Value) return;
|
||||||
string name = target is MonoBehaviour behaviour && behaviour != null ? behaviour.name : target.ToString();
|
string name = target is MonoBehaviour behaviour && behaviour != null ? behaviour.name : target.ToString();
|
||||||
Jotunn.Logger.LogInfo($"[FenrirForm] {form} swing hit '{name}' for {damage:0}.");
|
Jotunn.Logger.LogInfo($"[FenrirForm] {form} swing hit '{name}' for {damage:0}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogSwing(string form, int candidates)
|
public static void LogSwing(string form, int candidates)
|
||||||
{
|
{
|
||||||
if (!FenrirConfig.DebugFormHits.Value) return;
|
if (!DebugConfig.LogFormHits.Value) return;
|
||||||
Jotunn.Logger.LogInfo($"[FenrirForm] {form} swing: {candidates} collider(s) in reach.");
|
Jotunn.Logger.LogInfo($"[FenrirForm] {form} swing: {candidates} collider(s) in reach.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,13 +115,14 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>F8 turns the reach readout on and off.</summary>
|
/// <summary>The debug key (DebugConfig, F8 by default) turns the reach readout on and off.</summary>
|
||||||
[HarmonyPatch(typeof(Player), "Update")]
|
[HarmonyPatch(typeof(Player), "Update")]
|
||||||
internal static class RaceMeleeReachDebugKey
|
internal static class RaceMeleeReachDebugKey
|
||||||
{
|
{
|
||||||
private static void Postfix(Player __instance)
|
private static void Postfix(Player __instance)
|
||||||
{
|
{
|
||||||
if (__instance != Player.m_localPlayer || !Input.GetKeyDown(KeyCode.F8)) return;
|
if (__instance != Player.m_localPlayer || !DebugConfig.EnableDebugKey.Value) return;
|
||||||
|
if (!DebugConfig.DebugKey.Value.IsDownIgnoringHeldKeys()) return;
|
||||||
RaceMeleeReach.DebugOn = !RaceMeleeReach.DebugOn;
|
RaceMeleeReach.DebugOn = !RaceMeleeReach.DebugOn;
|
||||||
__instance.Message(MessageHud.MessageType.TopLeft, $"[RoV reach] debug {(RaceMeleeReach.DebugOn ? "on" : "off")}");
|
__instance.Message(MessageHud.MessageType.TopLeft, $"[RoV reach] debug {(RaceMeleeReach.DebugOn ? "on" : "off")}");
|
||||||
AlfarMiner.DebugReport(__instance);
|
AlfarMiner.DebugReport(__instance);
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ namespace RacesOfValheim
|
||||||
// Not a race either: the faction truce and the faction merchants, which cut across
|
// Not a race either: the faction truce and the faction merchants, which cut across
|
||||||
// every race at once, so they bind last rather than inside the alphabetical run above.
|
// every race at once, so they bind last rather than inside the alphabetical run above.
|
||||||
FactionsConfig.Bind(Config);
|
FactionsConfig.Bind(Config);
|
||||||
|
// The mod-wide debug switches, at the bottom of the list on purpose.
|
||||||
|
DebugConfig.Bind(Config);
|
||||||
// After every Bind above: tags the gameplay entries for Jotunn's server-to-client sync.
|
// After every Bind above: tags the gameplay entries for Jotunn's server-to-client sync.
|
||||||
ConfigSync.Apply(Config);
|
ConfigSync.Apply(Config);
|
||||||
harmony.PatchAll();
|
harmony.PatchAll();
|
||||||
|
|
|
||||||
|
|
@ -252,97 +252,6 @@ namespace RacesOfValheim
|
||||||
return bestCombo;
|
return bestCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DumpTransformHierarchy(Transform t, string indent)
|
|
||||||
{
|
|
||||||
if (t == null) return;
|
|
||||||
Jotunn.Logger.LogInfo(indent + t.name + " (Active: " + t.gameObject.activeSelf + ")");
|
|
||||||
for(int i = 0; i < t.childCount; i++)
|
|
||||||
{
|
|
||||||
DumpTransformHierarchy(t.GetChild(i), indent + " ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// F8 debug: fires a ray from the camera and logs whatever it hits. Cosmetic pieces
|
|
||||||
/// (hair, beard, helmet) carry no collider, so this mostly confirms terrain/creature hits
|
|
||||||
/// - LogHeadCosmeticsState below is what actually answers "what is that floating chunk."
|
|
||||||
/// Kept anyway because it is the general-purpose "what am I looking at" tool for any other
|
|
||||||
/// bone or prefab placement question that comes up later.
|
|
||||||
/// </summary>
|
|
||||||
private void LogRaycastHit()
|
|
||||||
{
|
|
||||||
Camera cam = Camera.main;
|
|
||||||
if (cam == null)
|
|
||||||
{
|
|
||||||
Jotunn.Logger.LogInfo("[F8] No camera found for raycast.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ray ray = new Ray(cam.transform.position, cam.transform.forward);
|
|
||||||
if (Physics.Raycast(ray, out RaycastHit hit, 50f))
|
|
||||||
{
|
|
||||||
Jotunn.Logger.LogInfo("--- F8 RAYCAST HIT ---");
|
|
||||||
Jotunn.Logger.LogInfo($"Collider: '{hit.collider.gameObject.name}' at {hit.point:F2}, distance={hit.distance:F2}");
|
|
||||||
Jotunn.Logger.LogInfo($"Full path: {GetFullPath(hit.collider.transform)}");
|
|
||||||
Renderer renderer = hit.collider.GetComponentInParent<Renderer>();
|
|
||||||
if (renderer != null)
|
|
||||||
{
|
|
||||||
Jotunn.Logger.LogInfo($"Nearest renderer: '{renderer.gameObject.name}' ({renderer.GetType().Name}), enabled={renderer.enabled}, scale={renderer.transform.lossyScale:F3}");
|
|
||||||
}
|
|
||||||
Jotunn.Logger.LogInfo("----------------------");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Jotunn.Logger.LogInfo("[F8] Raycast hit nothing within 50m (cosmetic pieces usually have no collider anyway).");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetFullPath(Transform t)
|
|
||||||
{
|
|
||||||
string path = t.name;
|
|
||||||
for (Transform parent = t.parent; parent != null; parent = parent.parent)
|
|
||||||
{
|
|
||||||
path = parent.name + "/" + path;
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// F8 debug: dumps the exact state of the three item slots this race hides (hair, beard,
|
|
||||||
/// helmet) - active flag, renderer enabled flag and scale for every renderer underneath.
|
|
||||||
/// This is the direct answer to "what is still visible and why": a chunk that survives
|
|
||||||
/// hiding will show up here as active=true, or as a renderer with enabled=true even while
|
|
||||||
/// its wrapper is scaled to zero (the skinned-mesh case scale alone cannot hide).
|
|
||||||
/// </summary>
|
|
||||||
private void LogHeadCosmeticsState()
|
|
||||||
{
|
|
||||||
if (Player.m_localPlayer == null) return;
|
|
||||||
VisEquipment vis = Player.m_localPlayer.GetComponent<VisEquipment>();
|
|
||||||
if (vis == null) return;
|
|
||||||
|
|
||||||
Jotunn.Logger.LogInfo("--- F8 SKELETON HEAD COSMETICS ---");
|
|
||||||
DumpItemInstanceField(vis, "m_hairItemInstance");
|
|
||||||
DumpItemInstanceField(vis, "m_beardItemInstance");
|
|
||||||
DumpItemInstanceField(vis, "m_helmetItemInstance");
|
|
||||||
Jotunn.Logger.LogInfo("----------------------------------");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void DumpItemInstanceField(VisEquipment vis, string fieldName)
|
|
||||||
{
|
|
||||||
GameObject go = HarmonyLib.Traverse.Create(vis).Field<GameObject>(fieldName).Value;
|
|
||||||
if (go == null)
|
|
||||||
{
|
|
||||||
Jotunn.Logger.LogInfo($"[F8] {fieldName}: null (nothing equipped/instantiated).");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Jotunn.Logger.LogInfo($"[F8] {fieldName}: '{go.name}' active={go.activeSelf} scale={go.transform.localScale:F3}");
|
|
||||||
foreach (Renderer r in go.GetComponentsInChildren<Renderer>(true))
|
|
||||||
{
|
|
||||||
Jotunn.Logger.LogInfo($"[F8] renderer '{r.gameObject.name}' ({r.GetType().Name}) enabled={r.enabled}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (Player.m_localPlayer == null) return;
|
if (Player.m_localPlayer == null) return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue