public void EnableUImgui() { if (uImguiCamera == null) { Logger.Warn("Not enabling UImGui, camera is null!"); return; } uImGui.enabled = true; }
private void Initialize() { if (client != null) { Logger.Error("The discord client is already running!"); return; } try { client = new global::Discord.GameSDK.Discord(long.Parse(Settings.clientId), CreateFlags.NoRequireDiscord); client.Init(); } catch (ResultException ex) { Logger.Error("Failed to connect with Discord! {@Message} {@ResultCode}", ex.Message, ex.Result); client = null; Destroy(gameObject); return; } client?.SetLogHook(Settings.logLevel, (level, message) => { switch (level) { case LogLevel.Error: Logger.Error(message); break; case LogLevel.Warn: Logger.Warn(message); break; case LogLevel.Info: Logger.Info(message); break; case LogLevel.Debug: Logger.Debug(message); break; default: throw new ArgumentOutOfRangeException(nameof(level), level, null); } }); activityManager = client?.GetActivityManager(); userManager = client?.GetUserManager(); TCScenesManager.PreparingSceneLoadEvent += PreparingSceneLoad; TCScenesManager.OnSceneLoadedEvent += SceneLoaded; SceneLoaded(TCScenesManager.GetActiveScene()); }
private static void WriteDefaultMotd(string motdPath) { Logger.Warn("Created new default MOTD."); string directory = Path.GetDirectoryName(motdPath); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } File.WriteAllText(motdPath, MotdDefaultText); }
private void Start() { TextMeshProUGUI text = GetComponent <TextMeshProUGUI>(); string currentId = text.text; text.text = GameUILocale.ResolveString(text.text); //The text was not found if (text.text == currentId) { Logger.Warn("The localization key '{@Key}' was not found in the GameUI locale! ({@ObjectName})", currentId, gameObject.name); } Destroy(this); }
private void Start() { if (ConsoleUI != null) { Destroy(gameObject); Logger.Warn("You should only ever load this script on a bootloader scene!"); return; } //If we are headless we need to create a console UI using the OS's terminal //I really which Unity would have this included... if (Game.IsHeadless) { #if UNITY_STANDALONE_WIN ConsoleUI = new ConsoleWindows($"{Application.productName} Server"); #elif UNITY_STANDALONE_LINUX ConsoleUI = new ConsoleLinux($"{Application.productName} Server"); #elif UNITY_STANDALONE_OSX //TODO: Add console for OSX #endif } else { GameObject consoleUiPrefab = Addressables.LoadAssetAsync <GameObject>(ConsoleUiPrefabPath).WaitForCompletion(); //Create in-game console GUI ConsoleUI = Instantiate(consoleUiPrefab, transform).GetComponent <ConsoleGUI>(); } //Init the console ConsoleUI.Init(); //Init the backend of the console ConsoleBackend.InitConsoleBackend(); //Exec autoexec ConsoleBackend.ExecuteFileCommand(new[] { "autoexec" }); }
/// <summary> /// Creates a new <see cref="Locale" /> instance /// </summary> /// <param name="fileLocation"></param> public Locale(string fileLocation) { //Try and load the locale for the native system language string systemLanguageLocaleLocation = fileLocation.Replace("%LANG%", Language.ToString()); if (!File.Exists(systemLanguageLocaleLocation)) //The locale doesn't exist for the system language { //Try and default to english (Should generally always exist, as Voltstro Studios is english...) systemLanguageLocaleLocation = fileLocation.Replace("%LANG%", "English"); if (!File.Exists(systemLanguageLocaleLocation)) { Logger.Error("No locale exists at {@LocalLocation}! The locale will not be loaded!", fileLocation); Tokens = new Dictionary <string, string>(); return; } Logger.Warn("No locale exists for system language {@Language}... defaulting to english!", Language.ToString()); } //Now to load the tokens Tokens = JsonConvert.DeserializeObject <Dictionary <string, string> >( File.ReadAllText(systemLanguageLocaleLocation)); }
private static void WriteDefaultMotd(string motdPath) { Logger.Warn("Created new default MOTD."); File.WriteAllText(motdPath, MotdDefaultText); }
private void OnRequestJoin(NetworkConnection conn, JoinRequestMessage msg) { //Check versions if (msg.ApplicationVersion != Application.version) { SendRequestResponseMessage(conn, HttpCode.PreconditionFailed, "Server and client versions mismatch!"); Logger.Warn("Client {Id} had mismatched versions with the server! Rejecting connection.", conn.connectionId); RefuseClientConnection(conn); return; } //Make sure they at least provided an account if (msg.UserAccounts.Length == 0) { SendRequestResponseMessage(conn, HttpCode.Unauthorized, "No accounts provided!"); Logger.Warn("Client {Id} sent no user accounts. Rejecting connection.", conn.connectionId); RefuseClientConnection(conn); return; } Logger.Debug("Got {UserAccountsNum} user accounts from {UserId}", msg.UserAccounts.Length, conn.connectionId); //Get the user account the server wants Option <IUser> userResult = msg.UserAccounts.AsValueEnumerable().Where(x => x.UserProvider == AuthMethod).First(); if (userResult.IsNone) { SendRequestResponseMessage(conn, HttpCode.Unauthorized, "No valid user accounts sent!"); Logger.Warn("Client {Id} sent no valid user accounts!. Rejecting connection.", conn.connectionId); RefuseClientConnection(conn); return; } IUser user = userResult.Value; if (authAccounts.ContainsValue(user)) { SendRequestResponseMessage(conn, HttpCode.Unauthorized, "User is already connected!"); Logger.Warn( "Client {Id} tried to connect with the same account as an existing client!. Rejecting connection.", conn.connectionId); RefuseClientConnection(conn); return; } try { inProgressAuth.Add(conn.connectionId, user); user.ServerStartClientAuthentication(() => { inProgressAuth.Remove(conn.connectionId); authAccounts.Add(conn.connectionId, user); SendRequestResponseMessage(conn, HttpCode.Ok, "Ok"); ServerAccept(conn); Logger.Debug("Accepted client {Id}", conn.connectionId); }, () => { SendRequestResponseMessage(conn, HttpCode.Unauthorized, "Failed authorization!"); Logger.Warn("Client {Id} failed to authorize!. Rejecting connection.", conn.connectionId); RefuseClientConnection(conn); }); } catch (Exception ex) { SendRequestResponseMessage(conn, HttpCode.InternalServerError, "An error occured with the server authorization!"); Logger.Error(ex, "An error occured on the server side with authorization"); RefuseClientConnection(conn); } }