Example #1
0
        void cmdsafecell(PlayerSession session, string command, string[] args)
        {
            if (permission.UserHasPermission(session.SteamId.ToString(), "customwipe.use") || session.IsAdmin)
            {
                var cell = ConstructionUtilities.GetOwnershipCell(session.WorldPlayerEntity.transform.position);
                var desc = args.Length >= 1 ? string.Join(" ", args) : Msg("defaultdescription", session.SteamId.ToString());

                if (!safeCells.Any(c => c.cellid == cell))
                {
                    safeCells.Add(new Cell {
                        cellid = cell, pos = Vector3ToString(session.WorldPlayerEntity.transform.position), description = desc
                    });
                    SaveData();
                    hurt.SendChatMessage(session, Msg("safecell", session.SteamId.ToString()).Replace("{cell}", cell + ""));
                }
                else
                {
                    hurt.SendChatMessage(session, Msg("safecell_safe", session.SteamId.ToString()).Replace("{cell}", cell + ""));
                }
            }
            else
            {
                hurt.SendChatMessage(session, Msg("nopermission", session.SteamId.ToString()));
            }
        }
Example #2
0
            private Bounds GetCellBounds(int cell)
            {
                var middle = (ConstructionUtilities.GetOwnershipCellMin(cell) +
                              ConstructionUtilities.GetOwnershipCellMax(cell)) / 2f;

                return(new Bounds(new Vector3(middle.x, 0, middle.y),
                                  new Vector3(ConstructionUtilities.OWNERSHIP_GRID_SIZE, float.MaxValue,
                                              ConstructionUtilities.OWNERSHIP_GRID_SIZE)));
            }
Example #3
0
        void cleanplayer(PlayerSession session, string command, string[] args)
        {
            if (!permission.UserHasPermission(session.SteamId.ToString(), "cleanplus.use") || !session.IsAdmin)
            {
                hurt.SendChatMessage(session, null, "У вас нет прав");
                return;
            }

            int a = 0;
            int s = 0;
            int z = 0;

            foreach (GameObject obj in Resources.FindObjectsOfTypeAll <GameObject>())
            {
                if (obj.name.Contains("Constructed") || obj.name.Contains("StructureManager") || obj.name.Contains("Dynamic") || obj.name.Contains("LadderCollider(Clone)"))
                {
                    long cell2 = ConstructionUtilities.GetOwnershipCell(obj.transform.position);
                    long cell1 = ConstructionUtilities.GetOwnershipCell(session.WorldPlayerEntity.transform.position);

                    if (cell2 == cell1)
                    {
                        z += 1;

                        if (obj.HNetworkView() != null)
                        {
                            ConstructionManager.Instance.OwnershipCells.TryGetValue(ConstructionUtilities.GetOwnershipCell(obj.transform.position), out stake);
                            if (stake == null)
                            {
                                Singleton <HNetworkManager> .Instance.NetDestroy(obj.HNetworkView());

                                s = 1;
                            }
                            else
                            {
                                a = 1;
                            }
                        }
                    }
                }
            }
            if (a == 1)
            {
                hurt.SendChatMessage(session, null, $"<color=green><b>[CleanPlus]</b></color> На территории есть тотем");
                return;
            }

            if (s == 1)
            {
                hurt.SendChatMessage(session, null, $"<color=green><b>[CleanPlus]</b></color> Очищено {z} объектов");
                return;
            }
            hurt.SendChatMessage(session, null, $"<color=green><b>[CleanPlus]</b></color> Территория пустая");
        }
 void CheckSelfForDestroy()
 {
     ConstructionManager.Instance.OwnershipCells.TryGetValue(ConstructionUtilities.GetOwnershipCell(gameObject.transform.position), out stake);
     if (stake == null)
     {
         currentSet++;
     }
     else
     {
         currentSet = 0;
     }
     if (currentSet >= currentMax * 60)
     {
         Destroy();
     }
 }
Example #5
0
        void cmdsafehome(PlayerSession session, string command, string[] args)
        {
            if (permission.UserHasPermission(session.SteamId.ToString(), "customwipe.use") || session.IsAdmin)
            {
                if (args.Length == 1)
                {
                    bool found = false;
                    foreach (PlayerIdentity identity in GameManager.Instance.GetIdentifierMap().Values)
                    {
                        if (identity.Name.ToLower().Equals(args[0].ToLower()) ||
                            identity.SteamId.ToString().Equals(args[0]))
                        {
                            found = true;
                            var count      = 0;
                            var enumerator = RefTrackedBehavior <OwnershipStakeServer> .GetEnumerator();

                            while (enumerator.MoveNext())
                            {
                                count++;
                                var stake = enumerator.Current.Value;
                                if (stake.AuthorizedPlayers.Contains(identity))
                                {
                                    var cell = ConstructionUtilities.GetOwnershipCell(stake.transform.position);
                                    var desc = "Player Home - " + identity.Name;
                                    safeCells.Add(new Cell {
                                        cellid = cell, pos = Vector3ToString(stake.transform.position), description = desc
                                    });
                                }
                            }
                            SaveData();
                            hurt.SendChatMessage(session, Msg("safehome_safe", session.SteamId.ToString()).Replace("{playername}", identity.Name).Replace("{count}", count + ""));
                            return;
                        }
                    }
                    if (!found)
                    {
                        hurt.SendChatMessage(session, Msg("safehome_notFound", session.SteamId.ToString()).Replace("{playername}", args[0]));
                    }
                }
            }
            else
            {
                hurt.SendChatMessage(session, Msg("nopermission", session.SteamId.ToString()));
            }
        }
Example #6
0
        int noclean(long c)
        {
            string a = Convert.ToString(c);
            int    z = 0;

            foreach (var pair in GameManager.Instance.GetSessions())
            {
                var pl = pair.Value;

                int cell1 = ConstructionUtilities.GetOwnershipCell(pl.WorldPlayerEntity.transform.position);

                if (ArroundCell(cell1).Contains(a))
                {
                    z++;
                }
            }
            return(z);
        }
Example #7
0
        int cleanserver()
        {
            int a = 0;
            int s = 0;
            int z = 0;

            foreach (GameObject obj in Resources.FindObjectsOfTypeAll <GameObject>())
            {
                if (obj.name.Contains("Constructed") || obj.name.Contains("StructureManager") || obj.name.Contains("Dynamic") || obj.name.Contains("LadderCollider(Clone)"))
                //if ((obj.name.Contains("Constructed") || obj.name.Contains("StructureManager") || obj.name.Contains("Dynamic") || obj.name.Contains("LadderCollider(Clone)")) && !obj.name.Contains("ShackDynamicConstructed(Clone)"))
                {
                    long cell2 = ConstructionUtilities.GetOwnershipCell(obj.transform.position);

                    ConstructionManager.Instance.OwnershipCells.TryGetValue(ConstructionUtilities.GetOwnershipCell(obj.transform.position), out stake);
                    if (stake == null)
                    {
                        //z += 1;
                        if (noclean(cell2) == 0)
                        {
                            if (obj.HNetworkView() != null)
                            {
                                Singleton <HNetworkManager> .Instance.NetDestroy(obj.HNetworkView());

                                z += 1;
                                s  = 1;
                                if (C.objs == z)
                                {
                                    Puts(GameManager.Instance.GetSession(obj.HNetworkView().owner).Identity.Name);
                                    //Puts($" Очищено {z} объектов");
                                    return(z);
                                }
                            }
                        }
                    }
                }
            }

            //if (s == 1)
            //Puts($" Очищено {z} объектов");

            return(z);
        }
Example #8
0
 void cmdremovecell(PlayerSession session, string command, string[] args)
 {
     if (permission.UserHasPermission(session.SteamId.ToString(), "customwipe.use") || session.IsAdmin)
     {
         var cell = ConstructionUtilities.GetOwnershipCell(session.WorldPlayerEntity.transform.position);
         if (safeCells.Any(c => c.cellid == cell))
         {
             Cell cellToRemove = safeCells.Find(c => c.cellid == cell);
             safeCells.Remove(cellToRemove);
             SaveData();
             hurt.SendChatMessage(session, Msg("removecell", session.SteamId.ToString()).Replace("{cell}", cell + ""));
         }
         else
         {
             hurt.SendChatMessage(session, Msg("removecell_removed", session.SteamId.ToString()).Replace("{cell}", cell + ""));
         }
     }
     else
     {
         hurt.SendChatMessage(session, Msg("nopermission", session.SteamId.ToString()));
     }
 }
Example #9
0
 void cmdwipe(PlayerSession session, string command, string[] args)
 {
     if (permission.UserHasPermission(session.SteamId.ToString(), "customwipe.use") || session.IsAdmin)
     {
         var allObjects = Resources.FindObjectsOfTypeAll <GameObject>();
         List <GameObject> removedObjects = new List <GameObject>();
         var count = 0;
         foreach (GameObject objects in allObjects)
         {
             if (objectNameCheck(objects.name))
             {
                 var cell = ConstructionUtilities.GetOwnershipCell(objects.transform.position);
                 if (!safeCells.Any(c => c.cellid == cell))
                 {
                     GameObject        root   = objects.transform.root.gameObject;
                     uLink.NetworkView rootNV = root.GetComponent <uLink.NetworkView>();
                     if (rootNV != null)
                     {
                         if (!removedObjects.Contains(root))
                         {
                             removedObjects.Add(root);
                             count++;
                             uLink.Network.Destroy(rootNV);
                         }
                     }
                 }
             }
         }
         hurt.SendChatMessage(session, Msg("destroyed", session.SteamId.ToString()).Replace("{Count}", count.ToString()));
         PrintWarning("All server objects (except safe cells) wiped. Saving now.");
         SaveServer();
     }
     else
     {
         hurt.SendChatMessage(session, Msg("nopermission", session.SteamId.ToString()));
     }
 }
Example #10
0
 public static int GetCell(Vector3 position)
 {
     return(ConstructionUtilities.GetOwnershipCell(position));
 }
Example #11
0
        void DoClean(bool automatic = true)
        {
            hasstake  = 0;
            nostake   = 0;
            destroyed = 0;
            num       = 0;
            float t = 0;

            if (automatic)
            {
                Server.Broadcast("<color=yellow>[DECAY]</color> Building Decay updating in 5 seconds.");
                t = 5f;
            }
            timer.Once(t, () =>
            {
                foreach (GameObject obj in Resources.FindObjectsOfTypeAll <GameObject>())
                {
                    if (obj.name.Contains("Constructed") || obj.name.Contains("StructureManager") || obj.name.Contains("Dynamic") || obj.name.Contains("LadderCollider(Clone)"))
                    {
                        var thecell = ConstructionUtilities.GetOwnershipCell(obj.transform.position);
                        if (thecell != null)
                        {
                            var nView = uLink.NetworkView.Get(obj);
                            if (nView != null && nView.isActiveAndEnabled)
                            {
                                string ID = nView.viewID.id.ToString();
                                ConstructionManager.Instance.OwnershipCells.TryGetValue(ConstructionUtilities.GetOwnershipCell(obj.transform.position), out stake);
                                if (stake == null)
                                {
                                    nostake++;
                                    if (_ObjectList.TryGetValue(ID, out num))
                                    {
                                        if (num == Convert.ToInt32(Config["IntervalsBeforeCleaning"]))
                                        {
                                            try
                                            {
                                                foreach (ShackDynamicServer shack in Resources.FindObjectsOfTypeAll <ShackDynamicServer>())
                                                {
                                                    if (shack.gameObject.GetComponent <uLink.NetworkView>().isActiveAndEnabled)
                                                    {
                                                        MeshRenderer mf = shack.gameObject.transform.GetChild(3).GetComponent <MeshRenderer>();
                                                        if (!mf.bounds.Contains(obj.gameObject.transform.position) && !obj.name.Contains("Shack"))
                                                        {
                                                            Singleton <HNetworkManager> .Instance.NetDestroy(nView.HNetworkView());
                                                            _ObjectList.Remove(ID);
                                                            destroyed++;
                                                        }
                                                    }
                                                }
                                            }
                                            catch { }
                                        }
                                        else
                                        {
                                            _ObjectList[ID] += 1;
                                        }
                                    }
                                    else
                                    {
                                        _ObjectList.Add(ID, 1);
                                    }
                                }
                                else
                                {
                                    hasstake++;
                                    if (_ObjectList.TryGetValue(ID, out num))
                                    {
                                        _ObjectList.Remove(ID);
                                    }
                                }
                            }
                        }
                    }
                }
                SaveObjects();
                if ((bool)Config["ShowConsoleMessages"])
                {
                    Puts("Has Stake: " + hasstake);
                    Puts("No Stake : " + nostake);
                    Puts("Destroyed: " + destroyed);
                }
            });
        }