From ad91bb24a5de8d1508cb0b17faf102f2ae243383 Mon Sep 17 00:00:00 2001 From: Fansana Date: Wed, 7 Aug 2024 04:30:16 +0200 Subject: [PATCH] add ores to planets --- Content.Server/Maps/PlanetCommand.cs | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Content.Server/Maps/PlanetCommand.cs b/Content.Server/Maps/PlanetCommand.cs index 718b4a64d91..5e8810d23f5 100644 --- a/Content.Server/Maps/PlanetCommand.cs +++ b/Content.Server/Maps/PlanetCommand.cs @@ -15,6 +15,8 @@ using Robust.Shared.Map.Components; using Robust.Shared.Prototypes; using Robust.Shared.Random; +using System.Threading.Tasks; +using Content.Shared.Procedural.Loot; namespace Content.Server.Maps; @@ -63,9 +65,44 @@ public void Execute(IConsoleShell shell, string argStr, string[] args) var mapUid = _mapManager.GetMapEntityId(mapId); biomeSystem.EnsurePlanet(mapUid, biomeTemplate); + foreach (var lootProto in _protoManager.EnumeratePrototypes()) + { + if (!lootProto.Guaranteed) + continue; + + SpawnDungeonLoot(biomeSystem ,lootProto, mapUid); + } + shell.WriteLine(Loc.GetString("cmd-planet-success", ("mapId", mapId))); } + private void SpawnDungeonLoot(BiomeSystem biomeSystem, SalvageLootPrototype loot, EntityUid gridUid) + { + for (var i = 0; i < loot.LootRules.Count; i++) + { + var rule = loot.LootRules[i]; + + switch (rule) + { + case BiomeMarkerLoot biomeLoot: + { + if (_entManager.TryGetComponent(gridUid, out var biome)) + { + biomeSystem.AddMarkerLayer(gridUid, biome, biomeLoot.Prototype); + } + } + break; + case BiomeTemplateLoot biomeLoot: + { + if (_entManager.TryGetComponent(gridUid, out var biome)) + { + biomeSystem.AddTemplate(gridUid, biome, "Loot", _protoManager.Index(biomeLoot.Prototype), i); + } + } + break; + } + } + } public CompletionResult GetCompletion(IConsoleShell shell, string[] args) { if (args.Length == 1)