diff --git a/Content.Server/Maps/PlanetCommand.cs b/Content.Server/Maps/PlanetCommand.cs new file mode 100644 index 0000000000..e5c249722b --- /dev/null +++ b/Content.Server/Maps/PlanetCommand.cs @@ -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; + +/// +/// Converts the supplied map into a "planet" with defaults. +/// +[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(mapUid); + parallax.Parallax = "Grass"; + _entManager.Dirty(parallax, metadata); + var gravity = _entManager.EnsureComponent(mapUid); + gravity.Enabled = true; + _entManager.Dirty(gravity); + _entManager.EnsureComponent(mapUid); + var atmos = _entManager.EnsureComponent(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(mapUid); + footstep.Sound = new SoundCollectionSpecifier("FootstepGrass"); + _entManager.Dirty(footstep); + + _entManager.EnsureComponent(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(true) + .Select(o => new CompletionOption(o.WorldMap.ToString(), "MapId")); + + return CompletionResult.FromOptions(options); + } +} diff --git a/Resources/Locale/en-US/maps/planet.ftl b/Resources/Locale/en-US/maps/planet.ftl new file mode 100644 index 0000000000..0d51694500 --- /dev/null +++ b/Resources/Locale/en-US/maps/planet.ftl @@ -0,0 +1,5 @@ +cmd-planet-desc = Converts the supplied map into a planet with sensible defaults. +cmd-planet-help = {$command} . +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. diff --git a/Resources/Prototypes/Parallaxes/planet.yml b/Resources/Prototypes/Parallaxes/planet.yml index df2373628e..d18d32b063 100644 --- a/Resources/Prototypes/Parallaxes/planet.yml +++ b/Resources/Prototypes/Parallaxes/planet.yml @@ -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: diff --git a/Resources/Textures/Tiles/Planet/grass.rsi/grass0.png b/Resources/Textures/Tiles/Planet/grass.rsi/grass0.png new file mode 100644 index 0000000000..8868223f7f Binary files /dev/null and b/Resources/Textures/Tiles/Planet/grass.rsi/grass0.png differ diff --git a/Resources/Textures/Tiles/Planet/grass.rsi/grass1.png b/Resources/Textures/Tiles/Planet/grass.rsi/grass1.png new file mode 100644 index 0000000000..9598fcb9a4 Binary files /dev/null and b/Resources/Textures/Tiles/Planet/grass.rsi/grass1.png differ diff --git a/Resources/Textures/Tiles/Planet/grass.rsi/grass2.png b/Resources/Textures/Tiles/Planet/grass.rsi/grass2.png new file mode 100644 index 0000000000..1d21d0234f Binary files /dev/null and b/Resources/Textures/Tiles/Planet/grass.rsi/grass2.png differ diff --git a/Resources/Textures/Tiles/Planet/grass.rsi/grass3.png b/Resources/Textures/Tiles/Planet/grass.rsi/grass3.png new file mode 100644 index 0000000000..deeddb3fef Binary files /dev/null and b/Resources/Textures/Tiles/Planet/grass.rsi/grass3.png differ diff --git a/Resources/Textures/Tiles/Planet/grass.rsi/grass_corners.png b/Resources/Textures/Tiles/Planet/grass.rsi/grass_corners.png new file mode 100644 index 0000000000..a1f647264c Binary files /dev/null and b/Resources/Textures/Tiles/Planet/grass.rsi/grass_corners.png differ diff --git a/Resources/Textures/Tiles/Planet/grass.rsi/grass_edge_corner.png b/Resources/Textures/Tiles/Planet/grass.rsi/grass_edge_corner.png new file mode 100644 index 0000000000..7f6508e0e4 Binary files /dev/null and b/Resources/Textures/Tiles/Planet/grass.rsi/grass_edge_corner.png differ diff --git a/Resources/Textures/Tiles/Planet/grass.rsi/grass_edges.png b/Resources/Textures/Tiles/Planet/grass.rsi/grass_edges.png new file mode 100644 index 0000000000..a11f225e7a Binary files /dev/null and b/Resources/Textures/Tiles/Planet/grass.rsi/grass_edges.png differ diff --git a/Resources/Textures/Tiles/Planet/grass.rsi/grass_edges_old.png b/Resources/Textures/Tiles/Planet/grass.rsi/grass_edges_old.png new file mode 100644 index 0000000000..af73ea013e Binary files /dev/null and b/Resources/Textures/Tiles/Planet/grass.rsi/grass_edges_old.png differ diff --git a/Resources/Textures/Tiles/Planet/grass.rsi/meta.json b/Resources/Textures/Tiles/Planet/grass.rsi/meta.json new file mode 100644 index 0000000000..c238d25175 --- /dev/null +++ b/Resources/Textures/Tiles/Planet/grass.rsi/meta.json @@ -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 + } + ] +} \ No newline at end of file