public static void SaveGameDatXml(string directory, string fileName, MloInterior interior)
        {
            AudioGameData    audioGameData = new AudioGameData(interior);
            InteriorEntry    interiorEntry = new InteriorEntry();
            List <RoomEntry> roomEntries   = new List <RoomEntry>();

            interiorEntry.name = interior.name;



            for (int i = 0; i < interior.Rooms.Count; i++)
            {
                RoomEntry roomEntry = new RoomEntry();
                roomEntry.name    = "prefix_int_room_" + interior.Rooms[i].name;
                roomEntry.mloRoom = interior.Rooms[i].name;

                interiorEntry.Items.Add(roomEntry);
                roomEntries.Add(roomEntry);
            }
            audioGameData.Items.Add(interiorEntry);
            for (int i = 0; i < roomEntries.Count; i++)
            {
                audioGameData.Items.Add(roomEntries[i]);
            }



            Version  version     = new Version();
            XElement gameDatFile = new XElement("Dat151");

            gameDatFile.Add(version.XML());
            gameDatFile.Add(audioGameData.XML());
            gameDatFile.Save(Path.Combine(directory, fileName + ".dat151.rel.xml"));
        }
        private void generateAudioOcclusion_Click(object sender, EventArgs e)
        {
            if (XDocImap != null && XDocItyp != null)
            {
                CommonFileDialogResult dialogResult = folderPicker.ShowDialog();

                if (dialogResult == CommonFileDialogResult.Ok)
                {
                    string         directory      = folderPicker.FileName;
                    MloInterior    mloInterior    = ParseXml.GetMloInterior(XDocItyp, XDocImap);
                    PortalInfoList portalInfoList = naOcclusionInteriorMetadata.GetPortalInfoList(mloInterior);
                    PathNodeList   pathNodeList   = naOcclusionInteriorMetadata.GetPathNodeList(portalInfoList, mloInterior);

                    if (mloInterior.name.StartsWith("hash_") || mloInterior.Rooms.Any(room => room.name.StartsWith("hash_")))
                    {
                        MessageBox.Show("CMloArchetypeDef, CMloInstanceDef, or CMloRoomDef had a hashed name! Real strings are required.", "Occlusion Generator", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    LogAction(">> Generated " + mloInterior.occlHash.occlusionHash + ".ymt.pso.xml");

                    naOcclusionInteriorMetadata.SavePsoXML(directory, mloInterior.occlHash.occlusionHash, portalInfoList, pathNodeList);
                }
            }
            else
            {
                MessageBox.Show("Empty field!", "Occlusion Generator", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        public static MloInterior GetMloInterior(XDocument XDocItyp, XDocument XDocImap)
        {
            List <Portal> mloPortals  = GetPortals(XDocItyp);
            List <Room>   mloRooms    = GetRooms(XDocItyp);
            string        mloName     = GetInstanceName(XDocImap);
            Vector3?      mloPosition = GetInstancePosition(XDocImap);
            MloInterior   mloInterior = new MloInterior(mloName, mloPosition, mloRooms, mloPortals);

            return(mloInterior);
        }
示例#4
0
        public static PathNodeList GetPaths(PortalInfoList portalInfoList, MloInterior mloInterior)
        {
            List <Node>  nodes        = Node.GetNodes(portalInfoList, mloInterior);
            PathNodeList pathNodeList = new PathNodeList();

            GetPathsOfType(pathNodeList, nodes, PathType.Unk01, PathType.Unk00);
            GetPathsOfType(pathNodeList, nodes, PathType.Unk02, PathType.Unk01);
            GetPathsOfType(pathNodeList, nodes, PathType.Unk03, PathType.Unk02);
            GetPathsOfType(pathNodeList, nodes, PathType.Unk04, PathType.Unk03);
            GetPathsOfType(pathNodeList, nodes, PathType.Unk05, PathType.Unk04);

            return(pathNodeList);
        }
        public static List <Node> GetNodes(PortalInfoList portalInfoList, MloInterior mloInterior)
        {
            List <Node> nodes = new List <Node>();

            foreach (Room room in mloInterior.Rooms)
            {
                Node node = new Node(room, mloInterior.occlHash);

                foreach (PortalInfoItem portal in portalInfoList.Items)
                {
                    if (portal.roomIdx == node.index)
                    {
                        node.Portals.Add(portal);
                    }
                }

                nodes.Add(node);
            }

            foreach (Node node in nodes)
            {
                foreach (Node neighbor in nodes)
                {
                    foreach (PortalInfoItem nodePortal in node.Portals)
                    {
                        if (nodePortal.destRoomIdx == neighbor.index)
                        {
                            if (!node.Edges.Contains(neighbor))
                            {
                                node.Edges.Add(neighbor);
                            }
                        }
                    }
                }
            }
            return(nodes);
        }
        public static void CommentOcclFile(XDocument XDoc, PortalInfoList portalInfoList, MloInterior mloInterior)
        {
            XElement    portalInfos  = XDoc.Root.Element("PortalInfoList");
            XElement    pathNodeKeys = XDoc.Root.Element("PathNodeList");
            List <Node> nodes        = Node.GetNodes(portalInfoList, mloInterior);

            foreach (XElement portalInfo in portalInfos.Elements("Item"))
            {
                XComment XCom = new XComment(portalInfo.ElementsBeforeSelf().Count().ToString());
                portalInfo.AddFirst(XCom);
            }

            foreach (XElement keyItem in pathNodeKeys.Elements("Item"))
            {
                XElement childList = keyItem.Element("PathNodeChildList");

                foreach (Node nodeA in nodes)
                {
                    foreach (Node nodeB in nodes)
                    {
                        if (nodeA != nodeB)
                        {
                            for (int i = 1; i < 6; i++)
                            {
                                if ((nodeA.key - nodeB.key) + i == int.Parse(keyItem.Element("Key").Attribute("value").Value, CultureInfo.InvariantCulture))
                                {
                                    XComment XCom = new XComment(nodeA.name + "[" + nodeA.index + "]" + " -> " + nodeB.name + "[" + nodeB.index + "]" + " +" + i);
                                    keyItem.Element("Key").AddAfterSelf(XCom);
                                }
                            }
                        }
                    }
                }

                foreach (XElement childItem in childList.Elements("Item"))
                {
                    string value =
                        " "
                        +
                        portalInfos.Elements("Item").ElementAt(int.Parse(childItem.Element("PortalInfoIdx").Attribute("value").Value, CultureInfo.InvariantCulture)).Element("RoomIdx").Attribute("value").Value.ToString()
                        +
                        "->"
                        +
                        portalInfos.Elements("Item").ElementAt(int.Parse(childItem.Element("PortalInfoIdx").Attribute("value").Value, CultureInfo.InvariantCulture)).Element("DestRoomIdx").Attribute("value").Value.ToString()
                        + " ";

                    XComment XComPortal = new XComment(value);
                    childItem.Element("PortalInfoIdx").AddAfterSelf(XComPortal);

                    foreach (Node nodeA in nodes)
                    {
                        foreach (Node nodeB in nodes)
                        {
                            if (nodeA != nodeB)
                            {
                                for (int i = 1; i < 6; i++)
                                {
                                    if ((nodeA.key - nodeB.key) + i == int.Parse(childItem.Element("PathNodeKey").Attribute("value").Value, CultureInfo.InvariantCulture))
                                    {
                                        XComment XCom = new XComment(nodeA.name + "[" + nodeA.index + "]" + " -> " + nodeB.name + "[" + nodeB.index + "]" + " +" + i);

                                        childItem.Element("PathNodeKey").AddAfterSelf(XCom);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            XDoc.Save("commentexample.xml");
        }
 public AudioGameData(MloInterior interior)
 {
     Items = new List <ItemEntry>();
 }
        public static PortalInfoList GetPortalInfoList(MloInterior mloInterior)
        {
            PortalInfoList portalInfoList = new PortalInfoList();

            foreach (Room room in mloInterior.Rooms)
            {
                uint portalIdx = 0;

                foreach (Portal portal in mloInterior.Portals)
                {
                    if (!Bit.IsBitSet(portal.flags, 1) && !Bit.IsBitSet(portal.flags, 2))
                    {
                        if (portal.roomFrom == room.roomIndex)
                        {
                            PortalInfoItem portalInfoItem = new PortalInfoItem(
                                mloInterior.occlHash.proxyHash,
                                portalIdx,
                                portal.roomFrom,
                                portal.roomTo
                                );


                            foreach (Entity entity in portal.attachedEntities)
                            {
                                PortalEntityItem portalEntityItem;
                                switch (entity.entityType)
                                {
                                case (EntityType.ENTITY_TYPE_DOOR):
                                    portalEntityItem = new PortalEntityItem(entity, true, false, 0.7f);
                                    break;

                                case (EntityType.ENTITY_TYPE_GLASS):
                                    portalEntityItem = new PortalEntityItem(entity, false, true, 0.0f);
                                    break;

                                default:
                                    portalEntityItem = new PortalEntityItem(entity, false, false, 0.0f);
                                    break;
                                }


                                portalInfoItem.Items.Add(portalEntityItem);
                            }

                            portalInfoList.Items.Add(portalInfoItem);

                            portalIdx++;
                        }
                        else if (portal.roomTo == room.roomIndex)
                        {
                            PortalInfoItem portalInfoItem = new PortalInfoItem(
                                mloInterior.occlHash.proxyHash,
                                portalIdx,
                                portal.roomTo,
                                portal.roomFrom
                                );

                            foreach (Entity entity in portal.attachedEntities)
                            {
                                PortalEntityItem portalEntityItem;
                                switch (entity.entityType)
                                {
                                case (EntityType.ENTITY_TYPE_DOOR):
                                    portalEntityItem = new PortalEntityItem(entity, true, false, 0.7f);
                                    break;

                                case (EntityType.ENTITY_TYPE_GLASS):
                                    portalEntityItem = new PortalEntityItem(entity, false, true, 0.0f);
                                    break;

                                default:
                                    portalEntityItem = new PortalEntityItem(entity, false, false, 0.0f);
                                    break;
                                }

                                portalInfoItem.Items.Add(portalEntityItem);
                            }

                            portalInfoList.Items.Add(portalInfoItem);

                            portalIdx++;
                        }
                    }
                }
            }

            foreach (PortalInfoItem portal in portalInfoList.Items)
            {
                portal.infoIdx = (uint)portalInfoList.Items.IndexOf(portal);
            }

            return(portalInfoList);
        }
        public static PathNodeList GetPathNodeList(PortalInfoList portalInfoList, MloInterior mloInterior)
        {
            PathNodeList pathNodeList = PathAlgorithm.GetPaths(portalInfoList, mloInterior);

            return(pathNodeList);
        }