Skip to content

Commit

Permalink
Фикс выпадение предметов с импланта хранилища в апстриме
Browse files Browse the repository at this point in the history
  • Loading branch information
VigersRay committed Jan 20, 2025
1 parent 3923c36 commit 28ba3e8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 39 deletions.
26 changes: 26 additions & 0 deletions Content.Server/Implants/ImplantedSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Body.Components;
using Content.Shared.Implants.Components;
using Robust.Shared.Containers;
Expand All @@ -6,6 +7,8 @@ namespace Content.Server.Implants;

public sealed partial class ImplanterSystem
{
public const string BaseStorageId = "storagebase";

public void InitializeImplanted()
{
SubscribeLocalEvent<ImplantedComponent, ComponentInit>(OnImplantedInit);
Expand All @@ -27,6 +30,29 @@ private void OnShutdown(EntityUid uid, ImplantedComponent component, ComponentSh

private void OnGibbed(Entity<ImplantedComponent> ent, ref BeingGibbedEvent args)
{
foreach (var implant in ent.Comp.ImplantContainer.ContainedEntities)
{
if (!TryComp<SubdermalImplantComponent>(implant, out var subdermalImplant))
continue;

if (!subdermalImplant.DropContainerItemsIfGib)
continue;

if (!_container.TryGetContainer(implant, BaseStorageId, out var storageImplant))
continue;

var entCoords = Transform(ent.Owner).Coordinates;

var containedEntites = storageImplant.ContainedEntities.ToArray();

foreach (var entity in containedEntites)
{
if (Terminating(entity))
continue;

_container.RemoveEntity(storageImplant.Owner, entity, force: true, destination: entCoords);
}
}
//If the entity is gibbed, get rid of the implants
_container.CleanContainer(ent.Comp.ImplantContainer);
}
Expand Down
32 changes: 0 additions & 32 deletions Content.Server/Implants/SubdermalImplantSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public sealed class SubdermalImplantSystem : SharedSubdermalImplantSystem
[Dependency] private readonly EntityLookupSystem _lookupSystem = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly IdentitySystem _identity = default!;
[Dependency] private readonly ContainerSystem _container = default!;

private EntityQuery<PhysicsComponent> _physicsQuery;
private HashSet<Entity<MapGridComponent>> _targetGrids = [];
Expand All @@ -63,37 +62,6 @@ public override void Initialize()
SubscribeLocalEvent<SubdermalImplantComponent, ActivateImplantEvent>(OnActivateImplantEvent);
SubscribeLocalEvent<SubdermalImplantComponent, UseScramImplantEvent>(OnScramImplant);
SubscribeLocalEvent<SubdermalImplantComponent, UseDnaScramblerImplantEvent>(OnDnaScramblerImplant);
SubscribeLocalEvent<ImplantedComponent, BeingGibbedEvent>(OnGibbed);
}

private void OnGibbed(EntityUid uid, ImplantedComponent component, BeingGibbedEvent args)
{
if (!_container.TryGetContainer(uid, ImplanterComponent.ImplantSlotId, out var implantContainer))
return;

foreach (var implant in implantContainer.ContainedEntities)
{
if (!TryComp<SubdermalImplantComponent>(implant, out var subdermalImplant))
continue;

if (!subdermalImplant.DropContainerItemsIfGibbed)
continue;

if (!_container.TryGetContainer(implant, BaseStorageId, out var storageImplant))
continue;

var entCoords = Transform(uid).Coordinates;

var containedEntites = storageImplant.ContainedEntities.ToArray();

foreach (var entity in containedEntites)
{
if (Terminating(entity))
continue;

_container.RemoveEntity(storageImplant.Owner, entity, force: true, destination: entCoords);
}
}
}

private void OnStoreRelay(EntityUid uid, StoreComponent store, ImplantRelayEvent<AfterInteractUsingEvent> implantRelay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,8 @@ public sealed partial class SubdermalImplantComponent : Component
public EntityWhitelist? Blacklist;

// Sunrise-Start
[ViewVariables(VVAccess.ReadWrite)]
[DataField("dropContainerItemsIfGibbed"), AutoNetworkedField]
public bool DropContainerItemsIfGibbed = true;

[ViewVariables(VVAccess.ReadWrite)]
[DataField("deleteWhenDraw"), AutoNetworkedField]
public bool DeleteWhenDraw;
[DataField, AutoNetworkedField]
public bool DropContainerItemsIfGib;
// Sunrise-End
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
whitelist:
components:
- Hands # no use giving a mouse a storage implant, but a monkey is another story...
dropContainerItemsIfGib: true
- type: Storage
grid:
- 0,0,2,2
Expand Down

0 comments on commit 28ba3e8

Please sign in to comment.