public static int IntRange(IItemSeed context, short StatID, int min, int max) { int value = Mathf.RoundToInt(Mathf.Lerp((float)min, (float)max, Value(context, StatID))); if (value == max + 1) { return(max); } return(value); }
public static float Value(IItemSeed context, short StatID) { if (StatID < 0) { int negativeIDs = 1 + StatID; foreach (float[] overrides in context.NegativeOverrides) { if (overrides == null) { continue; } if (overrides.Length > negativeIDs) { return(overrides[negativeIDs]); } } return(0.0f); } foreach (float[] overrides in context.PositiveOverrides) { if (overrides == null) { continue; } if (overrides.Length > StatID) { return(overrides[StatID]); } } int seed = (context.Seed.Value << 16) + StatID; var rand = new System.Random(seed); return((float)rand.NextDouble()); }
public static float FloatRange(IItemSeed context, short StatID, float min, float max) { return(Mathf.Lerp((float)min, (float)max, Value(context, StatID))); }