Change what items can be fultoned while stopping anchored items from fultoning (#20628)
* Check and restrict players from fultoning their equipped items * Changed fulton whitelist to items and anchorables * Stop from anchored items being fultoned * Moved containermanager check to CanFulton function * review --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -11,7 +11,6 @@ namespace Content.Server.Salvage;
|
||||
public sealed class FultonSystem : SharedFultonSystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -55,7 +54,8 @@ public sealed class FultonSystem : SharedFultonSystem
|
||||
{
|
||||
if (!Deleted(component.Beacon) &&
|
||||
TryComp<TransformComponent>(component.Beacon, out var beaconXform) &&
|
||||
!_container.IsEntityOrParentInContainer(component.Beacon.Value, xform: beaconXform))
|
||||
!Container.IsEntityOrParentInContainer(component.Beacon.Value, xform: beaconXform) &&
|
||||
CanFulton(uid))
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
var metadata = MetaData(uid);
|
||||
|
||||
@@ -39,9 +39,8 @@ public sealed partial class FultonComponent : Component
|
||||
{
|
||||
Components = new[]
|
||||
{
|
||||
"EntityStorage",
|
||||
"Item",
|
||||
"ReagentTank",
|
||||
"Anchorable"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public abstract partial class SharedFultonSystem : EntitySystem
|
||||
[Dependency] protected readonly SharedAudioSystem Audio = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly FoldableSystem _foldable = default!;
|
||||
[Dependency] protected readonly SharedContainerSystem Container = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedStackSystem _stack = default!;
|
||||
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
|
||||
@@ -138,7 +139,7 @@ public abstract partial class SharedFultonSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanFulton(args.Target.Value, uid, component))
|
||||
if (!CanApplyFulton(args.Target.Value, component))
|
||||
{
|
||||
_popup.PopupClient(Loc.GetString("fulton-invalid"), uid, uid);
|
||||
return;
|
||||
@@ -177,15 +178,27 @@ public abstract partial class SharedFultonSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
private bool CanFulton(EntityUid targetUid, EntityUid uid, FultonComponent component)
|
||||
protected bool CanApplyFulton(EntityUid targetUid, FultonComponent component)
|
||||
{
|
||||
if (Transform(targetUid).Anchored)
|
||||
if (!CanFulton(targetUid))
|
||||
return false;
|
||||
|
||||
if (component.Whitelist?.IsValid(targetUid, EntityManager) != true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool CanFulton(EntityUid uid)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
|
||||
if (xform.Anchored)
|
||||
return false;
|
||||
|
||||
// Shouldn't need recursive container checks I think.
|
||||
if (Container.IsEntityInContainer(uid))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user