示例#1
0
 void SendWorldInfo(int tilex, int tiley, bool fakeid)
 {
     using (var ms = new MemoryStream())
     {
         var msg = new WorldInfoMsg
         {
             Time         = (int)Main.time,
             DayTime      = Main.dayTime,
             MoonPhase    = (byte)Main.moonPhase,
             BloodMoon    = Main.bloodMoon,
             MaxTilesX    = Main.maxTilesX,
             MaxTilesY    = Main.maxTilesY,
             SpawnX       = tilex,
             SpawnY       = tiley,
             WorldSurface = (int)Main.worldSurface,
             RockLayer    = (int)Main.rockLayer,
             //Sending a fake world id causes the client to not be able to find a stored spawnx/y.
             //This fixes the bed spawn point bug. With a fake world id it wont be able to find the bed spawn.
             WorldID    = !fakeid ? Main.worldID : -1,
             WorldFlags = (WorldGen.shadowOrbSmashed ? WorldInfoFlag.OrbSmashed : WorldInfoFlag.None) |
                          (NPC.downedBoss1 ? WorldInfoFlag.DownedBoss1 : WorldInfoFlag.None) |
                          (NPC.downedBoss2 ? WorldInfoFlag.DownedBoss2 : WorldInfoFlag.None) |
                          (NPC.downedBoss3 ? WorldInfoFlag.DownedBoss3 : WorldInfoFlag.None) |
                          (Main.hardMode ? WorldInfoFlag.HardMode : WorldInfoFlag.None) |
                          (NPC.downedClown ? WorldInfoFlag.DownedClown : WorldInfoFlag.None),
             WorldName = Main.worldName
         };
         msg.PackFull(ms);
         SendRawData(ms.ToArray());
     }
 }
示例#2
0
        public static Entity ToEntity(this WorldInfoMsg msg)
        {
            var entity = EntityManager.Instance.CreateEntity(msg.Id);

            Assign(entity, msg);
            return(entity);
        }
示例#3
0
        public static WorldInfoMsg ToWorldInfoMsg(this Entity entity)
        {
            var msg = new WorldInfoMsg();

            Assign(msg, entity);
            return(msg);
        }
示例#4
0
 public static void Assign(this WorldInfoMsg msg, Entity entity)
 {
     msg.Id = entity.Id;
 }
示例#5
0
 public static void Assign(this Entity entity, WorldInfoMsg msg)
 {
     EntityHelper.SetEntityId(entity, msg.Id);
 }