74 lines
3.1 KiB
C#
74 lines
3.1 KiB
C#
using HarmonyLib;
|
|
using UnityEngine;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
[HarmonyPatch]
|
|
public static class TrolFoodDebug
|
|
{
|
|
[HarmonyPatch(typeof(Player), "Update")]
|
|
[HarmonyPostfix]
|
|
public static void Update_Postfix(Player __instance)
|
|
{
|
|
if (__instance != Player.m_localPlayer) return;
|
|
|
|
if (Input.GetKeyDown(KeyCode.F8))
|
|
{
|
|
Jotunn.Logger.LogInfo("=== F8 TROL FOOD DEBUG ===");
|
|
Jotunn.Logger.LogInfo($"IsTrol: {TrolRace.IsTrol()}");
|
|
|
|
var foods = Traverse.Create(__instance).Field("m_foods").GetValue<System.Collections.Generic.List<Player.Food>>();
|
|
Jotunn.Logger.LogInfo($"Native m_foods Count: {foods?.Count ?? 0}");
|
|
if (foods != null)
|
|
{
|
|
for (int i = 0; i < foods.Count; i++)
|
|
{
|
|
var f = foods[i];
|
|
Jotunn.Logger.LogInfo($" [{i}] {f.m_item?.m_shared?.m_name} | Time: {f.m_time} / {f.m_item?.m_shared?.m_foodBurnTime}");
|
|
}
|
|
}
|
|
|
|
if (TrolFoodManager.ExtraFoods.TryGetValue(__instance, out Player.Food extraFood))
|
|
{
|
|
Jotunn.Logger.LogInfo($"ExtraFoods Dictionary has entry:");
|
|
Jotunn.Logger.LogInfo($" Name: {extraFood?.m_item?.m_shared?.m_name}");
|
|
Jotunn.Logger.LogInfo($" Time: {extraFood?.m_time} / {extraFood?.m_item?.m_shared?.m_foodBurnTime}");
|
|
}
|
|
else
|
|
{
|
|
Jotunn.Logger.LogInfo($"ExtraFoods Dictionary is EMPTY for this player.");
|
|
}
|
|
|
|
if (__instance.m_customData.TryGetValue("TrolFood_Prefab", out string prefab))
|
|
{
|
|
Jotunn.Logger.LogInfo($"m_customData TrolFood_Prefab: {prefab}");
|
|
}
|
|
if (__instance.m_customData.TryGetValue("TrolFood_Time", out string time))
|
|
{
|
|
Jotunn.Logger.LogInfo($"m_customData TrolFood_Time: {time}");
|
|
}
|
|
Jotunn.Logger.LogInfo("==========================");
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(Humanoid), "ConsumeItem")]
|
|
[HarmonyPrefix]
|
|
public static void ConsumeItem_Prefix(Humanoid __instance, Inventory inventory, ItemDrop.ItemData item)
|
|
{
|
|
if (__instance == Player.m_localPlayer && item != null && item.m_shared.m_name == "$item_bukeperry")
|
|
{
|
|
Jotunn.Logger.LogInfo("=== BUKEPERRY CONSUMED ===");
|
|
Jotunn.Logger.LogInfo($"IsTrol: {TrolRace.IsTrol()}");
|
|
if (TrolFoodManager.ExtraFoods.ContainsKey((Player)__instance))
|
|
{
|
|
Jotunn.Logger.LogInfo("ExtraFoods HAS entry. Will it clear?");
|
|
}
|
|
else
|
|
{
|
|
Jotunn.Logger.LogInfo("ExtraFoods DOES NOT HAVE entry before clear.");
|
|
}
|
|
Jotunn.Logger.LogInfo("==========================");
|
|
}
|
|
}
|
|
}
|
|
}
|