CatStation/Content.Server/Paper/PaperRandomStorySystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

28 lines
816 B
C#

using Content.Shared.Paper;
using Content.Shared.StoryGen;
namespace Content.Server.Paper;
public sealed partial class PaperRandomStorySystem : EntitySystem
{
[Dependency] private StoryGeneratorSystem _storyGen = default!;
[Dependency] private PaperSystem _paper = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PaperRandomStoryComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(Entity<PaperRandomStoryComponent> paperStory, ref MapInitEvent ev)
{
if (!TryComp<PaperComponent>(paperStory, out var paper))
return;
if (!_storyGen.TryGenerateStoryFromTemplate(paperStory.Comp.Template, out var story))
return;
_paper.SetContent((paperStory.Owner, paper), story);
}
}