Skip to content

Commit

Permalink
Merge pull request #22 from brcoding/Experiments
Browse files Browse the repository at this point in the history
Upgraded BepInEx and added more to disable all post processing effects
  • Loading branch information
brcoding authored Jun 17, 2020
2 parents 5bb227d + 5385bb6 commit a376b55
Show file tree
Hide file tree
Showing 20 changed files with 1,903 additions and 1,239 deletions.
4 changes: 3 additions & 1 deletion Mods/RForRotate/RForRotatePlugin/RForRotate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class RForRotatePlugin: BaseUnityPlugin
// Awake is called once when both the game and the plug-in are loaded
void Awake()
{
Logger.LogInfo("In Awake for R For Rotate Plug-in");

UnityEngine.Debug.Log("R For Rotate Plug-in loaded");
ModdingTales.ModdingUtils.Initialize(this);
ModdingTales.ModdingUtils.Initialize(this, Logger);
}

private void RotateSelected(double amount)
Expand Down
47 changes: 29 additions & 18 deletions Mods/RemoveDoFPlugin/RemoveDoFPlugin/RemoveDoF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,30 @@ public class DeDoFIt: BaseUnityPlugin
// Awake is called once when both the game and the plug-in are loaded
void Awake()
{
Logger.LogInfo("In Awake for DepthofField Plug-in");
UnityEngine.Debug.Log("Remove Depth of Field Plug-in loaded");
ModdingTales.ModdingUtils.Initialize(this);
ModdingTales.ModdingUtils.Initialize(this, this.Logger);
}

private void ToggleAll()
{
this.allEnabled = !this.allEnabled;

// Disable all post processing effects
var postProcessLayer = Camera.main.GetComponent<PostProcessLayer>();
postProcessLayer.enabled = this.allEnabled;
SystemMessage.DisplayInfoText("Post processing " + getEnabledText(this.allEnabled) + ".");
}
private string getEnabledText(bool enabled)
{
if (enabled)
{
return "enabled";
} else
{
return "disabled";
}
}

private void ToggleDoF()
{
this.dofEnabled = !this.dofEnabled;
Expand All @@ -34,16 +54,9 @@ private void ToggleDoF()
var aa = (AtmosphereApplier)am.GetType().GetField("_applier", flags).GetValue(am);
var dof = (DepthOfField)aa.GetType().GetField("_depthOfField", flags).GetValue(aa);
var postProcessLayer = Camera.main.GetComponent<PostProcessLayer>();


//PostProcessVolume dv = (PostProcessVolume)aa.GetType().GetField("_dayVolume", flags).GetValue(aa);

//dv.enabled = this.dofEnabled;
//PostProcessVolume nv = (PostProcessVolume)aa.GetType().GetField("_nightVolume", flags).GetValue(aa);

//nv.enabled = this.dofEnabled;

dof.enabled.value = this.dofEnabled;
SystemMessage.DisplayInfoText("Depth of field " + getEnabledText(this.dofEnabled) + ".");
}
}
catch (System.Exception ex)
Expand All @@ -58,19 +71,17 @@ private void ToggleDoF()

void Update()
{
//Shader shader;// = new Shader();
//shader = Shader.Find("Hidden/ChromaticAberration");
//Material material = new Material(shader);
//if (shader != null)
//{
// material.SetFloat("_ChromaticAberration", 0f);
//}
if (Input.GetKeyUp(KeyCode.H))
if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyUp(KeyCode.H))
{
ToggleAll();
}
else if (Input.GetKeyUp(KeyCode.H))
{
ToggleDoF();
}
}

private bool allEnabled = true;
private bool dofEnabled = true;
}
}
4 changes: 3 additions & 1 deletion Mods/RemoveFogPlugin/RemoveFogPlugin/RemoveFog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class DefogIt: BaseUnityPlugin
// Awake is called once when both the game and the plug-in are loaded
void Awake()
{
Logger.LogInfo("In Awake for Remove Fog Plug-in");

UnityEngine.Debug.Log("Remove Fog Plug-in loaded");
ModdingTales.ModdingUtils.Initialize(this);
ModdingTales.ModdingUtils.Initialize(this, this.Logger);
}

private void ToggleFog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ class SetInjectionFlag : BaseUnityPlugin
{
void Awake()
{
Logger.LogInfo("In Awake for SetInjectionFlag Plug-in");

UnityEngine.Debug.Log("SetInjectionFlag Plug-in loaded");
ModdingUtils.Initialize(this);
ModdingUtils.Initialize(this, this.Logger);
}
}
}
4 changes: 3 additions & 1 deletion Mods/ShowPosition/ShowPositionPlugin/ShowPosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class ShowPositionPlugin: BaseUnityPlugin
// Awake is called once when both the game and the plug-in are loaded
void Awake()
{
Logger.LogInfo("In Awake for ShowPosition Plug-in");

UnityEngine.Debug.Log("Show Position Plug-in loaded");
ModdingTales.ModdingUtils.Initialize(this);
ModdingTales.ModdingUtils.Initialize(this, this.Logger);
}

void Update()
Expand Down
4 changes: 3 additions & 1 deletion Mods/SocketAPI/SocketAPIPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ class SocketAPIPlugin : BaseUnityPlugin
{
void Awake()
{
Logger.LogInfo("In Awake for SocketAPI Plug-in");

UnityEngine.Debug.Log("SocketAPI Plug-in loaded");
ModdingUtils.Initialize(this, true);
ModdingUtils.Initialize(this, this.Logger, true);
}

void Update()
Expand Down
22 changes: 18 additions & 4 deletions Utils/ModdingUtils/ModdingUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using DataModel;
using Unity.Mathematics;
using System.Collections;
using BepInEx.Logging;

namespace ModdingTales
{
Expand Down Expand Up @@ -102,6 +103,7 @@ public struct SlabData
public static class ModdingUtils
{
private static BaseUnityPlugin parentPlugin;
private static ManualLogSource parentLogger;
private static bool serverStarted = false;
//private static bool movingCreature = false;
//private static Queue<MoveAction> moveQueue = new Queue<MoveAction>();
Expand All @@ -114,7 +116,7 @@ public static class ModdingUtils
public static string slabSizeSlab = "";
public static bool slabSizeResponse;
public static float3 slabSize;
public static Copied beingCopied;
public static Copied beingCopied;

static ModdingUtils()
{
Expand Down Expand Up @@ -1094,6 +1096,7 @@ public static TextMeshProUGUI GetUITextByName(string name)
TextMeshProUGUI[] texts = UnityEngine.Object.FindObjectsOfType<TextMeshProUGUI>();
for (int i = 0; i < texts.Length; i++)
{
parentLogger.LogInfo("Found UI" + texts[i].name);
if (texts[i].name == name)
{
return texts[i];
Expand All @@ -1107,10 +1110,12 @@ public static PostProcessLayer GetPostProcessLayer()
return Camera.main.GetComponent<PostProcessLayer>();
}

public static void Initialize(BaseUnityPlugin parentPlugin, bool startSocket=false)
public static void Initialize(BaseUnityPlugin parentPlugin, ManualLogSource logger, bool startSocket=false)
{
AppStateManager.UsingCodeInjection = true;
ModdingUtils.parentPlugin = parentPlugin;
ModdingUtils.parentLogger = logger;
parentLogger.LogInfo("Inside initialize");
SceneManager.sceneLoaded += OnSceneLoaded;
// By default do not start the socket server. It requires the caller to also call OnUpdate in the plugin update method.
if (startSocket)
Expand All @@ -1121,14 +1126,18 @@ public static void Initialize(BaseUnityPlugin parentPlugin, bool startSocket=fal

public static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//UnityEngine.Debug.Log("Loading Scene: " + scene.name);
try
{

parentLogger.LogInfo("On Scene Loaded" + scene.name);
UnityEngine.Debug.Log("Loading Scene: " + scene.name);
if (scene.name == "UI") {
TextMeshProUGUI betaText = GetUITextByName("BETA");
if (betaText)
{
betaText.text = "INJECTED BUILD - unstable mods";
}
} else if (scene.name == "Login")
} else
{
TextMeshProUGUI modListText = GetUITextByName("TextMeshPro Text");
if (modListText)
Expand All @@ -1141,6 +1150,11 @@ public static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
modListText.text += "\n" + bepInPlugin.Name + " - " + bepInPlugin.Version;
}
}
}
catch (Exception ex)
{
parentLogger.LogFatal(ex);
}
}
}
}
117 changes: 117 additions & 0 deletions bepinexbin/BepInEx/config/BepInEx.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
[Caching]

## Enable/disable assembly metadata cache
## Enabling this will speed up discovery of plugins and patchers by caching the metadata of all types BepInEx discovers.
# Setting type: Boolean
# Default value: true
EnableAssemblyCache = true

[Harmony.Logger]

## Specifies which Harmony log channels to listen to.
## NOTE: IL channel dumps the whole patch methods, use only when needed!
# Setting type: LogChannel
# Default value: Warn, Error
# Acceptable values: None, Info, IL, Warn, Error, All
# Multiple values can be set at the same time by separating them with , (e.g. Debug, Warning)
LogChannels = All

[Logging]

## Redirects text from Console.Out during preloader patch loading to the BepInEx logging system.
# Setting type: Boolean
# Default value: true
PreloaderConsoleOutRedirection = true

## Enables showing unity log messages in the BepInEx logging system.
# Setting type: Boolean
# Default value: true
UnityLogListening = true

[Logging.Console]

## Enables showing a console for log output.
# Setting type: Boolean
# Default value: false
Enabled = false

## If true, console is set to the Shift-JIS encoding, otherwise UTF-8 encoding.
# Setting type: Boolean
# Default value: false
ShiftJisEncoding = false

## Which log levels to show in the console output.
# Setting type: LogLevel
# Default value: Fatal, Error, Message, Info
# Acceptable values: None, Fatal, Error, Warning, Message, Info, Debug, All
# Multiple values can be set at the same time by separating them with , (e.g. Debug, Warning)
LogLevels = Fatal, Error, Message, Info, Debug

[Logging.Disk]

## Include unity log messages in log file output.
# Setting type: Boolean
# Default value: false
WriteUnityLog = true

## Appends to the log file instead of overwriting, on game startup.
# Setting type: Boolean
# Default value: false
AppendLog = false

## Enables writing log messages to disk.
# Setting type: Boolean
# Default value: true
Enabled = true

## Which log leves are saved to the disk log output.
# Setting type: LogLevel
# Default value: Fatal, Error, Message, Info
# Acceptable values: None, Fatal, Error, Warning, Message, Info, Debug, All
# Multiple values can be set at the same time by separating them with , (e.g. Debug, Warning)
LogLevels = All

[Preloader]

## Enables or disables runtime patches.
## This should always be true, unless you cannot start the game due to a Harmony related issue (such as running .NET Standard runtime) or you know what you're doing.
# Setting type: Boolean
# Default value: true
ApplyRuntimePatches = true

## If enabled, BepInEx will save patched assemblies into BepInEx/DumpedAssemblies.
## This can be used by developers to inspect and debug preloader patchers.
# Setting type: Boolean
# Default value: false
DumpAssemblies = false

## If enabled, BepInEx will load patched assemblies from BepInEx/DumpedAssemblies instead of memory.
## This can be used to be able to load patched assemblies into debuggers like dnSpy.
## If set to true, will override DumpAssemblies.
# Setting type: Boolean
# Default value: false
LoadDumpedAssemblies = false

## If enabled, BepInEx will call Debugger.Break() once before loading patched assemblies.
## This can be used with debuggers like dnSpy to install breakpoints into patched assemblies before they are loaded.
# Setting type: Boolean
# Default value: false
BreakBeforeLoadAssemblies = false

[Preloader.Entrypoint]

## The local filename of the assembly to target.
# Setting type: String
# Default value: UnityEngine.CoreModule.dll
Assembly = UnityEngine.CoreModule.dll

## The name of the type in the entrypoint assembly to search for the entrypoint method.
# Setting type: String
# Default value: Application
Type = Application

## The name of the method in the specified entrypoint assembly and type to hook and load Chainloader from.
# Setting type: String
# Default value: .cctor
Method = .cctor

Binary file modified bepinexbin/BepInEx/core/0Harmony.dll
Binary file not shown.
Loading

0 comments on commit a376b55

Please sign in to comment.