コード例 #1
0
        public IActionResult GetFrame(int mobId)
        {
            Mob mobData = MobFactory.GetMob(mobId);

            string animation = mobData.Framebooks.ContainsKey("stand") ? "stand" : mobData.Framebooks.ContainsKey("fly") ? "fly" : null;

            if (animation == null)
            {
                return(NotFound());
            }

            FrameBook standing = mobData.GetFrameBook(animation).First();

            if (standing == null)
            {
                return(NotFound());
            }

            Frame firstFrame = standing.frames.First();

            if (firstFrame == null || firstFrame.Image == null)
            {
                return(NotFound());
            }

            return(File(firstFrame.Image.ImageToByte(Request), "image/png"));
        }
コード例 #2
0
        internal static CashEffect Parse(WZProperty wZProperty)
        {
            CashEffect effect = new CashEffect();

            bool isOnlyDefault = false;

            effect.isFollow = wZProperty.ResolveFor <bool>("follow") ?? false;

            foreach (WZProperty obj in wZProperty.Children.Where(c => c.NameWithoutExtension != "follow" && c.NameWithoutExtension != "info"))
            {
                int frameTest = 0;
                if (isOnlyDefault = (obj.Type == PropertyType.Canvas || int.TryParse(obj.NameWithoutExtension, out frameTest)))
                {
                    break;
                }

                if (obj.Children.Count() == 0)
                {
                    continue;
                }
                effect.framebooks.Add(obj.NameWithoutExtension, FrameBook.Parse(obj));
            }

            if (isOnlyDefault)
            {
                effect.framebooks.Add("default", FrameBook.Parse(wZProperty));
            }

            return(effect);
        }
コード例 #3
0
        public static Effects Parse(WZProperty effectContainer)
        {
            Effects effects = new Effects();

            int?z = effectContainer.ResolveFor <int>("effect/z");//itemEffect["effect"].HasChild("z") ? itemEffect["effect"]["z"].ValueOrDefault<int>(0) : 0;

            effects.entries = effectContainer.Children
                              .Where(c => !blacklistEntries.Contains(c.NameWithoutExtension))
                              .ToDictionary(c => c.NameWithoutExtension, c => FrameBook.Parse(c));

            return(effects);
        }
コード例 #4
0
ファイル: NPC.cs プロジェクト: steven1152/maplestory.io
        public static Frame GetFirstFrame(WZProperty anyWz, string id)
        {
            WZProperty npcImg = anyWz.ResolveOutlink($"Npc/{id}");

            if (npcImg == null)
            {
                return(null);
            }
            string linksTo = npcImg.ResolveForOrNull <string>("info/link");

            if (linksTo != null)
            {
                return(GetFirstFrame(anyWz, linksTo));
            }
            return(FrameBook.Parse(npcImg.Children.Where(c => c.NameWithoutExtension != "info").Select(c => c).FirstOrDefault())
                   .FirstOrDefault().frames.FirstOrDefault());
        }
コード例 #5
0
        public IActionResult Render(int mobId, string framebook, int frame = 0)
        {
            Mob mobData = MobFactory.GetMob(mobId);

            FrameBook standing = mobData.GetFrameBook(framebook).First();

            if (standing == null)
            {
                return(NotFound());
            }

            Frame firstFrame = standing.frames.ElementAt(frame % standing.frames.Count());

            if (firstFrame == null || firstFrame.Image == null)
            {
                return(NotFound());
            }

            return(File(firstFrame.Image.ImageToByte(Request), "image/png"));
        }
コード例 #6
0
        public IActionResult GetFrame(int npcId)
        {
            NPC npcData = NPCFactory.GetNPC(npcId);

            if (npcData.IsComponentNPC ?? false)
            {
                return(File(AvatarFactory.Render(new Character()
                {
                    AnimationName = "stand1",
                    ItemEntries = npcData.ComponentIds
                                  .Concat(new int[] { npcData.ComponentSkin ?? 2000, (npcData.ComponentSkin ?? 2000) + 10000 })
                                  .Select(c => new AvatarItemEntry()
                    {
                        ItemId = c, Region = Region, Version = Version
                    })
                                  .ToArray()
                }).ImageToByte(Request), "image/png"));
            }
            if (!npcData.Framebooks.ContainsKey("stand"))
            {
                return(NotFound());
            }

            FrameBook standing = npcData.GetFrameBook("stand").First();

            if (standing == null)
            {
                return(NotFound());
            }

            Frame firstFrame = standing.frames.First();

            if (firstFrame == null || firstFrame.Image == null)
            {
                return(NotFound());
            }

            return(File(firstFrame.Image.ImageToByte(Request), "image/png"));
        }
コード例 #7
0
        public IActionResult Render(int npcId, string framebook, int frame = 0)
        {
            NPC npcData = NPCFactory.GetNPC(npcId);

            if (npcData.IsComponentNPC ?? false)
            {
                return(File(AvatarFactory.Render(new Character()
                {
                    AnimationName = framebook,
                    FrameNumber = frame,
                    ItemEntries = npcData.ComponentIds
                                  .Concat(new int[] { npcData.ComponentSkin ?? 2000, (npcData.ComponentSkin ?? 2000) + 10000 })
                                  .Select(c => new AvatarItemEntry()
                    {
                        ItemId = c, Region = Region, Version = Version
                    })
                                  .ToArray()
                }).ImageToByte(Request), "image/png"));
            }

            FrameBook standing = npcData.GetFrameBook(framebook).First();

            if (standing == null)
            {
                return(NotFound());
            }

            Frame firstFrame = standing.frames.ElementAt(frame % standing.frames.Count());

            if (firstFrame == null || firstFrame.Image == null)
            {
                return(NotFound());
            }

            return(File(firstFrame.Image.ImageToByte(Request), "image/png"));
        }
コード例 #8
0
ファイル: Pet.cs プロジェクト: steven1152/maplestory.io
        public static Pet Parse(WZProperty stringWz)
        {
            int id;

            if (!int.TryParse(stringWz.NameWithoutExtension, out id))
            {
                return(null);
            }

            Pet        p        = new Pet(id);
            WZProperty petEntry = stringWz.ResolveOutlink($"Item/Pet/{id}");

            p.frameBooks  = petEntry.Children.Where(c => c.NameWithoutExtension != "info").ToDictionary(c => c.NameWithoutExtension, c => FrameBook.Parse(c));
            p.Description = ItemDescription.Parse(stringWz, id);
            p.MetaInfo    = ItemInfo.Parse(petEntry);

            return(p ?? null);
        }
コード例 #9
0
ファイル: NPC.cs プロジェクト: steven1152/maplestory.io
        public static NPC Parse(WZProperty stringWz, bool followLink = true)
        {
            int id;

            if (!int.TryParse(stringWz.NameWithoutExtension, out id))
            {
                return(null);
            }

            NPC result = new NPC();

            result.Id = id;

            if (stringWz?.FileContainer?.Collection is MSPackageCollection)
            {
                ((MSPackageCollection)stringWz.FileContainer.Collection).NPCQuests?.TryGetValue(id, out result.RelatedQuests);
            }

            result.npcImg = stringWz.ResolveOutlink($"Npc/{id.ToString("D7")}");
            result.Link   = result.npcImg.ResolveFor <int>("info/link") ?? result.npcImg.ResolveFor <int>("link");
            List <int> linkFollowed = new List <int>();
            NPC        linked       = result;

            while (followLink && linked.Link.HasValue && !linkFollowed.Contains(linked.Link.Value))
            {
                linkFollowed.Add(linked.Link.Value);
                linked = Parse(stringWz.ResolveOutlink($"String/Npc/{linked.Link.Value}"), false);
            }

            if (linked != result)
            {
                result.Extend(linked);
            }

            result.Function = stringWz.ResolveForOrNull <string>("func");
            result.Name     = stringWz.ResolveForOrNull <string>("name");
            result.Dialogue = stringWz.Children
                              .Where(c => c.NameWithoutExtension != "func" && c.NameWithoutExtension != "name" && c.NameWithoutExtension != "dialogue" && c is IWZPropertyVal)
                              .ToDictionary(c => c.NameWithoutExtension, c => ((IWZPropertyVal)c).GetValue().ToString());

            result.IsShop = result.npcImg?.ResolveFor <bool>("info/shop") ?? false;

            result.Framebooks = result.npcImg.Children
                                .Where(c => c.NameWithoutExtension != "info")
                                .ToDictionary(c => c.NameWithoutExtension, c => FrameBook.GetFrameCount(c));

            if (result.npcImg.Resolve("info/default")?.Type == PropertyType.Canvas)
            {
                result.Framebooks.Add("default", FrameBook.GetFrameCount(result.npcImg.Resolve("info/default")));
            }

            result.IsComponentNPC = result.npcImg.ResolveFor <bool>("info/componentNPC") ?? false;
            if (result.IsComponentNPC ?? false)
            {
                result.ComponentIds  = result.npcImg.Resolve("info/component")?.Children.Where(c => c.NameWithoutExtension != "skin").Select(c => c.ResolveFor <int>()).Where(c => c.HasValue).Select(c => c.Value).ToArray();
                result.ComponentSkin = result.npcImg.ResolveFor <int>("info/component/skin") + 2000;
            }

            result.FoundAt = result.npcImg.ResolveOutlink($"Etc/NpcLocation/{id}")?
                             .Children.Where(c => int.TryParse(c.NameWithoutExtension, out int blah))
                             .Select(c => MapName.GetMapNameLookup(result.npcImg)[int.Parse(c.NameWithoutExtension)].FirstOrDefault())
                             .Where(c => c != null).ToArray();

            return(result);
        }
コード例 #10
0
ファイル: NPC.cs プロジェクト: steven1152/maplestory.io
 public IEnumerable <FrameBook> GetFrameBook(string bookName = null)
 => bookName == null && Framebooks.Count == 0 ? null : FrameBook.Parse(npcImg.Resolve(bookName ?? Framebooks.First().Key));
コード例 #11
0
 public IEnumerable <FrameBook> GetFrameBook(string bookName = null)
 => FrameBook.Parse(mobImage.Resolve(bookName ?? Framebooks.First().Key));
コード例 #12
0
        public static Mob Parse(WZProperty stringWz, bool followLink = true)
        {
            int id;

            if (!int.TryParse(stringWz.NameWithoutExtension, out id))
            {
                return(null);
            }

            Mob result = new Mob();

            result.Id = id;

            result.mobImage = stringWz.ResolveOutlink($"Mob/{id.ToString("D7")}") ?? stringWz.ResolveOutlink($"Mob2/{id.ToString("D7")}");

            result.Name    = stringWz.ResolveForOrNull <string>("name");
            result.Meta    = result.mobImage.Children.Any(c => c.NameWithoutExtension.Equals("info")) ? MobMeta.Parse(result.mobImage.Resolve("info")) : null;
            result.LinksTo = result.Meta.LinksToOtherMob;

            result.Framebooks = result.mobImage.Children
                                .Where(c => c.NameWithoutExtension != "info")
                                .DistinctBy(c => c.NameWithoutExtension)
                                .ToDictionary(c => c.NameWithoutExtension, c => FrameBook.GetFrameCount(c));

            WZProperty familiarEntry = stringWz.ResolveOutlink($"String/MonsterBook/{id}");

            result.Description = familiarEntry?.ResolveForOrNull <string>("episode");

            ILookup <int, MapName> lookup = MapName.GetMapNameLookup(stringWz);

            result.FoundAt = stringWz.ResolveOutlink($"Etc/MobLocation/{id}")?
                             .Children.Concat(familiarEntry?.Resolve("map")?.Children ?? (new Dictionary <string, WZProperty>()).Values)
                             .Select(c => c.ResolveFor <int>() ?? -1).Distinct()
                             .Select(c => lookup[c]?.FirstOrDefault() ?? new MapName()
            {
                Name = "Unknown", StreetName = "Unknown", Id = c
            })
                             .ToArray();

            ILookup <int, ItemNameInfo> reportedDrops = ItemNameInfo.GetNameLookup(stringWz.ResolveOutlink("String"));

            result.Drops = familiarEntry?.Resolve("reward")?.Children
                           .Select(c => c.ResolveFor <int>() ?? -1)
                           .Select(c => reportedDrops[c]?.FirstOrDefault())
                           .Where(c => c != null)
                           .ToArray();

            List <int> linkFollowed = new List <int>();
            Mob        linked       = result;

            while (followLink && linked.Meta.LinksToOtherMob.HasValue && !linkFollowed.Contains(linked.Meta.LinksToOtherMob.Value))
            {
                linkFollowed.Add(linked.Meta.LinksToOtherMob.Value);
                linked = Parse(stringWz.ResolveOutlink($"String/Mob/{linked.Meta.LinksToOtherMob.Value}"), false);
            }

            if (linked != result)
            {
                result.Extend(linked);
            }

            return(result);
        }