You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.6 KiB
C#
90 lines
2.6 KiB
C#
using UnityEngine;
|
|
|
|
namespace Fusion.Addons.SimpleKCC
|
|
{
|
|
internal sealed class SmoothVector2 : SmoothValue<Vector2>
|
|
{
|
|
public SmoothVector2(int records)
|
|
: base(records)
|
|
{
|
|
}
|
|
|
|
public void FilterValues(bool positiveX, bool negativeX, bool positiveY, bool negativeY)
|
|
{
|
|
SmoothItem<Vector2>[] items = base.Items;
|
|
if (positiveX)
|
|
{
|
|
int i = 0;
|
|
for (int num = items.Length; i < num; i++)
|
|
{
|
|
SmoothItem<Vector2> smoothItem = items[i];
|
|
if (smoothItem.Value.x > 0f)
|
|
{
|
|
smoothItem.Value.x = 0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (negativeX)
|
|
{
|
|
int j = 0;
|
|
for (int num2 = items.Length; j < num2; j++)
|
|
{
|
|
SmoothItem<Vector2> smoothItem = items[j];
|
|
if (smoothItem.Value.x < 0f)
|
|
{
|
|
smoothItem.Value.x = 0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (positiveY)
|
|
{
|
|
int k = 0;
|
|
for (int num3 = items.Length; k < num3; k++)
|
|
{
|
|
SmoothItem<Vector2> smoothItem = items[k];
|
|
if (smoothItem.Value.y > 0f)
|
|
{
|
|
smoothItem.Value.y = 0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!negativeY)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int l = 0;
|
|
for (int num4 = items.Length; l < num4; l++)
|
|
{
|
|
SmoothItem<Vector2> smoothItem = items[l];
|
|
if (smoothItem.Value.y < 0f)
|
|
{
|
|
smoothItem.Value.y = 0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override Vector2 GetDefaultValue()
|
|
{
|
|
return Vector2.zero;
|
|
}
|
|
|
|
protected override Vector2 AccumulateValue(Vector2 accumulatedValue, Vector2 value, double scale)
|
|
{
|
|
accumulatedValue.x = (float)((double)accumulatedValue.x + (double)value.x * scale);
|
|
accumulatedValue.y = (float)((double)accumulatedValue.y + (double)value.y * scale);
|
|
return accumulatedValue;
|
|
}
|
|
|
|
protected override Vector2 GetSmoothValue(Vector2 accumulatedValue, double scale)
|
|
{
|
|
accumulatedValue.x = (float)((double)accumulatedValue.x * scale);
|
|
accumulatedValue.y = (float)((double)accumulatedValue.y * scale);
|
|
return accumulatedValue;
|
|
}
|
|
}
|
|
}
|