using UnityEngine; namespace Mtree { public class BranchFunction : TreeFunctionAsset { public float length = 7f; public AnimationCurve lengthCurve = AnimationCurve.Linear(0f, 1f, 1f, 0.8f); public float resolution = 1f; public int number = 30; public float splitProba = 0.1f; public float angle = 0.7f; public AnimationCurve shape = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f); public AnimationCurve splitProbaCurve = AnimationCurve.Linear(0f, 0.5f, 1f, 1f); public float radius = 0.6f; public float randomness = 0.25f; public float upAttraction = 0.5f; public float start = 0.2f; public float gravityStrength = 0.1f; public override void Init(TreeFunctionAsset parent, bool preserveSettings = false) { base.Init(parent); base.name = "Branch"; if (parent != null && !(parent is TrunkFunction) && !preserveSettings) { length = 3f; start = 0.3f; angle = 0.4f; number = 120; resolution = 1f; splitProba = 0.3f; radius = 0.8f; shape = AnimationCurve.Linear(0f, 1f, 1f, 0.1f); randomness = 0.4f; gravityStrength = 1f; } } public override void DrawProperties() { } public override void Execute(MTree tree) { base.Execute(tree); Random.InitState(seed); int selection = ((!(parent == null)) ? parent.id : 0); tree.AddBranches(selection, length, lengthCurve, resolution, number, splitProba, splitProbaCurve, angle, randomness, shape, radius, upAttraction, id, start, gravityStrength, 0f, 0.001f); } } }