-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstantEat.cs
More file actions
60 lines (53 loc) · 1.95 KB
/
InstantEat.cs
File metadata and controls
60 lines (53 loc) · 1.95 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using InstantEat.Patches;
using System.Collections;
using UnityEngine;
namespace InstantEat
{
[BepInPlugin(GUID, NAME, VERSION)]
[BepInProcess("Muck.exe")]
public class InstantEat : BaseUnityPlugin
{
public static ConfigEntry<bool> configInstantEatEnabled;
public static InventoryItem currentItem;
public static ParticleSystem.EmissionModule eatingEmission;
public const string
GUID = "InstantEat",
NAME = "InstantEat",
VERSION = "1.0.0";
public void Awake()
{
configInstantEatEnabled = Config.Bind("General", "Enabled", true, "Whether or not InstantEat is enabled");
Harmony.CreateAndPatchAll(typeof(MuckPatch));
Logger.LogMessage("Loaded InstantEat");
}
public void Update()
{
if (Input.GetMouseButtonDown(0))
{
if (currentItem != null && !InventoryUI.Instance.gameObject.activeInHierarchy)
{
if (configInstantEatEnabled.Value && currentItem.tag == InventoryItem.ItemTag.Food) FinishEating();
}
}
}
public void FinishEating()
{
UseInventory.Instance.eatSfx.Stop();
StartCoroutine(Play(UseInventory.Instance.eatSfx, 0.45f));
eatingEmission = UseInventory.Instance.eatingParticles.emission;
eatingEmission.enabled = false;
PlayerStatus.Instance.Eat(currentItem);
ClientSend.AnimationUpdate(OnlinePlayer.SharedAnimation.Eat, false);
Hotbar.Instance.UseItem(1);
}
public IEnumerator Play(AudioSource audioSource, float seconds)
{
audioSource.Play();
yield return new WaitForSeconds(seconds);
audioSource.Stop();
}
}
}