Esempio n. 1
0
            public static bool RPC_ToggleEnabled(long uid, long playerID, PrivateArea __instance)
            {
                // if using the original interaction behavior then just return true and run the original code
                if (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.Original)
                {
                    return(true);
                }

                ZLog.Log((object)("Toggle enabled from " + playerID + "  creator is " + __instance.m_piece.GetCreator()));
                if (__instance.m_nview.IsOwner() && ((__instance.IsPermitted(playerID) && Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.OwnerAndPermitted) || (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.All)))
                {
                    __instance.SetEnabled(!__instance.IsEnabled());
                }

                return(false);
            }
Esempio n. 2
0
            public static bool GetHoverText(PrivateArea __instance, ref string __result)
            {
                // if using the original interaction behavior then just return true and run the original code
                if (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.Original)
                {
                    return(true);
                }

                Plugin.LogDebug("Executing Patched GetHoverText");
                if (!__instance.m_nview.IsValid())
                {
                    __result = "";
                    return(false);
                }
                if (Player.m_localPlayer == null)
                {
                    __result = "";
                    return(false);
                }

                __instance.ShowAreaMarker();
                StringBuilder stringBuilder = new StringBuilder(256);

                // Player or owner hovering over so display activate/dectivate options
                if (__instance.m_piece.IsCreator() || (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.OwnerAndPermitted && __instance.IsPermitted(Player.m_localPlayer.GetPlayerID())) || Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.All)
                {
                    if (__instance.IsEnabled())
                    {
                        stringBuilder.Append(__instance.m_name + " ( $piece_guardstone_active )");
                        stringBuilder.Append("\n$piece_guardstone_owner:" + __instance.GetCreatorName());
                        stringBuilder.Append("\n[<color=yellow><b>$KEY_Use</b></color>] $piece_guardstone_deactivate");
                    }
                    else
                    {
                        stringBuilder.Append(__instance.m_name + " ($piece_guardstone_inactive )");
                        stringBuilder.Append("\n$piece_guardstone_owner:" + __instance.GetCreatorName());
                        stringBuilder.Append("\n[<color=yellow><b>$KEY_Use</b></color>] $piece_guardstone_activate");
                        if (Settings.WardInteractBehavior.Value != Plugin.WardInteractBehavior.OwnerOnly)
                        {
                            if (__instance.IsPermitted(Player.m_localPlayer.GetPlayerID()) && !__instance.m_piece.IsCreator())
                            {
                                stringBuilder.Append("\n[<color=yellow><b>" + Settings.InteractModifier.Value.ToString() + " - $KEY_Use</b></color>] $piece_guardstone_remove");
                            }
                            else if (!__instance.m_piece.IsCreator())
                            {
                                stringBuilder.Append("\n[<color=yellow><b>" + Settings.InteractModifier.Value.ToString() + " - $KEY_Use</b></color>] $piece_guardstone_add");
                            }
                        }
                    }
                }
                else if (__instance.IsEnabled())
                {
                    // Player is not permitted and is not the owner and ward is active... do nothing
                    stringBuilder.Append(__instance.m_name + " ( $piece_guardstone_active )");
                    stringBuilder.Append("\n$piece_guardstone_owner:" + __instance.GetCreatorName());
                    if (Settings.WardInteractBehavior.Value != Plugin.WardInteractBehavior.OwnerOnly)
                    {
                        stringBuilder.Append("\n[<color=yellow><b>" + Settings.InteractModifier.Value.ToString() + " - $KEY_Use</b></color>] $piece_guardstone_remove");
                    }
                }
                else
                {
                    // player is not permitted and is not the owner, but ward is inactive.... show modifier
                    stringBuilder.Append(__instance.m_name + " ( $piece_guardstone_inactive )");
                    stringBuilder.Append("\n$piece_guardstone_owner:" + __instance.GetCreatorName());
                    if (Settings.WardInteractBehavior.Value != Plugin.WardInteractBehavior.OwnerOnly)
                    {
                        stringBuilder.Append("\n[<color=yellow><b>" + Settings.InteractModifier.Value.ToString() + " - $KEY_Use</b></color>] $piece_guardstone_add");
                    }
                }
                __instance.AddUserList(stringBuilder);
                __result = Localization.instance.Localize(stringBuilder.ToString());
                Plugin.LogDebug($"Result {__result}");
                return(false);
            }
Esempio n. 3
0
            public static bool Interact(Humanoid human, bool hold, PrivateArea __instance, ref bool __result)
            {
                // if using the original interaction behavior then just return true and run the original code
                if (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.Original)
                {
                    return(true);
                }

                // default to a false just in case.
                __result = false;

                Plugin.Log("Patched Interact");

                // if not allowing permitted players to activate/deactivate, just run the standard function
                if (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.OwnerOnly)
                {
                    return(true);
                }

                if (hold)
                {
                    Plugin.Log("HOLDING");
                    __result = false;

                    //don't execute.. what's the point?
                    return(false);
                }
                Player player = human as Player;

                // If player is creator
                // or if ward mode is ownerandpermitted and is permitted or behavior is all AND modifier key is not being held....
                if (__instance.m_piece.IsCreator()
                    ||
                    ((Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.OwnerAndPermitted && __instance.IsPermitted(player.GetPlayerID()) || (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.All)) &&
                     !UtilityClass.CheckKeyHeld(Settings.InteractModifier.Value))
                    )
                {
                    __instance.m_nview.InvokeRPC("ToggleEnabled", player.GetPlayerID());
                    __result = true;

                    // don't execute the original code
                    return(false);
                }
                Plugin.Log("Wasn't normal activation");

                // if OwnerOnly then don't allow anyone to do anything else
                if (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.OwnerOnly)
                {
                    __result = false;
                    return(false);
                }

                // if the player is using the modifier key and gets this far, then toggle permitted
                // can only do this when the peice isn't active
                if (UtilityClass.CheckKeyHeld(Settings.InteractModifier.Value) && !__instance.IsEnabled())
                {
                    __instance.m_nview.InvokeRPC("TogglePermitted", player.GetPlayerID(), player.GetPlayerName());
                    __result = true;

                    // don't execute original code
                    return(false);
                }

                __result = false;
                return(false);
            }