Skip to content

Commit

Permalink
Add Random Alpha updater
Browse files Browse the repository at this point in the history
  • Loading branch information
rob5300 committed Apr 6, 2022
1 parent 91fe8fb commit f361df2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
new RandomColorUpdater(),
new RandomLifeTimeUpdater(),
new RandomRadiusUpdater(),
new RandomSequenceUpdater()
new RandomSequenceUpdater(),
new RandomAlphaUpdater()
};

Console.WriteLine("Enter folder to update files in:");
Expand Down
45 changes: 45 additions & 0 deletions Updaters/RandomAlphaUpdater.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KeyValue3Updater.Updaters
{
internal class RandomAlphaUpdater : Updater
{
public RandomAlphaUpdater()
{
findRegex = GetBlockRegex("C_INIT_RandomAlpha");
}

protected override string GetReplacement(string input)
{
var alphaMin = GetLineValue(GetLine(ref input, "m_nAlphaMin")) / 255f;
var alphaMax = GetLineValue(GetLine(ref input, "m_nAlphaMax")) / 255f;
var m_flOpStartFadeInTime = GetLineValue(GetLine(ref input, "m_flOpStartFadeInTime"));
var m_flOpEndFadeInTime = GetLineValue(GetLine(ref input, "m_flOpEndFadeInTime"));
var m_flOpStartFadeOutTime = GetLineValue(GetLine(ref input, "m_flOpStartFadeOutTime"));
var m_flOpEndFadeOutTime = GetLineValue(GetLine(ref input, "m_flOpEndFadeOutTime"));
var m_flOpFadeOscillatePeriod = GetLineValue(GetLine(ref input, "m_flOpFadeOscillatePeriod"));

string replacement = @"{{
_class = ""C_INIT_InitFloat""
m_InputValue =
{{
m_nType = ""PF_TYPE_RANDOM_UNIFORM""
m_flRandomMin = {0}
m_flRandomMax = {1}
}}
m_nOutputField = ""7""
m_flOpStartFadeInTime = {2}
m_flOpEndFadeInTime = {3}
m_flOpStartFadeOutTime = {4}
m_flOpEndFadeOutTime = {5}
m_flOpFadeOscillatePeriod = {6}
}},";

return string.Format(replacement, alphaMin, alphaMax, m_flOpStartFadeInTime, m_flOpEndFadeInTime, m_flOpStartFadeOutTime, m_flOpEndFadeOutTime, m_flOpFadeOscillatePeriod);
}
}
}

0 comments on commit f361df2

Please sign in to comment.