示例#1
0
 static void Postfix(Bed __instance, ref string __result, ZNetView ___m_nview)
 {
     if (__instance.IsMine() && (___m_nview.GetZDO().GetLong("owner", 0L) != 0) || Traverse.Create(__instance).Method("IsCurrent").GetValue <bool>())
     {
         __result += Localization.instance.Localize($"\n[<color=yellow><b>P</b></color>] Set hearthstone");
     }
 }
示例#2
0
        private void Update()
        {
            Player __instance = Player.m_localPlayer;

            if (Player.m_localPlayer is null)
            {
                return;
            }

            if (__instance.m_hovering)
            {
                Interactable componentInParent = __instance.m_hovering.GetComponentInParent <Interactable>();
                if (componentInParent != null)
                {
                    if (componentInParent is Bed)
                    {
                        Bed bed = (Bed)componentInParent;

                        if (bed.IsMine())
                        {
                            if (Input.GetKeyDown(KeyCode.P))
                            {
                                Hearthstone.SetHearthStonePosition();
                                Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Here is your new Hearthstone spawn", 0, null);
                            }
                        }
                    }
                }
            }
        }
示例#3
0
            public static bool GetHoverText(Bed __instance, ref string __result)
            {
                // No special logic, so defer to normal execution
                if (!modEnabled.Value && !enableMultipleBedfellows.Value && !sleepWithoutSpawnpoint.Value)
                {
                    return(true);
                }

                // @todo Better hook and not replace entire method
                string ownerName = __instance.GetOwnerName();

                if (ownerName == "")
                {
                    string claimText = "$piece_bed_unclaimed\n[<color=yellow><b>$KEY_Use</b></color>] $piece_bed_claim";

                    if (sleepWithoutClaiming.Value)
                    {
                        claimText += "\n[<color=yellow><b>left shift + $KEY_Use</b></color>] $piece_bed_sleep";
                    }

                    __result = Localization.instance.Localize(claimText);

                    return(false);
                }

                string ownerText = ownerName + "'s $piece_bed";

                if (!__instance.IsMine())
                {
                    if (enableMultipleBedfellows.Value)
                    {
                        __result = Localization.instance.Localize(ownerText + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_bed_sleep");
                    }
                    else
                    {
                        __result = Localization.instance.Localize(ownerText);
                    }

                    return(false);
                }

                if (sleepWithoutSpawnpoint.Value)
                {
                    __result = Localization.instance.Localize(ownerText + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_bed_sleep");
                    return(false);
                }

                if (!__instance.IsCurrent())
                {
                    __result = Localization.instance.Localize(ownerText + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_bed_setspawn");
                }

                return(false);
            }
示例#4
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);
            }