-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fishing aberrated fishes increases (in)sanity
- Loading branch information
1 parent
78ae566
commit 815a8f5
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
BeyondAbyss/Patches/Transpiler/HarvestMinigameView_Transpiler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Cinemachine; | ||
using HarmonyLib; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using System.Threading; | ||
using UnityEngine; | ||
using Winch.Core; | ||
|
||
namespace BeyondAbyss.Patches.Transpiler | ||
{ | ||
[HarmonyPatch(typeof(HarvestMinigameView))] | ||
internal class HarvestMinigameView_Transpiler | ||
{ | ||
[HarmonyTranspiler] | ||
[HarmonyPatch(typeof(HarvestMinigameView), "SpawnItem")] | ||
public static IEnumerable<CodeInstruction> SpawnItem_Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
CodeMatcher matcher = new CodeMatcher(instructions) | ||
.MatchEndForward( | ||
new CodeMatch(OpCodes.Ldarg_0), | ||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(HarvestMinigameView), "currentPOI")), | ||
new CodeMatch(OpCodes.Ldc_I4_0), | ||
new CodeMatch(i => i.opcode == OpCodes.Callvirt && ((MethodInfo)i.operand).Name == "SetIsCurrentlySpecial")); | ||
|
||
if (matcher.IsInvalid) | ||
{ | ||
WinchCore.Log.Error("Could not find IL code in HarvestMinigameView, skipping patch (no sanity effect on aberration catch)."); | ||
return instructions; | ||
} | ||
|
||
matcher | ||
.Advance(1) | ||
.Insert(Helper.Transpiler.EmitDelegate<System.Action>(() => | ||
{ | ||
AccessTools.Field(typeof(PlayerSanity), "_sanity").SetValue(GameManager.Instance.Player.Sanity, GameManager.Instance.Player.Sanity.CurrentSanity + 0.15f); | ||
new Thread(new ThreadStart(() => | ||
{ | ||
float defaultFOV = (float)AccessTools.Field(typeof(PlayerCamera), "defaultFOV").GetValue(GameManager.Instance.PlayerCamera); | ||
float hasteFOV = (float)AccessTools.Field(typeof(PlayerCamera), "hasteFOV").GetValue(GameManager.Instance.PlayerCamera); | ||
CinemachineFreeLook cmfl = (CinemachineFreeLook)AccessTools.Field(typeof(PlayerCamera), "cinemachineCamera").GetValue(GameManager.Instance.PlayerCamera); | ||
|
||
float value = 1f; | ||
while(value >= 0f) | ||
{ | ||
cmfl.m_Lens.FieldOfView = Mathf.Lerp(defaultFOV, hasteFOV, value); | ||
value -= 0.01f; | ||
|
||
Thread.Sleep(50); | ||
} | ||
})).Start(); | ||
})); | ||
|
||
return matcher.InstructionEnumeration(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters