-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
110 lines (89 loc) · 3.02 KB
/
Plugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using BepInEx;
using BepInEx.IL2CPP;
using BepInEx.Logging;
using FFPR_Fix.Patches;
using HarmonyLib;
using System;
namespace FFPR_Fix;
[BepInPlugin("d3xMachina.ffpr_fix", "FFPR Fix", "1.2.2")]
public partial class Plugin : BasePlugin
{
public static new ManualLogSource Log;
public static new ModConfiguration Config;
public override void Load()
{
Log = base.Log;
Log.LogInfo($"Game detected: {GameDetection.Version}");
Log.LogInfo("Loading...");
Config = new ModConfiguration(base.Config);
Config.Init();
if (ModComponent.Inject())
{
ApplyPatches();
}
}
private void ApplyPatches()
{
bool mountRotatePatch = false;
if (Config.UncapFPS.Value || Config.EnableVsync.Value)
{
ApplyPatch(typeof(FrameratePatch));
mountRotatePatch = true;
}
if (Config.ChocoboTurnFactor.Value != 1f || Config.AirshipTurnFactor.Value != 1f)
{
mountRotatePatch = true;
}
if (mountRotatePatch)
{
ApplyPatch(typeof(AirshipRotatePatch));
ApplyPatch(typeof(ChocoboRotatePatch), GameVersion.FF3 | GameVersion.FF5 | GameVersion.FF6);
}
if (Config.HideFieldMinimap.Value || Config.HideWorldMinimap.Value)
{
ApplyPatch(typeof(HideMinimapPatch));
}
if (Config.SkipSplashscreens.Value || Config.SkipPressAnyKey.Value)
{
ApplyPatch(typeof(SkipIntroPatch));
}
if (Config.BattleWaitPlayerCommand.Value)
{
ApplyPatch(typeof(BattleWaitPlayerCommand), GameVersion.FF4 | GameVersion.FF5 | GameVersion.FF6);
}
if (Config.BattleATBSpeed.Value > 0f && Config.BattleATBSpeed.Value != 1f)
{
ApplyPatch(typeof(BattleATBSpeed), GameVersion.FF4 | GameVersion.FF5 | GameVersion.FF6);
}
if (Config.PlayerWalkspeed.Value > 0f && Config.PlayerWalkspeed.Value != 1f)
{
ApplyPatch(typeof(PlayerMoveSpeedPatch));
}
if (Config.RunOnWorldMap.Value)
{
ApplyPatch(typeof(RunOnWorldMap));
}
if (Config.DisableDiagonalMovements.Value)
{
ApplyPatch(typeof(DisableDiagonalMovements));
}
if (Config.UseDecryptedSaveFiles.Value)
{
ApplyPatch(typeof(UseDecryptedSaveFiles));
}
else if (Config.BackupSaveFiles.Value) // already implemented in UseDecryptedSaveFiles
{
ApplyPatch(typeof(BackupSaveFiles));
}
Log.LogInfo("Patches applied!");
}
private void ApplyPatch(Type type, GameVersion versionsFlag = GameVersion.Any)
{
if ((GameDetection.Version & versionsFlag) != GameDetection.Version)
{
return;
}
Log.LogInfo($"Patching {type.Name}...");
Harmony.CreateAndPatchAll(type);
}
}