public TreeNode(TreeSettings aSettings, List <TreePoint> aPoints, int aDepth)
            {
                int axis = aSettings.GetAxis(aDepth);

                if (axis == 0)
                {
                    aPoints.Sort(sortX);
                }
                else if (axis == 1)
                {
                    aPoints.Sort(sortY);
                }
                else if (axis == 2)
                {
                    aPoints.Sort(sortZ);
                }

                int median = aPoints.Count / 2;

                point = aPoints[median];

                List <TreePoint> leftList  = aPoints.GetRange(0, median);
                List <TreePoint> rightList = aPoints.GetRange(median + 1, aPoints.Count - (median + 1));

                if (leftList.Count > 0)
                {
                    left = new TreeNode(aSettings, leftList, aDepth + 1);
                }
                if (rightList.Count > 0)
                {
                    right = new TreeNode(aSettings, rightList, aDepth + 1);
                }
            }
            public void Draw(TreeSettings aSettings, int aDepth, Vector3 aPt)
            {
                int axis = aSettings.GetAxis(aDepth);

                if (axis == 0)
                {
                    Gizmos.color = Color.red;
                    Gizmos.DrawLine(point.point + Vector3.left, point.point + Vector3.right);
                }
                else if (axis == 1)
                {
                    Gizmos.color = Color.green;
                    Gizmos.DrawLine(point.point + Vector3.up, point.point + Vector3.down);
                }
                else if (axis == 2)
                {
                    Gizmos.color = Color.blue;
                    Gizmos.DrawLine(point.point + Vector3.forward, point.point + Vector3.back);
                }

                if (left != null)
                {
                    left.Draw(aSettings, aDepth + 1, point.point);
                    Gizmos.color = point.data;
                    Gizmos.DrawLine(point.point, left.point.point);
                }
                if (right != null)
                {
                    right.Draw(aSettings, aDepth + 1, point.point);
                    Gizmos.color = point.data;
                    Gizmos.DrawLine(point.point, right.point.point);
                }
            }
 internal override void doExpand(TreeNode myNode, EbxDataContainers ebx, TreeSettings settings)
 {
     foreach (var childField in astruct.fields)
     {
         myNode.Nodes.Add(processField(childField.Key, childField.Value, ebx, settings));
     }
 }
            public void GetNearest(TreeSettings aSettings, int aDepth, Vector3 aPt, ref TreePoint aClosest, ref float aClosestDist)
            {
                if (IsLeaf)
                {
                    float dist = (point.point - aPt).sqrMagnitude;
                    if (aClosest == null || dist < aClosestDist)
                    {
                        aClosest     = point;
                        aClosestDist = dist;
                    }
                    return;
                }

                int  axis   = aSettings.GetAxis(aDepth);
                bool goLeft = false;

                if (axis == 0)
                {
                    goLeft = aPt.x <= point.point.x ? true : false;
                }
                else if (axis == 1)
                {
                    goLeft = aPt.y <= point.point.y ? true : false;
                }
                else if (axis == 2)
                {
                    goLeft = aPt.z <= point.point.z ? true : false;
                }

                TreeNode first = goLeft ? left : right;
                TreeNode other = goLeft ? right: left;

                if (first == null)
                {
                    first = other;
                    other = null;
                }

                first.GetNearest(aSettings, aDepth + 1, aPt, ref aClosest, ref aClosestDist);

                float thisDist = (point.point - aPt).sqrMagnitude;

                if (thisDist < aClosestDist)
                {
                    aClosest     = point;
                    aClosestDist = thisDist;
                }

                if (other != null)
                {
                    float axisDist = aSettings.AxisDist(axis, point.point, aPt);
                    if (axisDist * axisDist <= aClosestDist)
                    {
                        other.GetNearest(aSettings, aDepth + 1, aPt, ref aClosest, ref aClosestDist);
                    }
                }
            }
Beispiel #5
0
        public Trees(Vector2 meshCenter, TreeSettings treeSettings, ClearingSettings clearingSettings)
        {
            _meshCenter       = new Vector3(meshCenter.x, 0, meshCenter.y);
            _treeSettings     = treeSettings;
            _clearingSettings = clearingSettings;

            _trees      = new GameObject[0];
            _treePoints = new Vector3[0];
        }
            internal override void doExpand(TreeNode myNode, EbxDataContainers ebx, TreeSettings settings)
            {
                var elements = aarray.elements;

                for (int idx = 0; idx < elements.Count; idx++)
                {
                    myNode.Nodes.Add(processField(idx.ToString(), elements[idx], ebx, settings));
                }
            }
        protected internal virtual TreeSettings CreateNavigationSettings()
        {
            var navigationSettings = new TreeSettings
            {
                IndicateActiveContent = true
            };

            navigationSettings.Filters.Add(this.ContentFacade.Filters.NavigationFilter);

            return(navigationSettings);
        }
            internal override void doExpand(TreeNode myNode, EbxDataContainers ebx, TreeSettings settings)
            {
                foreach (var container in containers)
                {
                    AStruct dataRoot = settings.flattened ? ebx.getFlattenedDataFor(container.guid) : container.data;

                    var fieldName = settings.showGuids ? container.guid : "";
                    var tnode     = processField(fieldName, dataRoot, ebx, settings);
                    myNode.Nodes.Add(tnode);
                    guidToTreeNode.Add(container.guid, tnode);
                }
            }
Beispiel #9
0
        public TerrainChunk(Vector2 coord, HeightMapSettings heightMapSettings,
                            MeshSettings meshSettings, TreeSettings treeSettings,
                            LevelSettings levelSettings, ClearingSettings clearingSettings, LODInfo[] detailLevels,
                            int colliderLODIndex, Transform parent, Transform viewer, Material material,
                            bool createEnemies)
        {
            this.coord = coord;

            _droidsRequested     = !createEnemies;
            _meshDatSentForTower = !createEnemies;

            _detailLevels      = detailLevels;
            _prevLODIndex      = -1;
            _colliderLODIndex  = colliderLODIndex;
            _heightMapSettings = heightMapSettings;
            _meshSettings      = meshSettings;
            _viewer            = viewer;

            _sampleCenter = coord * meshSettings.meshWorldSize / meshSettings.meshScale;
            var position = coord * meshSettings.meshWorldSize;

            _bounds = new Bounds(position, Vector2.one * meshSettings.meshWorldSize);

            _meshObject = new GameObject("Terrain Chunk");
            _meshObject.transform.position = new Vector3(position.x, 0, position.y);
            _meshObject.transform.SetParent(parent);
            _meshObject.layer = 11;
            _meshObject.tag   = TagManager.Terrain;

            _meshRenderer          = _meshObject.AddComponent <MeshRenderer>();
            _meshRenderer.material = material;
            _meshFilter            = _meshObject.AddComponent <MeshFilter>();
            _meshCollider          = _meshObject.AddComponent <MeshCollider>();

            _chunkTrees           = new Trees(position, treeSettings, clearingSettings);
            _terrainInteractibles = new TerrainInteractiblesCreator(position, _meshObject.transform,
                                                                    levelSettings, clearingSettings);

            SetVisible(false);

            _lodMeshes = new LODMesh[detailLevels.Length];
            for (var i = 0; i < detailLevels.Length; i++)
            {
                _lodMeshes[i] = new LODMesh(detailLevels[i].lod);
                _lodMeshes[i].UpdateCallback += UpdateTerrainChunk;
                if (i == _colliderLODIndex)
                {
                    _lodMeshes[i].UpdateCallback += UpdateCollisionMesh;
                }
            }

            _maxViewDistance = detailLevels[detailLevels.Length - 1].visibleDistanceThreshold;
        }
Beispiel #10
0
        void Create(List <Vector3> aPoints, List <Color> aColors, bool aX, bool aY, bool aZ)
        {
            if (aPoints.Count != aColors.Count)
            {
                Debug.LogError("Arguments must be the same length!");
            }
            List <TreePoint> points = new List <TreePoint>(aPoints.Count);

            for (int i = 0; i < aPoints.Count; ++i)
            {
                points.Add(new TreePoint(aPoints[i], aColors[i]));
            }
            settings = new TreeSettings(aX, aY, aZ);
            root     = new TreeNode(settings, points, 0);
        }
        /// <summary>
        /// Converts the learned logic of the state space into a simple node based decision tree.
        /// </summary>
        /// <param name="treeSettings">Settings for defining tree creation.</param>
        /// <returns></returns>
        public TreeNode ToDecisionTree(TreeSettings treeSettings)
        {
            if (StateSpace.Count == 0)
            {
                return(new TreeNode("root", TreeNodeType.Root));
            }

            //Start with root state
            State rootState = StateSpace[0]; // 0 is the hashcode for a state with no features.

            TreeNode rootNode = new TreeNode("root", TreeNodeType.Root);

            ToDecisionTree(rootState, rootNode, treeSettings);

            return(rootNode);
        }
Beispiel #12
0
        private void InitializeSettings()
        {
            TreeNode general = new TreeNode(LanguageManager.GetText("GENERALSETTINGS", true));

            TreeSettings.Nodes.Add(general);

            TreeNode themes = new TreeNode(LanguageManager.GetText("THEMES", true));

            foreach (Theme theme in Themes.PresetList)
            {
                TreeNode node = new TreeNode(theme.Name);
                node.Tag = theme;
                themes.Nodes.Add(node);
            }
            TreeSettings.Nodes.Add(themes);
            TreeSettings.ExpandAll();
        }
Beispiel #13
0
        public static Vector3[] SelectTreePoints(Vector3[] vertices, int chunkSizeIndex,
                                                 Vector3 meshCenter, TreeSettings treeSettings, ClearingSettings clearingSettings)
        {
            var random          = new Random();
            var chunkSize       = MeshSettings.supportedChunkSizes[chunkSizeIndex];
            var totalTreePoints = Mathf.FloorToInt
                                      (random.Next(treeSettings.minTreesInMaxChunkSize, treeSettings.maxTreesInMaxChunkSize) /
                                      (float)MeshSettings.supportedChunkSizes[MeshSettings.supportedChunkSizes.Length - 1] *
                                      chunkSize);

            var selectedPoints = new Vector3[totalTreePoints];
            var index          = 0;
            var tileCenter     = clearingSettings.useOnlyCenterTile ? meshCenter : Vector3.zero;

            for (var i = 0; i < vertices.Length; i++)
            {
                if (clearingSettings.createClearing)
                {
                    var modifiedVertices = vertices[i] + tileCenter;

                    if (modifiedVertices.x > clearingSettings.clearingBottomLeft.x &&
                        modifiedVertices.z < clearingSettings.clearingTopRight.x &&
                        modifiedVertices.z > clearingSettings.clearingBottomLeft.y &&
                        modifiedVertices.z < clearingSettings.clearingTopRight.y)
                    {
                        continue;
                    }
                }

                var selectionProbability = (float)totalTreePoints / (vertices.Length - i);
                var randomValue          = (float)random.NextDouble();

                if (selectionProbability >= randomValue)
                {
                    selectedPoints[index] = vertices[i];
                    index           += 1;
                    totalTreePoints -= 1;
                }
            }

            return(selectedPoints);
        }
        void Create(List <Vector3> aPoints, List <Color> aColors, Matrix4x4?aTransform, bool aX, bool aY, bool aZ)
        {
            if (aPoints.Count != aColors.Count)
            {
                Debug.LogError("Arguments must be the same length!");
            }
            List <TreePoint> points = new List <TreePoint>(aPoints.Count);

            for (int i = 0; i < aPoints.Count; ++i)
            {
                Vector3 pt = aPoints[i];
                if (aTransform.HasValue)
                {
                    pt = aTransform.Value.MultiplyPoint(pt);
                }
                points.Add(new TreePoint(pt, aColors[i]));
            }
            settings = new TreeSettings(aX, aY, aZ);
            root     = new TreeNode(settings, points, 0);
        }
Beispiel #15
0
        private void ReadSettings(Uri location)
        {
            using (var reader = new StreamReader(location.LocalPath))
            {
                dynamic stuff = JsonConvert.DeserializeObject(reader.ReadToEnd());

                Settings = new TreeSettings
                {
                    Version            = stuff.version,
                    OctreeDir          = Path.GetDirectoryName(location.LocalPath) + @"\" + stuff.octreeDir + @"\r",
                    OverallPointNumber = stuff.points,

                    BoundingBox = new Rect3D
                    {
                        X     = stuff.boundingBox.lx,
                        Y     = stuff.boundingBox.lz,
                        Z     = stuff.boundingBox.ly,
                        SizeX = stuff.boundingBox.ux - stuff.boundingBox.lx.Value,
                        SizeY = stuff.boundingBox.uz - stuff.boundingBox.lz.Value,
                        SizeZ = stuff.boundingBox.uy - stuff.boundingBox.ly.Value
                    },

                    TightBoundingBox = new Rect3D
                    {
                        X     = stuff.tightBoundingBox.lx,
                        Y     = stuff.tightBoundingBox.lz,
                        Z     = stuff.tightBoundingBox.ly,
                        SizeX = stuff.tightBoundingBox.ux - stuff.tightBoundingBox.lx.Value,
                        SizeY = stuff.tightBoundingBox.uz - stuff.tightBoundingBox.lz.Value,
                        SizeZ = stuff.tightBoundingBox.uy - stuff.tightBoundingBox.ly.Value
                    },

                    Spacing           = stuff.spacing,
                    Scale             = stuff.scale,
                    HierarchyStepSize = stuff.hierarchyStepSize
                };
            }
        }
	public void PrepareTrees()
	{
		TreePlacement.TreeTextures = new List<TreeTextureSettings>();
		for(int index = 0; index < terrainData.splatPrototypes.Length; index++)
		{
			TreeTextureSettings s = new TreeTextureSettings();
			TreePlacement.TreeTextures.Add(s);
			foreach(TreePrototype tree in terrainData.treePrototypes)
			{
				TreeSettings t = new TreeSettings();
				t.Name = tree.prefab.name;
				t.IsUsed = false;
				s.Trees.Add(t);
			}
		}
		TreePlacement.TreeVariation = 0.2f;
		TreePlacement.TreeSize = 1.0f;
	}
Beispiel #17
0
        private void ReadSettings(Uri location)
        {
            using (var reader = new StreamReader(location.LocalPath))
            {
                dynamic stuff = JsonConvert.DeserializeObject(reader.ReadToEnd());

                Settings = new TreeSettings
                {
                    Version = stuff.version,
                    OctreeDir = Path.GetDirectoryName(location.LocalPath) + @"\" + stuff.octreeDir + @"\r",
                    OverallPointNumber = stuff.points,

                    BoundingBox = new Rect3D
                    {
                        X = stuff.boundingBox.lx,
                        Y = stuff.boundingBox.lz,
                        Z = stuff.boundingBox.ly,
                        SizeX = stuff.boundingBox.ux - stuff.boundingBox.lx.Value,
                        SizeY = stuff.boundingBox.uz - stuff.boundingBox.lz.Value,
                        SizeZ = stuff.boundingBox.uy - stuff.boundingBox.ly.Value
                    },

                    TightBoundingBox = new Rect3D
                    {
                        X = stuff.tightBoundingBox.lx,
                        Y = stuff.tightBoundingBox.lz,
                        Z = stuff.tightBoundingBox.ly,
                        SizeX = stuff.tightBoundingBox.ux - stuff.tightBoundingBox.lx.Value,
                        SizeY = stuff.tightBoundingBox.uz - stuff.tightBoundingBox.lz.Value,
                        SizeZ = stuff.tightBoundingBox.uy - stuff.tightBoundingBox.ly.Value
                    },

                    Spacing = stuff.spacing,
                    Scale = stuff.scale,
                    HierarchyStepSize = stuff.hierarchyStepSize
                };
            }
        }
        public void DrawTree()
        {
            TreeSettings settings = new TreeSettings(true, true, true);

            root.Draw(settings, 0, Vector3.zero);
        }
        private void ToDecisionTree(State currentState, TreeNode parentNode, TreeSettings treeSettings)
        {
            //Find best group of queries
            List <KeyValuePair <Query, double> > bestGroupQueries = currentState.GetAverageGroupQueries();

            //Filter queries. (expected value must be greater than the label's expected value)
            List <KeyValuePair <Query, double> > bestGroupQueriesFiltered = new List <KeyValuePair <Query, double> >();

            foreach (KeyValuePair <Query, double> queryPair in bestGroupQueries.ToList())
            {
                double queryExpectedReward = queryPair.Value;
                double labelExpectedReward = 0; //If label was never seen, then probability is zero.
                if (currentState.Labels.ContainsKey(queryPair.Key.Label))
                {
                    labelExpectedReward = currentState.Labels[queryPair.Key.Label];
                }

                if (queryExpectedReward > labelExpectedReward)
                {
                    bestGroupQueriesFiltered.Add(queryPair);
                }
            }

            //Check if all features can be queried. If not, remove all.
            if (!treeSettings.ShowBlanks)
            {
                List <FeatureValuePair> uniqueFeatures = bestGroupQueriesFiltered.Select(p => p.Key.Feature).Distinct().ToList();
                foreach (FeatureValuePair uniqueFeature in uniqueFeatures)
                {
                    if (uniqueFeature.Name.ToString() == "bruises")
                    {
                    }

                    //Find next state and modify node
                    int nextStateHashCode = currentState.GetHashCodeWith(uniqueFeature);
                    if (!StateSpace.ContainsKey(nextStateHashCode))
                    {
                        bestGroupQueriesFiltered.Clear();
                        break;
                    }
                }
            }

            //Create group node
            TreeNode groupNode = parentNode;

            if (bestGroupQueriesFiltered.Count > 0)
            {
                string groupName = bestGroupQueries.First().Key.Feature.Name;
                groupNode        = new TreeNode(groupName, TreeNodeType.Feature);
                groupNode.Parent = parentNode;
                parentNode.SubNodes.Add(groupNode);
            }

            //Add queries, as subnodes
            if (bestGroupQueriesFiltered.Count > 0)
            {
                foreach (FeatureValuePair uniqueFeature in bestGroupQueries.Select(p => p.Key.Feature).Distinct())
                {
                    //Create node
                    TreeNode valueNode = new TreeNode(uniqueFeature.Value, TreeNodeType.Value);

                    //Add group
                    groupNode.SubNodes.Add(valueNode);
                    valueNode.Parent = groupNode;

                    //Find next state and modify node
                    int nextStateHashCode = currentState.GetHashCodeWith(uniqueFeature);
                    if (StateSpace.ContainsKey(nextStateHashCode))
                    {
                        State nextState = StateSpace[nextStateHashCode];
                        ToDecisionTree(nextState, valueNode, treeSettings);
                    }
                }
            }

            //Add labels, as leaves
            if (bestGroupQueriesFiltered.Count == 0 || treeSettings.ShowSubScores)
            {
                foreach (var theLabel in currentState.Labels)
                {
                    object labelValue = theLabel.Key.Value;
                    double expReward  = theLabel.Value;

                    parentNode.Leaves.Add(new TreeLeaf(labelValue, expReward));
                }
            }

            //Order subnodes and leaves by value
            groupNode.SubNodes = groupNode.SubNodes.OrderBy(p => p.Name).ToList();
            groupNode.Leaves   = groupNode.Leaves.OrderBy(p => p.LabelValue).ToList();
            parentNode.Leaves  = parentNode.Leaves.OrderBy(p => p.LabelValue).ToList();
        }
 public CartoComponent(LiveSplitState state) : base(state)
 {
     memory   = new CartoMemory(logger);
     settings = new TreeSettings(state, Start, Reset, Options);
 }
        private void GenerateTrees()
        {
            float simplex1 = noise.GetSimplex(chunkPosX * .3f, chunkPosZ * .3f);
            float simplex2 = noise.GetSimplex(chunkPosX * 2f, chunkPosZ * 2f);
            float value    = (simplex1 + simplex2) / 2;

            if (value > 0)
            {
                int minpos = 4;
                int maxpos = ChunkSizeXZ - 5;

                NativeList <int2> treePositions = new NativeList <int2>(MaxTreesPerChunk, Allocator.Temp);
                for (int i = 0; i < MaxTreesPerChunk; i++)
                {
                    int x = random.NextInt(minpos, maxpos);
                    int z = random.NextInt(minpos, maxpos);

                    BiomeType biomeType = biomeTypes[Utils.BlockPosition2DtoIndex(x, z)];
                    // TODO: bool CanPlaceTree(BiomeType type)
                    if (biomeType != BiomeType.FOREST && biomeType != BiomeType.PLAINS)
                    {
                        continue;
                    }

                    bool doContinue = false;
                    for (int j = 0; j < treePositions.Length; j++)
                    {
                        int2 pos = treePositions[j];
                        if (math.sqrt((pos.x - x) * (pos.x - x) + (pos.y - x) * (pos.y - x)) < MinDistanceBetweenTrees)
                        {
                            doContinue = true;
                            break;
                        }
                    }
                    if (doContinue)
                    {
                        continue;
                    }

                    int y = ChunkSizeY - TreeHeightRange.x;
                    if (blockData[Utils.BlockPosition3DtoIndex(x, y, z)] != BlockType.AIR)
                    {
                        continue;       // continue if maxTerrainHeigth - minTreeHeigth hits ground
                    }
                    // find ground position
                    while (y > 0 && blockData[Utils.BlockPosition3DtoIndex(x, y, z)] == BlockType.AIR)
                    {
                        y--;
                    }

                    BlockType groundBlock = blockData[Utils.BlockPosition3DtoIndex(x, y, z)];
                    if (!WorldData.CanPlaceTree(groundBlock))
                    {
                        continue;       // continue if cant place tree on ground block
                    }
                    // add position to position list
                    treePositions.Add(new int2(x, z));

                    TreeSettings treeSettings = Trees.OakTree;
                    // place logs
                    int treeHeight = random.NextInt(treeSettings.TreeHeightRange.x, treeSettings.TreeHeightRange.y);
                    for (int j = 0; j < treeHeight; j++)
                    {
                        if (y + j < ChunkSizeY)
                        {
                            blockData[Utils.BlockPosition3DtoIndex(x, y + j, z)] = BlockType.OAK_LOG;
                        }
                    }

                    int treeTop = y + treeHeight - 1;
                    int index, xrange, zrange;

                    // <0, 1>
                    xrange = 1;
                    zrange = 1;
                    for (int _y = treeTop; _y <= treeTop + 1; _y++)
                    {
                        for (int _x = -xrange; _x <= xrange; _x++)
                        {
                            for (int _z = -zrange; _z <= zrange; _z++)
                            {
                                index = Utils.BlockPosition3DtoIndex(x + _x, _y, z + _z);
                                if (blockData[index] == BlockType.AIR)
                                {
                                    blockData[index] = BlockType.OAK_LEAVES;
                                }
                            }
                        }

                        // x- z-
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x - xrange, _y, z - zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                        // x- z+
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x - xrange, _y, z + zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                        // x+ z-
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x + xrange, _y, z - zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                        // x+ z+
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x + xrange, _y, z + zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                    }

                    // <-1, -2>
                    xrange = 2;
                    zrange = 2;
                    for (int _y = treeTop - 2; _y <= treeTop - 1; _y++)
                    {
                        for (int _x = -xrange; _x <= xrange; _x++)
                        {
                            for (int _z = -zrange; _z <= zrange; _z++)
                            {
                                index = Utils.BlockPosition3DtoIndex(x + _x, _y, z + _z);
                                if (blockData[index] == BlockType.AIR)
                                {
                                    blockData[index] = BlockType.OAK_LEAVES;
                                }
                            }
                        }

                        // x- z-
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x - xrange, _y, z - zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                        // x- z+
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x - xrange, _y, z + zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                        // x+ z-
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x + xrange, _y, z - zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                        // x+ z+
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x + xrange, _y, z + zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                    }

                    // <-3, -3>
                    xrange = 1;
                    zrange = 1;
                    for (int _y = treeTop - 3; _y <= treeTop - 3; _y++)
                    {
                        for (int _x = -xrange; _x <= xrange; _x++)
                        {
                            for (int _z = -zrange; _z <= zrange; _z++)
                            {
                                index = Utils.BlockPosition3DtoIndex(x + _x, _y, z + _z);
                                if (blockData[index] == BlockType.AIR)
                                {
                                    blockData[index] = BlockType.OAK_LEAVES;
                                }
                            }
                        }

                        // x- z-
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x - xrange, _y, z - zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                        // x- z+
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x - xrange, _y, z + zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                        // x+ z-
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x + xrange, _y, z - zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                        // x+ z+
                        if (random.NextBool() && AreTypesEqual(BlockType.OAK_LEAVES, x + xrange, _y, z + zrange, out index))
                        {
                            blockData[index] = BlockType.AIR;
                        }
                    }
                }
            }
        }
        private static TreeNode processField(String fieldName, AValue fieldValue, EbxDataContainers containers, TreeSettings settings)
        {
            TreeNode tnode = null;

            switch (fieldValue.Type)
            {
            case ValueTypes.SIMPLE:
                tnode = simpleFieldTNode(fieldName, fieldValue.castTo <ASimpleValue>().Val);
                break;

            case ValueTypes.NULL_REF:
                tnode = simpleFieldTNode(fieldName, "[null]");
                break;

            case ValueTypes.IN_REF:
                var aintref = fieldValue.castTo <AIntRef>();

                switch (aintref.refStatus)
                {
                case RefStatus.UNRESOLVED:
                    throw new Exception("At this point intrefs should be resolved!");

                case RefStatus.RESOLVED_SUCCESS:
                    if (settings.flatRefs)
                    {
                        var targetAStruct = settings.flattened
                                    ? containers.getFlattenedDataFor(aintref.instanceGuid)
                                    : containers.instances[aintref.instanceGuid].data;

                        tnode     = simpleFieldTNode(fieldName, targetAStruct.name);
                        tnode.Tag = new TNStructTag(targetAStruct);
                    }
                    else
                    {
                        tnode = simpleFieldTNode(fieldName, "INTREF");
                        var singletonContainerList = new List <DataContainer>();
                        singletonContainerList.Add(containers.instances[aintref.instanceGuid]);
                        tnode.Tag = new TNDataRootTag(singletonContainerList);
                    }
                    break;

                case RefStatus.RESOLVED_FAILURE:
                    tnode = simpleFieldTNode(fieldName, "Unresolved INTREF: " + aintref.instanceGuid);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                break;

            case ValueTypes.EX_REF:
                var aexref = fieldValue.castTo <AExRef>();

                var axrefStrRepr = settings.showGuids ? (aexref.instanceGuid + " ") : "";
                axrefStrRepr += (aexref.refStatus == RefStatus.RESOLVED_SUCCESS) ? $"[{aexref.refType}] {aexref.refName}" : "Unresolved";

                tnode = simpleFieldTNode(fieldName, axrefStrRepr);
                break;

            case ValueTypes.STRUCT:
                var astruct = fieldValue.castTo <AStruct>();

                var tnodeText = "";
                if (fieldName.Length > 0)
                {
                    tnodeText += fieldName + " -> ";
                }
                tnodeText += astruct.name;

                tnode     = new TreeNode(tnodeText);
                tnode.Tag = new TNStructTag(astruct);
                break;

            case ValueTypes.ARRAY:
                tnode     = new TreeNode(fieldName);
                tnode.Tag = new TNArrayTag(fieldValue.castTo <AArray>());
                break;
            }

            return(tnode);
        }
 public void expand(TreeNode myNode, EbxDataContainers ebx, TreeSettings settings)
 {
     doExpand(myNode, ebx, settings);
     myNode.Tag = null; // deactivate expansion logic
 }
 internal abstract void doExpand(TreeNode myNode, EbxDataContainers ebx, TreeSettings settings);