Beispiel #1
0
        public static TargetInfo TargetInfoFromNode(XmlNode node, string label, TargetInfo defaultValue)
        {
            LoadIDsWantedBank loadIDs = Scribe.loader.crossRefs.loadIDs;

            if (node != null && Scribe.EnterNode(label))
            {
                try
                {
                    string     innerText = node.InnerText;
                    TargetInfo result;
                    if (innerText.Length != 0 && innerText[0] == '(')
                    {
                        string str;
                        string targetLoadID;
                        ScribeExtractor.ExtractCellAndMapPairFromTargetInfo(innerText, out str, out targetLoadID);
                        loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), "thing");
                        loadIDs.RegisterLoadIDReadFromXml(targetLoadID, typeof(Map), "map");
                        result = new TargetInfo(IntVec3.FromString(str), null, true);
                        return(result);
                    }
                    loadIDs.RegisterLoadIDReadFromXml(innerText, typeof(Thing), "thing");
                    loadIDs.RegisterLoadIDReadFromXml(null, typeof(Map), "map");
                    result = TargetInfo.Invalid;
                    return(result);
                }
                finally
                {
                    Scribe.ExitNode();
                }
            }
            loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), label + "/thing");
            loadIDs.RegisterLoadIDReadFromXml(null, typeof(Map), label + "/map");
            return(defaultValue);
        }
Beispiel #2
0
        public static LocalTargetInfo LocalTargetInfoFromNode(XmlNode node, string label, LocalTargetInfo defaultValue)
        {
            LoadIDsWantedBank loadIDs = Scribe.loader.crossRefs.loadIDs;

            if (node != null && Scribe.EnterNode(label))
            {
                try
                {
                    string          innerText = node.InnerText;
                    LocalTargetInfo result;
                    if (innerText.Length != 0 && innerText[0] == '(')
                    {
                        loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), "thing");
                        result = new LocalTargetInfo(IntVec3.FromString(innerText));
                        return(result);
                    }
                    loadIDs.RegisterLoadIDReadFromXml(innerText, typeof(Thing), "thing");
                    result = LocalTargetInfo.Invalid;
                    return(result);
                }
                finally
                {
                    Scribe.ExitNode();
                }
            }
            loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), label + "/thing");
            return(defaultValue);
        }
Beispiel #3
0
        public static TargetInfo TargetInfoFromNode(XmlNode node, string label, TargetInfo defaultValue)
        {
            LoadIDsWantedBank loadIDs = Scribe.loader.crossRefs.loadIDs;

            if (node != null && Scribe.EnterNode(label))
            {
                try
                {
                    string innerText = node.InnerText;
                    if (innerText.Length != 0 && innerText[0] == '(')
                    {
                        ExtractCellAndMapPairFromTargetInfo(innerText, out var cell, out var map);
                        loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), "thing");
                        loadIDs.RegisterLoadIDReadFromXml(map, typeof(Map), "map");
                        return(new TargetInfo(IntVec3.FromString(cell), null, allowNullMap: true));
                    }
                    loadIDs.RegisterLoadIDReadFromXml(innerText, typeof(Thing), "thing");
                    loadIDs.RegisterLoadIDReadFromXml(null, typeof(Map), "map");
                    return(TargetInfo.Invalid);
                }
                finally
                {
                    Scribe.ExitNode();
                }
            }
            loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), label + "/thing");
            loadIDs.RegisterLoadIDReadFromXml(null, typeof(Map), label + "/map");
            return(defaultValue);
        }
        public static GlobalTargetInfo GlobalTargetInfoFromNode(XmlNode node, string label, GlobalTargetInfo defaultValue)
        {
            LoadIDsWantedBank loadIDs = Scribe.loader.crossRefs.loadIDs;

            if (node != null && Scribe.EnterNode(label))
            {
                try
                {
                    string innerText = node.InnerText;
                    if (innerText.Length != 0 && innerText[0] == '(')
                    {
                        string str;
                        string targetLoadID;
                        ScribeExtractor.ExtractCellAndMapPairFromTargetInfo(innerText, out str, out targetLoadID);
                        loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), "thing");
                        loadIDs.RegisterLoadIDReadFromXml(targetLoadID, typeof(Map), "map");
                        loadIDs.RegisterLoadIDReadFromXml(null, typeof(WorldObject), "worldObject");
                        return(new GlobalTargetInfo(IntVec3.FromString(str), null, true));
                    }
                    int tile;
                    if (int.TryParse(innerText, out tile))
                    {
                        loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), "thing");
                        loadIDs.RegisterLoadIDReadFromXml(null, typeof(Map), "map");
                        loadIDs.RegisterLoadIDReadFromXml(null, typeof(WorldObject), "worldObject");
                        return(new GlobalTargetInfo(tile));
                    }
                    if (innerText.Length != 0 && innerText[0] == '@')
                    {
                        loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), "thing");
                        loadIDs.RegisterLoadIDReadFromXml(null, typeof(Map), "map");
                        loadIDs.RegisterLoadIDReadFromXml(innerText.Substring(1), typeof(WorldObject), "worldObject");
                        return(GlobalTargetInfo.Invalid);
                    }
                    loadIDs.RegisterLoadIDReadFromXml(innerText, typeof(Thing), "thing");
                    loadIDs.RegisterLoadIDReadFromXml(null, typeof(Map), "map");
                    loadIDs.RegisterLoadIDReadFromXml(null, typeof(WorldObject), "worldObject");
                    return(GlobalTargetInfo.Invalid);
                }
                finally
                {
                    Scribe.ExitNode();
                }
            }
            loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), label + "/thing");
            loadIDs.RegisterLoadIDReadFromXml(null, typeof(Map), label + "/map");
            loadIDs.RegisterLoadIDReadFromXml(null, typeof(WorldObject), label + "/worldObject");
            return(defaultValue);
        }