34 lines
846 B
C#
Raw Normal View History

using HarmonyLib;
using QSB.CampfireSync.WorldObjects;
2021-03-29 23:36:51 +01:00
using QSB.Events;
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
{
2021-11-01 15:49:00 +00:00
var qsbCampfire = QSBWorldSync.GetWorldFromUnity<QSBCampfire>(__instance);
if (__instance._state == Campfire.State.LIT)
2021-03-29 23:36:51 +01:00
{
qsbCampfire.StartRoasting();
}
else
{
qsbCampfire.SetState(Campfire.State.LIT);
QSBEventManager.FireEvent(EventNames.QSBCampfireState, qsbCampfire.ObjectId, Campfire.State.LIT);
Locator.GetFlashlight().TurnOff(false);
}
2021-06-18 22:38:32 +01:00
2021-03-29 23:36:51 +01:00
return false;
}
}
}