Skip to content

Commit

Permalink
Merge pull request #83 from Fansana/add-ores-to-planets
Browse files Browse the repository at this point in the history
Add Ores to Planets
  • Loading branch information
Fansana authored Aug 7, 2024
2 parents abf03fa + ad91bb2 commit 2c22e97
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Content.Server/Maps/PlanetCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<SalvageLootPrototype>())
{
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<BiomeComponent>(gridUid, out var biome))
{
biomeSystem.AddMarkerLayer(gridUid, biome, biomeLoot.Prototype);
}
}
break;
case BiomeTemplateLoot biomeLoot:
{
if (_entManager.TryGetComponent<BiomeComponent>(gridUid, out var biome))
{
biomeSystem.AddTemplate(gridUid, biome, "Loot", _protoManager.Index<BiomeTemplatePrototype>(biomeLoot.Prototype), i);
}
}
break;
}
}
}
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
Expand Down

0 comments on commit 2c22e97

Please sign in to comment.