FloatingItemsDrawnSmoke waits on game time and a real-time budget
Both label loops wait on Time.time against the pickup's own persist and fade durations plus a second, not 1200 frames; Step's guard is a 300 s real-time budget, not 3000 frames. Batch frames can be far shorter than a game second, so a frame count could expire before the label faded (follow-up floating-items-smoke-label-fade-flake). Not yet run in Unity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
54e2f88702
commit
6957180450
1 changed files with 9 additions and 4 deletions
|
|
@ -24,7 +24,8 @@ public static class FloatingItemsDrawnSmoke
|
|||
private const string Flag = "FloatingItemsDrawnSmoke.running";
|
||||
private const string Wiring = "FloatingItemsDrawnSmoke.wiring";
|
||||
private static IEnumerator _check;
|
||||
private static int _frames;
|
||||
private const double Budget = 300; // real seconds: batch frames can be far shorter than a game second
|
||||
private static double _started;
|
||||
private static string _work;
|
||||
|
||||
static FloatingItemsDrawnSmoke()
|
||||
|
|
@ -52,6 +53,7 @@ public static class FloatingItemsDrawnSmoke
|
|||
if (change != PlayModeStateChange.EnteredPlayMode) return;
|
||||
_work = Path.Combine(Path.GetTempPath(), $"floating-items-smoke-{Guid.NewGuid():N}");
|
||||
Directory.CreateDirectory(_work);
|
||||
_started = Time.realtimeSinceStartupAsDouble;
|
||||
_check = Check();
|
||||
EditorApplication.update += Step;
|
||||
}
|
||||
|
|
@ -60,7 +62,7 @@ public static class FloatingItemsDrawnSmoke
|
|||
{
|
||||
try
|
||||
{
|
||||
if (++_frames > 3000) throw new InvalidOperationException("The check did not finish in 3000 frames.");
|
||||
if (Time.realtimeSinceStartupAsDouble - _started > Budget) throw new InvalidOperationException($"The check did not finish in {Budget} seconds.");
|
||||
if (_check.MoveNext()) return;
|
||||
Finish(0);
|
||||
}
|
||||
|
|
@ -185,10 +187,13 @@ public static class FloatingItemsDrawnSmoke
|
|||
var earlyPickup = Pickups().Single(p => p.Item == early.Item);
|
||||
earlyPickup.LabelPersistDuration = 1;
|
||||
earlyPickup.LabelFadeDuration = .2f;
|
||||
for (var i = 0; i < 1200 && earlyPickup.ScanLabel.color.a > .05f; i++) yield return null;
|
||||
// Game time, not frames: batch frames can be far shorter than a game second, so a frame count can run out before the fade.
|
||||
var labelUntil = Time.time + earlyPickup.LabelPersistDuration + earlyPickup.LabelFadeDuration + 1f;
|
||||
while (Time.time < labelUntil && earlyPickup.ScanLabel.color.a > .05f) yield return null;
|
||||
Require(earlyPickup.ScanLabel.color.a <= .05f, "label: an unviewed, unheld label did not go dark.");
|
||||
Require(zone.TryHold(taker, early.Id), "label: the zone refused to hold the item.");
|
||||
for (var i = 0; i < 1200 && earlyPickup.ScanLabel.color.a < .95f; i++) yield return null;
|
||||
labelUntil = Time.time + earlyPickup.LabelPersistDuration + earlyPickup.LabelFadeDuration + 1f;
|
||||
while (Time.time < labelUntil && earlyPickup.ScanLabel.color.a < .95f) yield return null;
|
||||
Require(earlyPickup.ScanLabel.color.a >= .95f, "label: a held item's label is not lit.");
|
||||
|
||||
// The test scene's stand-in sim and tendril ride the zone's own held-pose curve: its pose at each point of a grab
|
||||
|
|
|
|||
Loading…
Reference in a new issue