Example #1
0
 private static void FixupRadii(PrivateArea pa, float radius)
 {
     Plugin.Log($"FixupRaddi called - {radius}");
     foreach (SphereCollider sphere in pa.GetComponents <SphereCollider>())
     {
         Plugin.Log("sphere adjusted");
         sphere.radius    = radius;
         sphere.isTrigger = true;
         sphere.enabled   = pa.IsEnabled();
         sphere.name      = Plugin.SphereColliderName;
     }
 }
Example #2
0
    // Token: 0x06000E7E RID: 3710 RVA: 0x000679D0 File Offset: 0x00065BD0
    public static bool CheckAccess(Vector3 point, float radius = 0f, bool flash = true, bool wardCheck = false)
    {
        List <PrivateArea> list = new List <PrivateArea>();
        bool flag = true;

        if (wardCheck)
        {
            flag = true;
            using (List <PrivateArea> .Enumerator enumerator = PrivateArea.m_allAreas.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    PrivateArea privateArea = enumerator.Current;
                    if (privateArea.IsEnabled() && privateArea.IsInside(point, radius) && !privateArea.HaveLocalAccess())
                    {
                        flag = false;
                        list.Add(privateArea);
                    }
                }
                goto IL_B8;
            }
        }
        flag = false;
        foreach (PrivateArea privateArea2 in PrivateArea.m_allAreas)
        {
            if (privateArea2.IsEnabled() && privateArea2.IsInside(point, radius))
            {
                if (privateArea2.HaveLocalAccess())
                {
                    flag = true;
                }
                else
                {
                    list.Add(privateArea2);
                }
            }
        }
IL_B8:
        if (!flag && list.Count > 0)
        {
            if (flash)
            {
                foreach (PrivateArea privateArea3 in list)
                {
                    privateArea3.FlashShield(false);
                }
            }
            return(false);
        }
        return(true);
    }
Example #3
0
        private static SphereCollider GetAForceFieldForPrivateArea(PrivateArea pa)
        {
            Plugin.Log("GetAForceFieldForPrivateArea called");
            SphereCollider forceField = null;

            try
            {
                forceField = GetForceFieldInRange(pa.transform.position, 2);

                // if we didn't find one, make one
                if (null == forceField && pa.IsEnabled())
                {
                    Plugin.Log("GetAForceFieldForPrivateArea - forcefield not found but PA is active and enabled. Creating ForceField");
                    forceField         = CreateForceField(pa.transform.position, pa.m_radius);
                    forceField.enabled = pa.IsEnabled();
                }
            }
            catch (Exception ex)
            {
                Plugin.LogError($"GetAForceFieldForPrivateArea - {ex.Message}");
            }

            return(forceField);
        }
Example #4
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);
            }
Example #5
0
 private static void PostFix(PrivateArea __instance)
 {
     UpdateForceField(__instance, __instance.IsEnabled());
 }
Example #6
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);
            }
Example #7
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);
            }