Random book story generator refactor (#28082)
* Randomized book overhaul * Fix prototype names * Improved setting paper content * Praise Ratvar
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
using Content.Server.RandomMetadata;
|
||||
using Content.Shared.StoryGen;
|
||||
|
||||
namespace Content.Server.Paper;
|
||||
|
||||
public sealed class PaperRandomStorySystem : EntitySystem
|
||||
{
|
||||
|
||||
[Dependency] private readonly RandomMetadataSystem _randomMeta = default!;
|
||||
[Dependency] private readonly StoryGeneratorSystem _storyGen = default!;
|
||||
[Dependency] private readonly PaperSystem _paper = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -19,11 +19,9 @@ public sealed class PaperRandomStorySystem : EntitySystem
|
||||
if (!TryComp<PaperComponent>(paperStory, out var paper))
|
||||
return;
|
||||
|
||||
if (paperStory.Comp.StorySegments == null)
|
||||
if (!_storyGen.TryGenerateStoryFromTemplate(paperStory.Comp.Template, out var story))
|
||||
return;
|
||||
|
||||
var story = _randomMeta.GetRandomFromSegments(paperStory.Comp.StorySegments, paperStory.Comp.StorySeparator);
|
||||
|
||||
paper.Content += $"\n{story}";
|
||||
_paper.SetContent(paperStory.Owner, story, paper);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user