forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command for creating simple planet maps (space-wizards#12698)
- Loading branch information
1 parent
23be8a1
commit 375490b
Showing
12 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System.Linq; | ||
using Content.Server.Administration; | ||
using Content.Server.Atmos; | ||
using Content.Server.Atmos.Components; | ||
using Content.Server.Gravity.EntitySystems; | ||
using Content.Shared.Administration; | ||
using Content.Shared.Atmos; | ||
using Content.Shared.Gravity; | ||
using Content.Shared.Movement.Components; | ||
using Content.Shared.Parallax; | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.Console; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Map.Components; | ||
|
||
namespace Content.Server.Maps; | ||
|
||
/// <summary> | ||
/// Converts the supplied map into a "planet" with defaults. | ||
/// </summary> | ||
[AdminCommand(AdminFlags.Mapping)] | ||
public sealed class PlanetCommand : IConsoleCommand | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
[Dependency] private readonly IMapManager _mapManager = default!; | ||
|
||
public string Command => $"planet"; | ||
public string Description => Loc.GetString("cmd-planet-desc"); | ||
public string Help => Loc.GetString("cmd-planet-help", ("command", Command)); | ||
public void Execute(IConsoleShell shell, string argStr, string[] args) | ||
{ | ||
if (args.Length != 1) | ||
{ | ||
shell.WriteError(Loc.GetString($"cmd-planet-args")); | ||
return; | ||
} | ||
|
||
if (!int.TryParse(args[0], out var mapInt)) | ||
{ | ||
shell.WriteError(Loc.GetString($"cmd-planet-map", ("map", mapInt))); | ||
return; | ||
} | ||
|
||
var mapId = new MapId(mapInt); | ||
|
||
if (!_mapManager.MapExists(mapId)) | ||
{ | ||
shell.WriteError(Loc.GetString($"cmd-planet-map", ("map", mapId))); | ||
return; | ||
} | ||
|
||
var mapUid = _mapManager.GetMapEntityId(mapId); | ||
MetaDataComponent? metadata = null; | ||
|
||
var parallax = _entManager.EnsureComponent<ParallaxComponent>(mapUid); | ||
parallax.Parallax = "Grass"; | ||
_entManager.Dirty(parallax, metadata); | ||
var gravity = _entManager.EnsureComponent<GravityComponent>(mapUid); | ||
gravity.Enabled = true; | ||
_entManager.Dirty(gravity); | ||
_entManager.EnsureComponent<MapLightComponent>(mapUid); | ||
var atmos = _entManager.EnsureComponent<MapAtmosphereComponent>(mapUid); | ||
|
||
atmos.Space = false; | ||
var moles = new float[Atmospherics.TotalNumberOfGases]; | ||
moles[(int) Gas.Oxygen] = 21.824779f; | ||
moles[(int) Gas.Nitrogen] = 82.10312f; | ||
|
||
atmos.Mixture = new GasMixture(2500) | ||
{ | ||
Temperature = 293.15f, | ||
Moles = moles, | ||
}; | ||
|
||
var footstep = _entManager.EnsureComponent<FootstepModifierComponent>(mapUid); | ||
footstep.Sound = new SoundCollectionSpecifier("FootstepGrass"); | ||
_entManager.Dirty(footstep); | ||
|
||
_entManager.EnsureComponent<MapGridComponent>(mapUid); | ||
shell.WriteLine(Loc.GetString("cmd-planet-success", ("mapId", mapId))); | ||
} | ||
|
||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args) | ||
{ | ||
if (args.Length != 1) | ||
{ | ||
return CompletionResult.Empty; | ||
} | ||
|
||
var options = _entManager.EntityQuery<MapComponent>(true) | ||
.Select(o => new CompletionOption(o.WorldMap.ToString(), "MapId")); | ||
|
||
return CompletionResult.FromOptions(options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmd-planet-desc = Converts the supplied map into a planet with sensible defaults. | ||
cmd-planet-help = {$command} <mapid>. | ||
cmd-planet-args = Require 1 arg only. | ||
cmd-planet-map = Unable to parse {$map} as an existing map. | ||
cmd-planet-success = Set map {$mapId} to Planet. NOTE! You will need to load the map (either onto a new map or by restarting the game) for atmospherics to work. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"version": 1, | ||
"license": "CC-BY-SA-3.0", | ||
"copyright": "https://github.com/discordia-space/CEV-Eris/commit/026ee3250ac1de938b503e3eb46ad73dd9c3ca82", | ||
"size": { | ||
"x": 32, | ||
"y": 32 | ||
}, | ||
"states": [ | ||
{ | ||
"name": "grass0" | ||
}, | ||
{ | ||
"name": "grass1" | ||
}, | ||
{ | ||
"name": "grass2" | ||
}, | ||
{ | ||
"name": "grass3" | ||
}, | ||
{ | ||
"name": "grass_edges", | ||
"directions": 8 | ||
}, | ||
{ | ||
"name": "grass_edges_old", | ||
"directions": 8 | ||
}, | ||
{ | ||
"name": "grass_corners", | ||
"directions": 8 | ||
}, | ||
{ | ||
"name": "grass_edge_corner", | ||
"directions": 8 | ||
} | ||
] | ||
} |