-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
145 lines (128 loc) · 4.75 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using BepInEx;
using BepInEx.IL2CPP;
using BepInEx.Configuration;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using System;
using UnityEngine;
using UnhollowerBaseLib;
using UnhollowerRuntimeLib;
using UniverseLib;
// Made by Plasmatank. For Mystia's Izakaya.
namespace KokoroTest
{
[BepInPlugin("Plasmatank.KokoroTest", "KokoroTest", "1.0.0")]
public class Plugin : BasePlugin
{
public Harmony Harmony { get; } = new("VeryHarmonious");
public ConfigEntry<string> ConfigName { get; private set; }
public static BepInEx.Logging.ManualLogSource MyLogger;
public static PlayerCore Kokoro;
public static bool Get_Shield = false;
public static Shield MyShield;
public static void Print(object msg)
{
MyLogger.Log(BepInEx.Logging.LogLevel.Message, msg);
}
public override void Load()
{
MyLogger = Log;
Log.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
Print("First Mod!");
Harmony.PatchAll();
/*
ClassInjector.RegisterTypeInIl2Cpp<RuntimeListener>();
var Modifier = new GameObject("ModifierInstance");
Modifier.AddComponent<RuntimeListener>();
GameObject.DontDestroyOnLoad(Modifier);
Modifier.hideFlags |= HideFlags.HideAndDontSave;
*/
}
[HarmonyPatch(typeof(PlayerCore), nameof(PlayerCore.Awake))]
public static class AwakeHook
{
public static void Prefix(ref PlayerCore __instance)
{
Kokoro = __instance;
Print("I'm awake!");
}
}
[HarmonyPatch(typeof(PlayerCore), nameof(PlayerCore.AddShield))]
public static class GetShieldHook
{
public static void Prefix(Shield shield)
{
Get_Shield = true;
MyShield = shield;
Print("I got a shield!");
}
}
[HarmonyPatch(typeof(PlayerCore), nameof(PlayerCore.CostShield))]
public static class ShieldHook
{
public static bool Prefix(ref PlayerCore __instance, ref float damage)
{
if (damage >= 5)
{
damage *= 0.8f;
}
return true;
}
public static void Postfix(ref PlayerCore __instance)
{
Print("Cost: "+ Kokoro.aiShieldCostedNum.ToString());
}
}
[HarmonyPatch(typeof(PlayerCore), nameof(PlayerCore.AttackEntity), new Type[] {typeof(EntityCore), typeof(EntityCore), typeof(DamageType), typeof(float)})]
[HarmonyPatch(typeof(PlayerCore), nameof(PlayerCore.AttackEntity), new Type[] {typeof(EntityCore), typeof(EntityCore), typeof(AttackInfo), typeof(Il2CppSystem.Func<EntityCore, float, float>)})]
public static class HitHook
{
public static bool Prefix(ref PlayerCore __instance, ref EntityCore target)
{
Print("Target hit!");
var EntityInstance = target.TryCast<EntityCore>();
EntityInstance.BeHit(200f);
if (__instance.aiShieldCostedNum > 0)
{
Kokoro.CostShield(-(__instance.aiShieldCostedNum > 5 ? 5 : __instance.aiShieldCostedNum));
__instance.Heal(1f);
__instance.BeHit(1f); //Refresh UI
}
return true;
}
}
[HarmonyPatch(typeof(Mokou_SC1_Dash), nameof(Mokou_SC1_Dash.OnEnter))]
public static class DashHook
{
public static void Postfix()
{
Print("Incoming!");
var mokou = GameObject.FindObjectOfType<EntityCore>();
mokou.BeHit(300f);
}
}
[HarmonyPatch(typeof(EntityBuffList), nameof(EntityBuffList.InvincibleOn))]
public static class TransHook
{
public static bool Prefix(ref EntityBuffList __instance)
{
Print("Invincible? Show off!");
return false;
}
}
}
public class RuntimeListener : MonoBehaviour
{
void Start()
{
Plugin.Print("Listener is loaded!");
}
void Update()
{
if(UniverseLib.Input.InputManager.GetKeyDown(KeyCode.Backspace))
{
Plugin.Print(Plugin.Kokoro.aiShieldCostedNum);
}
}
}
}