mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-02-15 03:10:55 +01:00
crayons deleted when used up (#7282)
This commit is contained in:
@@ -25,6 +25,10 @@ namespace Content.Server.Crayon
|
||||
[DataField("capacity")]
|
||||
public int Capacity { get; set; } = 30;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("deleteEmpty")]
|
||||
public bool DeleteEmpty = true;
|
||||
|
||||
[ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(CrayonUiKey.Key);
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
|
||||
@@ -51,7 +51,11 @@ public sealed class CrayonSystem : EntitySystem
|
||||
|
||||
if (component.Charges <= 0)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("crayon-interact-not-enough-left-text"), uid, Filter.Entities(args.User));
|
||||
if (component.DeleteEmpty)
|
||||
UseUpCrayon(uid, args.User);
|
||||
else
|
||||
_popup.PopupEntity(Loc.GetString("crayon-interact-not-enough-left-text"), uid, Filter.Entities(args.User));
|
||||
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
@@ -74,6 +78,9 @@ public sealed class CrayonSystem : EntitySystem
|
||||
Dirty(component);
|
||||
_logs.Add(LogType.CrayonDraw, LogImpact.Low, $"{EntityManager.ToPrettyString(args.User):user} drew a {component._color:color} {component.SelectedState}");
|
||||
args.Handled = true;
|
||||
|
||||
if (component.DeleteEmpty && component.Charges <= 0)
|
||||
UseUpCrayon(uid, args.User);
|
||||
}
|
||||
|
||||
private void OnCrayonUse(EntityUid uid, CrayonComponent component, UseInHandEvent args)
|
||||
@@ -119,4 +126,10 @@ public sealed class CrayonSystem : EntitySystem
|
||||
if (TryComp<ActorComponent>(args.User, out var actor))
|
||||
component.UserInterface?.Close(actor.PlayerSession);
|
||||
}
|
||||
|
||||
private void UseUpCrayon(EntityUid uid, EntityUid user)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("crayon-interact-used-up-text", ("owner", uid)), user, Filter.Entities(user));
|
||||
EntityManager.QueueDeleteEntity(uid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
crayon-drawing-label = Drawing: [color={$color}]{$state}[/color] ({$charges}/{$capacity})
|
||||
crayon-interact-not-enough-left-text = Not enough left.
|
||||
crayon-interact-used-up-text = The {$owner} got used up.
|
||||
crayon-interact-invalid-location = Can't reach there!
|
||||
|
||||
## UI
|
||||
|
||||
Reference in New Issue
Block a user