Add command for creating simple planet maps (#12698)
95
Content.Server/Maps/PlanetCommand.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
5
Resources/Locale/en-US/maps/planet.ftl
Normal file
@@ -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.
|
||||
@@ -13,6 +13,16 @@
|
||||
scale: "2, 2"
|
||||
scrolling: "0.1, -0.05"
|
||||
|
||||
- type: parallax
|
||||
id: Grass
|
||||
layers:
|
||||
- texture:
|
||||
!type:ImageParallaxTextureSource
|
||||
path: "/Textures/Tiles/Planet/grass.rsi/grass0.png"
|
||||
slowness: 0
|
||||
scale: "1, 1"
|
||||
shader: ""
|
||||
|
||||
- type: parallax
|
||||
id: Snow
|
||||
layers:
|
||||
|
||||
BIN
Resources/Textures/Tiles/Planet/grass.rsi/grass0.png
Normal file
|
After Width: | Height: | Size: 695 B |
BIN
Resources/Textures/Tiles/Planet/grass.rsi/grass1.png
Normal file
|
After Width: | Height: | Size: 706 B |
BIN
Resources/Textures/Tiles/Planet/grass.rsi/grass2.png
Normal file
|
After Width: | Height: | Size: 692 B |
BIN
Resources/Textures/Tiles/Planet/grass.rsi/grass3.png
Normal file
|
After Width: | Height: | Size: 749 B |
BIN
Resources/Textures/Tiles/Planet/grass.rsi/grass_corners.png
Normal file
|
After Width: | Height: | Size: 608 B |
BIN
Resources/Textures/Tiles/Planet/grass.rsi/grass_edge_corner.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
Resources/Textures/Tiles/Planet/grass.rsi/grass_edges.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Resources/Textures/Tiles/Planet/grass.rsi/grass_edges_old.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
39
Resources/Textures/Tiles/Planet/grass.rsi/meta.json
Normal file
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||