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()); } }
public static Entity ToEntity(this WorldInfoMsg msg) { var entity = EntityManager.Instance.CreateEntity(msg.Id); Assign(entity, msg); return(entity); }
public static WorldInfoMsg ToWorldInfoMsg(this Entity entity) { var msg = new WorldInfoMsg(); Assign(msg, entity); return(msg); }
public static void Assign(this WorldInfoMsg msg, Entity entity) { msg.Id = entity.Id; }
public static void Assign(this Entity entity, WorldInfoMsg msg) { EntityHelper.SetEntityId(entity, msg.Id); }