public static HeightMapBuilder FromStream(System.IO.Stream stream)
        {
            HeightMapBuilder builder = new HeightMapBuilder();

            System.IO.BinaryReader br = new System.IO.BinaryReader(stream);
            builder.MinX = br.ReadInt16();
            builder.MaxX = br.ReadInt16();
            builder.MinY = br.ReadInt16();
            builder.MaxY = br.ReadInt16();
            builder.MinZ = br.ReadInt16();
            builder.MaxZ = br.ReadInt16();
            int count = br.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                int key = br.ReadInt32();
                if (!builder.values.ContainsKey(key))
                {
                    builder.values[key] = new ConcurrentDictionary <short, short>();
                }

                byte c = br.ReadByte();
                for (int j = 0; j < c; j++)
                {
                    builder.values[key][br.ReadInt16()] = 0;
                }
            }
            return(builder);
        }
Exemple #2
0
 public override void OnMoveActor(Actor mActor, MoveArg arg, bool knockBack)
 {
     builder.ActorMove(mActor.ActorID, (short)mActor.X, (short)mActor.Y, (short)mActor.Z, (short)arg.X, (short)arg.Y, (short)arg.Z);
     if (mActor.ActorType == ActorType.PC)
     {
         if (((ActorPC)mActor).HoldingItem != null)
         {
             MoveActor(((ActorPC)mActor).HoldingItem, arg);
         }
         if (arg is MoveArgument a)
         {
             if (a.BNSMoveType == MoveType.Run || a.BNSMoveType == MoveType.Dash)
             {
                 HeightMapBuilder.Collect((short)a.X, (short)a.Y, (short)a.Z);
             }
         }
     }
 }
Exemple #3
0
        protected override void ParseXML(System.Xml.XmlElement root, System.Xml.XmlElement current, Map item)
        {
            switch (root.Name.ToLower())
            {
            case "map":
            {
                switch (current.Name.ToLower())
                {
                case "id":
                    item.ID = uint.Parse(current.InnerText);
                    break;

                case "instancetype":
                    item.InstanceType = (MapInstanceType)int.Parse(current.InnerText);
                    break;

                case "respawn":
                    RespawnPoint point = new RespawnPoint()
                    {
                        MapID = current.HasAttribute("map") ? uint.Parse(current.Attributes["map"].Value) : item.ID,
                        X     = short.Parse(current.Attributes["x"].Value),
                        Y     = short.Parse(current.Attributes["y"].Value),
                        Z     = short.Parse(current.Attributes["z"].Value),
                        Dir   = ushort.Parse(current.Attributes["dir"].Value)
                    };
                    if (current.HasAttribute("teleportId"))
                    {
                        point.teleportId = ushort.Parse(current.Attributes["teleportId"].Value);
                    }

                    if (!respawnPoints.ContainsKey(item.ID))
                    {
                        respawnPoints.Add(item.ID, new List <RespawnPoint>());
                    }

                    respawnPoints[item.ID].Add(point);
                    break;

                case "heightmap":
                    HeightMapBuilder builder;
                    if (Map.heightmapBuilder.TryGetValue(current.InnerText, out builder))
                    {
                        item.HeightMapBuilder = builder;
                    }
                    else
                    {
                        if (VirtualFileSystemManager.Instance.FileSystem.Exists("DB/HeightMaps/" + current.InnerText + ".builder"))
                        {
                            System.IO.Stream st = VirtualFileSystemManager.Instance.FileSystem.OpenFile("DB/HeightMaps/" + current.InnerText + ".builder");
                            item.HeightMapBuilder = HeightMapBuilder.FromStream(st);
                            st.Close();
                        }
                        else
                        {
                            item.HeightMapBuilder = new HeightMapBuilder();
                        }

                        item.HeightMapBuilder.Name = current.InnerText;

                        Map.heightmapBuilder[current.InnerText] = item.HeightMapBuilder;
                    }
                    break;
                }
            }
            break;
            }
        }