From 4cff0264ed60c7d41cd75aef4e3619dccd4543e8 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Mon, 13 Jan 2025 02:10:46 +0100 Subject: [PATCH 01/18] Init --- Content.Client/Actions/ActionsSystem.cs | 1 + Content.Shared/Actions/BaseActionComponent.cs | 8 +++ Content.Shared/Actions/SharedActionsSystem.cs | 3 + .../ItemRecall/ItemRecallComponent.cs | 33 +++++++++++ Content.Shared/ItemRecall/ItemRecallEvents.cs | 12 ++++ .../ItemRecall/RecallMarkerComponent.cs | 14 +++++ .../ItemRecall/SharedItemRecallSystem.cs | 56 +++++++++++++++++++ .../Prototypes/Catalog/spellbook_catalog.yml | 13 +++++ Resources/Prototypes/Magic/recall_spell.yml | 16 ++++++ 9 files changed, 156 insertions(+) create mode 100644 Content.Shared/ItemRecall/ItemRecallComponent.cs create mode 100644 Content.Shared/ItemRecall/ItemRecallEvents.cs create mode 100644 Content.Shared/ItemRecall/RecallMarkerComponent.cs create mode 100644 Content.Shared/ItemRecall/SharedItemRecallSystem.cs create mode 100644 Resources/Prototypes/Magic/recall_spell.yml diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index b594817701ea..d836c2ed7a88 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -137,6 +137,7 @@ private void BaseHandleState(EntityUid uid, BaseActionComponent component, Ba component.Priority = state.Priority; component.AttachedEntity = EnsureEntity(state.AttachedEntity, uid); component.RaiseOnUser = state.RaiseOnUser; + component.RaiseOnAction = state.RaiseOnAction; component.AutoPopulate = state.AutoPopulate; component.Temporary = state.Temporary; component.ItemIconStyle = state.ItemIconStyle; diff --git a/Content.Shared/Actions/BaseActionComponent.cs b/Content.Shared/Actions/BaseActionComponent.cs index c3aa6cc97eeb..ec2e4602e6d4 100644 --- a/Content.Shared/Actions/BaseActionComponent.cs +++ b/Content.Shared/Actions/BaseActionComponent.cs @@ -167,6 +167,12 @@ public EntityUid? EntityIcon [DataField] public bool RaiseOnUser; + /// + /// If true, this will cause the the action event to always be raised directed at the action itself instead of the action's container/provider. + /// + [DataField] + public bool RaiseOnAction; + /// /// Whether or not to automatically add this action to the action bar when it becomes available. /// @@ -212,6 +218,7 @@ public abstract class BaseActionComponentState : ComponentState public int Priority; public NetEntity? AttachedEntity; public bool RaiseOnUser; + public bool RaiseOnAction; public bool AutoPopulate; public bool Temporary; public ItemActionIconStyle ItemIconStyle; @@ -223,6 +230,7 @@ protected BaseActionComponentState(BaseActionComponent component, IEntityManager EntityIcon = entManager.GetNetEntity(component.EntIcon); AttachedEntity = entManager.GetNetEntity(component.AttachedEntity); RaiseOnUser = component.RaiseOnUser; + RaiseOnAction = component.RaiseOnAction; Icon = component.Icon; IconOn = component.IconOn; IconColor = component.IconColor; diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index fc6f0baf7721..1ab409903664 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -679,6 +679,9 @@ public void PerformAction(EntityUid performer, ActionsComponent? component, Enti if (!action.RaiseOnUser && action.Container != null && !HasComp(action.Container)) target = action.Container.Value; + if (action.RaiseOnAction && !HasComp(actionId)) + target = actionId; + RaiseLocalEvent(target, (object) actionEvent, broadcast: true); handled = actionEvent.Handled; } diff --git a/Content.Shared/ItemRecall/ItemRecallComponent.cs b/Content.Shared/ItemRecall/ItemRecallComponent.cs new file mode 100644 index 000000000000..3b0103313759 --- /dev/null +++ b/Content.Shared/ItemRecall/ItemRecallComponent.cs @@ -0,0 +1,33 @@ +using Robust.Shared.GameStates; +using Robust.Shared.Utility; + +namespace Content.Shared.ItemRecall; + +[RegisterComponent, NetworkedComponent, Access(typeof(SharedItemRecallSystem))] +public sealed partial class ItemRecallComponent : Component +{ + /// + /// Does this spell require Wizard Robes & Hat? + /// + [DataField] + public bool RequiresClothes = true; + + [DataField] + public LocId WhileMarkedName = ""; + + [DataField] + public LocId WhileMarkedDescription = ""; + + [DataField] + public SpriteSpecifier? WhileMarkedSprite; + + [ViewVariables] + public EntityUid? MarkedEntity; + + /// + /// Does this spell require the user to speak? + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public bool RequiresSpeech; + +} diff --git a/Content.Shared/ItemRecall/ItemRecallEvents.cs b/Content.Shared/ItemRecall/ItemRecallEvents.cs new file mode 100644 index 000000000000..b258d85121ba --- /dev/null +++ b/Content.Shared/ItemRecall/ItemRecallEvents.cs @@ -0,0 +1,12 @@ +using Content.Shared.Actions; + +namespace Content.Shared.ItemRecall; + +/// +/// Raised directed on an entity when it embeds in another entity. +/// +[ByRefEvent] +public sealed partial class OnItemRecallActionEvent : InstantActionEvent +{ + +} diff --git a/Content.Shared/ItemRecall/RecallMarkerComponent.cs b/Content.Shared/ItemRecall/RecallMarkerComponent.cs new file mode 100644 index 000000000000..9d5bc53f079f --- /dev/null +++ b/Content.Shared/ItemRecall/RecallMarkerComponent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.GameStates; +using Robust.Shared.Utility; + +namespace Content.Shared.ItemRecall; + +[RegisterComponent, NetworkedComponent, Access(typeof(SharedItemRecallSystem))] +public sealed partial class RecallMarkerComponent : Component +{ + /// + /// Does this spell require Wizard Robes & Hat? + /// + [DataField] + public EntityUid MarkedByEntity; +} diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs new file mode 100644 index 000000000000..544b7fca4c77 --- /dev/null +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -0,0 +1,56 @@ +using Content.Shared.Hands.Components; +using Content.Shared.Hands.EntitySystems; + +namespace Content.Shared.ItemRecall; + +/// +/// uwu +/// +public sealed partial class SharedItemRecallSystem : EntitySystem +{ + + [Dependency] private readonly SharedHandsSystem _hands = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnItemRecallUse); + } + + public void OnItemRecallUse(Entity ent, ref OnItemRecallActionEvent args) + { + + if (ent.Comp.MarkedEntity == null) + { + Log.Debug("Trying for hands"); + if (!TryComp(args.Performer, out var hands)) + return; + + Log.Debug("Marking"); + var markItem = _hands.GetActiveItem((args.Performer, hands)); + TryMarkItem(ent, markItem, args.Performer); + return; + } + + RecallItem(ent.Comp.MarkedEntity); + } + + private void TryMarkItem(Entity ent, EntityUid? item, EntityUid markedBy) + { + if (item == null) + return; + Log.Debug("Adding component"); + EnsureComp(item.Value, out var marker); + ent.Comp.MarkedEntity = item; + marker.MarkedByEntity = markedBy; + } + + private void RecallItem(EntityUid? item) + { + if (!TryComp(item, out var marker)) + return; + + _hands.TryForcePickupAnyHand(marker.MarkedByEntity, item.Value); + } +} diff --git a/Resources/Prototypes/Catalog/spellbook_catalog.yml b/Resources/Prototypes/Catalog/spellbook_catalog.yml index d5a9b0f1b9a3..fd93fdf6ea8c 100644 --- a/Resources/Prototypes/Catalog/spellbook_catalog.yml +++ b/Resources/Prototypes/Catalog/spellbook_catalog.yml @@ -225,3 +225,16 @@ - SpellbookJaunt - !type:ListingLimitedStockCondition stock: 2 + +- type: listing + id: SpellbookItemRecallSwap + name: recall + description: recall + productAction: ActionItemRecall + cost: + WizCoin: 1 + categories: + - SpellbookUtility + conditions: + - !type:ListingLimitedStockCondition + stock: 1 diff --git a/Resources/Prototypes/Magic/recall_spell.yml b/Resources/Prototypes/Magic/recall_spell.yml new file mode 100644 index 000000000000..399fd293868c --- /dev/null +++ b/Resources/Prototypes/Magic/recall_spell.yml @@ -0,0 +1,16 @@ +- type: entity + id: ActionItemRecall + name: item recall + description: Mark and summon an item back into your hand. + components: + - type: InstantAction + useDelay: 5 + raiseOnAction: true + itemIconStyle: BigAction + sound: !type:SoundPathSpecifier + path: /Audio/Magic/forcewall.ogg + icon: + sprite: Objects/Magic/magicactions.rsi + state: shield + event: !type:OnItemRecallActionEvent + - type: ItemRecall From ce089fb0e267e3871b3f6d870e4be790bf49425b Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Mon, 13 Jan 2025 11:41:47 +0100 Subject: [PATCH 02/18] embeddable proj fix --- .../ItemRecall/ItemRecallComponent.cs | 13 ------ .../ItemRecall/SharedItemRecallSystem.cs | 5 +++ .../Projectiles/SharedProjectileSystem.cs | 43 +++++++++++-------- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/Content.Shared/ItemRecall/ItemRecallComponent.cs b/Content.Shared/ItemRecall/ItemRecallComponent.cs index 3b0103313759..ae097c43dde3 100644 --- a/Content.Shared/ItemRecall/ItemRecallComponent.cs +++ b/Content.Shared/ItemRecall/ItemRecallComponent.cs @@ -6,12 +6,6 @@ namespace Content.Shared.ItemRecall; [RegisterComponent, NetworkedComponent, Access(typeof(SharedItemRecallSystem))] public sealed partial class ItemRecallComponent : Component { - /// - /// Does this spell require Wizard Robes & Hat? - /// - [DataField] - public bool RequiresClothes = true; - [DataField] public LocId WhileMarkedName = ""; @@ -23,11 +17,4 @@ public sealed partial class ItemRecallComponent : Component [ViewVariables] public EntityUid? MarkedEntity; - - /// - /// Does this spell require the user to speak? - /// - [DataField, ViewVariables(VVAccess.ReadWrite)] - public bool RequiresSpeech; - } diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 544b7fca4c77..00d2c322803f 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -1,5 +1,6 @@ using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; +using Content.Shared.Projectiles; namespace Content.Shared.ItemRecall; @@ -10,6 +11,7 @@ public sealed partial class SharedItemRecallSystem : EntitySystem { [Dependency] private readonly SharedHandsSystem _hands = default!; + [Dependency] private readonly SharedProjectileSystem _proj = default!; public override void Initialize() { @@ -51,6 +53,9 @@ private void RecallItem(EntityUid? item) if (!TryComp(item, out var marker)) return; + if (TryComp(item, out var projectile)) + _proj.UnEmbed(item.Value, marker.MarkedByEntity, projectile); + _hands.TryForcePickupAnyHand(marker.MarkedByEntity, item.Value); } } diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs index 85e75d6d2913..446eddfbdc9f 100644 --- a/Content.Shared/Projectiles/SharedProjectileSystem.cs +++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs @@ -67,25 +67,7 @@ private void OnEmbedRemove(EntityUid uid, EmbeddableProjectileComponent componen return; } - var xform = Transform(uid); - TryComp(uid, out var physics); - _physics.SetBodyType(uid, BodyType.Dynamic, body: physics, xform: xform); - _transform.AttachToGridOrMap(uid, xform); - component.EmbeddedIntoUid = null; - Dirty(uid, component); - - // Reset whether the projectile has damaged anything if it successfully was removed - if (TryComp(uid, out var projectile)) - { - projectile.Shooter = null; - projectile.Weapon = null; - projectile.DamagedEntity = false; - } - - // Land it just coz uhhh yeah - var landEv = new LandEvent(args.User, true); - RaiseLocalEvent(uid, ref landEv); - _physics.WakeBody(uid, body: physics); + UnEmbed(uid, args.User, component); // try place it in the user's hand _hands.TryPickupAnyHand(args.User, uid); @@ -135,6 +117,29 @@ private void Embed(EntityUid uid, EntityUid target, EntityUid? user, EmbeddableP Dirty(uid, component); } + public void UnEmbed(EntityUid uid, EntityUid user, EmbeddableProjectileComponent component) + { + var xform = Transform(uid); + TryComp(uid, out var physics); + _physics.SetBodyType(uid, BodyType.Dynamic, body: physics, xform: xform); + _transform.AttachToGridOrMap(uid, xform); + component.EmbeddedIntoUid = null; + Dirty(uid, component); + + // Reset whether the projectile has damaged anything if it successfully was removed + if (TryComp(uid, out var projectile)) + { + projectile.Shooter = null; + projectile.Weapon = null; + projectile.DamagedEntity = false; + } + + // Land it just coz uhhh yeah + var landEv = new LandEvent(user, true); + RaiseLocalEvent(uid, ref landEv); + _physics.WakeBody(uid, body: physics); + } + private void PreventCollision(EntityUid uid, ProjectileComponent component, ref PreventCollideEvent args) { if (component.IgnoreShooter && (args.OtherEntity == component.Shooter || args.OtherEntity == component.Weapon)) From d83c9400caaf0c4e39a95b371257ebcc0e42dd30 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Mon, 13 Jan 2025 12:23:20 +0100 Subject: [PATCH 03/18] Unbind on break --- .../ItemRecall/ItemRecallComponent.cs | 4 +- Content.Shared/ItemRecall/ItemRecallEvents.cs | 3 ++ .../ItemRecall/RecallMarkerComponent.cs | 5 ++- .../ItemRecall/SharedItemRecallSystem.cs | 41 +++++++++++++++++-- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/Content.Shared/ItemRecall/ItemRecallComponent.cs b/Content.Shared/ItemRecall/ItemRecallComponent.cs index ae097c43dde3..517358831731 100644 --- a/Content.Shared/ItemRecall/ItemRecallComponent.cs +++ b/Content.Shared/ItemRecall/ItemRecallComponent.cs @@ -7,10 +7,10 @@ namespace Content.Shared.ItemRecall; public sealed partial class ItemRecallComponent : Component { [DataField] - public LocId WhileMarkedName = ""; + public LocId? WhileMarkedName = ""; [DataField] - public LocId WhileMarkedDescription = ""; + public LocId? WhileMarkedDescription = ""; [DataField] public SpriteSpecifier? WhileMarkedSprite; diff --git a/Content.Shared/ItemRecall/ItemRecallEvents.cs b/Content.Shared/ItemRecall/ItemRecallEvents.cs index b258d85121ba..79fb3640cf63 100644 --- a/Content.Shared/ItemRecall/ItemRecallEvents.cs +++ b/Content.Shared/ItemRecall/ItemRecallEvents.cs @@ -10,3 +10,6 @@ public sealed partial class OnItemRecallActionEvent : InstantActionEvent { } + +[ByRefEvent] +public sealed partial class RecallItemEvent(EntityUid item); diff --git a/Content.Shared/ItemRecall/RecallMarkerComponent.cs b/Content.Shared/ItemRecall/RecallMarkerComponent.cs index 9d5bc53f079f..7c71672c55b7 100644 --- a/Content.Shared/ItemRecall/RecallMarkerComponent.cs +++ b/Content.Shared/ItemRecall/RecallMarkerComponent.cs @@ -9,6 +9,9 @@ public sealed partial class RecallMarkerComponent : Component /// /// Does this spell require Wizard Robes & Hat? /// - [DataField] + [ViewVariables] public EntityUid MarkedByEntity; + + [ViewVariables] + public EntityUid MarkedByAction; } diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 00d2c322803f..5a7c4a154e12 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -17,10 +17,13 @@ public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnItemRecallUse); + SubscribeLocalEvent(OnItemRecallActionUse); + + SubscribeLocalEvent(OnItemRecallEvent); + SubscribeLocalEvent(OnRecallMarkerShutdown); } - public void OnItemRecallUse(Entity ent, ref OnItemRecallActionEvent args) + private void OnItemRecallActionUse(Entity ent, ref OnItemRecallActionEvent args) { if (ent.Comp.MarkedEntity == null) @@ -35,7 +38,18 @@ public void OnItemRecallUse(Entity ent, ref OnItemRecallAct return; } - RecallItem(ent.Comp.MarkedEntity); + var ev = new RecallItemEvent(ent.Comp.MarkedEntity.Value); + RaiseLocalEvent(ent.Comp.MarkedEntity.Value, ref ev); + } + + private void OnRecallMarkerShutdown(Entity ent, ref ComponentShutdown args) + { + TryUnmarkItem(ent); + } + + private void OnItemRecallEvent(Entity ent, ref RecallItemEvent args) + { + RecallItem(ent.Owner); } private void TryMarkItem(Entity ent, EntityUid? item, EntityUid markedBy) @@ -45,7 +59,28 @@ private void TryMarkItem(Entity ent, EntityUid? item, Entit Log.Debug("Adding component"); EnsureComp(item.Value, out var marker); ent.Comp.MarkedEntity = item; + Dirty(ent); + marker.MarkedByEntity = markedBy; + marker.MarkedByAction = ent.Owner; + Dirty(item.Value, marker); + } + + private void TryUnmarkItem(EntityUid? item) + { + if (item == null) + return; + + if (!TryComp(item.Value, out var marker)) + return; + + if (TryComp(marker.MarkedByAction, out var action)) + { + action.MarkedEntity = null; + Dirty(marker.MarkedByAction, action); + } + + RemCompDeferred(item.Value); } private void RecallItem(EntityUid? item) From 1ba31343b4eeae925ea5d7504008287f1a5e28ce Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Mon, 13 Jan 2025 19:59:09 +0100 Subject: [PATCH 04/18] Cooldown fix --- Content.Shared/ItemRecall/SharedItemRecallSystem.cs | 4 +--- Resources/Prototypes/Magic/recall_spell.yml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 5a7c4a154e12..2326266dda97 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -28,11 +28,9 @@ private void OnItemRecallActionUse(Entity ent, ref OnItemRe if (ent.Comp.MarkedEntity == null) { - Log.Debug("Trying for hands"); if (!TryComp(args.Performer, out var hands)) return; - Log.Debug("Marking"); var markItem = _hands.GetActiveItem((args.Performer, hands)); TryMarkItem(ent, markItem, args.Performer); return; @@ -40,6 +38,7 @@ private void OnItemRecallActionUse(Entity ent, ref OnItemRe var ev = new RecallItemEvent(ent.Comp.MarkedEntity.Value); RaiseLocalEvent(ent.Comp.MarkedEntity.Value, ref ev); + args.Handled = true; } private void OnRecallMarkerShutdown(Entity ent, ref ComponentShutdown args) @@ -56,7 +55,6 @@ private void TryMarkItem(Entity ent, EntityUid? item, Entit { if (item == null) return; - Log.Debug("Adding component"); EnsureComp(item.Value, out var marker); ent.Comp.MarkedEntity = item; Dirty(ent); diff --git a/Resources/Prototypes/Magic/recall_spell.yml b/Resources/Prototypes/Magic/recall_spell.yml index 399fd293868c..b603124f8070 100644 --- a/Resources/Prototypes/Magic/recall_spell.yml +++ b/Resources/Prototypes/Magic/recall_spell.yml @@ -4,7 +4,7 @@ description: Mark and summon an item back into your hand. components: - type: InstantAction - useDelay: 5 + useDelay: 10 raiseOnAction: true itemIconStyle: BigAction sound: !type:SoundPathSpecifier From 6e6e0404e8206e3a59dae8d1c4e36198e6f18ec5 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Tue, 14 Jan 2025 00:07:22 +0100 Subject: [PATCH 05/18] a lot of stuff --- Content.Client/ItemRecall/ItemRecallSystem.cs | 8 +++ Content.Server/ItemRecall/ItemRecallSystem.cs | 8 +++ .../ItemRecall/ItemRecallComponent.cs | 7 +-- Content.Shared/ItemRecall/ItemRecallEvents.cs | 7 +-- .../ItemRecall/SharedItemRecallSystem.cs | 54 +++++++++++++++++-- .../Locale/en-US/item-recall/item-recall.ftl | 10 ++++ .../Prototypes/Catalog/spellbook_catalog.yml | 4 +- Resources/Prototypes/Magic/recall_spell.yml | 4 +- 8 files changed, 83 insertions(+), 19 deletions(-) create mode 100644 Content.Client/ItemRecall/ItemRecallSystem.cs create mode 100644 Content.Server/ItemRecall/ItemRecallSystem.cs create mode 100644 Resources/Locale/en-US/item-recall/item-recall.ftl diff --git a/Content.Client/ItemRecall/ItemRecallSystem.cs b/Content.Client/ItemRecall/ItemRecallSystem.cs new file mode 100644 index 000000000000..a10687948b89 --- /dev/null +++ b/Content.Client/ItemRecall/ItemRecallSystem.cs @@ -0,0 +1,8 @@ +using Content.Shared.ItemRecall; + +namespace Content.Client.ItemRecall; + +public sealed partial class ItemRecallSystem : SharedItemRecallSystem +{ + +} diff --git a/Content.Server/ItemRecall/ItemRecallSystem.cs b/Content.Server/ItemRecall/ItemRecallSystem.cs new file mode 100644 index 000000000000..cce0d3b13643 --- /dev/null +++ b/Content.Server/ItemRecall/ItemRecallSystem.cs @@ -0,0 +1,8 @@ +using Content.Shared.ItemRecall; + +namespace Content.Server.ItemRecall; + +public sealed partial class ItemRecallSystem : SharedItemRecallSystem +{ + +} diff --git a/Content.Shared/ItemRecall/ItemRecallComponent.cs b/Content.Shared/ItemRecall/ItemRecallComponent.cs index 517358831731..6680ab542878 100644 --- a/Content.Shared/ItemRecall/ItemRecallComponent.cs +++ b/Content.Shared/ItemRecall/ItemRecallComponent.cs @@ -7,13 +7,10 @@ namespace Content.Shared.ItemRecall; public sealed partial class ItemRecallComponent : Component { [DataField] - public LocId? WhileMarkedName = ""; + public LocId? WhileMarkedName = "item-recall-marked-name"; [DataField] - public LocId? WhileMarkedDescription = ""; - - [DataField] - public SpriteSpecifier? WhileMarkedSprite; + public LocId? WhileMarkedDescription = "item-recall-marked-description"; [ViewVariables] public EntityUid? MarkedEntity; diff --git a/Content.Shared/ItemRecall/ItemRecallEvents.cs b/Content.Shared/ItemRecall/ItemRecallEvents.cs index 79fb3640cf63..2bfabc928666 100644 --- a/Content.Shared/ItemRecall/ItemRecallEvents.cs +++ b/Content.Shared/ItemRecall/ItemRecallEvents.cs @@ -6,10 +6,7 @@ namespace Content.Shared.ItemRecall; /// Raised directed on an entity when it embeds in another entity. /// [ByRefEvent] -public sealed partial class OnItemRecallActionEvent : InstantActionEvent -{ - -} +public sealed partial class OnItemRecallActionEvent : InstantActionEvent; [ByRefEvent] -public sealed partial class RecallItemEvent(EntityUid item); +public sealed partial class RecallItemEvent; diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 2326266dda97..8cd38658695f 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -1,17 +1,23 @@ +using Content.Shared.Actions; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; +using Content.Shared.Popups; using Content.Shared.Projectiles; +using Robust.Shared.Network; namespace Content.Shared.ItemRecall; /// -/// uwu +/// System for handling the ItemRecall ability for wizards. /// -public sealed partial class SharedItemRecallSystem : EntitySystem +public abstract partial class SharedItemRecallSystem : EntitySystem { - + [Dependency] private readonly INetManager _net = default!; + [Dependency] private readonly SharedActionsSystem _actions = default!; [Dependency] private readonly SharedHandsSystem _hands = default!; [Dependency] private readonly SharedProjectileSystem _proj = default!; + [Dependency] private readonly MetaDataSystem _metaData = default!; + [Dependency] private readonly SharedPopupSystem _popups = default!; public override void Initialize() { @@ -25,18 +31,22 @@ public override void Initialize() private void OnItemRecallActionUse(Entity ent, ref OnItemRecallActionEvent args) { - if (ent.Comp.MarkedEntity == null) { if (!TryComp(args.Performer, out var hands)) return; var markItem = _hands.GetActiveItem((args.Performer, hands)); + + if (markItem == null) + return; + + _popups.PopupClient(Loc.GetString("item-recall-item-marked", ("item", markItem.Value)), args.Performer, args.Performer); TryMarkItem(ent, markItem, args.Performer); return; } - var ev = new RecallItemEvent(ent.Comp.MarkedEntity.Value); + var ev = new RecallItemEvent(); RaiseLocalEvent(ent.Comp.MarkedEntity.Value, ref ev); args.Handled = true; } @@ -61,6 +71,8 @@ private void TryMarkItem(Entity ent, EntityUid? item, Entit marker.MarkedByEntity = markedBy; marker.MarkedByAction = ent.Owner; + + UpdateActionAppearance(ent); Dirty(item.Value, marker); } @@ -74,7 +86,11 @@ private void TryUnmarkItem(EntityUid? item) if (TryComp(marker.MarkedByAction, out var action)) { + if(_net.IsServer) // This is the only way it worked, not even PopupClient + _popups.PopupEntity(Loc.GetString("item-recall-item-unmark", ("item", item.Value)), marker.MarkedByEntity, marker.MarkedByEntity, PopupType.MediumCaution); + action.MarkedEntity = null; + UpdateActionAppearance((marker.MarkedByAction, action)); Dirty(marker.MarkedByAction, action); } @@ -89,6 +105,34 @@ private void RecallItem(EntityUid? item) if (TryComp(item, out var projectile)) _proj.UnEmbed(item.Value, marker.MarkedByEntity, projectile); + _popups.PopupEntity(Loc.GetString("item-recall-item-summon", ("item", item.Value)), marker.MarkedByEntity, marker.MarkedByEntity); + _hands.TryForcePickupAnyHand(marker.MarkedByEntity, item.Value); } + + private void UpdateActionAppearance(Entity action) + { + if (!TryComp(action, out var instantAction)) + return; + + if (action.Comp.MarkedEntity == null) + { + _metaData.SetEntityName(action, Prototype(action)!.Name); + _metaData.SetEntityDescription(action, Prototype(action)!.Description); + _actions.SetEntityIcon(action, null, instantAction); + } + else + { + if (action.Comp.WhileMarkedName != null) + _metaData.SetEntityName(action, Loc.GetString(action.Comp.WhileMarkedName, + ("item", action.Comp.MarkedEntity.Value))); + + if (action.Comp.WhileMarkedDescription != null) + _metaData.SetEntityDescription(action, Loc.GetString(action.Comp.WhileMarkedDescription, + ("item", action.Comp.MarkedEntity.Value))); + + _actions.SetEntityIcon(action, action.Comp.MarkedEntity, instantAction); + } + Dirty(action); + } } diff --git a/Resources/Locale/en-US/item-recall/item-recall.ftl b/Resources/Locale/en-US/item-recall/item-recall.ftl new file mode 100644 index 000000000000..33b654688ccc --- /dev/null +++ b/Resources/Locale/en-US/item-recall/item-recall.ftl @@ -0,0 +1,10 @@ +item-recall-grimoire-name = Item Recall +item-recall-grimoire-desc = Mark a held item and summon it back at any time with just a snap of your fingers! + +item-recall-marked-name = Recall {CAPITALIZE($item)} +item-recall-marked-description = Recall {THE($item)} back into your hand. + +item-recall-item-marked = You draw a magical sigil on {THE($item)}. +item-recall-item-summon = {CAPITALIZE(THE($item))} appears in your hand! +item-recall-item-unmark = You feel your connection with {THE($item)} sever. + diff --git a/Resources/Prototypes/Catalog/spellbook_catalog.yml b/Resources/Prototypes/Catalog/spellbook_catalog.yml index fd93fdf6ea8c..3583fe7eb422 100644 --- a/Resources/Prototypes/Catalog/spellbook_catalog.yml +++ b/Resources/Prototypes/Catalog/spellbook_catalog.yml @@ -228,8 +228,8 @@ - type: listing id: SpellbookItemRecallSwap - name: recall - description: recall + name: item-recall-grimoire-name + description: item-recall-grimoire-desc productAction: ActionItemRecall cost: WizCoin: 1 diff --git a/Resources/Prototypes/Magic/recall_spell.yml b/Resources/Prototypes/Magic/recall_spell.yml index b603124f8070..7f3c3335870a 100644 --- a/Resources/Prototypes/Magic/recall_spell.yml +++ b/Resources/Prototypes/Magic/recall_spell.yml @@ -1,7 +1,7 @@ - type: entity id: ActionItemRecall - name: item recall - description: Mark and summon an item back into your hand. + name: Mark Item + description: Mark a held item to later summon into your hand. components: - type: InstantAction useDelay: 10 From be5d4d5fff27ccd84bf04cfea61c711c052f5c7c Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Tue, 14 Jan 2025 15:24:05 +0100 Subject: [PATCH 06/18] Requested Changes part 1 --- Content.Client/ItemRecall/ItemRecallSystem.cs | 8 ------- Content.Server/ItemRecall/ItemRecallSystem.cs | 8 ------- Content.Shared/Actions/BaseActionComponent.cs | 1 + Content.Shared/Actions/SharedActionsSystem.cs | 2 +- Content.Shared/ItemRecall/ItemRecallEvents.cs | 7 ++++-- .../ItemRecall/RecallMarkerComponent.cs | 9 +++++--- .../ItemRecall/SharedItemRecallSystem.cs | 22 ++++++++++++------- .../Projectiles/SharedProjectileSystem.cs | 5 ++++- 8 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 Content.Client/ItemRecall/ItemRecallSystem.cs delete mode 100644 Content.Server/ItemRecall/ItemRecallSystem.cs diff --git a/Content.Client/ItemRecall/ItemRecallSystem.cs b/Content.Client/ItemRecall/ItemRecallSystem.cs deleted file mode 100644 index a10687948b89..000000000000 --- a/Content.Client/ItemRecall/ItemRecallSystem.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Content.Shared.ItemRecall; - -namespace Content.Client.ItemRecall; - -public sealed partial class ItemRecallSystem : SharedItemRecallSystem -{ - -} diff --git a/Content.Server/ItemRecall/ItemRecallSystem.cs b/Content.Server/ItemRecall/ItemRecallSystem.cs deleted file mode 100644 index cce0d3b13643..000000000000 --- a/Content.Server/ItemRecall/ItemRecallSystem.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Content.Shared.ItemRecall; - -namespace Content.Server.ItemRecall; - -public sealed partial class ItemRecallSystem : SharedItemRecallSystem -{ - -} diff --git a/Content.Shared/Actions/BaseActionComponent.cs b/Content.Shared/Actions/BaseActionComponent.cs index ec2e4602e6d4..1744751715c4 100644 --- a/Content.Shared/Actions/BaseActionComponent.cs +++ b/Content.Shared/Actions/BaseActionComponent.cs @@ -169,6 +169,7 @@ public EntityUid? EntityIcon /// /// If true, this will cause the the action event to always be raised directed at the action itself instead of the action's container/provider. + /// Takes priority over RaiseOnUser. /// [DataField] public bool RaiseOnAction; diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index 1ab409903664..8079885a5ac5 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -679,7 +679,7 @@ public void PerformAction(EntityUid performer, ActionsComponent? component, Enti if (!action.RaiseOnUser && action.Container != null && !HasComp(action.Container)) target = action.Container.Value; - if (action.RaiseOnAction && !HasComp(actionId)) + if (action.RaiseOnAction) target = actionId; RaiseLocalEvent(target, (object) actionEvent, broadcast: true); diff --git a/Content.Shared/ItemRecall/ItemRecallEvents.cs b/Content.Shared/ItemRecall/ItemRecallEvents.cs index 2bfabc928666..91ba671f4a7d 100644 --- a/Content.Shared/ItemRecall/ItemRecallEvents.cs +++ b/Content.Shared/ItemRecall/ItemRecallEvents.cs @@ -3,10 +3,13 @@ namespace Content.Shared.ItemRecall; /// -/// Raised directed on an entity when it embeds in another entity. +/// Raise on using the ItemRecall action. /// [ByRefEvent] public sealed partial class OnItemRecallActionEvent : InstantActionEvent; +/// +/// Raised on the item to recall it back to its user. +/// [ByRefEvent] -public sealed partial class RecallItemEvent; +public record struct RecallItemEvent; diff --git a/Content.Shared/ItemRecall/RecallMarkerComponent.cs b/Content.Shared/ItemRecall/RecallMarkerComponent.cs index 7c71672c55b7..398bc3dcbdd9 100644 --- a/Content.Shared/ItemRecall/RecallMarkerComponent.cs +++ b/Content.Shared/ItemRecall/RecallMarkerComponent.cs @@ -7,11 +7,14 @@ namespace Content.Shared.ItemRecall; public sealed partial class RecallMarkerComponent : Component { /// - /// Does this spell require Wizard Robes & Hat? + /// The entity that marked this item. /// [ViewVariables] - public EntityUid MarkedByEntity; + public EntityUid? MarkedByEntity; + /// + /// The action that marked this item. + /// [ViewVariables] - public EntityUid MarkedByAction; + public EntityUid? MarkedByAction; } diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 8cd38658695f..cd1c05b03312 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -10,7 +10,7 @@ namespace Content.Shared.ItemRecall; /// /// System for handling the ItemRecall ability for wizards. /// -public abstract partial class SharedItemRecallSystem : EntitySystem +public sealed partial class SharedItemRecallSystem : EntitySystem { [Dependency] private readonly INetManager _net = default!; [Dependency] private readonly SharedActionsSystem _actions = default!; @@ -84,14 +84,17 @@ private void TryUnmarkItem(EntityUid? item) if (!TryComp(item.Value, out var marker)) return; + if (marker.MarkedByEntity == null) + return; + if (TryComp(marker.MarkedByAction, out var action)) { - if(_net.IsServer) // This is the only way it worked, not even PopupClient - _popups.PopupEntity(Loc.GetString("item-recall-item-unmark", ("item", item.Value)), marker.MarkedByEntity, marker.MarkedByEntity, PopupType.MediumCaution); + if(_net.IsServer) + _popups.PopupEntity(Loc.GetString("item-recall-item-unmark", ("item", item.Value)), marker.MarkedByEntity.Value, marker.MarkedByEntity.Value, PopupType.MediumCaution); action.MarkedEntity = null; - UpdateActionAppearance((marker.MarkedByAction, action)); - Dirty(marker.MarkedByAction, action); + UpdateActionAppearance((marker.MarkedByAction.Value, action)); + Dirty(marker.MarkedByAction.Value, action); } RemCompDeferred(item.Value); @@ -102,12 +105,15 @@ private void RecallItem(EntityUid? item) if (!TryComp(item, out var marker)) return; + if (marker.MarkedByEntity == null) + return; + if (TryComp(item, out var projectile)) - _proj.UnEmbed(item.Value, marker.MarkedByEntity, projectile); + _proj.UnEmbed(item.Value, marker.MarkedByEntity.Value, projectile); - _popups.PopupEntity(Loc.GetString("item-recall-item-summon", ("item", item.Value)), marker.MarkedByEntity, marker.MarkedByEntity); + _popups.PopupEntity(Loc.GetString("item-recall-item-summon", ("item", item.Value)), marker.MarkedByEntity.Value, marker.MarkedByEntity.Value); - _hands.TryForcePickupAnyHand(marker.MarkedByEntity, item.Value); + _hands.TryForcePickupAnyHand(marker.MarkedByEntity.Value, item.Value); } private void UpdateActionAppearance(Entity action) diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs index 446eddfbdc9f..b289c10ce459 100644 --- a/Content.Shared/Projectiles/SharedProjectileSystem.cs +++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs @@ -117,8 +117,11 @@ private void Embed(EntityUid uid, EntityUid target, EntityUid? user, EmbeddableP Dirty(uid, component); } - public void UnEmbed(EntityUid uid, EntityUid user, EmbeddableProjectileComponent component) + public void UnEmbed(EntityUid uid, EntityUid user, EmbeddableProjectileComponent? component) { + if (!Resolve(uid, ref component)) + return; + var xform = Transform(uid); TryComp(uid, out var physics); _physics.SetBodyType(uid, BodyType.Dynamic, body: physics, xform: xform); From 008ea6462d5d91dc3f4e7c054b5c396e9376e322 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Wed, 15 Jan 2025 14:58:59 +0100 Subject: [PATCH 07/18] Requested Changes part 2 --- .../ItemRecall/ItemRecallComponent.cs | 3 +++ .../ItemRecall/SharedItemRecallSystem.cs | 25 ++++++++----------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Content.Shared/ItemRecall/ItemRecallComponent.cs b/Content.Shared/ItemRecall/ItemRecallComponent.cs index 6680ab542878..7ef4a89623ca 100644 --- a/Content.Shared/ItemRecall/ItemRecallComponent.cs +++ b/Content.Shared/ItemRecall/ItemRecallComponent.cs @@ -12,6 +12,9 @@ public sealed partial class ItemRecallComponent : Component [DataField] public LocId? WhileMarkedDescription = "item-recall-marked-description"; + /// + /// The entity currently marked to be recalled by this action. + /// [ViewVariables] public EntityUid? MarkedEntity; } diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index cd1c05b03312..9e64f109fe44 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -25,7 +25,7 @@ public override void Initialize() SubscribeLocalEvent(OnItemRecallActionUse); - SubscribeLocalEvent(OnItemRecallEvent); + SubscribeLocalEvent(OnItemRecall); SubscribeLocalEvent(OnRecallMarkerShutdown); } @@ -42,7 +42,7 @@ private void OnItemRecallActionUse(Entity ent, ref OnItemRe return; _popups.PopupClient(Loc.GetString("item-recall-item-marked", ("item", markItem.Value)), args.Performer, args.Performer); - TryMarkItem(ent, markItem, args.Performer); + TryMarkItem(ent, markItem.Value, args.Performer); return; } @@ -56,16 +56,14 @@ private void OnRecallMarkerShutdown(Entity ent, ref Compo TryUnmarkItem(ent); } - private void OnItemRecallEvent(Entity ent, ref RecallItemEvent args) + private void OnItemRecall(Entity ent, ref RecallItemEvent args) { RecallItem(ent.Owner); } - private void TryMarkItem(Entity ent, EntityUid? item, EntityUid markedBy) + private void TryMarkItem(Entity ent, EntityUid item, EntityUid markedBy) { - if (item == null) - return; - EnsureComp(item.Value, out var marker); + EnsureComp(item, out var marker); ent.Comp.MarkedEntity = item; Dirty(ent); @@ -73,15 +71,12 @@ private void TryMarkItem(Entity ent, EntityUid? item, Entit marker.MarkedByAction = ent.Owner; UpdateActionAppearance(ent); - Dirty(item.Value, marker); + Dirty(item, marker); } - private void TryUnmarkItem(EntityUid? item) + private void TryUnmarkItem(EntityUid item) { - if (item == null) - return; - - if (!TryComp(item.Value, out var marker)) + if (!TryComp(item, out var marker)) return; if (marker.MarkedByEntity == null) @@ -90,14 +85,14 @@ private void TryUnmarkItem(EntityUid? item) if (TryComp(marker.MarkedByAction, out var action)) { if(_net.IsServer) - _popups.PopupEntity(Loc.GetString("item-recall-item-unmark", ("item", item.Value)), marker.MarkedByEntity.Value, marker.MarkedByEntity.Value, PopupType.MediumCaution); + _popups.PopupEntity(Loc.GetString("item-recall-item-unmark", ("item", item)), marker.MarkedByEntity.Value, marker.MarkedByEntity.Value, PopupType.MediumCaution); action.MarkedEntity = null; UpdateActionAppearance((marker.MarkedByAction.Value, action)); Dirty(marker.MarkedByAction.Value, action); } - RemCompDeferred(item.Value); + RemCompDeferred(item); } private void RecallItem(EntityUid? item) From 0828c0f876197136dd58a7559c8507eb7f07782d Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Wed, 15 Jan 2025 15:37:02 +0100 Subject: [PATCH 08/18] Requested Changes part 3 --- .../ItemRecall/SharedItemRecallSystem.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 9e64f109fe44..1fe7f3d0b27b 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -58,7 +58,7 @@ private void OnRecallMarkerShutdown(Entity ent, ref Compo private void OnItemRecall(Entity ent, ref RecallItemEvent args) { - RecallItem(ent.Owner); + RecallItem(ent); } private void TryMarkItem(Entity ent, EntityUid item, EntityUid markedBy) @@ -95,20 +95,17 @@ private void TryUnmarkItem(EntityUid item) RemCompDeferred(item); } - private void RecallItem(EntityUid? item) + private void RecallItem(Entity ent) { - if (!TryComp(item, out var marker)) - return; - - if (marker.MarkedByEntity == null) + if (ent.Comp.MarkedByEntity == null) return; - if (TryComp(item, out var projectile)) - _proj.UnEmbed(item.Value, marker.MarkedByEntity.Value, projectile); + if (TryComp(ent, out var projectile)) + _proj.UnEmbed(ent, ent.Comp.MarkedByEntity.Value, projectile); - _popups.PopupEntity(Loc.GetString("item-recall-item-summon", ("item", item.Value)), marker.MarkedByEntity.Value, marker.MarkedByEntity.Value); + _popups.PopupEntity(Loc.GetString("item-recall-item-summon", ("item", ent)), ent.Comp.MarkedByEntity.Value, ent.Comp.MarkedByEntity.Value); - _hands.TryForcePickupAnyHand(marker.MarkedByEntity.Value, item.Value); + _hands.TryForcePickupAnyHand(ent.Comp.MarkedByEntity.Value, ent); } private void UpdateActionAppearance(Entity action) @@ -116,10 +113,15 @@ private void UpdateActionAppearance(Entity action) if (!TryComp(action, out var instantAction)) return; + var proto = Prototype(action); + + if (proto == null) + return; + if (action.Comp.MarkedEntity == null) { - _metaData.SetEntityName(action, Prototype(action)!.Name); - _metaData.SetEntityDescription(action, Prototype(action)!.Description); + _metaData.SetEntityName(action, proto.Name); + _metaData.SetEntityDescription(action, proto.Description); _actions.SetEntityIcon(action, null, instantAction); } else @@ -134,6 +136,5 @@ private void UpdateActionAppearance(Entity action) _actions.SetEntityIcon(action, action.Comp.MarkedEntity, instantAction); } - Dirty(action); } } From 4d685aeaa09370ffc1124e7d18d42623e1712f0d Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Wed, 15 Jan 2025 16:09:13 +0100 Subject: [PATCH 09/18] Requested Changes part 4 --- Content.Shared/ItemRecall/ItemRecallEvents.cs | 2 +- .../ItemRecall/SharedItemRecallSystem.cs | 4 ++-- .../Projectiles/SharedProjectileSystem.cs | 14 +++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Content.Shared/ItemRecall/ItemRecallEvents.cs b/Content.Shared/ItemRecall/ItemRecallEvents.cs index 91ba671f4a7d..06bf619e0ebe 100644 --- a/Content.Shared/ItemRecall/ItemRecallEvents.cs +++ b/Content.Shared/ItemRecall/ItemRecallEvents.cs @@ -3,7 +3,7 @@ namespace Content.Shared.ItemRecall; /// -/// Raise on using the ItemRecall action. +/// Raised when using the ItemRecall action. /// [ByRefEvent] public sealed partial class OnItemRecallActionEvent : InstantActionEvent; diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 1fe7f3d0b27b..30ef8226b504 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -101,9 +101,9 @@ private void RecallItem(Entity ent) return; if (TryComp(ent, out var projectile)) - _proj.UnEmbed(ent, ent.Comp.MarkedByEntity.Value, projectile); + _proj.UnEmbed(ent, projectile, ent.Comp.MarkedByEntity.Value); - _popups.PopupEntity(Loc.GetString("item-recall-item-summon", ("item", ent)), ent.Comp.MarkedByEntity.Value, ent.Comp.MarkedByEntity.Value); + _popups.PopupPredicted(Loc.GetString("item-recall-item-summon", ("item", ent)), ent.Comp.MarkedByEntity.Value, ent.Comp.MarkedByEntity.Value); _hands.TryForcePickupAnyHand(ent.Comp.MarkedByEntity.Value, ent); } diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs index b289c10ce459..78ad1ea5b3c5 100644 --- a/Content.Shared/Projectiles/SharedProjectileSystem.cs +++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs @@ -67,7 +67,7 @@ private void OnEmbedRemove(EntityUid uid, EmbeddableProjectileComponent componen return; } - UnEmbed(uid, args.User, component); + UnEmbed(uid, component, args.User); // try place it in the user's hand _hands.TryPickupAnyHand(args.User, uid); @@ -117,7 +117,7 @@ private void Embed(EntityUid uid, EntityUid target, EntityUid? user, EmbeddableP Dirty(uid, component); } - public void UnEmbed(EntityUid uid, EntityUid user, EmbeddableProjectileComponent? component) + public void UnEmbed(EntityUid uid, EmbeddableProjectileComponent? component, EntityUid? user = null) { if (!Resolve(uid, ref component)) return; @@ -137,9 +137,13 @@ public void UnEmbed(EntityUid uid, EntityUid user, EmbeddableProjectileComponent projectile.DamagedEntity = false; } - // Land it just coz uhhh yeah - var landEv = new LandEvent(user, true); - RaiseLocalEvent(uid, ref landEv); + if (user != null) + { + // Land it just coz uhhh yeah + var landEv = new LandEvent(user, true); + RaiseLocalEvent(uid, ref landEv); + } + _physics.WakeBody(uid, body: physics); } From eadd12a04ab9ef8e0617ad2f14503c300388537f Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Wed, 15 Jan 2025 16:39:14 +0100 Subject: [PATCH 10/18] Requested Changes part 5 --- Content.Client/ItemRecall/ItemRecallSystem.cs | 11 +++++ Content.Server/ItemRecall/ItemRecallSystem.cs | 41 +++++++++++++++++++ .../ItemRecall/ItemRecallComponent.cs | 4 +- .../ItemRecall/RecallMarkerComponent.cs | 6 +-- .../ItemRecall/SharedItemRecallSystem.cs | 22 +--------- 5 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 Content.Client/ItemRecall/ItemRecallSystem.cs create mode 100644 Content.Server/ItemRecall/ItemRecallSystem.cs diff --git a/Content.Client/ItemRecall/ItemRecallSystem.cs b/Content.Client/ItemRecall/ItemRecallSystem.cs new file mode 100644 index 000000000000..11d3015c21ff --- /dev/null +++ b/Content.Client/ItemRecall/ItemRecallSystem.cs @@ -0,0 +1,11 @@ +using Content.Shared.ItemRecall; + +namespace Content.Client.ItemRecall; + +/// +/// System for handling the ItemRecall ability for wizards. +/// +public sealed partial class ItemRecallSystem : SharedItemRecallSystem +{ + +} diff --git a/Content.Server/ItemRecall/ItemRecallSystem.cs b/Content.Server/ItemRecall/ItemRecallSystem.cs new file mode 100644 index 000000000000..8016b49f6aec --- /dev/null +++ b/Content.Server/ItemRecall/ItemRecallSystem.cs @@ -0,0 +1,41 @@ +using Content.Shared.Hands.EntitySystems; +using Content.Shared.ItemRecall; +using Content.Shared.Popups; +using Content.Shared.Projectiles; + +namespace Content.Server.ItemRecall; + +/// +/// System for handling the ItemRecall ability for wizards. +/// +public sealed partial class ItemRecallSystem : SharedItemRecallSystem +{ + [Dependency] private readonly SharedHandsSystem _hands = default!; + [Dependency] private readonly SharedProjectileSystem _proj = default!; + [Dependency] private readonly SharedPopupSystem _popups = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnItemRecall); + } + + private void OnItemRecall(Entity ent, ref RecallItemEvent args) + { + RecallItem(ent); + } + + private void RecallItem(Entity ent) + { + if (ent.Comp.MarkedByEntity == null) + return; + + if (TryComp(ent, out var projectile)) + _proj.UnEmbed(ent, projectile, ent.Comp.MarkedByEntity.Value); + + _popups.PopupEntity(Loc.GetString("item-recall-item-summon", ("item", ent)), ent.Comp.MarkedByEntity.Value, ent.Comp.MarkedByEntity.Value); + + _hands.TryForcePickupAnyHand(ent.Comp.MarkedByEntity.Value, ent); + } +} diff --git a/Content.Shared/ItemRecall/ItemRecallComponent.cs b/Content.Shared/ItemRecall/ItemRecallComponent.cs index 7ef4a89623ca..a32378f5596f 100644 --- a/Content.Shared/ItemRecall/ItemRecallComponent.cs +++ b/Content.Shared/ItemRecall/ItemRecallComponent.cs @@ -3,7 +3,7 @@ namespace Content.Shared.ItemRecall; -[RegisterComponent, NetworkedComponent, Access(typeof(SharedItemRecallSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedItemRecallSystem))] public sealed partial class ItemRecallComponent : Component { [DataField] @@ -15,6 +15,6 @@ public sealed partial class ItemRecallComponent : Component /// /// The entity currently marked to be recalled by this action. /// - [ViewVariables] + [DataField, AutoNetworkedField] public EntityUid? MarkedEntity; } diff --git a/Content.Shared/ItemRecall/RecallMarkerComponent.cs b/Content.Shared/ItemRecall/RecallMarkerComponent.cs index 398bc3dcbdd9..9c1e2e941cbe 100644 --- a/Content.Shared/ItemRecall/RecallMarkerComponent.cs +++ b/Content.Shared/ItemRecall/RecallMarkerComponent.cs @@ -3,18 +3,18 @@ namespace Content.Shared.ItemRecall; -[RegisterComponent, NetworkedComponent, Access(typeof(SharedItemRecallSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedItemRecallSystem))] public sealed partial class RecallMarkerComponent : Component { /// /// The entity that marked this item. /// - [ViewVariables] + [DataField, AutoNetworkedField] public EntityUid? MarkedByEntity; /// /// The action that marked this item. /// - [ViewVariables] + [DataField, AutoNetworkedField] public EntityUid? MarkedByAction; } diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 30ef8226b504..5e408b3baa9a 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -10,12 +10,11 @@ namespace Content.Shared.ItemRecall; /// /// System for handling the ItemRecall ability for wizards. /// -public sealed partial class SharedItemRecallSystem : EntitySystem +public abstract partial class SharedItemRecallSystem : EntitySystem { [Dependency] private readonly INetManager _net = default!; [Dependency] private readonly SharedActionsSystem _actions = default!; [Dependency] private readonly SharedHandsSystem _hands = default!; - [Dependency] private readonly SharedProjectileSystem _proj = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; [Dependency] private readonly SharedPopupSystem _popups = default!; @@ -25,7 +24,6 @@ public override void Initialize() SubscribeLocalEvent(OnItemRecallActionUse); - SubscribeLocalEvent(OnItemRecall); SubscribeLocalEvent(OnRecallMarkerShutdown); } @@ -56,11 +54,6 @@ private void OnRecallMarkerShutdown(Entity ent, ref Compo TryUnmarkItem(ent); } - private void OnItemRecall(Entity ent, ref RecallItemEvent args) - { - RecallItem(ent); - } - private void TryMarkItem(Entity ent, EntityUid item, EntityUid markedBy) { EnsureComp(item, out var marker); @@ -95,19 +88,6 @@ private void TryUnmarkItem(EntityUid item) RemCompDeferred(item); } - private void RecallItem(Entity ent) - { - if (ent.Comp.MarkedByEntity == null) - return; - - if (TryComp(ent, out var projectile)) - _proj.UnEmbed(ent, projectile, ent.Comp.MarkedByEntity.Value); - - _popups.PopupPredicted(Loc.GetString("item-recall-item-summon", ("item", ent)), ent.Comp.MarkedByEntity.Value, ent.Comp.MarkedByEntity.Value); - - _hands.TryForcePickupAnyHand(ent.Comp.MarkedByEntity.Value, ent); - } - private void UpdateActionAppearance(Entity action) { if (!TryComp(action, out var instantAction)) From 8515fac608975cda49912e74b88510f7e97c5769 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Wed, 15 Jan 2025 17:19:10 +0100 Subject: [PATCH 11/18] Requested Changes part 6 --- Content.Shared/ItemRecall/SharedItemRecallSystem.cs | 11 ++++++++--- Resources/Locale/en-US/item-recall/item-recall.ftl | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 5e408b3baa9a..bdde3134fb88 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -37,8 +37,11 @@ private void OnItemRecallActionUse(Entity ent, ref OnItemRe var markItem = _hands.GetActiveItem((args.Performer, hands)); if (markItem == null) + { + _popups.PopupClient(Loc.GetString("item-recall-item-mark-empty"), args.Performer, args.Performer); return; - + } + _popups.PopupClient(Loc.GetString("item-recall-item-marked", ("item", markItem.Value)), args.Performer, args.Performer); TryMarkItem(ent, markItem.Value, args.Performer); return; @@ -77,8 +80,10 @@ private void TryUnmarkItem(EntityUid item) if (TryComp(marker.MarkedByAction, out var action)) { - if(_net.IsServer) - _popups.PopupEntity(Loc.GetString("item-recall-item-unmark", ("item", item)), marker.MarkedByEntity.Value, marker.MarkedByEntity.Value, PopupType.MediumCaution); + // 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. + _popups.PopupClient(Loc.GetString("item-recall-item-unmark", ("item", item)), marker.MarkedByEntity.Value, marker.MarkedByEntity.Value, PopupType.MediumCaution); action.MarkedEntity = null; UpdateActionAppearance((marker.MarkedByAction.Value, action)); diff --git a/Resources/Locale/en-US/item-recall/item-recall.ftl b/Resources/Locale/en-US/item-recall/item-recall.ftl index 33b654688ccc..7054c0ab7865 100644 --- a/Resources/Locale/en-US/item-recall/item-recall.ftl +++ b/Resources/Locale/en-US/item-recall/item-recall.ftl @@ -5,6 +5,7 @@ item-recall-marked-name = Recall {CAPITALIZE($item)} item-recall-marked-description = Recall {THE($item)} back into your hand. item-recall-item-marked = You draw a magical sigil on {THE($item)}. +item-recall-item-mark-empty = You must be holding an item! item-recall-item-summon = {CAPITALIZE(THE($item))} appears in your hand! item-recall-item-unmark = You feel your connection with {THE($item)} sever. From 8eaf4dbc6add1ff2bb4385f67fb01816e001f812 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Wed, 15 Jan 2025 18:07:55 +0100 Subject: [PATCH 12/18] something something fixes --- Content.Server/ItemRecall/ItemRecallSystem.cs | 14 ++++++++++---- .../ItemRecall/RecallMarkerComponent.cs | 6 ------ .../ItemRecall/SharedItemRecallSystem.cs | 19 ++++++++++++++----- .../Locale/en-US/item-recall/item-recall.ftl | 1 + 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Content.Server/ItemRecall/ItemRecallSystem.cs b/Content.Server/ItemRecall/ItemRecallSystem.cs index 8016b49f6aec..9b2ee3a82ad0 100644 --- a/Content.Server/ItemRecall/ItemRecallSystem.cs +++ b/Content.Server/ItemRecall/ItemRecallSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.Actions; using Content.Shared.Hands.EntitySystems; using Content.Shared.ItemRecall; using Content.Shared.Popups; @@ -28,14 +29,19 @@ private void OnItemRecall(Entity ent, ref RecallItemEvent private void RecallItem(Entity ent) { - if (ent.Comp.MarkedByEntity == null) + if (!TryComp(ent.Comp.MarkedByAction, out var instantAction)) + return; + + var actionOwner = instantAction.AttachedEntity; + + if (actionOwner == null) return; if (TryComp(ent, out var projectile)) - _proj.UnEmbed(ent, projectile, ent.Comp.MarkedByEntity.Value); + _proj.UnEmbed(ent, projectile, actionOwner.Value); - _popups.PopupEntity(Loc.GetString("item-recall-item-summon", ("item", ent)), ent.Comp.MarkedByEntity.Value, ent.Comp.MarkedByEntity.Value); + _popups.PopupEntity(Loc.GetString("item-recall-item-summon", ("item", ent)), actionOwner.Value, actionOwner.Value); - _hands.TryForcePickupAnyHand(ent.Comp.MarkedByEntity.Value, ent); + _hands.TryForcePickupAnyHand(actionOwner.Value, ent); } } diff --git a/Content.Shared/ItemRecall/RecallMarkerComponent.cs b/Content.Shared/ItemRecall/RecallMarkerComponent.cs index 9c1e2e941cbe..85ff4a0b5fe1 100644 --- a/Content.Shared/ItemRecall/RecallMarkerComponent.cs +++ b/Content.Shared/ItemRecall/RecallMarkerComponent.cs @@ -6,12 +6,6 @@ namespace Content.Shared.ItemRecall; [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedItemRecallSystem))] public sealed partial class RecallMarkerComponent : Component { - /// - /// The entity that marked this item. - /// - [DataField, AutoNetworkedField] - public EntityUid? MarkedByEntity; - /// /// The action that marked this item. /// diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index bdde3134fb88..4a9ac34ab639 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -12,7 +12,6 @@ namespace Content.Shared.ItemRecall; /// public abstract partial class SharedItemRecallSystem : EntitySystem { - [Dependency] private readonly INetManager _net = default!; [Dependency] private readonly SharedActionsSystem _actions = default!; [Dependency] private readonly SharedHandsSystem _hands = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; @@ -41,7 +40,13 @@ private void OnItemRecallActionUse(Entity ent, ref OnItemRe _popups.PopupClient(Loc.GetString("item-recall-item-mark-empty"), args.Performer, args.Performer); return; } - + + if (HasComp(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, args.Performer); return; @@ -63,7 +68,6 @@ private void TryMarkItem(Entity ent, EntityUid item, Entity ent.Comp.MarkedEntity = item; Dirty(ent); - marker.MarkedByEntity = markedBy; marker.MarkedByAction = ent.Owner; UpdateActionAppearance(ent); @@ -75,7 +79,12 @@ private void TryUnmarkItem(EntityUid item) if (!TryComp(item, out var marker)) return; - if (marker.MarkedByEntity == null) + if (!TryComp(item, out var instantAction)) + return; + + var actionOwner = instantAction.AttachedEntity; + + if (actionOwner == null) return; if (TryComp(marker.MarkedByAction, out var action)) @@ -83,7 +92,7 @@ private void TryUnmarkItem(EntityUid item) // 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. - _popups.PopupClient(Loc.GetString("item-recall-item-unmark", ("item", item)), marker.MarkedByEntity.Value, marker.MarkedByEntity.Value, PopupType.MediumCaution); + _popups.PopupClient(Loc.GetString("item-recall-item-unmark", ("item", item)), actionOwner.Value, actionOwner.Value, PopupType.MediumCaution); action.MarkedEntity = null; UpdateActionAppearance((marker.MarkedByAction.Value, action)); diff --git a/Resources/Locale/en-US/item-recall/item-recall.ftl b/Resources/Locale/en-US/item-recall/item-recall.ftl index 7054c0ab7865..85510734c93c 100644 --- a/Resources/Locale/en-US/item-recall/item-recall.ftl +++ b/Resources/Locale/en-US/item-recall/item-recall.ftl @@ -5,6 +5,7 @@ item-recall-marked-name = Recall {CAPITALIZE($item)} item-recall-marked-description = Recall {THE($item)} back into your hand. item-recall-item-marked = You draw a magical sigil on {THE($item)}. +item-recall-item-already-marked = {CAPITALIZE(THE($item))} is already marked! item-recall-item-mark-empty = You must be holding an item! item-recall-item-summon = {CAPITALIZE(THE($item))} appears in your hand! item-recall-item-unmark = You feel your connection with {THE($item)} sever. From a8f6c51e93d44a1a72be3d6f0535e1d7e5916b44 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Thu, 16 Jan 2025 21:47:01 +0100 Subject: [PATCH 13/18] sprite + sound changes --- Resources/Prototypes/Magic/recall_spell.yml | 7 ++++++- .../Magic/magicactions.rsi/item_recall.png | Bin 0 -> 7081 bytes .../Objects/Magic/magicactions.rsi/meta.json | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 Resources/Textures/Objects/Magic/magicactions.rsi/item_recall.png diff --git a/Resources/Prototypes/Magic/recall_spell.yml b/Resources/Prototypes/Magic/recall_spell.yml index 7f3c3335870a..c5bb96870db0 100644 --- a/Resources/Prototypes/Magic/recall_spell.yml +++ b/Resources/Prototypes/Magic/recall_spell.yml @@ -9,8 +9,13 @@ itemIconStyle: BigAction sound: !type:SoundPathSpecifier path: /Audio/Magic/forcewall.ogg + params: + volume: -5 + pitch: 1.2 + maxDistance: 5 + variation: 0.2 icon: sprite: Objects/Magic/magicactions.rsi - state: shield + state: item_recall event: !type:OnItemRecallActionEvent - type: ItemRecall diff --git a/Resources/Textures/Objects/Magic/magicactions.rsi/item_recall.png b/Resources/Textures/Objects/Magic/magicactions.rsi/item_recall.png new file mode 100644 index 0000000000000000000000000000000000000000..00bbe363793c6f14ac45c6e52aba3b6852ab5ae9 GIT binary patch literal 7081 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 m!^VOu=Qc_=p|)?T6A)Q Date: Sun, 19 Jan 2025 22:13:32 +0100 Subject: [PATCH 14/18] requested changes --- Resources/Locale/en-US/item-recall/item-recall.ftl | 3 --- Resources/Locale/en-US/store/spellbook-catalog.ftl | 3 +++ Resources/Prototypes/Catalog/spellbook_catalog.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Resources/Locale/en-US/item-recall/item-recall.ftl b/Resources/Locale/en-US/item-recall/item-recall.ftl index 85510734c93c..680c7b7b3fb7 100644 --- a/Resources/Locale/en-US/item-recall/item-recall.ftl +++ b/Resources/Locale/en-US/item-recall/item-recall.ftl @@ -1,6 +1,3 @@ -item-recall-grimoire-name = Item Recall -item-recall-grimoire-desc = Mark a held item and summon it back at any time with just a snap of your fingers! - item-recall-marked-name = Recall {CAPITALIZE($item)} item-recall-marked-description = Recall {THE($item)} back into your hand. diff --git a/Resources/Locale/en-US/store/spellbook-catalog.ftl b/Resources/Locale/en-US/store/spellbook-catalog.ftl index 1450cc86082f..1f9bfe548d93 100644 --- a/Resources/Locale/en-US/store/spellbook-catalog.ftl +++ b/Resources/Locale/en-US/store/spellbook-catalog.ftl @@ -23,6 +23,9 @@ spellbook-ethereal-jaunt-description = Slip into the ethereal plane to slip away spellbook-mind-swap-name = Mind Swap spellbook-mind-swap-description = Exchange bodies with another person! +spellbook-item-recall-name = Item Recall +spellbook-item-recall-description = Mark a held item and summon it back at any time with just a snap of your fingers! + # Equipment spellbook-wand-polymorph-door-name = Wand of Entrance diff --git a/Resources/Prototypes/Catalog/spellbook_catalog.yml b/Resources/Prototypes/Catalog/spellbook_catalog.yml index 3583fe7eb422..e72761811ab3 100644 --- a/Resources/Prototypes/Catalog/spellbook_catalog.yml +++ b/Resources/Prototypes/Catalog/spellbook_catalog.yml @@ -228,8 +228,8 @@ - type: listing id: SpellbookItemRecallSwap - name: item-recall-grimoire-name - description: item-recall-grimoire-desc + name: spellbook-item-recall-name + description: spellbook-item-recall-description productAction: ActionItemRecall cost: WizCoin: 1 From 6888107c273c8f032d276178a98f975e7a8395b4 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Thu, 23 Jan 2025 19:23:34 +0100 Subject: [PATCH 15/18] something something small changes --- Content.Shared/ItemRecall/RecallMarkerComponent.cs | 4 ++++ .../ItemRecall/SharedItemRecallSystem.cs | 14 +++++--------- .../Projectiles/SharedProjectileSystem.cs | 2 ++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Content.Shared/ItemRecall/RecallMarkerComponent.cs b/Content.Shared/ItemRecall/RecallMarkerComponent.cs index 85ff4a0b5fe1..a85b22e9e340 100644 --- a/Content.Shared/ItemRecall/RecallMarkerComponent.cs +++ b/Content.Shared/ItemRecall/RecallMarkerComponent.cs @@ -3,6 +3,10 @@ namespace Content.Shared.ItemRecall; + +/// +/// Component used as a marker for an item marked by the ItemRecall ability. +/// [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedItemRecallSystem))] public sealed partial class RecallMarkerComponent : Component { diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 4a9ac34ab639..166fb66cefe4 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -48,7 +48,7 @@ private void OnItemRecallActionUse(Entity ent, ref OnItemRe } _popups.PopupClient(Loc.GetString("item-recall-item-marked", ("item", markItem.Value)), args.Performer, args.Performer); - TryMarkItem(ent, markItem.Value, args.Performer); + TryMarkItem(ent, markItem.Value); return; } @@ -62,7 +62,7 @@ private void OnRecallMarkerShutdown(Entity ent, ref Compo TryUnmarkItem(ent); } - private void TryMarkItem(Entity ent, EntityUid item, EntityUid markedBy) + private void TryMarkItem(Entity ent, EntityUid item) { EnsureComp(item, out var marker); ent.Comp.MarkedEntity = item; @@ -79,12 +79,7 @@ private void TryUnmarkItem(EntityUid item) if (!TryComp(item, out var marker)) return; - if (!TryComp(item, out var instantAction)) - return; - - var actionOwner = instantAction.AttachedEntity; - - if (actionOwner == null) + if (!TryComp(marker.MarkedByAction, out var instantAction)) return; if (TryComp(marker.MarkedByAction, out var action)) @@ -92,7 +87,8 @@ private void TryUnmarkItem(EntityUid item) // 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. - _popups.PopupClient(Loc.GetString("item-recall-item-unmark", ("item", item)), actionOwner.Value, actionOwner.Value, PopupType.MediumCaution); + if (instantAction.AttachedEntity != null) + _popups.PopupClient(Loc.GetString("item-recall-item-unmark", ("item", item)), instantAction.AttachedEntity.Value, instantAction.AttachedEntity.Value, PopupType.MediumCaution); action.MarkedEntity = null; UpdateActionAppearance((marker.MarkedByAction.Value, action)); diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs index 78ad1ea5b3c5..f3c42bbcc0c8 100644 --- a/Content.Shared/Projectiles/SharedProjectileSystem.cs +++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs @@ -135,6 +135,8 @@ public void UnEmbed(EntityUid uid, EmbeddableProjectileComponent? component, Ent projectile.Shooter = null; projectile.Weapon = null; projectile.DamagedEntity = false; + + Dirty(uid, projectile); } if (user != null) From 5f7e6e5cd2348ffe16e5f566f3f00eda554b29ad Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Wed, 29 Jan 2025 17:59:52 +0100 Subject: [PATCH 16/18] requested change (singular) --- .../ItemRecall/ItemRecallComponent.cs | 7 ++++++- .../ItemRecall/SharedItemRecallSystem.cs | 18 +++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Content.Shared/ItemRecall/ItemRecallComponent.cs b/Content.Shared/ItemRecall/ItemRecallComponent.cs index a32378f5596f..591874db7321 100644 --- a/Content.Shared/ItemRecall/ItemRecallComponent.cs +++ b/Content.Shared/ItemRecall/ItemRecallComponent.cs @@ -1,5 +1,4 @@ using Robust.Shared.GameStates; -using Robust.Shared.Utility; namespace Content.Shared.ItemRecall; @@ -12,6 +11,12 @@ public sealed partial class ItemRecallComponent : Component [DataField] public LocId? WhileMarkedDescription = "item-recall-marked-description"; + [DataField] + public string? InitialName; + + [DataField] + public string? InitialDescription; + /// /// The entity currently marked to be recalled by this action. /// diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 166fb66cefe4..ebe0396ff414 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -21,11 +21,18 @@ public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnItemRecallActionUse); SubscribeLocalEvent(OnRecallMarkerShutdown); } + private void OnMapInit(Entity ent, ref MapInitEvent args) + { + ent.Comp.InitialName = Name(ent); + ent.Comp.InitialDescription = Description(ent); + } + private void OnItemRecallActionUse(Entity ent, ref OnItemRecallActionEvent args) { if (ent.Comp.MarkedEntity == null) @@ -103,15 +110,12 @@ private void UpdateActionAppearance(Entity action) if (!TryComp(action, out var instantAction)) return; - var proto = Prototype(action); - - if (proto == null) - return; - if (action.Comp.MarkedEntity == null) { - _metaData.SetEntityName(action, proto.Name); - _metaData.SetEntityDescription(action, proto.Description); + if (action.Comp.InitialName != null) + _metaData.SetEntityName(action, action.Comp.InitialName); + if (action.Comp.InitialDescription != null) + _metaData.SetEntityDescription(action, action.Comp.InitialDescription); _actions.SetEntityIcon(action, null, instantAction); } else From d113e8caaddc19317bff05a17e0c8d065f087794 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Thu, 30 Jan 2025 15:56:59 +0100 Subject: [PATCH 17/18] changes --- Content.Server/ItemRecall/ItemRecallSystem.cs | 39 ++++---------- .../ItemRecall/SharedItemRecallSystem.cs | 52 +++++++++++++++++++ 2 files changed, 63 insertions(+), 28 deletions(-) diff --git a/Content.Server/ItemRecall/ItemRecallSystem.cs b/Content.Server/ItemRecall/ItemRecallSystem.cs index 9b2ee3a82ad0..c7fa5720c65d 100644 --- a/Content.Server/ItemRecall/ItemRecallSystem.cs +++ b/Content.Server/ItemRecall/ItemRecallSystem.cs @@ -1,8 +1,5 @@ -using Content.Shared.Actions; -using Content.Shared.Hands.EntitySystems; using Content.Shared.ItemRecall; -using Content.Shared.Popups; -using Content.Shared.Projectiles; +using Robust.Server.GameStates; namespace Content.Server.ItemRecall; @@ -11,37 +8,23 @@ namespace Content.Server.ItemRecall; /// public sealed partial class ItemRecallSystem : SharedItemRecallSystem { - [Dependency] private readonly SharedHandsSystem _hands = default!; - [Dependency] private readonly SharedProjectileSystem _proj = default!; - [Dependency] private readonly SharedPopupSystem _popups = default!; + [Dependency] private readonly PvsOverrideSystem _pvs = default!; - public override void Initialize() + protected override void AddToPVSOverride(EntityUid uid, EntityUid user) { - base.Initialize(); + if (!_mind.TryGetMind(user, out var _, out var mind)) + return; - SubscribeLocalEvent(OnItemRecall); + if (mind.Session != null) + _pvs.AddSessionOverride(uid, mind.Session); } - private void OnItemRecall(Entity ent, ref RecallItemEvent args) + protected override void RemoveFromPVSOverride(EntityUid uid, EntityUid user) { - RecallItem(ent); - } - - private void RecallItem(Entity ent) - { - if (!TryComp(ent.Comp.MarkedByAction, out var instantAction)) + if (!_mind.TryGetMind(user, out var _, out var mind)) return; - var actionOwner = instantAction.AttachedEntity; - - if (actionOwner == null) - return; - - if (TryComp(ent, out var projectile)) - _proj.UnEmbed(ent, projectile, actionOwner.Value); - - _popups.PopupEntity(Loc.GetString("item-recall-item-summon", ("item", ent)), actionOwner.Value, actionOwner.Value); - - _hands.TryForcePickupAnyHand(actionOwner.Value, ent); + if (mind.Session != null) + _pvs.RemoveSessionOverride(uid, mind.Session); } } diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index ebe0396ff414..1d6404521194 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -1,9 +1,11 @@ using Content.Shared.Actions; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; +using Content.Shared.Mind; using Content.Shared.Popups; using Content.Shared.Projectiles; using Robust.Shared.Network; +using Robust.Shared.Player; namespace Content.Shared.ItemRecall; @@ -16,6 +18,9 @@ public abstract partial class SharedItemRecallSystem : EntitySystem [Dependency] private readonly SharedHandsSystem _hands = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; [Dependency] private readonly SharedPopupSystem _popups = default!; + [Dependency] private readonly SharedProjectileSystem _proj = default!; + [Dependency] protected readonly SharedMindSystem _mind = default!; + [Dependency] private readonly INetManager _net = default!; public override void Initialize() { @@ -23,6 +28,7 @@ public override void Initialize() SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnItemRecallActionUse); + SubscribeLocalEvent(OnItemRecall); SubscribeLocalEvent(OnRecallMarkerShutdown); } @@ -64,6 +70,29 @@ private void OnItemRecallActionUse(Entity ent, ref OnItemRe args.Handled = true; } + private void OnItemRecall(Entity ent, ref RecallItemEvent args) + { + RecallItem(ent); + } + + private void RecallItem(Entity ent) + { + if (!TryComp(ent.Comp.MarkedByAction, out var instantAction)) + return; + + var actionOwner = instantAction.AttachedEntity; + + if (actionOwner == null) + return; + + if (TryComp(ent, out var projectile)) + _proj.UnEmbed(ent, projectile, actionOwner.Value); + + _popups.PopupPredicted(Loc.GetString("item-recall-item-summon", ("item", ent)), actionOwner.Value, actionOwner.Value); + + _hands.TryForcePickupAnyHand(actionOwner.Value, ent); + } + private void OnRecallMarkerShutdown(Entity ent, ref ComponentShutdown args) { TryUnmarkItem(ent); @@ -71,6 +100,16 @@ private void OnRecallMarkerShutdown(Entity ent, ref Compo private void TryMarkItem(Entity ent, EntityUid item) { + if (!TryComp(ent, out var instantAction)) + return; + + var actionOwner = instantAction.AttachedEntity; + + if (actionOwner == null) + return; + + AddToPVSOverride(item, actionOwner.Value); + EnsureComp(item, out var marker); ent.Comp.MarkedEntity = item; Dirty(ent); @@ -95,7 +134,10 @@ private void TryUnmarkItem(EntityUid item) // 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 (instantAction.AttachedEntity != null) + { _popups.PopupClient(Loc.GetString("item-recall-item-unmark", ("item", item)), instantAction.AttachedEntity.Value, instantAction.AttachedEntity.Value, PopupType.MediumCaution); + RemoveFromPVSOverride(item, instantAction.AttachedEntity.Value); + } action.MarkedEntity = null; UpdateActionAppearance((marker.MarkedByAction.Value, action)); @@ -131,4 +173,14 @@ private void UpdateActionAppearance(Entity action) _actions.SetEntityIcon(action, action.Comp.MarkedEntity, instantAction); } } + + protected virtual void AddToPVSOverride(EntityUid uid, EntityUid user) + { + + } + + protected virtual void RemoveFromPVSOverride(EntityUid uid, EntityUid user) + { + + } } From cb26c7de3c9e8e9d164be805d35cc0fe5c767e26 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Thu, 30 Jan 2025 16:02:53 +0100 Subject: [PATCH 18/18] more --- Content.Shared/ItemRecall/SharedItemRecallSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs index 1d6404521194..d76ebb99d625 100644 --- a/Content.Shared/ItemRecall/SharedItemRecallSystem.cs +++ b/Content.Shared/ItemRecall/SharedItemRecallSystem.cs @@ -110,7 +110,7 @@ private void TryMarkItem(Entity ent, EntityUid item) AddToPVSOverride(item, actionOwner.Value); - EnsureComp(item, out var marker); + var marker = AddComp(item); ent.Comp.MarkedEntity = item; Dirty(ent);