Slimes and their habitats (#15379)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Nim
2023-05-01 11:21:39 +03:00
committed by GitHub
parent 9e9d9c1a4a
commit 78f56a4369
20 changed files with 452 additions and 50 deletions

View File

@@ -1,9 +0,0 @@
using Content.Server.StationEvents.Events;
namespace Content.Server.StationEvents.Components;
[RegisterComponent, Access(typeof(SpiderSpawnRule))]
public sealed class SpiderSpawnRuleComponent : Component
{
}

View File

@@ -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<string> SpawnedPrototypeChoices = new()
{
"MobMouse",
"MobMouse1",
"MobMouse2"
};
[DataField("entries")]
public List<EntitySpawnEntry> Entries = new();
}

View File

@@ -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<SpiderSpawnRuleComponent>
{
protected override void Started(EntityUid uid, SpiderSpawnRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
var spawnLocations = EntityQuery<VentCritterSpawnLocationComponent>().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);
}
}
}

View File

@@ -7,15 +7,24 @@ namespace Content.Server.StationEvents.Events;
public sealed class VentCrittersRule : StationEventSystem<VentCrittersRuleComponent>
{
/*
* 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<VentCritterSpawnLocationComponent>().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<VentCrittersRuleCompon
break;
var coords = Transform(location.Owner);
Spawn(spawnChoice, coords.Coordinates);
Spawn(spawnChoice.PrototypeId, coords.Coordinates);
}
}
}