Click or drag to resize

GeneratorApplyTSource Method

Makes a generator that applies a function on the elements it generates.

Namespace:  Gamelogic.Extensions.Algorithms
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
C#
public static IGenerator<TSource> Apply<TSource>(
	this IGenerator<TSource> generator,
	Action<TSource> action
)

Parameters

generator
Type: Gamelogic.Extensions.AlgorithmsIGeneratorTSource
The source generator.
action
Type: SystemActionTSource
The action to apply to generated elements.

Type Parameters

TSource
The type of the elements to generate.

Return Value

Type: IGeneratorTSource
A new generator.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IGeneratorTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
ArgumentNullExceptiongenerator is $(null).
ArgumentNullExceptionaction is $(null).
Examples
The following will generate a generator that generates 0 1 2 3 0 1 2 ... and print the values to the console.
var generator = Generator.Count(4).Apply((x) => {Debug.Log(x);});
The following will generate a monster, and sets its properties based on the player's current level:
var monsterGenerator = Generator
    .Constant(monsterTemplate)
    .Apply(m => m.SetProperties(GetPlayerLevel());
See Also