2021-10-15 20:06:51 +00:00
|
|
|
|
using HarmonyLib;
|
2021-12-25 05:49:18 +00:00
|
|
|
|
using QSB.CampfireSync.Messages;
|
2021-10-15 20:06:51 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2021-10-15 20:06:51 +00:00
|
|
|
|
[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;
|
|
|
|
|
|
2021-10-15 20:06:51 +00:00
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
[HarmonyPatch(typeof(Campfire), nameof(Campfire.OnPressInteract))]
|
|
|
|
|
public static bool LightCampfireEvent(Campfire __instance)
|
2021-03-29 22:36:51 +00:00
|
|
|
|
{
|
2021-12-26 06:37:20 +00:00
|
|
|
|
var qsbCampfire = __instance.GetWorldObject<QSBCampfire>();
|
2021-10-15 20:06:51 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|