fix material storage popup (#11798)
This commit is contained in:
@@ -9,8 +9,12 @@ namespace Content.Client.Materials;
|
||||
public sealed class MaterialStorageSystem : SharedMaterialStorageSystem
|
||||
{
|
||||
[Dependency] private readonly TransformSystem _transform = default!;
|
||||
protected override void OnFinishInsertMaterialEntity(EntityUid toInsert, MaterialStorageComponent component)
|
||||
|
||||
public override bool TryInsertMaterialEntity(EntityUid user, EntityUid toInsert, EntityUid receiver, MaterialStorageComponent? component = null)
|
||||
{
|
||||
if (!base.TryInsertMaterialEntity(user, toInsert, receiver, component))
|
||||
return false;
|
||||
_transform.DetachParentToNull(Transform(toInsert));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,16 @@ public sealed class MaterialStorageSystem : SharedMaterialStorageSystem
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
|
||||
protected override void OnFinishInsertMaterialEntity(EntityUid toInsert, MaterialStorageComponent component)
|
||||
public override bool TryInsertMaterialEntity(EntityUid user, EntityUid toInsert, EntityUid receiver, MaterialStorageComponent? component = null)
|
||||
{
|
||||
if (!Resolve(receiver, ref component))
|
||||
return false;
|
||||
if (!base.TryInsertMaterialEntity(user, toInsert, receiver, component))
|
||||
return false;
|
||||
_audio.PlayPvs(component.InsertingSound, component.Owner);
|
||||
_popup.PopupEntity(Loc.GetString("machine-insert-item", ("machine", component.Owner),
|
||||
_popup.PopupEntity(Loc.GetString("machine-insert-item", ("user", user), ("machine", component.Owner),
|
||||
("item", toInsert)), component.Owner, Filter.Pvs(component.Owner));
|
||||
|
||||
QueueDel(toInsert);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,11 +136,12 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
||||
/// <summary>
|
||||
/// Tries to insert an entity into the material storage.
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="toInsert"></param>
|
||||
/// <param name="receiver"></param>
|
||||
/// <param name="component"></param>
|
||||
/// <returns>If it was successful</returns>
|
||||
public bool TryInsertMaterialEntity(EntityUid toInsert, EntityUid receiver, MaterialStorageComponent? component = null)
|
||||
public virtual bool TryInsertMaterialEntity(EntityUid user, EntityUid toInsert, EntityUid receiver, MaterialStorageComponent? component = null)
|
||||
{
|
||||
if (!Resolve(receiver, ref component))
|
||||
return false;
|
||||
@@ -182,7 +183,6 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
||||
TryChangeMaterialAmount(receiver, mat, vol * multiplier, component);
|
||||
}
|
||||
|
||||
OnFinishInsertMaterialEntity(toInsert, component);
|
||||
RaiseLocalEvent(component.Owner, new MaterialEntityInsertedEvent(material._materials));
|
||||
return true;
|
||||
}
|
||||
@@ -203,16 +203,10 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This is done because of popup spam and not being able
|
||||
/// to do entity deletion clientside.
|
||||
/// </remarks>
|
||||
protected abstract void OnFinishInsertMaterialEntity(EntityUid toInsert, MaterialStorageComponent component);
|
||||
|
||||
private void OnInteractUsing(EntityUid uid, MaterialStorageComponent component, InteractUsingEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
args.Handled = TryInsertMaterialEntity(args.Used, uid, component);
|
||||
args.Handled = TryInsertMaterialEntity(args.User, args.Used, uid, component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
machine-insert-item = You insert {THE($item)} into {THE($machine)}.
|
||||
machine-insert-item = {THE($user)} inserted {THE($item)} into {THE($machine)}.
|
||||
|
||||
Reference in New Issue
Block a user