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 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!"); } }
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!"); } }
private bool LoadShipBlueprint(MyObjectBuilder_ShipBlueprintDefinition shipBlueprint, Vector3D GridSaveLocation, Vector3D SpawningPlayerLocation, bool keepOriginalLocation, Chat chat) { var grids = shipBlueprint.CubeGrids; if (grids == null || grids.Length == 0) { Chat?.Respond("No grids in blueprint!"); return(false); } MyIdentity Identity = MySession.Static.Players.TryGetPlayerIdentity(new MyPlayer.PlayerId(SteamID)); if (Identity != null) { PluginDependencies.BackupGrid(grids.ToList(), Identity.IdentityId); } Vector3D TargetLocation; bool AlignToGravity = false; if (keepOriginalLocation || SpawningPlayerLocation == Vector3D.Zero) { TargetLocation = GridSaveLocation; } else { AlignToGravity = true; TargetLocation = SpawningPlayerLocation; } ParallelSpawner Spawner = new ParallelSpawner(grids, chat, AlignToGravity); Log.Info("Attempting Grid Spawning @" + TargetLocation.ToString()); return(Spawner.Start(keepOriginalLocation, TargetLocation)); }
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!"); } }