Files
Delta-v/Content.Server/Weather/Commands/WeatherRemoveCommand.cs
T
4186c8caa2 Weather entities (#41427)
* weather status effect entities

* proto port + fixes

* Update weather.yml

* fix visuals

* Update SharedWeatherSystem.cs

* Update SharedWeatherSystem.cs

* Update WeatherSystem.cs

* Thanks Slarti, thats a much better

* Update WeatherSystem.cs

* Update StencilOverlay.Weather.cs

* Update Content.Client/Overlays/StencilOverlay.Weather.cs

Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com>

* Update Content.Shared/StatusEffectNew/Components/StatusEffectComponent.cs

Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com>

* Update Content.Client/Overlays/StencilOverlay.Weather.cs

Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com>

* Revise weather command help descriptions

Updated weather command help texts for clarity.

* Merge branch 'master' into ed-14-11-2025-weather-entities

* Tayrtahn review apply

* fixes and cleanup

---------

Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
2026-06-29 12:44:02 +02:00

83 lines
2.6 KiB
C#

using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.Prototypes;
using Content.Shared.Weather;
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
namespace Content.Server.Weather.Commands;
/// <summary>
/// Remove specific weather from map.
/// </summary>
[AdminCommand(AdminFlags.Fun)]
public sealed class WeatherRemoveCommand : LocalizedEntityCommands
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedMapSystem _map = default!;
[Dependency] private readonly WeatherSystem _weather = default!;
[Dependency] private readonly IComponentFactory _compFactory = default!;
public override string Command => "weatherremove";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length < 2)
{
shell.WriteError(Loc.GetString("cmd-weather-error-no-arguments"));
return;
}
//MapId parse
if (!int.TryParse(args[0], out var mapInt))
return;
var mapId = new MapId(mapInt);
if (!_map.MapExists(mapId))
{
shell.WriteError(Loc.GetString("cmd-weather-error-wrong-map", ("id", mapId.ToString())));
return;
}
//Weather proto parse
EntProtoId weatherProto = args[1];
if (!_proto.TryIndex(weatherProto, out _))
{
shell.WriteError(Loc.GetString("cmd-weather-error-unknown-proto"));
return;
}
if (!_weather.HasWeather(mapId, weatherProto))
{
shell.WriteError(Loc.GetString("cmd-weather-error-no-weather"));
return;
}
_weather.TryRemoveWeather(mapId, weatherProto);
}
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
return CompletionResult.FromHintOptions(CompletionHelper.MapIds(EntityManager), Loc.GetString("cmd-weather-hint-map-id"));
if (args.Length == 2) //TODO: dont show ALL weathers here, only weathers applied to selected map
{
var opts = new List<CompletionOption>();
foreach (var proto in _proto.EnumeratePrototypes<EntityPrototype>())
{
if (!proto.HasComponent<WeatherStatusEffectComponent>(_compFactory))
continue;
opts.Add(new CompletionOption(proto.ID, proto.Name));
}
return CompletionResult.FromHintOptions(opts, Loc.GetString("cmd-weather-hint-prototype"));
}
return CompletionResult.Empty;
}
}