This commit is contained in:
2025-12-14 01:42:22 +01:00
parent 3fbaac2346
commit 60d509344c
2 changed files with 7 additions and 51 deletions

View File

@@ -637,7 +637,9 @@ namespace KCM
lastVillagerMoveMs = now;
}
if ((now - lastVillagerMoveMs) >= 15000 && (now - lastVillagerStallLogMs) >= 15000)
// Note: We now have proactive loadTickDelay refresh above, so villager stall detection
// is less critical. Only log if there's an actual extended stall with bad delay values.
if ((now - lastVillagerMoveMs) >= 30000 && (now - lastVillagerStallLogMs) >= 30000)
{
lastVillagerStallLogMs = now;
Main.helper.Log(

View File

@@ -21,57 +21,11 @@ namespace KCM.Packets.Game
try
{
// Apply speed setting
Main.helper.Log($"Received SetSpeed packet: speed={speed}, isPaused={isPaused}");
// Simply apply the speed - SpeedControlUISetSpeedHook will handle this correctly
// since we're coming from a packet (PacketHandler.IsHandlingPacket will be true)
SpeedControlUI.inst.SetSpeed(speed);
// Handle pause/unpause state
if (isPaused && Time.timeScale > 0)
{
// Game should be paused
Time.timeScale = 0f;
Main.helper.Log("Game paused via network sync");
}
else if (!isPaused && Time.timeScale == 0)
{
// Game should be unpaused - restore speed
Time.timeScale = 1f;
SpeedControlUI.inst.SetSpeed(speed);
Main.helper.Log("Game unpaused via network sync");
}
// Force AI system update when speed changes
if (speed > 0)
{
try
{
// Force villager system refresh to ensure they continue working
if (VillagerSystem.inst != null)
{
// Use reflection to call any refresh methods on VillagerSystem
var villagerSystemType = typeof(VillagerSystem);
var refreshMethods = villagerSystemType.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
.Where(m => m.Name.Contains("Refresh") || m.Name.Contains("Update") || m.Name.Contains("Restart"));
foreach (var method in refreshMethods)
{
if (method.GetParameters().Length == 0)
{
try
{
method.Invoke(VillagerSystem.inst, null);
Main.helper.Log($"Called VillagerSystem.{method.Name} for speed change");
}
catch { }
}
}
}
Main.helper.Log($"AI systems refreshed for speed change to {speed}");
}
catch (Exception e)
{
Main.helper.Log("Error refreshing AI on speed change: " + e.Message);
}
}
}
catch (Exception e)
{