public void NormalizeAngle() { X = ExtraMath.Clamp(X, -89, 89); while (Y < -180) { Y += 360; } while (Y > 180) { Y -= 360; } }
/// <summary> /// Creates a new instance of the <see cref="ConsoleLogger"/> class with a specified output type. /// </summary> /// <param name="type"> The output type of the logger. </param> /// <param name="suppressConsoleResize"> Whether to suppress the console buffer from getting resized. </param> public ConsoleLogger(LogOutputType type = LogOutputType.ThreadTime, bool suppressConsoleResize = false) { Log.AddLogger(this); this.type = type; if (hndlr == null) { AddConsoleHandle(hndlr += OnConsoleExit); } if (!suppressConsoleResize) { BufferHeight = ExtraMath.Clamp(BufferHeight << 2, MIN_SIZE, MAX_SIZE); BufferWidth = ExtraMath.Clamp(BufferWidth << 2, MIN_SIZE, MAX_SIZE); } }
private void UpdateByValue(Item item, int value) { Logger.Log(string.Format("Updating by value={0}: name={1}, sellin={2}, startQuality={3}", value, item.Name, item.SellIn, item.Quality)); int calculatedQuality = item.Quality + value; if (item.SellIn <= 0) { calculatedQuality = item.Quality + 2 * value; } item.Quality = ExtraMath.Clamp(0, calculatedQuality, 50); item.SellIn--; Logger.Log(string.Format("Updated by value={0} parameters: name={1}, sellin={2}, startQuality={3}", value, item.Name, item.SellIn, item.Quality)); }
public void Clamp() { X = ExtraMath.Clamp(X, -89, 89); Y = ExtraMath.Clamp(Y, -180, 180); Z = 0; }
public void ClampMinTest() { Assert.Equal(ExtraMath.Clamp(0, -10, 50), 0); }
public void ClampInRangeTest() { Assert.Equal(ExtraMath.Clamp(0, 20, 50), 20); }
public void ClampMaxTest() { Assert.Equal(ExtraMath.Clamp(0, 60, 50), 50); }