Skip to content

Commit

Permalink
Fix AI cameratarget bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Keelhauled committed Dec 13, 2019
1 parent a2c1cbe commit 4094cd8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
19 changes: 16 additions & 3 deletions src/CameraTargetFix.AISyoujyo/CameraTargetFix.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
using BepInEx;
using CharaCustom;
using HarmonyLib;

namespace KeelPlugins
{
[BepInProcess(AISyoujyoConstants.StudioProcessName)]
[BepInPlugin(GUID, PluginName, Version)]
public class CameraTargetFix : CameraTargetFixCore
{
protected override void Awake()
{
base.Awake();

Harmony.Patch(typeof(Studio.CameraControl).GetMethod("InternalUpdateCameraState", AccessTools.all),
transpiler: new HarmonyMethod(typeof(CameraTargetFixCore).GetMethod(nameof(StudioPatch), AccessTools.all)));
if(Paths.ProcessName == AISyoujyoConstants.StudioProcessName)
{
Harmony.Patch(typeof(Studio.CameraControl).GetMethod("InternalUpdateCameraState", AccessTools.all),
transpiler: new HarmonyMethod(typeof(CameraTargetFixCore).GetMethod(nameof(StudioPatch), AccessTools.all)));
}
else
{
Harmony.Patch(typeof(CustomControl).GetMethod("Start", AccessTools.all),
postfix: new HarmonyMethod(GetType().GetMethod(nameof(MakerPatch), AccessTools.all)));
}
}

private static void MakerPatch()
{
Singleton<CustomBase>.Instance.centerDraw = Manager.Config.ActData.Look;
}
}
}
5 changes: 3 additions & 2 deletions src/CameraTargetFix.Core/CameraTargetFixCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ public abstract class CameraTargetFixCore : BaseUnityPlugin
public const string Version = "1.0.0." + BuildNumber.Version;

protected static new ManualLogSource Logger;
protected static Harmony Harmony = new Harmony($"{GUID}.harmony");
protected static Harmony Harmony;

protected virtual void Awake()
{

Logger = base.Logger;
Harmony = new Harmony($"{GUID}.harmony");
}

#if DEBUG
Expand Down
7 changes: 2 additions & 5 deletions src/CameraTargetFix.Koikatu/CameraTargetFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ protected override void Awake()
{
base.Awake();

if(SceneHelper.StudioInit)
{
Harmony.Patch(typeof(Studio.CameraControl).GetMethod("LateUpdate", AccessTools.all),
transpiler: new HarmonyMethod(typeof(CameraTargetFixCore).GetMethod(nameof(StudioPatch), AccessTools.all)));
}
Harmony.Patch(typeof(Studio.CameraControl).GetMethod("LateUpdate", AccessTools.all),
transpiler: new HarmonyMethod(typeof(CameraTargetFixCore).GetMethod(nameof(StudioPatch), AccessTools.all)));
}
}
}
1 change: 0 additions & 1 deletion src/Common.Koikatu/Common.Koikatu.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)KoikatuConstants.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SceneHelper.cs" />
</ItemGroup>
</Project>
9 changes: 0 additions & 9 deletions src/Common.Koikatu/SceneHelper.cs

This file was deleted.

0 comments on commit 4094cd8

Please sign in to comment.