Files
tbd-station-14/Content.Server/Administration/Commands/LoadGameMapCommand.cs
Moony ec68226e99 Refactor how jobs are handed out (#5422)
* Completely refactor how job spawning works

* Remove remains of old system.

* Squash the final bug, cleanup.

* Attempt to fix tests

* Adjusts packed's round-start crew roster, re-enables a bunch of old roles.
Also adds the Central Command Official as a proper role.

* pretty up ui

* refactor StationSystem into the correct folder & namespace.

* remove a log, make sure the lobby gets updated if a new map is spontaneously added.

* re-add accidentally removed log

* We do a little logging

* we do a little resolving

* we do a little documenting

* Renamed OverflowJob to FallbackOverflowJob
Allows stations to configure their own roundstart overflow job list.

* narrator: it did not compile

* oops

* support having no overflow jobs

* filescope for consistency

* small fixes

* Bumps a few role counts for Packed, namely engis

* log moment

* E

* Update Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>

* Update Content.Server/Maps/GameMapPrototype.cs

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>

* factored job logic, cleanup.

* e

* Address reviews

* Remove the concept of a "default" grid.
It has no future in our new multi-station world

* why was clickable using that in the first place

* fix bad evil bug that almost slipped through
also adds chemist

* rms obsolete things from chemist

* Adds a sanity fallback

* address reviews

* adds ability to set name

* fuck

* cleanup joingame
2021-11-26 20:02:46 +11:00

67 lines
2.5 KiB
C#

using Content.Server.Maps;
using Content.Server.Roles;
using Content.Server.Station;
using Content.Shared.Administration;
using Robust.Server.Maps;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.Fun)]
public sealed class LoadGameMapCommand : IConsoleCommand
{
public string Command => "loadgamemap";
public string Description => "Loads the given game map at the given coordinates.";
public string Help => "loadgamemap <gamemap> <mapid> [<x> <y> [<name>]] ";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var mapLoader = IoCManager.Resolve<IMapLoader>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var stationSystem = entityManager.EntitySysManager.GetEntitySystem<StationSystem>();
if (args.Length is not (2 or 4 or 5))
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
return;
}
if (prototypeManager.TryIndex<GameMapPrototype>(args[0], out var gameMap))
{
if (int.TryParse(args[1], out var mapId))
{
var gameMapEnt = mapLoader.LoadBlueprint(new MapId(mapId), gameMap.MapPath);
if (gameMapEnt is null)
{
shell.WriteError($"Failed to create the given game map, is the path {gameMap.MapPath} correct?");
return;
}
if (args.Length >= 4 && int.TryParse(args[2], out var x) && int.TryParse(args[3], out var y))
{
var transform = entityManager.GetComponent<TransformComponent>(gameMapEnt.GridEntityId);
transform.WorldPosition = new Vector2(x, y);
}
var stationName = args.Length == 5 ? args[4] : null;
stationSystem.InitialSetupStationGrid(gameMapEnt.GridEntityId, gameMap, stationName);
}
}
else
{
shell.WriteError($"The given map prototype {args[0]} is invalid.");
}
}
}
}