RoR2-ChensHelpers

Contains simple and useful helpers for RoR2 mod creators to use. Mainly caters to Chen's mods.

View on GitHub

ChensHelpers

Chen.Helpers.MathHelpers.Arithmetic

Arithmetic.Sum(int[], Func<int,int>) Method

Adds all the values contained in the array. Preprocessing each item is possible before they are computed by providing the logic.
e.g. Sum(new int[] { 2, -4, 1 }, item => Mathf.Max(0, item)) will yield a result of 3.

public static int Sum(this int[] numbers, System.Func<int,int> preProcess=null);

Parameters

numbers System.Int32[]
Array of numbers

preProcess System.Func<System.Int32,System.Int32>
Preprocessor code

Returns

System.Int32
Sum of the values in the array