private static void Postfix(Bed __instance, Humanoid human, bool repeat, ZNetView ___m_nview) { if (Configuration.Current.Bed.IsEnabled && Configuration.Current.Bed.sleepWithoutSpawn) { if (Input.GetKey(KeyCode.LeftShift)) { if (Input.GetKeyDown(KeyCode.E)) { bool flag = Traverse.Create(__instance).Method("IsCurrent", new object[0]).GetValue <bool>() || repeat || Configuration.Current.Bed.unclaimedBedsOnly && ___m_nview.GetZDO().GetLong("owner", 0L) != 0L; if (!flag) { Player humanPlayer = human as Player; if (!EnvMan.instance.IsAfternoon() && !EnvMan.instance.IsNight()) { human.Message(MessageHud.MessageType.Center, "$msg_cantsleep", 0, null); return; } if (!__instance.CheckEnemies(humanPlayer)) { return; } if (!__instance.CheckExposure(humanPlayer)) { return; } if (!__instance.CheckFire(humanPlayer)) { return; } if (!__instance.CheckWet(humanPlayer)) { return; } human.AttachStart(__instance.m_spawnPoint, __instance.gameObject, true, true, false, "attach_bed", new Vector3(0f, 0.5f, 0f)); return; } } } } }
public static bool Interact(Bed __instance, ref bool __result, ref Humanoid human, ref bool repeat) { if (!modEnabled.Value) { return(true); } // No special logic, so defer to normal execution if (!enableMultipleBedfellows.Value && !sleepWithoutSpawnpoint.Value && !sleepAnyTime.Value && !sleepWithoutClaiming.Value) { return(true); } if (repeat) { return(false); } long playerID = Game.instance.GetPlayerProfile().GetPlayerID(); bool owner = __instance.GetOwner() != 0L; bool altFunc = Input.GetKey(ALT_FUNC_KEY); Player thePlayer = human as Player; // If there is no owner at all if (!owner) { if (!__instance.CheckExposure(thePlayer)) { __result = false; return(false); } if (!altFunc) { __instance.SetOwner(playerID, Game.instance.GetPlayerProfile().GetName()); __result = false; return(false); } if (!sleepWithoutSpawnpoint.Value) { Game.instance.GetPlayerProfile().SetCustomSpawnPoint(__instance.GetSpawnPoint()); human.Message(MessageHud.MessageType.Center, "$msg_spawnpointset", 0, null); } if (!altFunc && sleepWithoutClaiming.Value && sleepWithoutSpawnpoint.Value) { __result = false; return(false); } } // If the bed belongs to the current player if (__instance.IsMine() || enableMultipleBedfellows.Value) { if (__instance.IsCurrent() || sleepWithoutSpawnpoint.Value) { if (!sleepAnyTime.Value && !EnvMan.instance.IsAfternoon() && !EnvMan.instance.IsNight()) { human.Message(MessageHud.MessageType.Center, "$msg_cantsleep", 0, null); __result = false; return(false); } if (!__instance.CheckEnemies(thePlayer)) { __result = false; return(false); } if (!__instance.CheckExposure(thePlayer)) { __result = false; return(false); } if (!__instance.CheckFire(thePlayer)) { __result = false; return(false); } if (!__instance.CheckWet(thePlayer)) { __result = false; return(false); } human.AttachStart(__instance.m_spawnPoint, human.gameObject, true, true, false, "attach_bed", new Vector3(0f, 0.5f, 0f)); __result = false; return(false); } else { if (!__instance.CheckExposure(thePlayer)) { __result = false; return(false); } if (!sleepWithoutSpawnpoint.Value) { Game.instance.GetPlayerProfile().SetCustomSpawnPoint(__instance.GetSpawnPoint()); human.Message(MessageHud.MessageType.Center, "$msg_spawnpointset", 0, null); } } } __result = false; return(false); }