namespace ICRebuild.Core; public sealed record DungeonSnapshot(bool Valid, uint Territory, byte DungeonId, int Floor) { public static readonly DungeonSnapshot Empty = new(false, 0, 0, 0); public bool SpecialFloor => Valid && (Floor % 10 == 0 || (Floor == 99 && Territory is 1108 or 1290)); public string Description => !Valid ? "不在有效深层迷宫实例中" : $"区域 {Territory} · 迷宫 {DungeonId} · {Floor} 层 · {(SpecialFloor ? "特殊层" : "普通层")}"; } public static class Policies { public static float FiniteClamp(float value, float min, float max, float fallback = 0) => float.IsFinite(value) ? Math.Clamp(value, min, max) : Math.Clamp(fallback, min, max); public static float HeightDelta(bool ready, bool dungeonOnly, DungeonSnapshot dungeon, float amount) => !ready || (dungeonOnly && (!dungeon.Valid || dungeon.Floor <= 0 || dungeon.SpecialFloor)) ? 0 : FiniteClamp(amount, -10, 10); public static bool BlockTimeline(uint timeline, IReadOnlySet list, bool blockListed) => list.Count > 0 && (blockListed ? list.Contains(timeline) : !list.Contains(timeline)); public static bool IsMudra(int id) => id>=0 && NativeIds.MudraActions.Contains((uint)id); public static uint FallFlags(uint flags) => (flags & 0b11100000000) == 0 ? flags : (flags & ~0b11100000000u) | 2u; }