Esempio n. 1
0
        public static bool SetNpcNoZone(Action <PgNpcLocation> setter, MapAreaName areaName, string npcId, string parsedFile, string parsedKey, ErrorControl errorControl)
        {
            PgNpc      ParsedNpc = null !;
            SpecialNpc NpcEnum   = SpecialNpc.Internal_None;
            string     NpcName   = string.Empty;

            PgNpcLocation NpcLocation = new PgNpcLocation();

            NpcLocation.NpcId = npcId;

            if (Inserter <PgNpc> .SetItemByKey((PgNpc valueNpc) => ParsedNpc = valueNpc, npcId, ErrorControl.IgnoreIfNotFound))
            {
                NpcLocation.Npc_Key = ParsedNpc.Key;
            }
            else if (StringToEnumConversion <SpecialNpc> .TryParse(npcId, out NpcEnum, ErrorControl.IgnoreIfNotFound))
            {
                NpcLocation.NpcEnum = NpcEnum;
            }
            else if (npcId.ToUpper().StartsWith("NPC_"))
            {
                NpcLocation.NpcName = npcId.Substring(4);
            }
            else
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"'{npcId}' unknown NPC name", errorControl));
            }

            ParsingContext.AddSuplementaryObject(NpcLocation);

            Debug.Assert(!string.IsNullOrEmpty(NpcLocation.NpcId));
            Debug.Assert(NpcLocation.Npc_Key != null || NpcLocation.NpcEnum != SpecialNpc.Internal_None || NpcLocation.NpcName.Length > 0);

            setter(NpcLocation);
            return(true);
        }
Esempio n. 2
0
        public static bool ParseAreaEvent(object value, string parsedFile, string parsedKey, out MapAreaName areaName)
        {
            areaName = MapAreaName.Internal_None;

            if (!(value is string AreaString))
            {
                return(Program.ReportFailure(parsedFile, parsedKey, $"Value '{value}' was expected to be a string"));
            }

            if (AreaString == "Daytime")
            {
                areaName = MapAreaName.Daytime;
                StringToEnumConversion <MapAreaName> .SetCustomParsedEnum(areaName);

                return(true);
            }

            if (AreaString == "PovusNightlyQuest")
            {
                areaName = MapAreaName.PovusNightlyQuest;
                StringToEnumConversion <MapAreaName> .SetCustomParsedEnum(areaName);

                return(true);
            }

            int AreaIndex = AreaString.LastIndexOf('_');

            if (AreaIndex > 0)
            {
                int KeyIndex = AreaString.LastIndexOf('_', AreaIndex - 1);
                if (KeyIndex > 0)
                {
                    string AreaName  = AreaString.Substring(AreaIndex + 1);
                    string KeyName   = AreaString.Substring(KeyIndex + 1, AreaIndex - KeyIndex - 1);
                    string QuestName = AreaString.Substring(0, KeyIndex);

                    if (AreaName == "Ilmari")
                    {
                        AreaName = "Desert1";
                    }
                    else if (AreaName == "Kur")
                    {
                        AreaName = "KurMountains";
                    }

                    MapAreaName ParsedAreaName = MapAreaName.Internal_None;
                    bool        Result         = StringToEnumConversion <MapAreaName> .SetEnum((MapAreaName valueEnum) => ParsedAreaName = valueEnum, AreaName);

                    areaName = ParsedAreaName;
                    return(Result);
                }
            }

            return(Program.ReportFailure(parsedFile, parsedKey, $"Unknown area '{AreaString}'"));
        }