using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; using Verse; namespace Rimworld_Animations_Patch { public static class MathUtility { public static float Repeat(float value, float min, float max) { if (Mathf.Abs(max) < Mathf.Abs(min)) { Log.Error("RepeatDual: min value must be greater than max value"); return -1; } float range = max - min; float m = value % range; if (m < 0) { m = range + m; } return min + m; } public static IntVec3 FindRandomCellNearPawn(Pawn pawn, int maxRadius) { if (maxRadius > 0) { for (int radius = 1; radius < maxRadius; radius++) { List cells = GenRadial.RadialCellsAround(pawn.Position, radius + 0.75f, false).Where(x => x.Standable(pawn.Map) && x.GetRoom(pawn.Map) == pawn.GetRoom())?.ToList(); if (cells.NullOrEmpty() == false && cells.Count > 0) { return cells.RandomElement(); } } } return GenAdj.RandomAdjacentCellCardinal(pawn); } } }