private static void setDimensionPath(DimPlayer p, Dictionary <string, LocalizedText> dictionary, FieldInfo textInfo) { if (getPlayerDim() != "overworld") { Main.WorldPath = Main.SavePath + "/World/" + getPlayerDim().Replace(' ', '_'); } else if (getPlayerDim() == "overworld") { Main.WorldPath = Main.SavePath + "/World"; } }
public override void UpdateMusic(ref int music, ref MusicPriority musicPriority) { if (Main.myPlayer != -1 && Main.gameMenu && Main.LocalPlayer.name != "") { DimPlayer p = Main.player[Main.myPlayer].GetModPlayer <DimPlayer>(); FieldInfo info = typeof(LanguageManager).GetField("_localizedTexts", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary <string, LocalizedText> dictionary = info.GetValue(LanguageManager.Instance) as Dictionary <string, LocalizedText>; FieldInfo textInfo = typeof(LocalizedText).GetField("value", BindingFlags.Instance | BindingFlags.NonPublic); setDimensionPath(p, dictionary, textInfo); } }
public void ClientThread(object context) { Main.gameMenu = true; Main.menuMode = 888; Main.MenuUI.SetState(new UINetworkConnection()); object[] parameter = (object[])context; bool exitThread = false; DimPlayer player = (DimPlayer)parameter[0]; int numberOfAttempt = 0; RemoteAddress adress = new TcpAddress(Netplay.ServerIP, 7776); ClientLoopSetup(adress); ISocket secondarySocket = new TcpSocket(); secondarySocket.Connect(new TcpAddress(Netplay.ServerIP, 7776)); while (!exitThread) { try { Thread.Sleep(2500); if (secondarySocket.IsDataAvailable()) { byte[] data = new byte[ushort.MaxValue]; secondarySocket.AsyncReceive(data, 0, ushort.MaxValue, new SocketReceiveCallback(Netplay.Connection.ClientReadCallBack), null); using (MemoryStream stream = new MemoryStream(data)) { BinaryReader reader = new BinaryReader(new MemoryStream(data)); } numberOfAttempt++; } else { byte[] data = new byte[ushort.MaxValue]; using (MemoryStream stream = new MemoryStream(data)) { BinaryWriter writer = new BinaryWriter(stream); writer.Write("hey"); secondarySocket.AsyncSend(writer.BaseStream.ReadAllBytes(), 0, ushort.MaxValue, new SocketSendCallback(Netplay.Connection.ClientWriteCallBack), null); } } } catch (Exception e) { LogManager.GetLogger("Second thread").Error(e.Message, e); } } Netplay.Connection.Socket.Close(); Netplay.StartTcpClient(); player.inTransit = false; }
public static string getPlayerDim() { DimPlayer plr = Main.LocalPlayer.GetModPlayer <DimPlayer>(); return(plr.getCurrentDimension()); }