EvolvingNatFloat: Difference between revisions
From Vintage Story Wiki
m (Updated navbox to new code navbox.) |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{GameVersion|1.19.3}} | |||
= EvolvingNatFloat = | = EvolvingNatFloat = | ||
A number generator whose return value changes over time according to a transform and factor.<br> | A number generator whose return value changes over time according to a transform and factor.<br> | ||
Each sequential value is retrieved according to the first value and the sequence number. | Each sequential value is retrieved according to the first value and the sequence number. | ||
To use EvolvingNatFloat, add the using statement for '''Vintagestory.API.MathTools'''.<br> | To use EvolvingNatFloat, add the using statement for '''Vintagestory.API.MathTools'''.<br>'''''Important note''': The value of sequence should always satisfy '''sequence >= 0''''' | ||
'''''Important note''': The value of sequence should always satisfy '''sequence >= 0''''' | |||
== Example in code == | == Example in code == | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
using Vintagestory.API.MathTools; | using Vintagestory.API.MathTools; | ||
class | public class EvolvingNatFloatMod : ModSystem | ||
{ | { | ||
EvolvingNatFloat evolve; | public override void StartServerSide(ICoreServerAPI api) | ||
{ | |||
float factor = 1; | |||
EvolvingNatFloat evolve; | |||
evolve = new EvolvingNatFloat( | |||
EnumTransformFunction.CLAMPEDPOSITIVESINUS, | |||
factor | |||
); | |||
float firstValue = 5; | |||
for (float sequence = firstValue; sequence < 100; sequence++) | |||
{ | |||
// Retrieve each sequential value | |||
float y = evolve.nextFloat(firstValue, sequence); | |||
} | |||
} | } | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 88: | Line 89: | ||
For every representation except smoothstep, linearnullify, the '''initalValue = 1'''<br> | For every representation except smoothstep, linearnullify, the '''initalValue = 1'''<br> | ||
[[File:Txtpositiveclampedsinus.png| | [[File:Txtpositiveclampedsinus.png|180px]] | ||
[[File:Txtcosinus.png| | [[File:Txtcosinus.png|180px]] | ||
[[File:Txtidentical.png| | [[File:Txtidentical.png|180px]] | ||
[[File:Txtinverselinear.png| | [[File:Txtinverselinear.png|180px]]<br><br> | ||
[[File:Txtlinear.png| | [[File:Txtlinear.png|180px]] | ||
[[File:Txtlinearincrease.png| | [[File:Txtlinearincrease.png|180px]] | ||
[[File:TxtlinearnullifyFirstValMinusFive.png| | [[File:TxtlinearnullifyFirstValMinusFive.png|180px]] | ||
[[File:Txtlinearreduce.png| | [[File:Txtlinearreduce.png|180px]]<br><br> | ||
[[File:Txtquadratic.png| | [[File:Txtquadratic.png|180px]] | ||
[[File:Txtroot.png| | [[File:Txtroot.png|180px]] | ||
[[File:Txtsinus.png| | [[File:Txtsinus.png|180px]] | ||
[[File:Txtsmoothstep.png| | [[File:Txtsmoothstep.png|180px]] | ||
{{Navbox/codemodding}} |
Latest revision as of 17:07, 27 March 2024
This page was last verified for Vintage Story version 1.19.3.
EvolvingNatFloat
A number generator whose return value changes over time according to a transform and factor.
Each sequential value is retrieved according to the first value and the sequence number.
To use EvolvingNatFloat, add the using statement for Vintagestory.API.MathTools.
Important note: The value of sequence should always satisfy sequence >= 0
Example in code
using Vintagestory.API.MathTools;
public class EvolvingNatFloatMod : ModSystem
{
public override void StartServerSide(ICoreServerAPI api)
{
float factor = 1;
EvolvingNatFloat evolve;
evolve = new EvolvingNatFloat(
EnumTransformFunction.CLAMPEDPOSITIVESINUS,
factor
);
float firstValue = 5;
for (float sequence = firstValue; sequence < 100; sequence++)
{
// Retrieve each sequential value
float y = evolve.nextFloat(firstValue, sequence);
}
}
}
Transform variants
Overview | |
---|---|
Name | Explanation |
clampedpositivesinus | Clamped positive sine wave function. |
cosinus | Cosine wave function. |
identical | Identical to first value. |
inverselinear | Linear change in the direction of the first value. |
linearnullify | Linear change towards zero, then clamp at zero. |
linearreduce | Linear change in the opposite direction of the first value. |
quadratic | Quadratic function. |
root | Root function. |
sinus | Sine wave function. |
smoothstep | Smooth step function. |
Visual representation
For every representation except smoothstep, the factor = 1
For every representation except smoothstep, linearnullify, the initalValue = 1
Code Modding | |||||||
---|---|---|---|---|---|---|---|
Basics | Code Mods • Preparing For Code Mods • Creating A Code Mod | ||||||
Tutorials |
|
||||||
Advanced | Server-Client Considerations • Setting up your Development Environment • Advanced Blocks • Advanced Items • Block and Item Interactions • Block Behavior • Block Entity • Particle Effects • World Access • Inventory Handling • Commands • GUIs • Network API • Monkey patching (Harmony) | ||||||
Data Management | Savegame Data Storage • ModConfig File • Chunk Data Storage • TreeAttribute | ||||||
Worldgen | WorldGen API • NatFloat • EvolvingNatFloat | ||||||
Rendering | Shaders and Renderers |
Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.
Modding | |
---|---|
Modding Introduction | Getting Started • Theme Pack |
Content Modding | Content Mods • Developing a Content Mod • Basic Tutorials • Intermediate Tutorials • Advanced Tutorials • Content Mod Concepts |
Code Modding | Code Mods • Setting up your Development Environment |
Property Overview | Item • Entity • Block • Block Behaviors • Block Classes • Block Entities • Block Entity Behaviors • World properties |
Workflows & Infrastructure | Modding Efficiency Tips • Mod-engine compatibility • Mod Extensibility • VS Engine |
Additional Resources | Community Resources • Modding API Updates • Programming Languages • List of server commands • List of client commands • Client startup parameters • Server startup parameters Example Mods • API Docs • GitHub Repository |