mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 08:07:28 +00:00
* Reapply "Nubody Merge" (#5807) This reverts commitd62f7cef10. * Revert "Nubody Merge (#5670)" This reverts commitb465cfb3fd. * Revert "IPC fibers (#4968)" This reverts commitc2b42211f0. * Revert "IPC Polymorph fix (#4545)" This reverts commitfa03d8c655. * Revert "fix IPC not having humanoid emotes (#4445)" This reverts commit216fdf999f. * Revert "ipc heat/cold (#4306)" This reverts commitfafd5cf816. * Revert "ipc cables (#4283)" This reverts commit54958039a1. * Revert "feat: ipcs now have dynamic power draw based off movement speed (#3917)" This reverts commit71e8b7e64b. * Revert "fix ipcs not being able to disarm (#3374)" This reverts commit764c4dcf54. * Revert "make steel heal caustic for ipcs (#3206)" This reverts commit450ac82550. * Revert "add missing ipc survival boxes (#3065)" This reverts commit888c9cdb00. * Revert "make borgs use ipc repairing (#3064)" This reverts commitf77a49dd0b. * Revert "Update hud.yml to add ipcs to diagnostic hud (#3019)" This reverts commit7220643531. * Revert "Tweak IPCs (#2979)" This reverts commit98b47476de. * Revert "fix nukies ipc test fail (#2957)" This reverts commit4a1acbf863. * Revert "fix ipc nukies not getting comms (#2884)" This reverts commit8a2254770e. * Revert "fix ipc encryption key mispredict (#2879)" This reverts commitf08726efc1. * Revert "Merge pull request #2800 from Spielern/port-ipc" This reverts commit822fa4312c, reversing changes made tofe4c23c702. * Remove and Fix rest of IPC Hangons causing crashes * Integration test Errors * Expand migration file with removed IPC stuff * IPC Leg was found and migrated to naught * Revert "Merge pull request #2542 from deltanedas/shitmed-ops" This reverts commit83a8002922, reversing changes made tobaa89b0052. * Revert "Set up surgical augments infrastructure & add tool panel augments (#3059)" This reverts commita40f0be6fd. * Revert "Psionic Prosthetics (#4689)" This reverts commit2679bb238a. * Revert "Add surgical cleanliness and sanitation (#2847)" This reverts commit64565ba4f7. * Remove unremoved mentions * Revert "Add autoclave to easily sanitize large amounts of items and faster (#2933)" This reverts commitd0da90fa2e. * Shit Med Removed * Remove _ShitMed Folders and fix Errors in Console * Add OrganAnimalBrain into the mirgraiton file * Heads no Input Mover * Monke * Full migration file I guess * oops * shiv state fix * Restore accidental deleted recipe * Forgot one flt mention * Fix more issues * Comment out Damage Visual for motorkind for now * Motorkind... * Commenting stuff out for now * thought there'd be more of this to gut --------- Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
184 lines
6.6 KiB
C#
184 lines
6.6 KiB
C#
using Content.Shared.Actions;
|
|
using Content.Shared.Actions.Components;
|
|
using Content.Shared.Hands.Components;
|
|
using Content.Shared.Hands.EntitySystems;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Projectiles;
|
|
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Shared.ItemRecall;
|
|
|
|
/// <summary>
|
|
/// System for handling the ItemRecall ability for wizards.
|
|
/// </summary>
|
|
public abstract partial class SharedItemRecallSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly ISharedPlayerManager _player = default!;
|
|
[Dependency] private readonly SharedPvsOverrideSystem _pvs = default!;
|
|
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
|
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
|
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popups = default!;
|
|
[Dependency] private readonly SharedProjectileSystem _proj = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ItemRecallComponent, MapInitEvent>(OnMapInit);
|
|
SubscribeLocalEvent<ItemRecallComponent, OnItemRecallActionEvent>(OnItemRecallActionUse);
|
|
|
|
SubscribeLocalEvent<RecallMarkerComponent, ComponentShutdown>(OnRecallMarkerShutdown);
|
|
}
|
|
|
|
private void OnMapInit(Entity<ItemRecallComponent> ent, ref MapInitEvent args)
|
|
{
|
|
ent.Comp.InitialName = Name(ent);
|
|
ent.Comp.InitialDescription = Description(ent);
|
|
}
|
|
|
|
private void OnItemRecallActionUse(Entity<ItemRecallComponent> ent, ref OnItemRecallActionEvent args)
|
|
{
|
|
if (ent.Comp.MarkedEntity == null)
|
|
{
|
|
if (!TryComp<HandsComponent>(args.Performer, out var hands))
|
|
return;
|
|
|
|
var markItem = _hands.GetActiveItem((args.Performer, hands));
|
|
|
|
if (markItem == null)
|
|
{
|
|
_popups.PopupClient(Loc.GetString("item-recall-item-mark-empty"), args.Performer, args.Performer);
|
|
return;
|
|
}
|
|
|
|
if (HasComp<RecallMarkerComponent>(markItem))
|
|
{
|
|
_popups.PopupClient(Loc.GetString("item-recall-item-already-marked", ("item", markItem)), args.Performer, args.Performer);
|
|
return;
|
|
}
|
|
|
|
_popups.PopupClient(Loc.GetString("item-recall-item-marked", ("item", markItem.Value)), args.Performer, args.Performer);
|
|
TryMarkItem(ent, markItem.Value);
|
|
return;
|
|
}
|
|
|
|
RecallItem(ent.Comp.MarkedEntity.Value);
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void RecallItem(Entity<RecallMarkerComponent?> ent)
|
|
{
|
|
if (!Resolve(ent.Owner, ref ent.Comp, false))
|
|
return;
|
|
|
|
if (_actions.GetAction(ent.Comp.MarkedByAction) is not {} action)
|
|
return;
|
|
|
|
if (action.Comp.AttachedEntity is not {} user)
|
|
return;
|
|
|
|
if (TryComp<EmbeddableProjectileComponent>(ent, out var projectile))
|
|
_proj.EmbedDetach(ent, projectile, user);
|
|
|
|
_popups.PopupPredicted(Loc.GetString("item-recall-item-summon-self", ("item", ent)),
|
|
Loc.GetString("item-recall-item-summon-others", ("item", ent), ("name", Identity.Entity(user, EntityManager))),
|
|
user, user);
|
|
_popups.PopupPredictedCoordinates(Loc.GetString("item-recall-item-disappear", ("item", ent)), Transform(ent).Coordinates, user);
|
|
|
|
_hands.TryForcePickupAnyHand(user, ent);
|
|
}
|
|
|
|
private void OnRecallMarkerShutdown(Entity<RecallMarkerComponent> ent, ref ComponentShutdown args)
|
|
{
|
|
TryUnmarkItem(ent);
|
|
}
|
|
|
|
private void TryMarkItem(Entity<ItemRecallComponent> ent, EntityUid item)
|
|
{
|
|
if (_actions.GetAction(ent.Owner) is not {} action)
|
|
return;
|
|
|
|
if (action.Comp.AttachedEntity is not {} user)
|
|
return;
|
|
|
|
AddToPvsOverride(item, user);
|
|
|
|
ent.Comp.MarkedEntity = item;
|
|
Dirty(ent);
|
|
|
|
var marker = AddComp<RecallMarkerComponent>(item);
|
|
marker.MarkedByAction = ent;
|
|
Dirty(item, marker);
|
|
|
|
UpdateActionAppearance((action, action, ent));
|
|
}
|
|
|
|
private void TryUnmarkItem(EntityUid item)
|
|
{
|
|
if (!TryComp<RecallMarkerComponent>(item, out var marker))
|
|
return;
|
|
|
|
if (_actions.GetAction(marker.MarkedByAction) is not {} action)
|
|
return;
|
|
|
|
if (TryComp<ItemRecallComponent>(action, out var itemRecall))
|
|
{
|
|
// For some reason client thinks the station grid owns the action on client and this doesn't work. It doesn't work in PopupEntity(mispredicts) and PopupPredicted either(doesnt show).
|
|
// I don't have the heart to move this code to server because of this small thing.
|
|
// This line will only do something once that is fixed.
|
|
if (action.Comp.AttachedEntity is {} user)
|
|
{
|
|
_popups.PopupClient(Loc.GetString("item-recall-item-unmark", ("item", item)), user, user, PopupType.MediumCaution);
|
|
RemoveFromPvsOverride(item, user);
|
|
}
|
|
|
|
itemRecall.MarkedEntity = null;
|
|
UpdateActionAppearance((action, action, itemRecall));
|
|
Dirty(action, itemRecall);
|
|
}
|
|
|
|
RemCompDeferred<RecallMarkerComponent>(item);
|
|
}
|
|
|
|
private void UpdateActionAppearance(Entity<ActionComponent, ItemRecallComponent> action)
|
|
{
|
|
if (action.Comp2.MarkedEntity is {} marked)
|
|
{
|
|
if (action.Comp2.WhileMarkedName is {} name)
|
|
_metaData.SetEntityName(action, Loc.GetString(name, ("item", marked)));
|
|
|
|
if (action.Comp2.WhileMarkedDescription is {} desc)
|
|
_metaData.SetEntityDescription(action, Loc.GetString(desc, ("item", marked)));
|
|
|
|
_actions.SetEntityIcon((action, action), marked);
|
|
}
|
|
else
|
|
{
|
|
if (action.Comp2.InitialName is {} name)
|
|
_metaData.SetEntityName(action, name);
|
|
if (action.Comp2.InitialDescription is {} desc)
|
|
_metaData.SetEntityDescription(action, desc);
|
|
_actions.SetEntityIcon((action, action), null);
|
|
}
|
|
}
|
|
|
|
private void AddToPvsOverride(EntityUid uid, EntityUid user)
|
|
{
|
|
if (!_player.TryGetSessionByEntity(user, out var mindSession))
|
|
return;
|
|
|
|
_pvs.AddSessionOverride(uid, mindSession);
|
|
}
|
|
|
|
private void RemoveFromPvsOverride(EntityUid uid, EntityUid user)
|
|
{
|
|
if (!_player.TryGetSessionByEntity(user, out var mindSession))
|
|
return;
|
|
|
|
_pvs.RemoveSessionOverride(uid, mindSession);
|
|
}
|
|
}
|