public static void SetConfig(IModConfig config) { OverrideRefreshRate = config.GetSettingsValue <int>("refreshRateOverride"); VibrationStrength = config.GetSettingsValue <float>("vibrationIntensity"); ShowHelmet = config.GetSettingsValue <bool>("helmetVisibility"); ControllerOrientedMovement = config.GetSettingsValue <bool>("movementControllerOriented"); EnableGesturePrompts = config.GetSettingsValue <bool>("showGesturePrompts"); PreventCursorLock = config.GetSettingsValue <bool>("disableCursorLock"); DebugMode = config.GetSettingsValue <bool>("debug"); AutoHideToolbelt = config.GetSettingsValue <bool>("autoHideToolbelt"); HudScale = config.GetSettingsValue <float>("hudScale"); BypassFatalErrors = config.GetSettingsValue <bool>("bypassFatalErrors"); // OWML doesn't support negative slider values so I subtract it here. ToolbeltHeight = config.GetSettingsValue <float>("toolbeltHeight") - 1f; if (PreventCursorLock) { NomaiVRPatch.Empty <CursorManager>("Update"); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } OnConfigChange?.Invoke(); }
/// <summary> /// Contains information about a loaded in mod. /// </summary> /// <param name="state">The current state of the mod.</param> /// <param name="modConfig">The current mod configuration.</param> /// <param name="canSuspend">Whether the mod can be suspended.</param> /// <param name="canUnload">Whether the mod can be reloaded.</param> public ModInfo(ModState state, IModConfig modConfig, bool canSuspend, bool canUnload) { State = state; Config = modConfig; CanSuspend = canSuspend; CanUnload = canUnload; }
/* Setup for mod loading */ private Type[] GetExportsForModConfig(IModConfig modConfig) { var exports = SharedTypes.AsEnumerable(); // Share the mod's types with the mod itself. // The type is already preloaded into the default load context, and as such, will be inherited from the default context. // i.e. The version loaded into the default context will be used. // This is important because we need a single source for the other mods, i.e. ones which take this one as dependency. if (_modIdToMetadata.ContainsKey(modConfig.ModId)) { exports = exports.Concat(_modIdToMetadata[modConfig.ModId].Exports); } foreach (var dep in modConfig.ModDependencies) { if (_modIdToMetadata.ContainsKey(dep)) { exports = exports.Concat(_modIdToMetadata[dep].Exports); } } foreach (var optionalDep in modConfig.OptionalDependencies) { if (_modIdToMetadata.ContainsKey(optionalDep)) { exports = exports.Concat(_modIdToMetadata[optionalDep].Exports); } } return(exports.ToArray()); }
/// <summary> /// Entry point for your mod. /// </summary> public void StartEx(IModLoaderV1 loaderApi, IModConfigV1 modConfig) { #if DEBUG // Attaches debugger in debug mode; ignored in release. //Debugger.Launch(); #endif _modLoader = (IModLoader)loaderApi; _modConfig = (IModConfig)modConfig; _logger = (ILogger)_modLoader.GetLogger(); _modLoader.GetController <IReloadedHooks>().TryGetTarget(out _hooks !); // Your config file is in Config.json. // Need a different name, format or more configurations? Modify the `Configurator`. // If you do not want a config, remove Configuration folder and Config class. var configurator = new Configurator(_modLoader.GetModConfigDirectory(_modConfig.ModId)); _configuration = configurator.GetConfiguration <Config>(0); _configuration.ConfigurationUpdated += OnConfigurationUpdated; /* * Your mod code starts below. * Visit https://github.com/Reloaded-Project for additional optional libraries. */ _mod = new Mod(_hooks, _logger); }
private void ListenForOutput(IModConfig config) { var listener = new OutputListener(config); listener.OnOutput += Console.Write; listener.Start(); }
/// <summary> /// Entry point for your mod. /// </summary> public void StartEx(IModLoaderV1 loaderApi, IModConfigV1 modConfig) { _modLoader = (IModLoader)loaderApi; _modConfig = (IModConfig)modConfig; _logger = (ILogger)_modLoader.GetLogger(); _modLoader.GetController <IReloadedHooks>()?.TryGetTarget(out _hooks !); #if (IncludeConfig) // Your config file is in Config.json. // Need a different name, format or more configurations? Modify the `Configurator`. // If you do not want a config, remove Configuration folder and Config class. var configurator = new Configurator(_modLoader.GetModConfigDirectory(_modConfig.ModId)); _configuration = configurator.GetConfiguration <Config>(0); _configuration.ConfigurationUpdated += OnConfigurationUpdated; #endif // Please put your mod code in the class below, // use this class for only interfacing with mod loader. _mod = new Mod(new ModContext() { Logger = _logger, Hooks = _hooks, ModLoader = _modLoader, ModConfig = _modConfig, Owner = this, #if (IncludeConfig) Configuration = _configuration, #endif }); }
private bool IsValidGamePath(IModConfig config) { return(Directory.Exists(config.GamePath) && Directory.Exists(config.ManagedPath) && File.Exists($"{config.GamePath}/OuterWilds.exe") && _filesToCopy.All(filename => File.Exists($"{config.ManagedPath}/{filename}"))); }
public override void Configure(IModConfig config) { if (instance != null) { instance.ResetLog(); } }
/* Native Mods */ public ModInstance(IModV1 mod, IModConfig config) { Mod = mod; ModConfig = config; CanSuspend = mod.CanSuspend(); CanUnload = mod.CanUnload(); }
/// <summary> /// Generates a nuget package spec package from a given mod configuration file. /// </summary> private static Package FromModConfig(IModConfig modConfig) { var dependencies = modConfig.ModDependencies.Select(x => new Structures.Dependency(x, "0.0.0")).ToArray(); var dependencyGroup = new DependencyGroup(dependencies); var metadata = new Metadata(modConfig.ModName, modConfig.ModId, modConfig.ModVersion, modConfig.ModAuthor, modConfig.ModDescription, dependencyGroup); return(new Package(metadata)); }
public override void Configure(IModConfig config) { ModHelper.HarmonyHelper.AddPostfix <PadEZ.GamePad_PC_XB1>("SetUp", typeof(GamePad_PC_XB1_Fix), "SetUp_Postfix"); ModHelper.HarmonyHelper.AddPrefix <PadEZ.GamePad_PC_XB1>("Destroy", typeof(GamePad_PC_XB1_Fix), "Destr_Prefix"); ModHelper.HarmonyHelper.AddPrefix <PadEZ.PadManager>("CreateController", typeof(PadManager_Fix), "Prefix"); ModHelper.Console.WriteLine("Controller Fix patched in!"); base.Configure(config); }
private void CopyGameFiles(IModConfig config) { foreach (var fileName in _filesToCopy) { File.Copy($"{config.ManagedPath}/{fileName}", fileName, true); } Console.WriteLine("Game files copied."); }
/* Dll Mods */ public ModInstance(LoadContext context, IModV1 mod, IModConfig config) { Context = context; Mod = mod; ModConfig = config; CanSuspend = mod.CanSuspend(); CanUnload = mod.CanUnload(); }
public ModHelper(IModConfig config, IModLogger logger, IModConsole console, IModEvents events, IHarmonyHelper harmonyHelper, IModAssets assets) { Config = config; Logger = logger; Console = console; Events = events; HarmonyHelper = harmonyHelper; Assets = assets; }
/* Dll Mods */ public ModInstance(PluginLoader loader, IModV1 mod, IModConfig config) { Loader = loader; Mod = mod; ModConfig = config; CanSuspend = mod.CanSuspend(); CanUnload = mod.CanUnload(); }
public override void Configure(IModConfig config) { _size = config.GetSettingsValue <int>("size"); if (_size < 1) { _size = 1; } ModHelper.Console.WriteLine($"Set screenshot size to {_size}"); }
public override void Configure(IModConfig config) { DebugMode = config.GetSettingsValue <bool>("debugMode"); XRSettings.showDeviceView = config.GetSettingsValue <bool>("showMirrorView"); // Prevent application from stealing mouse focus; ModHelper.HarmonyHelper.EmptyMethod <CursorManager>("Update"); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; }
public override void Configure(IModConfig config) { ToggleMusic(config.GetSettingsValue <bool>("enableMusic")); _isDucksEnabled = config.GetSettingsValue <bool>("enableDucks"); _isCubesEnabled = config.GetSettingsValue <bool>("enableCubes"); var speed = config.GetSettingsValue <float>("speed"); var power = config.GetSettingsValue <float>("power"); var enableSuperMode = config.GetSettingsValue <bool>("enableSuperMode"); }
public override void Configure(IModConfig config) { DefaultServerIP = config.GetSettingsValue <string>("defaultServerIP"); Port = config.GetSettingsValue <int>("port"); if (QSBNetworkManager.Instance != null) { QSBNetworkManager.Instance.networkPort = Port; } DebugMode = config.GetSettingsValue <bool>("debugMode"); }
public override void Configure(IModConfig config) { if (_crouchCombo != null) { ModHelper.Input.UnregisterCombination(_crouchCombo); } var combination = config.GetSettingsValue <string>("Crouch combination"); _crouchCombo = ModHelper.Input.RegisterCombination(this, "Crouch", combination) ?? TemporaryHack("Crouch"); }
private void StartGame(IModConfig config) { Console.WriteLine("Starting game..."); try { Process.Start($"{config.GamePath}/OuterWilds.exe"); } catch (Exception ex) { Console.WriteLine("Error while starting game: " + ex.Message); } }
private void PatchGame(IModConfig config) { var patcher = new ModPatcher(config); patcher.PatchGame(); var filesToCopy = new[] { "OWML.ModLoader.dll", "OWML.Common.dll", "OWML.Events.dll", "OWML.Assets.dll", "Newtonsoft.Json.dll", "System.Runtime.Serialization.dll", "0Harmony.dll" }; foreach (var filename in filesToCopy) { File.Copy(filename, $"{config.ManagedPath}/{filename}", true); } File.WriteAllText($"{config.ManagedPath}/OWML.Config.json", JsonConvert.SerializeObject(config)); }
public ModHelper(IModLogger logger, IModConsole console, IHarmonyHelper harmonyHelper, IModEvents events, IModAssets assets, IModStorage storage, IModMenus menus, IModManifest manifest, IModConfig config, IOwmlConfig owmlConfig, IModInteraction interaction) { Logger = logger; Console = console; HarmonyHelper = harmonyHelper; Events = events; Assets = assets; Storage = storage; Menus = menus; Manifest = manifest; Config = config; OwmlConfig = owmlConfig; Interaction = interaction; }
public override void Configure(IModConfig config) { Helper = ModHelper; Config = new ModConfig { debugMode = config.GetSettingsValue <bool>("debugMode"), showMirrorView = config.GetSettingsValue <bool>("showMirrorView"), overrideRefreshRate = config.GetSettingsValue <int>("overrideRefreshRate"), preventCursorLock = config.GetSettingsValue <bool>("preventCursorLock"), showHelmet = config.GetSettingsValue <bool>("showHelmet"), vibrationStrength = config.GetSettingsValue <float>("vibrationStrength"), enableGesturePrompts = config.GetSettingsValue <bool>("enableGesturePrompts"), controllerOrientedMovement = config.GetSettingsValue <bool>("controllerOrientedMovement"), }; }
public override void Configure(IModConfig config) { DefaultServerIP = config.GetSettingsValue <string>("defaultServerIP"); Port = config.GetSettingsValue <int>("port"); if (QSBNetworkManager.Instance != null) { QSBNetworkManager.Instance.networkPort = Port; } DebugMode = config.GetSettingsValue <bool>("debugMode"); if (!DebugMode) { FindObjectsOfType <DebugZOverride>().ToList().ForEach(x => Destroy(x.gameObject)); } ShowLinesInDebug = config.GetSettingsValue <bool>("showLinesInDebug"); SocketedObjToDebug = config.GetSettingsValue <int>("socketedObjToDebug"); }
/// <summary> /// Creates a NuGet package given the directory of a mod. /// </summary> /// <param name="modDirectory">Full path to the directory containing the mod.</param> /// <param name="outputDirectory">The path to the folder where the NuGet package should be output.</param> /// <param name="modConfig">The mod configuration for which to create the NuGet package.</param> /// <returns>The path of the generated .nupkg file.</returns> public string FromModDirectory(string modDirectory, string outputDirectory, IModConfig modConfig) { var xmlSerializer = new XmlSerializer(typeof(Package), "http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"); // Write .nuspec using (TextWriter writer = new StreamWriter($"{modDirectory}\\{modConfig.ModId}.nuspec")) { xmlSerializer.Serialize(writer, FromModConfig(modConfig)); } // Compress string nupkgPath = Path.Combine(outputDirectory, $"{modConfig.ModId}.nupkg"); ArchiveFile.CompressDirectory(modDirectory, nupkgPath); return(nupkgPath); }
public ModConfig(IModConfig config) { overrideRefreshRate = config.GetSettingsValue <int>("refreshRateOverride"); vibrationStrength = config.GetSettingsValue <float>("vibrationIntensity"); showHelmet = config.GetSettingsValue <bool>("helmetVisibility"); hideHudInConversations = config.GetSettingsValue <bool>("hideHudDuringDialogue"); controllerOrientedMovement = config.GetSettingsValue <bool>("movementControllerOriented"); enableGesturePrompts = config.GetSettingsValue <bool>("showGesturePrompts"); preventCursorLock = config.GetSettingsValue <bool>("disableCursorLock"); debugMode = config.GetSettingsValue <bool>("debug"); if (preventCursorLock) { NomaiVRPatch.Empty <CursorManager>("Update"); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } }
/// <summary> /// Entry point for your mod. /// </summary> public async void StartEx(IModLoaderV1 loaderApi, IModConfigV1 modConfig) { // For more information about this template, please see // https://reloaded-project.github.io/Reloaded-II/ModTemplate/ _modLoader = (IModLoader)loaderApi; _modConfig = (IModConfig)modConfig; _logger = (ILogger)_modLoader.GetLogger(); // Your config file is in Config.json. // Need a different name, format or more configurations? Modify the `Configurator`. // If you do not want a config, remove Configuration folder and Config class. var configurator = new Configurator(_modLoader.GetModConfigDirectory(_modConfig.ModId)); _configuration = configurator.GetConfiguration <Config>(0); _configuration.ConfigurationUpdated += OnConfigurationUpdated; // Start the server on another thread so we don't delay startup with JIT overhead. _lnlServer = await Task.Run(() => LiteNetLibServer.Create(_logger, _modLoader, _configuration)); }
public override void Configure(IModConfig config) { if (_inputs != null) { foreach (var key in _inputs.Keys) { ModHelper.Input.UnregisterCombination(_inputs[key]); } } _inputs = new Dictionary <string, IModInputCombination>(); foreach (var key in config.Settings.Keys) { var value = config.GetSettingsValue <string>(key); if (!string.IsNullOrEmpty(value)) { var combination = ModHelper.Input.RegisterCombination(this, key, value); _inputs.Add(key, combination); } } }
public override void Configure(IModConfig config) { console = ModHelper.Console; logger = ModHelper.Logger; if (inputs != null) { foreach (string key in inputs.Keys) { ModHelper.Input.UnregisterCombination(inputs[key]); } } inputs = new Dictionary <string, IModInputCombination>(); foreach (string name in config.Settings.Keys) { if (config.GetSettingsValue <string>(name) != null) { var combination = ModHelper.Input.RegisterCombination(this, name, config.GetSettingsValue <string>(name)); inputs.Add(name, combination); } } }