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

35 lines
840 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]
2021-03-29 22:37:36 +00:00
internal class CampfirePatches : QSBPatch
2021-03-29 22:36:51 +00:00
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPrefix]
[HarmonyPatch(typeof(Campfire), nameof(Campfire.OnPressInteract))]
public static bool LightCampfireEvent(Campfire __instance)
2021-03-29 22:36:51 +00:00
{
var qsbCampfire = __instance.GetWorldObject<QSBCampfire>();
if (__instance._state == Campfire.State.LIT)
2021-03-29 22:36:51 +00:00
{
qsbCampfire.StartRoasting();
}
else
{
qsbCampfire.SetState(Campfire.State.LIT);
2021-12-25 05:49:18 +00:00
qsbCampfire.SendMessage(new CampfireStateMessage(Campfire.State.LIT));
2021-03-29 22:36:51 +00:00
Locator.GetFlashlight().TurnOff(false);
}
2021-06-18 21:38:32 +00:00
2021-03-29 22:36:51 +00:00
return false;
}
}
}