コード例 #1
0
        public void LoadGrid(int ID, bool LoadNearPlayer)
        {
            if (!PerformMainChecks(false))
            {
                return;
            }

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


            if (!PlayersHanger.CheckLimits(Stamp, Grids))
            {
                return;
            }

            if (!CheckEnemyDistance(Config.LoadType, Stamp.GridSavePosition))
            {
                return;
            }

            if (!RequireLoadCurrency(Stamp))
            {
                return;
            }

            PluginDependencies.BackupGrid(Grids.ToList(), IdentityID);
            Vector3D SpawnPos = DetermineSpawnPosition(Stamp.GridSavePosition, PlayerPosition, out bool KeepOriginalPosition, LoadNearPlayer);

            if (!CheckDistanceToLoadPoint(SpawnPos))
            {
                return;
            }


            ParallelSpawner Spawner = new ParallelSpawner(Grids, Chat, !KeepOriginalPosition, SpawnedGridsSuccessful);

            Log.Info("Attempting Grid Spawning @" + SpawnPos.ToString());
            if (Spawner.Start(KeepOriginalPosition, SpawnPos))
            {
                Chat?.Respond("Spawning Complete!");
                PlayersHanger.RemoveGridStamp(Stamp);
            }
            else
            {
                Chat?.Respond("An error occured while spawning the grid!");
            }
        }
コード例 #2
0
        public void LoadGrid(string input, bool LoadNearPlayer)
        {
            if (!PerformMainChecks(false))
            {
                return;
            }


            if (!PlayersHanger.ParseInput(input, out int ID))
            {
                Chat.Respond($"Grid {input} could not be found!");
                return;
            }



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



            //Check to see if the grid is for sale. We need to let the player know if it is
            if (!CheckGridForSale(Stamp, ID))
            {
                return;
            }



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

            if (!PlayersHanger.CheckLimits(Stamp, Grids))
            {
                return;
            }

            if (!CheckEnemyDistance(Config.LoadType, Stamp.GridSavePosition) && !Config.AllowLoadNearEnemy)
            {
                return;
            }

            if (!RequireLoadCurrency(Stamp))
            {
                return;
            }

            PluginDependencies.BackupGrid(Grids.ToList(), IdentityID);
            Vector3D SpawnPos = DetermineSpawnPosition(Stamp.GridSavePosition, PlayerPosition, out bool KeepOriginalPosition, LoadNearPlayer);

            if (!CheckDistanceToLoadPoint(SpawnPos))
            {
                return;
            }

            if (PluginDependencies.NexusInstalled && Config.NexusAPI &&
                NexusSupport.RelayLoadIfNecessary(SpawnPos, ID, LoadNearPlayer, Chat, SteamID, IdentityID, PlayerPosition))
            {
                return;
            }

            ParallelSpawner Spawner = new ParallelSpawner(Grids, Chat, SpawnedGridsSuccessful);

            Log.Info("Attempting Grid Spawning @" + SpawnPos.ToString());
            if (Spawner.Start(SpawnPos, KeepOriginalPosition))
            {
                Chat?.Respond("Spawning Complete!");
                PlayersHanger.RemoveGridStamp(ID);
            }
            else
            {
                Chat?.Respond("An error occured while spawning the grid!");
            }
        }