fix GeneratePathForCurrentState exception, add catchup perf logging
This commit is contained in:
@@ -286,11 +286,16 @@ public class BlockEntityBehaviorBeeSwarm(BlockEntity blockEntity) : BlockEntityB
|
|||||||
activeBees.Add(bee);
|
activeBees.Add(bee);
|
||||||
if (catchup)
|
if (catchup)
|
||||||
{
|
{
|
||||||
var totalDelta = Api.World.Calendar.ElapsedSeconds - packet.TimeElapsedSeconds;
|
var totalDelta = Math.Abs(Api.World.Calendar.ElapsedSeconds - packet.TimeElapsedSeconds);
|
||||||
if (modSystem?.Mod.Info.Version.Contains("dev") == true)
|
if (modSystem?.Mod.Info.Version.Contains("dev") == true)
|
||||||
modSystem.Mod.Logger.Notification($"HandleBeeParticleSpawn catchup totalDelta: {totalDelta}s");
|
modSystem.Mod.Logger.Notification($"HandleBeeParticleSpawn catchup totalDelta: {totalDelta}s");
|
||||||
|
|
||||||
|
var stopwatch = Stopwatch.StartNew();
|
||||||
for (var i = 0; i < totalDelta / 0.1f; i++)
|
for (var i = 0; i < totalDelta / 0.1f; i++)
|
||||||
bee.Step(0.1f, 0.1f); // todo
|
bee.Step(0.1f, 0.1f); // todo
|
||||||
|
stopwatch.Stop();
|
||||||
|
if (stopwatch.Elapsed.TotalSeconds > 0.02)
|
||||||
|
modSystem?.Mod?.Logger.Warning($"{nameof(BlockEntityBehaviorBeeSwarm)} {nameof(HandleBeeParticleSpawn)} catchup took {stopwatch.Elapsed.TotalSeconds:F2}s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +513,7 @@ public class BlockEntityBehaviorBeeSwarm(BlockEntity blockEntity) : BlockEntityB
|
|||||||
case SwarmState.BuildingSwarm:
|
case SwarmState.BuildingSwarm:
|
||||||
{
|
{
|
||||||
var path = GenerateBuildingSwarmPath(blockAccessor, cfg);
|
var path = GenerateBuildingSwarmPath(blockAccessor, cfg);
|
||||||
var start = path is not null ? path[0].Position : hiddenAnchor;
|
var start = path is not null && path.Length > 0 ? path[0].Position : hiddenAnchor;
|
||||||
return (path, BeeRole.Traveling, start, hiddenAnchor);
|
return (path, BeeRole.Traveling, start, hiddenAnchor);
|
||||||
}
|
}
|
||||||
case SwarmState.HangingOut:
|
case SwarmState.HangingOut:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using RoamingBees.Particles.Catchup;
|
|||||||
using RoamingBees.Utilities;
|
using RoamingBees.Utilities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Vintagestory.API.Client;
|
using Vintagestory.API.Client;
|
||||||
@@ -153,11 +154,16 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
|
|||||||
activeBees.Add(bee);
|
activeBees.Add(bee);
|
||||||
if (catchup)
|
if (catchup)
|
||||||
{
|
{
|
||||||
var totalDelta = Api.World.Calendar.ElapsedSeconds - packet.TimeElapsedSeconds;
|
var totalDelta = Math.Abs(Api.World.Calendar.ElapsedSeconds - packet.TimeElapsedSeconds);
|
||||||
if (modSystem?.Mod.Info.Version.Contains("dev") == true)
|
if (modSystem?.Mod.Info.Version.Contains("dev") == true)
|
||||||
modSystem.Mod.Logger.Notification($"HandleBeeParticleSpawn catchup totalDelta: {totalDelta}s");
|
modSystem.Mod.Logger.Notification($"HandleBeeParticleSpawn catchup totalDelta: {totalDelta}s");
|
||||||
|
|
||||||
|
var stopwatch = Stopwatch.StartNew();
|
||||||
for (var i = 0; i < totalDelta / 0.1f; i++)
|
for (var i = 0; i < totalDelta / 0.1f; i++)
|
||||||
bee.Step(0.1f, 0.1f); // todo
|
bee.Step(0.1f, 0.1f); // todo
|
||||||
|
stopwatch.Stop();
|
||||||
|
if (stopwatch.Elapsed.TotalSeconds > 0.02)
|
||||||
|
modSystem?.Mod?.Logger.Warning($"{nameof(BlockEntityBehaviorRoamingBees)} {nameof(HandleBeeParticleSpawn)} catchup took {stopwatch.Elapsed.TotalSeconds:F2}s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"OrekiWoof"
|
"OrekiWoof"
|
||||||
],
|
],
|
||||||
"description": "Cute immersive roaming bees. Now on vanilla skeps and other mods' hives.",
|
"description": "Cute immersive roaming bees. Now on vanilla skeps and other mods' hives.",
|
||||||
"version": "2.0.0-dev.5",
|
"version": "2.0.0-dev.6",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"game": "1.21.0"
|
"game": "1.21.0"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user