From: Nim <128169402+Nimfar11@users.noreply.github.com> Date: Mon, 1 May 2023 08:21:39 +0000 (+0300) Subject: Slimes and their habitats (#15379) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=78f56a4369ede4209fbbb890282d7de427eff3bb;p=space-station-14.git Slimes and their habitats (#15379) Co-authored-by: metalgearsloth --- diff --git a/Content.Server/StationEvents/Components/SpiderSpawnRuleComponent.cs b/Content.Server/StationEvents/Components/SpiderSpawnRuleComponent.cs deleted file mode 100644 index 15e01ac8a8..0000000000 --- a/Content.Server/StationEvents/Components/SpiderSpawnRuleComponent.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Content.Server.StationEvents.Events; - -namespace Content.Server.StationEvents.Components; - -[RegisterComponent, Access(typeof(SpiderSpawnRule))] -public sealed class SpiderSpawnRuleComponent : Component -{ - -} diff --git a/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs b/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs index 5332796e84..0cb4fc44f5 100644 --- a/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs +++ b/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs @@ -1,15 +1,11 @@ using Content.Server.StationEvents.Events; +using Content.Shared.Storage; namespace Content.Server.StationEvents.Components; [RegisterComponent, Access(typeof(VentCrittersRule))] public sealed class VentCrittersRuleComponent : Component { - [DataField("spawnedPrototypeChoices")] - public List SpawnedPrototypeChoices = new() - { - "MobMouse", - "MobMouse1", - "MobMouse2" - }; + [DataField("entries")] + public List Entries = new(); } diff --git a/Content.Server/StationEvents/Events/SpiderSpawnRule.cs b/Content.Server/StationEvents/Events/SpiderSpawnRule.cs deleted file mode 100644 index ba440f8cde..0000000000 --- a/Content.Server/StationEvents/Events/SpiderSpawnRule.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Content.Server.StationEvents.Components; -using System.Linq; -using Content.Server.GameTicking.Rules.Components; - -namespace Content.Server.StationEvents.Events; - -public sealed class SpiderSpawnRule : StationEventSystem -{ - protected override void Started(EntityUid uid, SpiderSpawnRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) - { - base.Started(uid, component, gameRule, args); - var spawnLocations = EntityQuery().ToList(); - RobustRandom.Shuffle(spawnLocations); - - var mod = Math.Sqrt(GetSeverityModifier()); - - var spawnAmount = (int) (RobustRandom.Next(4, 8) * mod); - Sawmill.Info($"Spawning {spawnAmount} of spiders"); - foreach (var location in spawnLocations) - { - if (spawnAmount-- == 0) - break; - - var xform = Transform(location.Owner); - Spawn("MobGiantSpiderAngry", xform.Coordinates); - } - } -} diff --git a/Content.Server/StationEvents/Events/VentCrittersRule.cs b/Content.Server/StationEvents/Events/VentCrittersRule.cs index 696828838d..78188e642b 100644 --- a/Content.Server/StationEvents/Events/VentCrittersRule.cs +++ b/Content.Server/StationEvents/Events/VentCrittersRule.cs @@ -7,15 +7,24 @@ namespace Content.Server.StationEvents.Events; public sealed class VentCrittersRule : StationEventSystem { + /* + * DO NOT COPY PASTE THIS TO MAKE YOUR MOB EVENT. + * USE THE PROTOTYPE. + */ + protected override void Started(EntityUid uid, VentCrittersRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) { base.Started(uid, component, gameRule, args); - var spawnChoice = RobustRandom.Pick(component.SpawnedPrototypeChoices); + var spawnChoice = RobustRandom.Pick(component.Entries); + // TODO: What we should actually do is take the component count and then multiply a prob by that + // then just iterate until we get it + // This will be on average twice as fast. var spawnLocations = EntityManager.EntityQuery().ToList(); RobustRandom.Shuffle(spawnLocations); - var spawnAmount = RobustRandom.Next(4, 12); // A small colony of critters. + // A small colony of critters. + var spawnAmount = RobustRandom.Next(spawnChoice.Amount, spawnChoice.MaxAmount); Sawmill.Info($"Spawning {spawnAmount} of {spawnChoice}"); foreach (var location in spawnLocations) { @@ -23,7 +32,7 @@ public sealed class VentCrittersRule : StationEventSystem