Ejemplo n.º 1
0
        public void InitNodesFromDictionary()
        {
            if (NodeDictionary != null)
            {
                if (NodeDictionary.Nodes != null)
                {
                    var nodes = NodeDictionary.Nodes;
                    Nodes = new YndNode[nodes.Length];
                    for (int i = 0; i < nodes.Length; i++)
                    {
                        var n = new YndNode();
                        n.Init(this, nodes[i]);
                        Nodes[i] = n;
                        if (n.NodeID != i)
                        {
                        }   //never hit here - nodeid's have to match the index!
                    }
                }
                if ((NodeDictionary.JunctionRefs != null) && (NodeDictionary.Junctions != null))
                {
                    var juncrefs = NodeDictionary.JunctionRefs;
                    var juncs    = NodeDictionary.Junctions;
                    Junctions = new YndJunction[juncrefs.Length];
                    for (int i = 0; i < juncrefs.Length; i++)
                    {
                        var juncref = juncrefs[i];
                        if (juncref.JunctionID >= juncs.Length)
                        {
                            continue;
                        }

                        var j = new YndJunction();
                        j.Init(this, juncs[juncref.JunctionID], juncref);
                        j.Heightmap  = new YndJunctionHeightmap(NodeDictionary.JunctionHeightmapBytes, j);
                        Junctions[i] = j;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public YndNode AddNode()
        {
            int     cnt = Nodes?.Length ?? 0;
            YndNode yn  = new YndNode();
            Node    n   = new Node();

            n.AreaID = (ushort)AreaID;
            n.NodeID = (ushort)cnt;
            yn.Init(this, n);

            int ncnt = cnt + 1;

            YndNode[] nnodes = new YndNode[ncnt];
            for (int i = 0; i < cnt; i++)
            {
                nnodes[i] = Nodes[i];
            }
            nnodes[cnt] = yn;
            Nodes       = nnodes;
            NodeDictionary.NodesCount = (uint)ncnt;

            return(yn);
        }
Ejemplo n.º 3
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;

            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);


            NodeDictionary = rd.ReadBlock <NodeDictionary>();

            if (NodeDictionary != null)
            {
                if (NodeDictionary.Nodes != null)
                {
                    var nodes = NodeDictionary.Nodes;
                    Nodes = new YndNode[nodes.Length];
                    for (int i = 0; i < nodes.Length; i++)
                    {
                        var n = new YndNode();
                        n.Init(this, nodes[i]);
                        Nodes[i] = n;
                        if (n.NodeID != i)
                        {
                        }   //never hit here - nodeid's have to match the index!
                    }
                }
                if ((NodeDictionary.JunctionRefs != null) && (NodeDictionary.Junctions != null))
                {
                    var juncrefs = NodeDictionary.JunctionRefs;
                    var juncs    = NodeDictionary.Junctions;
                    Junctions = new YndJunction[juncrefs.Length];
                    for (int i = 0; i < juncrefs.Length; i++)
                    {
                        var juncref = NodeDictionary.JunctionRefs[i];
                        if (juncref.JunctionID >= juncs.Length)
                        {
                            continue;
                        }

                        var j = new YndJunction();
                        j.Init(this, juncs[juncref.JunctionID], juncref);
                        j.Heightmap  = new YndJunctionHeightmap(NodeDictionary.JunctionHeightmapBytes, j);
                        Junctions[i] = j;
                    }
                }
            }

            UpdateAllNodePositions();

            //links will be populated by the space... maybe move that code here?



            string areaidstr = Name.ToLower().Replace("nodes", "").Replace(".ynd", "");
            int    areaid    = 0;

            int.TryParse(areaidstr, out areaid);
            AreaID = areaid;

            UpdateBoundingBox();


            BuildBVH();


            Loaded     = true;
            LoadQueued = true;
        }