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