Add smuggler stashes (#19460)
* Add smuggler stashes * Prevent anchor/collision test fail * Enabled = false * Oops, missed one * NYAH!1984 * Split/Rebalance loot pools and fix test fail * Errg, still with the canCollide thing * Removed notes, additional balance tweaking, removed some blank lines * Replace generator IDs * Adjust briefcase fill * Node moved * Use noSpawn * Goldschlonger * Adjusts fills for grid-inv * Replace removed items * Replace removed items part 2 * Add empty satchel to clothesmate contraband inventory * Merge master and switch spawning to roundstart event * Cleaned up and converted to entity spawn tables + Added funny clown satchel * Adds comp to prevent stacking bags * Inital cleanup * More changes * ff * Some fixes but yaml needs to be organized and a few bugs remain * Final fixes * Cleanup * good * One more * minor tweaks * Rename * Combine dupe fields * address review * review * make linter happy * names, contraband status * uplink * small bugfix --------- Co-authored-by: Jeff <velcroboy333@hotmail.com> Co-authored-by: beck-thompson <beck314159@hotmail.com> Co-authored-by: Milon <milonpl.git@proton.me> Co-authored-by: ScarKy0 <scarky0@onet.eu>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Content.Shared.Construction.EntitySystems;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Construction.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Will not allow anchoring if there is an anchored item in the same tile that fails the <see cref="EntityWhitelist"/>.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(BlockAnchorOnSystem))]
|
||||
public sealed partial class BlockAnchorOnComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// If not null, entities that match this whitelist are allowed.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public EntityWhitelist? Whitelist;
|
||||
|
||||
/// <summary>
|
||||
/// If not null, entities that match this blacklist are not allowed.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public EntityWhitelist? Blacklist;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using Content.Shared.Construction.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
namespace Content.Shared.Construction.EntitySystems;
|
||||
|
||||
/// <summary>
|
||||
/// Prevents anchoring an item in the same tile as an item matching the <see cref="EntityWhitelist"/>.
|
||||
/// <seealso cref="BlockAnchorOnComponent"/>
|
||||
/// </summary>
|
||||
public sealed class BlockAnchorOnSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _xform = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<BlockAnchorOnComponent, AnchorStateChangedEvent>(OnAnchorStateChanged);
|
||||
SubscribeLocalEvent<BlockAnchorOnComponent, AnchorAttemptEvent>(OnAnchorAttempt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the <see cref="AnchorStateChangedEvent"/>.
|
||||
/// </summary>
|
||||
private void OnAnchorStateChanged(Entity<BlockAnchorOnComponent> ent, ref AnchorStateChangedEvent args)
|
||||
{
|
||||
if (!args.Anchored)
|
||||
return;
|
||||
|
||||
if (!HasOverlap((ent, ent.Comp, Transform(ent))))
|
||||
return;
|
||||
|
||||
_popup.PopupPredicted(Loc.GetString("anchored-already-present"), ent, null);
|
||||
_xform.Unanchor(ent, Transform(ent));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the <see cref="AnchorAttemptEvent"/>.
|
||||
/// </summary>
|
||||
private void OnAnchorAttempt(Entity<BlockAnchorOnComponent> ent, ref AnchorAttemptEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
return;
|
||||
|
||||
if (!HasOverlap((ent, ent.Comp, Transform(ent))))
|
||||
return;
|
||||
|
||||
_popup.PopupPredicted(Loc.GetString("anchored-already-present"), ent, args.User);
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if there is any anchored overlap with non whitelisted or blacklisted entities.
|
||||
/// </summary>
|
||||
/// <returns>True if there is, false if there isn't</returns>
|
||||
private bool HasOverlap(Entity<BlockAnchorOnComponent, TransformComponent> ent)
|
||||
{
|
||||
if (ent.Comp2.GridUid is not { } grid || !TryComp<MapGridComponent>(grid, out var gridComp))
|
||||
return false;
|
||||
|
||||
var indices = _map.TileIndicesFor(grid, gridComp, ent.Comp2.Coordinates);
|
||||
var enumerator = _map.GetAnchoredEntitiesEnumerator(grid, gridComp, indices);
|
||||
|
||||
while (enumerator.MoveNext(out var otherEnt))
|
||||
{
|
||||
// Don't match yourself.
|
||||
if (otherEnt == ent)
|
||||
continue;
|
||||
|
||||
if (!_whitelist.CheckBoth(otherEnt, ent.Comp1.Blacklist, ent.Comp1.Whitelist))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Storage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Entities with this component will eject all items that match the whitelist / blacklist when anchored.
|
||||
/// It also doesn't allow any items to be inserted that fit the whitelist / blacklist while anchored.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// If you have a smuggler stash that has a player inside of it, you want to eject the player before its anchored so they don't get stuck
|
||||
/// </example>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(AnchoredStorageFilterSystem))]
|
||||
public sealed partial class AnchoredStorageFilterComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// If not null, entities that do not match this whitelist will be ejected.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public EntityWhitelist? Whitelist;
|
||||
|
||||
/// <summary>
|
||||
/// If not null, entities that match this blacklist will be ejected..
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public EntityWhitelist? Blacklist;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Shared.Storage.EntitySystems;
|
||||
|
||||
/// <summary>
|
||||
/// Ejects items that do not match a <see cref="EntityWhitelist"/> from a storage when it is anchored.
|
||||
/// <seealso cref="AnchoredStorageFilterComponent"/>
|
||||
/// </summary>
|
||||
public sealed class AnchoredStorageFilterSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<AnchoredStorageFilterComponent, AnchorStateChangedEvent>(OnAnchorStateChanged);
|
||||
SubscribeLocalEvent<AnchoredStorageFilterComponent, ContainerIsInsertingAttemptEvent>(OnInsertAttempt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the <see cref="AnchorStateChangedEvent"/>.
|
||||
/// </summary>
|
||||
private void OnAnchorStateChanged(Entity<AnchoredStorageFilterComponent> ent, ref AnchorStateChangedEvent args)
|
||||
{
|
||||
if (!args.Anchored)
|
||||
return;
|
||||
|
||||
if (!TryComp<StorageComponent>(ent, out var storage))
|
||||
return;
|
||||
|
||||
foreach (var item in storage.StoredItems.Keys)
|
||||
{
|
||||
if (!_whitelist.CheckBoth(item, ent.Comp.Blacklist, ent.Comp.Whitelist))
|
||||
_container.RemoveEntity(ent, item);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the <see cref="ContainerIsInsertingAttemptEvent"/>.
|
||||
/// </summary>
|
||||
private void OnInsertAttempt(Entity<AnchoredStorageFilterComponent> ent, ref ContainerIsInsertingAttemptEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
return;
|
||||
|
||||
if (Transform(ent).Anchored && !_whitelist.CheckBoth(args.EntityUid, ent.Comp.Blacklist, ent.Comp.Whitelist))
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user