Ejemplo n.º 1
0
        public unsafe void LoadJson(void *world, string embeddedResource, IntPoint *pos, void *wmap)
        {
            if (embeddedResource == null)
            {
                return;
            }
            string resource = embeddedResource.Replace(".jm", "");
            Stream stream   = typeof(RealmManager).Assembly.GetManifestResourceStream("gameserver.realm.mapsetpiece.maps." + resource + ".jm");

            if (stream == null)
            {
                throw new ArgumentException("JSON map resource " + nameof(resource) + " not found!");
            }
            FromWorldMap(new MemoryStream(Json2Wmap.Convert((GCHandle.FromIntPtr(new IntPtr(world)).Target as World).Manager.GameData, new StreamReader(stream).ReadToEnd())), world, pos, wmap);
        }
Ejemplo n.º 2
0
        private unsafe void FromWorldMap(Stream dat, void *world, IntPoint *pos, void *wmap)
        {
            Wmap map = (GCHandle.FromIntPtr(new IntPtr(wmap)).Target as Wmap);

            map.Load(dat, 0);
            int w = map.Width, h = map.Height;

            pos->X = ((GCHandle.FromIntPtr(new IntPtr(world)).Target as World).Map.Width / 2) - (w / 2);
            pos->Y = ((GCHandle.FromIntPtr(new IntPtr(world)).Target as World).Map.Width / 2) - (w / 2);

            IEnumerable <Entity> ens = map.InstantiateEntities((GCHandle.FromIntPtr(new IntPtr(world)).Target as World).Manager);

            foreach (Entity i in ens)
            {
                i.Move(i.X + pos->X, i.Y + pos->Y);
                (GCHandle.FromIntPtr(new IntPtr(world)).Target as World).EnterWorld(i);
            }
        }