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);
|
||||
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)
|
||||
modSystem.Mod.Logger.Notification($"HandleBeeParticleSpawn catchup totalDelta: {totalDelta}s");
|
||||
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
for (var i = 0; i < totalDelta / 0.1f; i++)
|
||||
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:
|
||||
{
|
||||
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);
|
||||
}
|
||||
case SwarmState.HangingOut:
|
||||
|
||||
@@ -4,6 +4,7 @@ using RoamingBees.Particles.Catchup;
|
||||
using RoamingBees.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Vintagestory.API.Client;
|
||||
@@ -153,11 +154,16 @@ public class BlockEntityBehaviorRoamingBees(BlockEntity blockEntity) : BlockEnti
|
||||
activeBees.Add(bee);
|
||||
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)
|
||||
modSystem.Mod.Logger.Notification($"HandleBeeParticleSpawn catchup totalDelta: {totalDelta}s");
|
||||
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
for (var i = 0; i < totalDelta / 0.1f; i++)
|
||||
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"
|
||||
],
|
||||
"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": {
|
||||
"game": "1.21.0"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user