public int SetProjectorProjections(string blueprintName, string ProjectorTag, IMyCubeGrid grid) { int projectionsChangedCount = 0; List <IMySlimBlock> blocks = new List <IMySlimBlock>(); List <IMySlimBlock> temp = new List <IMySlimBlock>(); grid.GetBlocks(blocks); for (int i = 0; i < blocks.Count; i++) { var projector = blocks[i].FatBlock as IMyProjector; if (projector == null || !projector.CustomName.Contains(ProjectorTag)) { continue; } if (projector.LoadBlueprint(Path.Combine(MyBlueprintUtils.BLUEPRINT_FOLDER_LOCAL, blueprintName, "bp.sbc"))) { projectionsChangedCount++; } else { HaEConsole.WriteLine($"ERR: {projector.CustomName} COULDNT UPDATE PROJECTION!, check blueprint name!"); } } return(projectionsChangedCount); }
public void LoadTexturesFrom(string texturePackName) { string source = HaEConstants.pluginFolder + "\\" + HamTweakConstants.TexturePackFolder + "\\" + texturePackName; List <string> directories = new List <string>(); List <string> nextDirs = new List <string>(); directories.Add(source); while (directories.Count != 0) { nextDirs.Clear(); foreach (var directory in directories) { HaEConsole.WriteLine($"In: {directory}"); foreach (var file in Directory.EnumerateFiles(directory)) { var substr = file.Substring(source.Length + 1); SwapCustomTexture(substr, texturePackName); } nextDirs.AddRange(Directory.GetDirectories(directory)); } directories.Clear(); directories.AddRange(nextDirs); } }
public void SwapCustomTexture(string texture, string texturePackName) { string toReplacePath = MyFileSystem.ContentPath + "\\Textures\\" + texture; string backupVanillaPath = HaEConstants.pluginFolder + "\\" + HamTweakConstants.VanillaTextureFolder + "\\" + texture; string fullTexturePath = HaEConstants.pluginFolder + "\\" + HamTweakConstants.TexturePackFolder + "\\" + texturePackName + "\\" + texture; if (!File.Exists(backupVanillaPath)) { if (!Directory.Exists(Path.GetDirectoryName(backupVanillaPath))) { Directory.CreateDirectory(Path.GetDirectoryName(backupVanillaPath)); HaEConsole.WriteLine($"Backup directory: {Path.GetDirectoryName(backupVanillaPath)} Created!"); } HaEConsole.WriteLine($"Vanilla Backup: {backupVanillaPath} Created!"); File.Copy(toReplacePath, backupVanillaPath); } if (File.Exists(fullTexturePath)) { HaEConsole.WriteLine($"Swapping in Texture: {fullTexturePath}"); File.Delete(toReplacePath); File.Copy(fullTexturePath, toReplacePath, true); } }
public static void ColorGridOrBlockRequestValidationPatch(HarmonyInstance harmony) { harmony.Patch(typeof(MyCubeGrid).GetMethod("ColorGridOrBlockRequestValidation", BindingFlags.NonPublic | BindingFlags.Instance), new HarmonyMethod(typeof(Patch).GetMethod("PrefixColorGridOrBlockRequestValidation", BindingFlags.Public | BindingFlags.Static))); HaEConsole.WriteLine($"Patched MyCubeGrid.ColorGridOrBlockRequestValidation"); }
public static void IsSettingsExperimentalPatch(HarmonyInstance harmony) { harmony.Patch(typeof(MySession).GetMethod("IsSettingsExperimental", BindingFlags.Public | BindingFlags.Instance), new HarmonyMethod(typeof(Patch).GetMethod("PrefixIsSettingsExperimental", BindingFlags.Public | BindingFlags.Static))); HaEConsole.WriteLine($"Patched MySession.IsSettingsExperimental"); }
public static void PBProfilingPatch(HarmonyInstance harmony) { harmony.Patch(typeof(MyProgrammableBlock).GetMethod("ExecuteCode", BindingFlags.Public | BindingFlags.Instance), null, new HarmonyMethod(typeof(ProfilerPatches).GetMethod("SuffixProfilePB", BindingFlags.NonPublic | BindingFlags.Static))); HaEConsole.WriteLine($"Patched MyProgrammableBlock.ExecuteCode"); }
public static void ApplyPatch() { HaEConsole.WriteLine($"Patching ProfilerPatches..."); var harmony = HarmonyInstance.Create("com.HaE.HamTweaks.Profiler"); PBProfilingPatch(harmony); HaEConsole.WriteLine($"ProfilerPatches: Patched 1 method"); }
public static void ApplyPatch() { var harmony = HarmonyInstance.Create("com.HaE.HamTweaks.UXTweaks"); HaEConsole.WriteLine($"Patching UXPatches..."); IsSettingsExperimentalPatch(harmony); //ColorGridOrBlockRequestValidationPatch(harmony); HaEConsole.WriteLine($"UXPatches: Patched 2 methods"); }
public void ApplyLightingPatch() { if (!HaEHamTweaks.config.lightingPatch) { HaEConsole.WriteLine("lighting patch disabled."); return; } HaEConsole.WriteLine("lighting patch is no longer supported."); //RendertweakPatches.ApplyPatch(); //string filePath = MyFileSystem.ContentPath + "\\Shaders\\Lighting\\LightDefs.hlsli"; //StreamReader reader = new StreamReader(filePath); //string input = reader.ReadToEnd(); //reader.Close(); //if (input.Contains($"#define MAX_TILE_LIGHTS 256")) //{ // using (StreamWriter writer = new StreamWriter(filePath, false)) // { // { // string output = input.Replace("#define MAX_TILE_LIGHTS 256", $"#define MAX_TILE_LIGHTS {RendertweakPatches.pointlightCount}"); // writer.Write(output); // } // writer.Close(); // } // try // { // Directory.Delete(MyFileSystem.UserDataPath + "\\ShaderCache2", true); // } catch(DirectoryNotFoundException e) // { // HaEConsole.WriteLine("Could not find shadercache!"); // } // MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Info, MyMessageBoxButtonsType.YES_NO, // new StringBuilder("Please restart SE for lighting change to take effect!"), // new StringBuilder("HaE HamTweaks:"), // null, null, null, null, new Action<MyGuiScreenMessageBox.ResultEnum>(ExitCallback))); //} }