Mime can no longer write on paper without breaking their vow (#35043)
Co-authored-by: Simon <63975668+Simyon264@users.noreply.github.com>
This commit is contained in:
@@ -113,6 +113,21 @@ public sealed class PaperSystem : EntitySystem
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var ev = new PaperWriteAttemptEvent(entity.Owner);
|
||||
RaiseLocalEvent(args.User, ref ev);
|
||||
if (ev.Cancelled)
|
||||
{
|
||||
if (ev.FailReason is not null)
|
||||
{
|
||||
var fileWriteMessage = Loc.GetString(ev.FailReason);
|
||||
_popupSystem.PopupClient(fileWriteMessage, entity.Owner, args.User);
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var writeEvent = new PaperWriteEvent(entity, args.User);
|
||||
RaiseLocalEvent(args.Used, ref writeEvent);
|
||||
|
||||
@@ -156,6 +171,11 @@ public sealed class PaperSystem : EntitySystem
|
||||
|
||||
private void OnInputTextMessage(Entity<PaperComponent> entity, ref PaperInputTextMessage args)
|
||||
{
|
||||
var ev = new PaperWriteAttemptEvent(entity.Owner);
|
||||
RaiseLocalEvent(args.Actor, ref ev);
|
||||
if (ev.Cancelled)
|
||||
return;
|
||||
|
||||
if (args.Text.Length <= entity.Comp.ContentSize)
|
||||
{
|
||||
SetContent(entity, args.Text);
|
||||
@@ -229,3 +249,10 @@ public sealed class PaperSystem : EntitySystem
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public record struct PaperWriteEvent(EntityUid User, EntityUid Paper);
|
||||
|
||||
/// <summary>
|
||||
/// Cancellable event for attempting to write on a piece of paper.
|
||||
/// </summary>
|
||||
/// <param name="paper">The paper that the writing will take place on.</param>
|
||||
[ByRefEvent]
|
||||
public record struct PaperWriteAttemptEvent(EntityUid Paper, string? FailReason = null, bool Cancelled = false);
|
||||
|
||||
Reference in New Issue
Block a user