Gamerule Entities, Take 2 (#15765)
This commit is contained in:
34
Content.Server/StationEvents/Events/BluespaceArtifactRule.cs
Normal file
34
Content.Server/StationEvents/Events/BluespaceArtifactRule.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.StationEvents.Events;
|
||||
|
||||
public sealed class BluespaceArtifactRule : StationEventSystem<BluespaceArtifactRuleComponent>
|
||||
{
|
||||
protected override void Added(EntityUid uid, BluespaceArtifactRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
|
||||
{
|
||||
base.Added(uid, component, gameRule, args);
|
||||
|
||||
var str = Loc.GetString("bluespace-artifact-event-announcement",
|
||||
("sighting", Loc.GetString(RobustRandom.Pick(component.PossibleSighting))));
|
||||
ChatSystem.DispatchGlobalAnnouncement(str, colorOverride: Color.FromHex("#18abf5"));
|
||||
}
|
||||
|
||||
protected override void Started(EntityUid uid, BluespaceArtifactRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
||||
{
|
||||
base.Started(uid, component, gameRule, args);
|
||||
|
||||
var amountToSpawn = Math.Max(1, (int) MathF.Round(GetSeverityModifier() / 1.5f));
|
||||
for (var i = 0; i < amountToSpawn; i++)
|
||||
{
|
||||
if (!TryFindRandomTile(out _, out _, out _, out var coords))
|
||||
return;
|
||||
|
||||
Spawn(component.ArtifactSpawnerPrototype, coords);
|
||||
Spawn(component.ArtifactFlashPrototype, coords);
|
||||
|
||||
Sawmill.Info($"Spawning random artifact at {coords}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user