34 lines
839 B
C#
Raw Normal View History

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