-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSecondaryUseCustomPatch.cs
More file actions
46 lines (44 loc) · 1.52 KB
/
SecondaryUseCustomPatch.cs
File metadata and controls
46 lines (44 loc) · 1.52 KB
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
using CoreLib.Submodules.ModSystem;
using HarmonyLib;
using Unity.Entities;
using UnityEngine;
namespace PainMod;
[HarmonyPatch]
internal class SecondaryUseCustomPatch
{
public static bool isStarting = false;
public static int currentTier = -1;
public static float duration;
public static bool tierIsDifferentToLastFrame = false;
public static bool justStarted = false;
[HarmonyPatch(typeof(EquipmentSlot), nameof(EquipmentSlot.StartWindup))]
[HarmonyPostfix]
public static void OnWindup(EquipmentSlot __instance)
{
if (__instance.objectData.objectID != Plugin.myCustomShootThing)
return;
isStarting = true;
duration = __instance.windupTimer.lifespan;
Plugin.logger.LogInfo("Wind up time is " + duration + "and current windup tier is " + currentTier);
}
[HarmonyPatch(typeof(EquipmentSlot), nameof(EquipmentSlot.Windup))]
[HarmonyPostfix]
public static void OnWindupDone(EquipmentSlot __instance)
{
if (__instance.objectData.objectID != Plugin.myCustomShootThing)
return;
if (currentTier != __instance.currentWindupTier)
{
Plugin.logger.LogInfo("Current windup tier is now " + __instance.currentWindupTier);
tierIsDifferentToLastFrame = true;
if (currentTier == 0)
justStarted = true;
}
else
{
tierIsDifferentToLastFrame = false;
justStarted = false;
}
currentTier = __instance.currentWindupTier;
}
}