Firstborn/Assets/AwesomeTechnologies/VegetationStudioPro/Runtime/VegetationSystemPro/Wind/TreeCreatorWindController.cs
Schaken-Mods 959e80cf72 assets upload
assets upload description.
2023-03-28 12:16:30 -05:00

61 lines
1.6 KiB
C#

using UnityEngine;
namespace AwesomeTechnologies.VegetationSystem.Wind
{
public class TreeCreatorWindController : IWindController
{
public string WindControlerID { get; }
private WindControllerSettings _windControllerSettings;
private int _wind;
public WindControllerSettings Settings
{
get { return _windControllerSettings; }
set
{
_windControllerSettings = value;
RefreshSettings();
}
}
public TreeCreatorWindController()
{
WindControlerID = "TreeCreatorWindController";
_wind = Shader.PropertyToID("_Wind");
}
public WindControllerSettings CreateDefaultSettings()
{
Settings = new WindControllerSettings
{
WindControlerID = WindControlerID,
Heading = "Tree creator wind"
};
return Settings;
}
public void RefreshSettings()
{
}
public void UpdateWind(WindZone windZone, float windSpeedFactor)
{
Vector3 dir = Vector3.forward;
Vector4 dir4;
if (windZone)
{
dir = windZone.transform.forward;
dir4 = new Vector4(dir.x, dir.y, dir.z, Mathf.Abs(windZone.windMain) * windSpeedFactor);
}
else
{
dir4 = new Vector4(dir.x, dir.y, dir.z, windSpeedFactor);
}
Shader.SetGlobalVector(_wind,dir4);
}
}
}