crayons deleted when used up (#7282)
This commit is contained in:
@@ -25,6 +25,10 @@ namespace Content.Server.Crayon
|
|||||||
[DataField("capacity")]
|
[DataField("capacity")]
|
||||||
public int Capacity { get; set; } = 30;
|
public int Capacity { get; set; } = 30;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("deleteEmpty")]
|
||||||
|
public bool DeleteEmpty = true;
|
||||||
|
|
||||||
[ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(CrayonUiKey.Key);
|
[ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(CrayonUiKey.Key);
|
||||||
|
|
||||||
void ISerializationHooks.AfterDeserialization()
|
void ISerializationHooks.AfterDeserialization()
|
||||||
|
|||||||
@@ -51,7 +51,11 @@ public sealed class CrayonSystem : EntitySystem
|
|||||||
|
|
||||||
if (component.Charges <= 0)
|
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;
|
args.Handled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -74,6 +78,9 @@ public sealed class CrayonSystem : EntitySystem
|
|||||||
Dirty(component);
|
Dirty(component);
|
||||||
_logs.Add(LogType.CrayonDraw, LogImpact.Low, $"{EntityManager.ToPrettyString(args.User):user} drew a {component._color:color} {component.SelectedState}");
|
_logs.Add(LogType.CrayonDraw, LogImpact.Low, $"{EntityManager.ToPrettyString(args.User):user} drew a {component._color:color} {component.SelectedState}");
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
|
|
||||||
|
if (component.DeleteEmpty && component.Charges <= 0)
|
||||||
|
UseUpCrayon(uid, args.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCrayonUse(EntityUid uid, CrayonComponent component, UseInHandEvent args)
|
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))
|
if (TryComp<ActorComponent>(args.User, out var actor))
|
||||||
component.UserInterface?.Close(actor.PlayerSession);
|
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-drawing-label = Drawing: [color={$color}]{$state}[/color] ({$charges}/{$capacity})
|
||||||
crayon-interact-not-enough-left-text = Not enough left.
|
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!
|
crayon-interact-invalid-location = Can't reach there!
|
||||||
|
|
||||||
## UI
|
## UI
|
||||||
|
|||||||
Reference in New Issue
Block a user