static bool Prefix(Bed __instance, Humanoid human, bool repeat, ref bool __result, ZNetView ___m_nview)
            {
                if (___m_nview.GetZDO().GetLong("owner", 0L) == Game.instance.GetPlayerProfile().GetPlayerID())
                {
                    return(true);
                }
                if (repeat || !AedenthornUtils.CheckKeyHeld(modKey.Value) || (unclaimedOnly.Value && ___m_nview.GetZDO().GetLong("owner", 0L) != 0))
                {
                    Dbgl($"something's wrong: {repeat} {!AedenthornUtils.CheckKeyHeld(modKey.Value)} {unclaimedOnly.Value && ___m_nview.GetZDO().GetLong("owner", 0L) != 0}");
                    return(true);
                }
                Dbgl($"trying to sleep on bed");

                Player player = human as Player;

                if (!EnvMan.instance.IsAfternoon() && !EnvMan.instance.IsNight())
                {
                    human.Message(MessageHud.MessageType.Center, "$msg_cantsleep", 0, null);
                    __result = false;
                    return(false);
                }
                if (!Traverse.Create(__instance).Method("CheckEnemies", new object[] { player }).GetValue <bool>())
                {
                    __result = false;
                    return(false);
                }
                if (!Traverse.Create(__instance).Method("CheckExposure", new object[] { player }).GetValue <bool>())
                {
                    __result = false;
                    return(false);
                }
                if (!Traverse.Create(__instance).Method("CheckFire", new object[] { player }).GetValue <bool>())
                {
                    __result = false;
                    return(false);
                }
                if (!Traverse.Create(__instance).Method("CheckWet", new object[] { player }).GetValue <bool>())
                {
                    __result = false;
                    return(false);
                }
                human.AttachStart(__instance.m_spawnPoint, true, true, "attach_bed", new Vector3(0f, 0.5f, 0f));
                __result = false;
                return(false);
            }
Пример #2
0
 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;
                 }
             }
         }
     }
 }
Пример #3
0
            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);
            }
Пример #4
0
    // Token: 0x06000C61 RID: 3169 RVA: 0x00058E44 File Offset: 0x00057044
    public bool Interact(Humanoid human, bool repeat)
    {
        if (repeat)
        {
            return(false);
        }
        long   playerID = Game.instance.GetPlayerProfile().GetPlayerID();
        bool   owner    = this.GetOwner() != 0L;
        Player human2   = human as Player;

        if (!owner)
        {
            ZLog.Log("Has no creator");
            if (!this.CheckExposure(human2))
            {
                return(false);
            }
            this.SetOwner(playerID, Game.instance.GetPlayerProfile().GetName());
            Game.instance.GetPlayerProfile().SetCustomSpawnPoint(this.GetSpawnPoint());
            human.Message(MessageHud.MessageType.Center, "$msg_spawnpointset", 0, null);
        }
        else if (this.IsMine())
        {
            ZLog.Log("Is mine");
            if (this.IsCurrent())
            {
                ZLog.Log("is current spawnpoint");
                if (!EnvMan.instance.IsAfternoon() && !EnvMan.instance.IsNight())
                {
                    human.Message(MessageHud.MessageType.Center, "$msg_cantsleep", 0, null);
                    return(false);
                }
                if (!this.CheckEnemies(human2))
                {
                    return(false);
                }
                if (!this.CheckExposure(human2))
                {
                    return(false);
                }
                if (!this.CheckFire(human2))
                {
                    return(false);
                }
                if (!this.CheckWet(human2))
                {
                    return(false);
                }
                human.AttachStart(this.m_spawnPoint, true, true, "attach_bed", new Vector3(0f, 0.5f, 0f));
                return(false);
            }
            else
            {
                ZLog.Log("Not current spawn point");
                if (!this.CheckExposure(human2))
                {
                    return(false);
                }
                Game.instance.GetPlayerProfile().SetCustomSpawnPoint(this.GetSpawnPoint());
                human.Message(MessageHud.MessageType.Center, "$msg_spawnpointset", 0, null);
            }
        }
        return(false);
    }