public static void BiomeSurfaceGraphValidGraphOutOfBounds() { var graph = new BiomeSurfaceGraph(); graph.BuildGraph(GenerateValidBiomeSurfaces()); var surface10 = graph.GetSurface(-10); var surface99 = graph.GetSurface(99); Assert.That(surface10 == null); Assert.That(surface99 == null); }
public static void BiomeSurfaceGraphValidGraphBounds() { var graph = new BiomeSurfaceGraph(); graph.BuildGraph(GenerateValidBiomeSurfaces()); var surface0 = graph.GetSurface(0); var surface40 = graph.GetSurface(40); var surface20 = graph.GetSurface(20, 30); Assert.That(surface0.name == "3"); Assert.That(surface40.name == "4" || surface40.name == "5"); Assert.That(surface20.name == "4" || surface20.name == "5"); }
public static void BiomeSurfaceGraphInvalidHoleGraph() { var graph = new BiomeSurfaceGraph(); bool valid = graph.BuildGraph(GenerateInvalidHoleBiomeSurfaces()); Assert.That(valid == false); var surface10 = graph.GetSurface(10); var surface35 = graph.GetSurface(35); var surface41 = graph.GetSurface(41); Assert.That(surface10 == null); Assert.That(surface35 == null); Assert.That(surface41 == null); }
public static void BiomeSurfaceGraphValidGraph() { var graph = new BiomeSurfaceGraph(); graph.BuildGraph(GenerateValidBiomeSurfaces()); var surface1 = graph.GetSurface(1, 1); var surface21 = graph.GetSurface(21, 1); var surface41 = graph.GetSurface(41, 90); var surface22 = graph.GetSurface(22, 50); Assert.That(surface1.name == "3"); Assert.That(surface21.name == "4"); Assert.That(surface22.name == "5"); Assert.That(surface41.name == "2"); }
public void OnEnable() { switchList = new ReorderableList(surfaceSwitches, typeof(BiomeSurfaceSwitch)); switchList.drawElementCallback = (rect, index, active, focused) => { var sSwitch = surfaceSwitches[index]; Rect stateRect = rect; stateRect.height = EditorGUIUtility.singleLineHeight; stateRect.width = 100; float defaultX = stateRect.x; EditorGUIUtility.labelWidth = 50; { sSwitch.surface.name = EditorGUI.TextField(stateRect, sSwitch.surface.name); stateRect.x += 120; sSwitch.surface.color.baseColor = EditorGUI.ColorField(stateRect, sSwitch.surface.color.baseColor); } stateRect.y += EditorGUIUtility.singleLineHeight; stateRect.x = defaultX; { sSwitch.heightEnabled = EditorGUI.Toggle(stateRect, "Height", sSwitch.heightEnabled); if (sSwitch.heightEnabled) { stateRect.x += 120; sSwitch.minHeight = EditorGUI.FloatField(stateRect, "min", sSwitch.minHeight); stateRect.x += 120; sSwitch.maxHeight = EditorGUI.FloatField(stateRect, "max", sSwitch.maxHeight); } } stateRect.y += EditorGUIUtility.singleLineHeight; stateRect.x = defaultX; { sSwitch.slopeEnabled = EditorGUI.Toggle(stateRect, "Slope", sSwitch.slopeEnabled); if (sSwitch.slopeEnabled) { stateRect.x += 120; sSwitch.minSlope = EditorGUI.FloatField(stateRect, "min", sSwitch.minSlope); stateRect.x += 120; sSwitch.maxSlope = EditorGUI.FloatField(stateRect, "max", sSwitch.maxSlope); } } stateRect.y += EditorGUIUtility.singleLineHeight; stateRect.x = defaultX; { sSwitch.paramEnabled = EditorGUI.Toggle(stateRect, "Param", sSwitch.paramEnabled); if (sSwitch.paramEnabled) { stateRect.x += 120; sSwitch.minParam = EditorGUI.FloatField(stateRect, "min", sSwitch.minParam); stateRect.x += 120; sSwitch.maxParam = EditorGUI.FloatField(stateRect, "max", sSwitch.maxParam); } } }; switchList.onAddCallback = (list) => { var newSwitch = new BiomeSurfaceSwitch(); newSwitch.surface.color = new BiomeSurfaceColor(); newSwitch.surface.color.baseColor = Random.ColorHSV(); surfaceSwitches.Add(newSwitch); }; switchList.elementHeight = EditorGUIUtility.singleLineHeight * 4; if (surfaceSwitches.Count > 0) { biomeSurfaceGraph.BuildGraph(surfaceSwitches); } }
void UpdateGraph() { surfaceGraph.BuildGraph(inputSurfaces.GetValuesWithoutNull()); }