quantum-space-buddies/QSB/CampfireSync/Patches/CampfirePatches.cs

33 lines
815 B
C#
Raw Normal View History

using HarmonyLib;
2021-12-25 05:49:18 +00:00
using QSB.CampfireSync.Messages;
using QSB.CampfireSync.WorldObjects;
2021-12-25 05:49:18 +00:00
using QSB.Messaging;
2021-03-29 22:36:51 +00:00
using QSB.Patches;
using QSB.WorldSync;
namespace QSB.CampfireSync.Patches;
[HarmonyPatch]
internal class CampfirePatches : QSBPatch
2021-03-29 22:36:51 +00:00
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
2021-03-29 22:36:51 +00:00
[HarmonyPrefix]
[HarmonyPatch(typeof(Campfire), nameof(Campfire.OnPressInteract))]
public static bool LightCampfireEvent(Campfire __instance)
{
var qsbCampfire = __instance.GetWorldObject<QSBCampfire>();
if (__instance._state == Campfire.State.LIT)
2021-03-29 22:36:51 +00:00
{
qsbCampfire.StartRoasting();
2021-03-29 22:36:51 +00:00
}
else
{
qsbCampfire.SetState(Campfire.State.LIT);
qsbCampfire.SendMessage(new CampfireStateMessage(Campfire.State.LIT));
Locator.GetFlashlight().TurnOff(false);
}
return false;
2021-03-29 22:36:51 +00:00
}
}