forked from frankc123/RustSource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LightStyleCurve.cs
47 lines (39 loc) · 1.34 KB
/
LightStyleCurve.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using UnityEngine;
public class LightStyleCurve : LightStyle
{
[SerializeField]
private AnimationCurve curve;
protected override LightStyle.Simulation ConstructSimulation(LightStylist stylist)
{
return new Simulation(this);
}
protected override bool DeconstructSimulation(LightStyle.Simulation simulation)
{
return true;
}
private float GetCurveValue(double relativeStartTime)
{
return this.curve.Evaluate((float) relativeStartTime);
}
protected class Simulation : LightStyle.Simulation<LightStyleCurve>
{
private float? lastValue;
public Simulation(LightStyleCurve creator) : base(creator)
{
this.lastValue = null;
}
protected override void Simulate(double currentTime)
{
float curveValue = base.creator.GetCurveValue(currentTime - base.startTime);
if (!this.lastValue.HasValue || (this.lastValue.Value != curveValue))
{
this.lastValue = new float?(curveValue);
for (LightStyle.Mod.Element element = LightStyle.Mod.Element.Red; element < (LightStyle.Mod.Element.SpotAngle | LightStyle.Mod.Element.Green); element += 1)
{
this.mod[element] = this.lastValue;
}
}
}
}
}