Snapshot for release 2026.10.13.1 (internal 90a2f4a)
This commit is contained in:
parent
b0f9d74b21
commit
1d86acdf27
218 changed files with 24019 additions and 1517 deletions
38
src/RynthCore.Engine/Compatibility/CastStopRules.cs
Normal file
38
src/RynthCore.Engine/Compatibility/CastStopRules.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - Compatibility/CastStopRules.cs
|
||||
//
|
||||
// The cast drain's question about the action ring: is a movement stop queued at or
|
||||
// before the pending cast? (AcMainThreadQueue.StopQueuedAtOrBefore: such a stop runs
|
||||
// first, so the cast's own stop is not sent while AC's locomotion is still on.)
|
||||
//
|
||||
// Every queued entry is checked. An entry's time is taken before ActionRing's producer
|
||||
// lock, so two producers can land slightly out of time order, and a walk that stopped
|
||||
// at the first entry newer than the cast could miss an older stop queued behind it.
|
||||
//
|
||||
// Pure: no engine state. Consumer side of the ring only (AC's main thread). Compiled
|
||||
// into tools\EngineRobustnessTests.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
||||
namespace RynthCore.Engine.Compatibility;
|
||||
|
||||
internal static class CastStopRules
|
||||
{
|
||||
/// <summary>
|
||||
/// True when any entry in <paramref name="ring"/> was queued at or before
|
||||
/// <paramref name="castQueuedAt"/> (by <paramref name="queuedAt"/>) and is a movement stop
|
||||
/// (by <paramref name="isStop"/>). Pass static lambdas: nothing is allocated per call.
|
||||
/// </summary>
|
||||
public static bool AnyStopAtOrBefore<T>(ActionRing<T> ring, long castQueuedAt,
|
||||
Func<T, long> queuedAt, Func<T, bool> isStop) where T : struct
|
||||
{
|
||||
int count = ring.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (!ring.TryPeekAt(i, out T e)) break;
|
||||
if (queuedAt(e) <= castQueuedAt && isStop(e)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue