Biome rework (#37735)
* DungeonData rework Back to fields, serializes better, just make new layers dumby. * wawawewa * Fix this * Fixes * Port the work over * wawawewa * zoom * Kinda workin * Adjust wawa * Unloading work * Ore + entitytable fixes Iterate every dungeon not just last. * Big shot * wawawewa * Fixes * true * Fixes # Conflicts: # Content.Server/Procedural/DungeonJob/DungeonJob.cs * wawawewa * Fixes * Fix * Lot of work * wawawewa * Fixing * eh? * a * Fix a heap of stuff * Better ignored check * Reserve tile changes * biome * changes * wawawewa * Fixes & snow * Shadow fixes * wawawewa * smol * Add layer API * More work * wawawewa * Preloads and running again * wawawewa * Modified * Replacements and command * Runtime support * werk * Fix expeds + dungeon alltiles * reh --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
@@ -1,188 +0,0 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Parallax.Biomes;
|
||||
using Content.Shared.Parallax.Biomes.Layers;
|
||||
using Content.Shared.Parallax.Biomes.Markers;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
namespace Content.Server.Parallax;
|
||||
|
||||
public sealed partial class BiomeSystem
|
||||
{
|
||||
private void InitializeCommands()
|
||||
{
|
||||
_console.RegisterCommand("biome_clear", Loc.GetString("cmd-biome_clear-desc"), Loc.GetString("cmd-biome_clear-help"), BiomeClearCallback, BiomeClearCallbackHelper);
|
||||
_console.RegisterCommand("biome_addlayer", Loc.GetString("cmd-biome_addlayer-desc"), Loc.GetString("cmd-biome_addlayer-help"), AddLayerCallback, AddLayerCallbackHelp);
|
||||
_console.RegisterCommand("biome_addmarkerlayer", Loc.GetString("cmd-biome_addmarkerlayer-desc"), Loc.GetString("cmd-biome_addmarkerlayer-desc"), AddMarkerLayerCallback, AddMarkerLayerCallbackHelper);
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
private void BiomeClearCallback(IConsoleShell shell, string argstr, string[] args)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int.TryParse(args[0], out var mapInt);
|
||||
var mapId = new MapId(mapInt);
|
||||
var mapUid = _mapSystem.GetMapOrInvalid(mapId);
|
||||
|
||||
if (_mapSystem.MapExists(mapId) ||
|
||||
!TryComp<BiomeComponent>(mapUid, out var biome))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClearTemplate(mapUid, biome);
|
||||
}
|
||||
|
||||
private CompletionResult BiomeClearCallbackHelper(IConsoleShell shell, string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
return CompletionResult.FromHintOptions(CompletionHelper.Components<BiomeComponent>(args[0], EntityManager), "Biome");
|
||||
}
|
||||
|
||||
return CompletionResult.Empty;
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
private void AddLayerCallback(IConsoleShell shell, string argstr, string[] args)
|
||||
{
|
||||
if (args.Length < 3 || args.Length > 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[0], out var mapInt))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var mapId = new MapId(mapInt);
|
||||
var mapUid = _mapSystem.GetMapOrInvalid(mapId);
|
||||
|
||||
if (!_mapSystem.MapExists(mapId) || !TryComp<BiomeComponent>(mapUid, out var biome))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ProtoManager.TryIndex<BiomeTemplatePrototype>(args[1], out var template))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var offset = 0;
|
||||
|
||||
if (args.Length == 4)
|
||||
{
|
||||
int.TryParse(args[3], out offset);
|
||||
}
|
||||
|
||||
AddTemplate(mapUid, biome, args[2], template, offset);
|
||||
}
|
||||
|
||||
private CompletionResult AddLayerCallbackHelp(IConsoleShell shell, string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
return CompletionResult.FromHintOptions(CompletionHelper.MapIds(EntityManager), "Map ID");
|
||||
}
|
||||
|
||||
if (args.Length == 2)
|
||||
{
|
||||
return CompletionResult.FromHintOptions(
|
||||
CompletionHelper.PrototypeIDs<BiomeTemplatePrototype>(proto: ProtoManager), "Biome template");
|
||||
}
|
||||
|
||||
if (args.Length == 3)
|
||||
{
|
||||
if (int.TryParse(args[0], out var mapInt))
|
||||
{
|
||||
var mapId = new MapId(mapInt);
|
||||
|
||||
if (TryComp<BiomeComponent>(_mapSystem.GetMapOrInvalid(mapId), out var biome))
|
||||
{
|
||||
var results = new List<string>();
|
||||
|
||||
foreach (var layer in biome.Layers)
|
||||
{
|
||||
if (layer is not BiomeDummyLayer dummy)
|
||||
continue;
|
||||
|
||||
results.Add(dummy.ID);
|
||||
}
|
||||
|
||||
return CompletionResult.FromHintOptions(results, "Dummy layer ID");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.Length == 4)
|
||||
{
|
||||
return CompletionResult.FromHint("Seed offset");
|
||||
}
|
||||
|
||||
return CompletionResult.Empty;
|
||||
}
|
||||
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
private void AddMarkerLayerCallback(IConsoleShell shell, string argstr, string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[0], out var mapInt))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var mapId = new MapId(mapInt);
|
||||
|
||||
if (!_mapSystem.MapExists(mapId) || !TryComp<BiomeComponent>(_mapSystem.GetMapOrInvalid(mapId), out var biome))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ProtoManager.HasIndex<BiomeMarkerLayerPrototype>(args[1]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!biome.MarkerLayers.Add(args[1]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
biome.ForcedMarkerLayers.Add(args[1]);
|
||||
}
|
||||
|
||||
private CompletionResult AddMarkerLayerCallbackHelper(IConsoleShell shell, string[] args)
|
||||
{
|
||||
if (args.Length == 1)
|
||||
{
|
||||
var allQuery = AllEntityQuery<MapComponent, BiomeComponent>();
|
||||
var options = new List<CompletionOption>();
|
||||
|
||||
while (allQuery.MoveNext(out var mapComp, out _))
|
||||
{
|
||||
options.Add(new CompletionOption(mapComp.MapId.ToString()));
|
||||
}
|
||||
|
||||
return CompletionResult.FromHintOptions(options, "Biome");
|
||||
}
|
||||
|
||||
if (args.Length == 2)
|
||||
{
|
||||
return CompletionResult.FromHintOptions(
|
||||
CompletionHelper.PrototypeIDs<BiomeMarkerLayerPrototype>(proto: ProtoManager), "Marker");
|
||||
}
|
||||
|
||||
return CompletionResult.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user