Skip to content

Commit

Permalink
Printer paper now has a tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Just-a-Unity-Dev committed Mar 31, 2024
1 parent f4089c8 commit 4e5a734
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Content.Server/_FTL/PrinterPaper/PrinterPaperPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public sealed class PrinterPaperPrototype : IPrototype
[DataField("corruptProb")]
public float CorruptionProbability { get; } = 0.1f;

[DataField("tag")]
public string Tag = "Default";

[DataField("corruptChars")]
public List<string> CorruptionCharacters = new ()
{
Expand Down
14 changes: 13 additions & 1 deletion Content.Server/_FTL/PrinterPaper/PrinterPaperSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@ public override void Initialize()
private void OnComponentInit(EntityUid uid, RandomPrinterPaperComponent component, ComponentInit args)
{
var prototypes = _prototypeManager.EnumeratePrototypes<PrinterPaperPrototype>().ToList();
var prototype = _random.Pick(prototypes);
PrinterPaperPrototype? prototype = null;

while (prototype == null)
{
var chosenPrototype = _random.Pick(prototypes);
if (component.Tag == null)
{
prototype = chosenPrototype;
break;
}
if (component.Tag == chosenPrototype.Tag)
prototype = chosenPrototype;
}

var contentPicked = prototype.Content;
var content = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ namespace Content.Server._FTL.PrinterPaper;
[RegisterComponent]
public sealed partial class RandomPrinterPaperComponent : Component
{
[ViewVariables(VVAccess.ReadOnly)] public string Content = "";
[DataField, ViewVariables(VVAccess.ReadOnly)]
public string Content = "";
[DataField] public string? Tag;
}

0 comments on commit 4e5a734

Please sign in to comment.