talán fix geic végre big-pickle
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -11,18 +11,64 @@ namespace KCM.Packets.Game
|
||||
public override ushort packetId => (int)Enums.Packets.SetSpeed;
|
||||
|
||||
public int speed { get; set; }
|
||||
public bool isPaused { get; set; }
|
||||
|
||||
public override void HandlePacketClient()
|
||||
{
|
||||
if (clientId == KCClient.client.Id) // Prevent speed softlock
|
||||
return;
|
||||
|
||||
SpeedControlUI.inst.SetSpeed(speed);
|
||||
try
|
||||
{
|
||||
// Apply speed setting
|
||||
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
|
||||
{
|
||||
// Restart villager AI to ensure they continue working
|
||||
for (int i = 0; i < Villager.villagers.Count; i++)
|
||||
{
|
||||
Villager v = Villager.villagers.data[i];
|
||||
if (v != null && v.brain != null)
|
||||
{
|
||||
v.brain.Restart();
|
||||
}
|
||||
}
|
||||
Main.helper.Log($"AI systems restarted for speed change to {speed}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Main.helper.Log("Error restarting AI on speed change: " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Main.helper.Log("Error handling SetSpeed packet: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public override void HandlePacketServer()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
// Server doesn't need to handle this packet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user