public void SaveGrid(string NameOrIdentity = "")
        {
            GridResult Result = new GridResult(true);



            //Gets grids player is looking at
            if (!Result.GetGrids(Chat, AdminUserCharacter, NameOrIdentity))
            {
                return;
            }

            GridStamp stamp = Result.GenerateGridStamp();


            PlayerHangar PlayersHanger = new PlayerHangar(Result.OwnerSteamID, Chat, true);


            GridUtilities.FormatGridName(PlayersHanger, stamp);
            if (PlayersHanger.SaveGridsToFile(Result, stamp.GridName))
            {
                PlayersHanger.SaveGridStamp(stamp, true);
                Chat?.Respond("Save Complete!");
            }
            else
            {
                Chat?.Respond("Saved Failed!");
                return;
            }
        }
        public void LoadGrid(string NameOrSteamID, int ID, bool FromSavePos = true)
        {
            if (!AdminTryGetPlayerSteamID(NameOrSteamID, out ulong PlayerSteamID))
            {
                return;
            }

            PlayerHangar PlayersHanger = new PlayerHangar(PlayerSteamID, Chat, true);

            if (!PlayersHanger.LoadGrid(ID, out IEnumerable <MyObjectBuilder_CubeGrid> Grids, out GridStamp Stamp))
            {
                return;
            }


            if (FromSavePos == false && InConsole == true)
            {
                FromSavePos = true;
            }


            ParallelSpawner Spawner = new ParallelSpawner(Grids, Chat, !FromSavePos);

            if (Spawner.Start(FromSavePos, AdminPlayerPosition))
            {
                Chat?.Respond("Spawning Complete!");
                PlayersHanger.RemoveGridStamp(Stamp);
            }
            else
            {
                Chat?.Respond("An error occured while spawning the grid!");
            }
        }
 public void RemoveGrid(int ID)
 {
     PlayersHanger = new PlayerHangar(SteamID, Chat);
     if (PlayersHanger.RemoveGridStamp(ID))
     {
         Chat.Respond("Successfully removed grid!");
     }
 }
        public void SyncHangar(string NameOrSteamID)
        {
            if (!AdminTryGetPlayerSteamID(NameOrSteamID, out ulong PlayerSteamID))
            {
                return;
            }

            PlayerHangar PlayersHanger = new PlayerHangar(PlayerSteamID, Chat, true);

            PlayersHanger.UpdateHangar();
        }
Exemple #5
0
        public void DetailedInfo(string input)
        {
            if (!PlayersHanger.ParseInput(input, out int ID))
            {
                Chat.Respond($"Grid {input} could not be found!");
                return;
            }

            PlayersHanger = new PlayerHangar(SteamID, Chat);
            PlayersHanger.DetailedReport(ID);
        }
        public void ListGrids(string NameOrSteamID)
        {
            if (!AdminTryGetPlayerSteamID(NameOrSteamID, out ulong PlayerSteamID))
            {
                return;
            }


            PlayerHangar PlayersHanger = new PlayerHangar(PlayerSteamID, Chat, true);

            PlayersHanger.ListAllGrids();
        }
        public void RemoveGrid(string NameOrSteamID, int Index)
        {
            if (!AdminTryGetPlayerSteamID(NameOrSteamID, out ulong PlayerSteamID))
            {
                return;
            }

            PlayerHangar PlayersHanger = new PlayerHangar(PlayerSteamID, Chat, true);

            if (PlayersHanger.RemoveGridStamp(Index))
            {
                Chat.Respond("Successfully removed grid!");
            }
        }
Exemple #8
0
        public void RemoveGrid(string input)
        {
            if (!PlayersHanger.ParseInput(input, out int ID))
            {
                Chat.Respond($"Grid {input} could not be found!");
                return;
            }

            PlayersHanger = new PlayerHangar(SteamID, Chat);
            if (PlayersHanger.RemoveGridStamp(ID))
            {
                Chat.Respond("Successfully removed grid!");
            }
        }
        public void LoadGrid(string NameOrSteamID, int ID, bool FromSavePos = true)
        {
            if (!AdminTryGetPlayerSteamID(NameOrSteamID, out ulong PlayerSteamID))
            {
                return;
            }

            PlayerHangar PlayersHanger = new PlayerHangar(PlayerSteamID, Chat, true);

            if (!PlayersHanger.TryGetGridStamp(ID, out GridStamp Stamp))
            {
                return;
            }


            if (!PlayersHanger.LoadGrid(Stamp, out IEnumerable <MyObjectBuilder_CubeGrid> Grids))
            {
                Log.Error($"Loading grid {ID} failed for {NameOrSteamID}!");
                Chat.Respond("Loading grid failed! Report this to staff and check logs for more info!");
                return;
            }


            Vector3D LoadPos = Stamp.GridSavePosition;

            if (FromSavePos == false && InConsole == true)
            {
                FromSavePos = true;
            }

            if (!FromSavePos)
            {
                LoadPos = AdminPlayerPosition;
            }



            ParallelSpawner Spawner = new ParallelSpawner(Grids, Chat);

            if (Spawner.Start(LoadPos, FromSavePos))
            {
                Chat?.Respond($"Spawning Completed! \n Location: {LoadPos}");
                PlayersHanger.RemoveGridStamp(ID);
            }
            else
            {
                Chat?.Respond("An error occured while spawning the grid!");
            }
        }
Exemple #10
0
        private bool PerformMainChecks(bool IsSaving)
        {
            if (!Config.PluginEnabled)
            {
                Chat?.Respond("Plugin is not enabled!");
                return(false);
            }


            if (PlayerHangar.IsServerSaving(Chat))
            {
                Chat?.Respond("Server is saving or is paused!");
                return(false);
            }


            if (!CheckZoneRestrictions(IsSaving))
            {
                Chat?.Respond("You are not in the right zone!");
                return(false);
            }


            if (!CheckGravity())
            {
                Chat?.Respond("Unable to perform this action in gravity!");
                return(false);
            }


            PlayersHanger = new PlayerHangar(SteamID, Chat);

            if (!PlayersHanger.CheckPlayerTimeStamp())
            {
                Chat?.Respond("Command cooldown is still in affect!");
                return(false);
            }



            /*
             * if (CheckEnemyDistance(LoadingAtSave, PlayerPosition))
             *  return false;
             */

            return(true);
        }
        public async void SaveGrid(string NameOrIdentity = "")
        {
            GridResult Result = new GridResult(true);



            //Gets grids player is looking at
            if (!Result.GetGrids(Chat, AdminUserCharacter, NameOrIdentity))
            {
                return;
            }


            if (Result.OwnerSteamID == 0)
            {
                Chat?.Respond("Unable to get major grid owner!");
                return;
            }


            GridStamp    stamp         = Result.GenerateGridStamp();
            PlayerHangar PlayersHanger = new PlayerHangar(Result.OwnerSteamID, Chat, true);

            string Name = Result.OwnerSteamID.ToString();

            if (MySession.Static.Players.TryGetIdentityFromSteamID(Result.OwnerSteamID, out MyIdentity identity))
            {
                Name = identity.DisplayName;
            }

            PlayersHanger.SelectedPlayerFile.FormatGridName(stamp);

            bool val = await PlayersHanger.SaveGridsToFile(Result, stamp.GridName);

            if (val)
            {
                PlayersHanger.SaveGridStamp(stamp, true);
                Chat?.Respond($"{stamp.GridName} was saved to {Name}'s hangar!");
            }
            else
            {
                Chat?.Respond($"{stamp.GridName} failed to send to {Name}'s hangar!");
                return;
            }
        }
        public void SyncAll()
        {
            //Get All hangar folders
            foreach (var folder in Directory.GetDirectories(Hangar.MainPlayerDirectory))
            {
                string PlayerID = Path.GetFileName(folder);

                ulong ID = UInt64.Parse(PlayerID);


                if (ID == 0)
                {
                    continue;
                }


                PlayerHangar PlayersHanger = new PlayerHangar(ID, Chat, true);
                PlayersHanger.UpdateHangar();
            }
        }
Exemple #13
0
        public void SellGrid(int ID, long Price, string Description)
        {
            PlayersHanger = new PlayerHangar(SteamID, Chat);

            if (!PlayersHanger.TryGetGridStamp(ID, out GridStamp Stamp))
            {
                return;
            }

            //Check to see if grid is already for sale
            if (Stamp.IsGridForSale())
            {
                Chat.Respond("This grid is already for sale!");
                return;
            }


            if (!PlayersHanger.SellSelectedGrid(Stamp, Price, Description))
            {
                return;
            }

            Chat.Respond("Grid has been succesfully listed!");
        }
Exemple #14
0
 public void ListGrids()
 {
     PlayersHanger = new PlayerHangar(SteamID, Chat);
     PlayersHanger.ListAllGrids();
 }
 public void DetailedInfo(int ID)
 {
     PlayersHanger = new PlayerHangar(SteamID, Chat);
     PlayersHanger.DetailedReport(ID);
 }