fix material storage popup (#11798)
This commit is contained in:
@@ -9,8 +9,12 @@ namespace Content.Client.Materials;
|
|||||||
public sealed class MaterialStorageSystem : SharedMaterialStorageSystem
|
public sealed class MaterialStorageSystem : SharedMaterialStorageSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly TransformSystem _transform = default!;
|
[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));
|
_transform.DetachParentToNull(Transform(toInsert));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,16 @@ public sealed class MaterialStorageSystem : SharedMaterialStorageSystem
|
|||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popup = 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);
|
_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));
|
("item", toInsert)), component.Owner, Filter.Pvs(component.Owner));
|
||||||
|
|
||||||
QueueDel(toInsert);
|
QueueDel(toInsert);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,11 +136,12 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to insert an entity into the material storage.
|
/// Tries to insert an entity into the material storage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="user"></param>
|
||||||
/// <param name="toInsert"></param>
|
/// <param name="toInsert"></param>
|
||||||
/// <param name="receiver"></param>
|
/// <param name="receiver"></param>
|
||||||
/// <param name="component"></param>
|
/// <param name="component"></param>
|
||||||
/// <returns>If it was successful</returns>
|
/// <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))
|
if (!Resolve(receiver, ref component))
|
||||||
return false;
|
return false;
|
||||||
@@ -182,7 +183,6 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
|||||||
TryChangeMaterialAmount(receiver, mat, vol * multiplier, component);
|
TryChangeMaterialAmount(receiver, mat, vol * multiplier, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
OnFinishInsertMaterialEntity(toInsert, component);
|
|
||||||
RaiseLocalEvent(component.Owner, new MaterialEntityInsertedEvent(material._materials));
|
RaiseLocalEvent(component.Owner, new MaterialEntityInsertedEvent(material._materials));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -203,16 +203,10 @@ public abstract class SharedMaterialStorageSystem : EntitySystem
|
|||||||
Dirty(component);
|
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)
|
private void OnInteractUsing(EntityUid uid, MaterialStorageComponent component, InteractUsingEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
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