diff --git a/Content.Client/Input/ContentContexts.cs b/Content.Client/Input/ContentContexts.cs index 68ef25517eb..ca22ab095d6 100644 --- a/Content.Client/Input/ContentContexts.cs +++ b/Content.Client/Input/ContentContexts.cs @@ -68,7 +68,7 @@ public static void SetupContexts(IInputContextContainer contexts) human.AddFunction(ContentKeyFunctions.SmartEquipBelt); human.AddFunction(ContentKeyFunctions.OpenBackpack); human.AddFunction(ContentKeyFunctions.OpenBelt); - human.AddFunction(ContentKeyFunctions.OfferingItem); + human.AddFunction(ContentKeyFunctions.OfferItem); human.AddFunction(ContentKeyFunctions.MouseMiddle); human.AddFunction(ContentKeyFunctions.ArcadeUp); human.AddFunction(ContentKeyFunctions.ArcadeDown); diff --git a/Content.Client/OfferingItem/OfferingItemIndicatorsOverlay.cs b/Content.Client/OfferItem/OfferItemIndicatorsOverlay.cs similarity index 88% rename from Content.Client/OfferingItem/OfferingItemIndicatorsOverlay.cs rename to Content.Client/OfferItem/OfferItemIndicatorsOverlay.cs index 2082954b6dd..16a314a2cf4 100644 --- a/Content.Client/OfferingItem/OfferingItemIndicatorsOverlay.cs +++ b/Content.Client/OfferItem/OfferItemIndicatorsOverlay.cs @@ -6,14 +6,14 @@ using Robust.Shared.Enums; using Robust.Shared.Utility; -namespace Content.Client.OfferingItem; +namespace Content.Client.OfferItem; -public sealed class OfferingItemIndicatorsOverlay : Overlay +public sealed class OfferItemIndicatorsOverlay : Overlay { private readonly IInputManager _inputManager; private readonly IEntityManager _entMan; private readonly IEyeManager _eye; - private readonly OfferingItemSystem _offer; + private readonly OfferItemSystem _offer; private readonly Texture _sight; @@ -23,8 +23,8 @@ public sealed class OfferingItemIndicatorsOverlay : Overlay private readonly Color _strokeColor = Color.Black.WithAlpha(0.5f); private readonly float _scale = 0.6f; // 1 is a little big - public OfferingItemIndicatorsOverlay(IInputManager input, IEntityManager entMan, - IEyeManager eye, OfferingItemSystem offerSys) + public OfferItemIndicatorsOverlay(IInputManager input, IEntityManager entMan, + IEyeManager eye, OfferItemSystem offerSys) { _inputManager = input; _entMan = entMan; diff --git a/Content.Client/OfferingItem/OfferingItemSystem.cs b/Content.Client/OfferItem/OfferItemSystem.cs similarity index 76% rename from Content.Client/OfferingItem/OfferingItemSystem.cs rename to Content.Client/OfferItem/OfferItemSystem.cs index b87bac2c53a..51b8dcbc0bc 100644 --- a/Content.Client/OfferingItem/OfferingItemSystem.cs +++ b/Content.Client/OfferItem/OfferItemSystem.cs @@ -1,13 +1,13 @@ using Content.Shared.CCVar; -using Content.Shared.OfferingItem; +using Content.Shared.OfferItem; using Robust.Client.Graphics; using Robust.Client.Input; using Robust.Client.Player; using Robust.Shared.Configuration; -namespace Content.Client.OfferingItem; +namespace Content.Client.OfferItem; -public sealed class OfferingItemSystem : SharedOfferingItemSystem +public sealed class OfferItemSystem : SharedOfferItemSystem { [Dependency] private readonly IOverlayManager _overlayManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; @@ -21,7 +21,7 @@ public override void Initialize() } public override void Shutdown() { - _overlayManager.RemoveOverlay(); + _overlayManager.RemoveOverlay(); base.Shutdown(); } @@ -39,13 +39,13 @@ private void OnShowOfferIndicatorsChanged(bool isShow) { if (isShow) { - _overlayManager.AddOverlay(new OfferingItemIndicatorsOverlay( + _overlayManager.AddOverlay(new OfferItemIndicatorsOverlay( _inputManager, EntityManager, _eye, this)); } else - _overlayManager.RemoveOverlay(); + _overlayManager.RemoveOverlay(); } } diff --git a/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs b/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs index aeda17caa4f..9daca74dd3a 100644 --- a/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs +++ b/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs @@ -183,7 +183,7 @@ void AddCheckBox(string checkBoxName, bool currentState, Action [UsedImplicitly] [DataDefinition] -public sealed partial class AcceptingOffer : IAlertClick +public sealed partial class AcceptOffer : IAlertClick { public void AlertClicked(EntityUid player) { var entManager = IoCManager.Resolve(); - if (entManager.TryGetComponent(player, out OfferingItemComponent? offeringItem)) + if (entManager.TryGetComponent(player, out OfferItemComponent? offerItem)) { - entManager.System().Receiving(player, offeringItem); + entManager.System().Receiving(player, offerItem); } } } diff --git a/Content.Server/OfferingItem/OfferingItemSystem.cs b/Content.Server/OfferItem/OfferItemSystem.cs similarity index 50% rename from Content.Server/OfferingItem/OfferingItemSystem.cs rename to Content.Server/OfferItem/OfferItemSystem.cs index c71914976e4..00a40277529 100644 --- a/Content.Server/OfferingItem/OfferingItemSystem.cs +++ b/Content.Server/OfferItem/OfferItemSystem.cs @@ -1,11 +1,11 @@ using Content.Shared.Hands.Components; using Content.Shared.Alert; using Content.Shared.Hands.EntitySystems; -using Content.Shared.OfferingItem; +using Content.Shared.OfferItem; -namespace Content.Server.OfferingItem; +namespace Content.Server.OfferItem; -public sealed class OfferingItemSystem : SharedOfferingItemSystem +public sealed class OfferItemSystem : SharedOfferItemSystem { [Dependency] private readonly AlertsSystem _alertsSystem = default!; [Dependency] private readonly SharedHandsSystem _hands = default!; @@ -14,36 +14,36 @@ public override void Update(float frameTime) { base.Update(frameTime); - var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid, out var offeringItem)) + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var offerItem)) { if (!TryComp(uid, out var hands) || hands.ActiveHand == null) continue; - if (offeringItem.Hand != null && - hands.Hands[offeringItem.Hand].HeldEntity == null) - UnOffer(uid, offeringItem); + if (offerItem.Hand != null && + hands.Hands[offerItem.Hand].HeldEntity == null) + UnOffer(uid, offerItem); - if (!offeringItem.IsInReceiveMode) + if (!offerItem.IsInReceiveMode) { - _alertsSystem.ClearAlert(uid, AlertType.Offering); + _alertsSystem.ClearAlert(uid, AlertType.Offer); continue; } - _alertsSystem.ShowAlert(uid, AlertType.Offering); + _alertsSystem.ShowAlert(uid, AlertType.Offer); } } - public void Receiving(EntityUid uid, OfferingItemComponent? component = null) + public void Receiving(EntityUid uid, OfferItemComponent? component = null) { if (!Resolve(uid, ref component) || - !TryComp(component.Target, out var offeringItem) || - offeringItem.Hand == null || + !TryComp(component.Target, out var offerItem) || + offerItem.Hand == null || !TryComp(uid, out var hands) || !TryComp(component.Target, out var handsTarget)) return; - var item = handsTarget.Hands[offeringItem.Hand].HeldEntity; + var item = handsTarget.Hands[offerItem.Hand].HeldEntity; _hands.TryPickup(component.Target.GetValueOrDefault(), item.GetValueOrDefault(), handsComp:hands); UnOffer(uid, component); diff --git a/Content.Shared/Alert/AlertType.cs b/Content.Shared/Alert/AlertType.cs index 7d12e9559ae..308969f8564 100644 --- a/Content.Shared/Alert/AlertType.cs +++ b/Content.Shared/Alert/AlertType.cs @@ -53,7 +53,7 @@ public enum AlertType : byte BorgHealth, BorgCrit, BorgDead, - Offering + Offer } } diff --git a/Content.Shared/Input/ContentKeyFunctions.cs b/Content.Shared/Input/ContentKeyFunctions.cs index 227e12b649d..19514a4ee0f 100644 --- a/Content.Shared/Input/ContentKeyFunctions.cs +++ b/Content.Shared/Input/ContentKeyFunctions.cs @@ -54,7 +54,7 @@ public static class ContentKeyFunctions public static readonly BoundKeyFunction ZoomOut = "ZoomOut"; public static readonly BoundKeyFunction ZoomIn = "ZoomIn"; public static readonly BoundKeyFunction ResetZoom = "ResetZoom"; - public static readonly BoundKeyFunction OfferingItem = "OfferingItem"; + public static readonly BoundKeyFunction OfferItem = "OfferItem"; public static readonly BoundKeyFunction ArcadeUp = "ArcadeUp"; public static readonly BoundKeyFunction ArcadeDown = "ArcadeDown"; diff --git a/Content.Shared/OfferingItem/OfferingItemComponent.cs b/Content.Shared/OfferItem/OfferItemComponent.cs similarity index 76% rename from Content.Shared/OfferingItem/OfferingItemComponent.cs rename to Content.Shared/OfferItem/OfferItemComponent.cs index d6114671997..f533211e46d 100644 --- a/Content.Shared/OfferingItem/OfferingItemComponent.cs +++ b/Content.Shared/OfferItem/OfferItemComponent.cs @@ -1,10 +1,10 @@ using Robust.Shared.GameStates; -namespace Content.Shared.OfferingItem; +namespace Content.Shared.OfferItem; [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] -[Access(typeof(SharedOfferingItemSystem))] -public sealed partial class OfferingItemComponent : Component +[Access(typeof(SharedOfferItemSystem))] +public sealed partial class OfferItemComponent : Component { [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public bool IsInOfferMode; diff --git a/Content.Shared/OfferItem/SharedOfferItemSystem.Interactions.cs b/Content.Shared/OfferItem/SharedOfferItemSystem.Interactions.cs new file mode 100644 index 00000000000..ee9dfaba7f6 --- /dev/null +++ b/Content.Shared/OfferItem/SharedOfferItemSystem.Interactions.cs @@ -0,0 +1,73 @@ +using Content.Shared.ActionBlocker; +using Content.Shared.Input; +using Content.Shared.Hands.Components; +using Robust.Shared.Input.Binding; +using Robust.Shared.Player; + +namespace Content.Shared.OfferItem; + +public abstract partial class SharedOfferItemSystem +{ + [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; + + private void InitializeInteractions() + { + CommandBinds.Builder + .Bind(ContentKeyFunctions.OfferItem, InputCmdHandler.FromDelegate(SetInOfferMode, handle: false, outsidePrediction: false)) + .Register(); + } + + public override void Shutdown() + { + base.Shutdown(); + + CommandBinds.Unregister(); + } + + private void SetInOfferMode(ICommonSession? session) + { + if (session is not { } playerSession) + return; + + if ((playerSession.AttachedEntity is not { Valid: true } uid || !Exists(uid)) || + !_actionBlocker.CanInteract(uid, null)) + return; + + if (!TryComp(uid, out var offerItem)) + return; + + if (!TryComp(uid, out var hands) || hands.ActiveHand == null) + return; + + var handItem = hands.ActiveHand.HeldEntity; + + if (offerItem.IsInOfferMode == false) + { + if (handItem == null) + return; + + if (offerItem.Hand == null || offerItem.Target == null) + { + offerItem.IsInOfferMode = true; + offerItem.Hand = hands.ActiveHand.Name; + + Dirty(uid, offerItem); + return; + } + + if (TryComp(offerItem.Target, out var offerItemTarget)) + { + offerItemTarget.IsInReceiveMode = false; + offerItemTarget.Target = null; + + Dirty(offerItem.Target.Value, offerItemTarget); + } + } + + offerItem.Hand = null; + offerItem.IsInOfferMode = false; + offerItem.Target = null; + + Dirty(uid, offerItem); + } +} diff --git a/Content.Shared/OfferItem/SharedOfferItemSystem.cs b/Content.Shared/OfferItem/SharedOfferItemSystem.cs new file mode 100644 index 00000000000..b3c162dd1a6 --- /dev/null +++ b/Content.Shared/OfferItem/SharedOfferItemSystem.cs @@ -0,0 +1,67 @@ +using Content.Shared.Interaction; + +namespace Content.Shared.OfferItem; + +public abstract partial class SharedOfferItemSystem : EntitySystem +{ + [Dependency] private readonly SharedTransformSystem _transform = default!; + + public override void Initialize() + { + SubscribeLocalEvent(SetInReceiveMode); + SubscribeLocalEvent(OnMove); + + InitializeInteractions(); + } + + private void SetInReceiveMode(EntityUid uid, OfferItemComponent component, AfterInteractUsingEvent args) + { + if (!TryComp(args.User, out var offerItem)) + return; + + component.IsInReceiveMode = true; + component.Target = args.User; + + Dirty(uid, component); + + offerItem.Target = uid; + offerItem.IsInOfferMode = false; + + Dirty(args.User, offerItem); + } + + private void OnMove(EntityUid uid, OfferItemComponent component, MoveEvent args) + { + if (component.Target == null || + args.NewPosition.InRange(EntityManager, _transform, + Transform(component.Target.GetValueOrDefault()).Coordinates, component.MaxOfferDistance)) + return; + + UnOffer(uid, component); + } + + protected void UnOffer(EntityUid uid, OfferItemComponent component) + { + if (TryComp(component.Target, out var offerItem) && component.Target != null) + { + offerItem.IsInOfferMode = false; + offerItem.IsInReceiveMode = false; + offerItem.Hand = null; + offerItem.Target = null; + + Dirty(component.Target.Value, offerItem); + } + + component.IsInOfferMode = false; + component.IsInReceiveMode = false; + component.Hand = null; + component.Target = null; + + Dirty(uid, component); + } + + public bool IsInOfferMode(EntityUid? entity, OfferItemComponent? component = null) + { + return entity != null && Resolve(entity.Value, ref component, false) && component.IsInOfferMode; + } +} diff --git a/Content.Shared/OfferingItem/SharedOfferingItemSystem.Interactions.cs b/Content.Shared/OfferingItem/SharedOfferingItemSystem.Interactions.cs deleted file mode 100644 index db576c796ae..00000000000 --- a/Content.Shared/OfferingItem/SharedOfferingItemSystem.Interactions.cs +++ /dev/null @@ -1,73 +0,0 @@ -using Content.Shared.ActionBlocker; -using Content.Shared.Input; -using Content.Shared.Hands.Components; -using Robust.Shared.Input.Binding; -using Robust.Shared.Player; - -namespace Content.Shared.OfferingItem; - -public abstract partial class SharedOfferingItemSystem -{ - [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; - - private void InitializeInteractions() - { - CommandBinds.Builder - .Bind(ContentKeyFunctions.OfferingItem, InputCmdHandler.FromDelegate(SetInOfferMode, handle: false, outsidePrediction: false)) - .Register(); - } - - public override void Shutdown() - { - base.Shutdown(); - - CommandBinds.Unregister(); - } - - private void SetInOfferMode(ICommonSession? session) - { - if (session is not { } playerSession) - return; - - if ((playerSession.AttachedEntity is not { Valid: true } uid || !Exists(uid)) || - !_actionBlocker.CanInteract(uid, null)) - return; - - if (!TryComp(uid, out var offeringItem)) - return; - - if (!TryComp(uid, out var hands) || hands.ActiveHand == null) - return; - - var handItem = hands.ActiveHand.HeldEntity; - - if (offeringItem.IsInOfferMode == false) - { - if (handItem == null) - return; - - if (offeringItem.Hand == null || offeringItem.Target == null) - { - offeringItem.IsInOfferMode = true; - offeringItem.Hand = hands.ActiveHand.Name; - - Dirty(uid, offeringItem); - return; - } - - if (TryComp(offeringItem.Target, out var offeringItemTarget)) - { - offeringItemTarget.IsInReceiveMode = false; - offeringItemTarget.Target = null; - - Dirty(offeringItem.Target.Value, offeringItemTarget); - } - } - - offeringItem.Hand = null; - offeringItem.IsInOfferMode = false; - offeringItem.Target = null; - - Dirty(uid, offeringItem); - } -} diff --git a/Content.Shared/OfferingItem/SharedOfferingItemSystem.cs b/Content.Shared/OfferingItem/SharedOfferingItemSystem.cs deleted file mode 100644 index ff3bf3f15de..00000000000 --- a/Content.Shared/OfferingItem/SharedOfferingItemSystem.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Content.Shared.Interaction; - -namespace Content.Shared.OfferingItem; - -public abstract partial class SharedOfferingItemSystem : EntitySystem -{ - [Dependency] private readonly SharedTransformSystem _transform = default!; - - public override void Initialize() - { - SubscribeLocalEvent(SetInReceiveMode); - SubscribeLocalEvent(OnMove); - - InitializeInteractions(); - } - - private void SetInReceiveMode(EntityUid uid, OfferingItemComponent component, AfterInteractUsingEvent args) - { - if (!TryComp(args.User, out var offeringItem)) - return; - - component.IsInReceiveMode = true; - component.Target = args.User; - - Dirty(uid, component); - - offeringItem.Target = uid; - offeringItem.IsInOfferMode = false; - - Dirty(args.User, offeringItem); - } - - private void OnMove(EntityUid uid, OfferingItemComponent component, MoveEvent args) - { - if (component.Target == null || - args.NewPosition.InRange(EntityManager, _transform, - Transform(component.Target.GetValueOrDefault()).Coordinates, component.MaxOfferDistance)) - return; - - UnOffer(uid, component); - } - - protected void UnOffer(EntityUid uid, OfferingItemComponent component) - { - if (TryComp(component.Target, out var offeringItem) && component.Target != null) - { - offeringItem.IsInOfferMode = false; - offeringItem.IsInReceiveMode = false; - offeringItem.Hand = null; - offeringItem.Target = null; - - Dirty(component.Target.Value, offeringItem); - } - - component.IsInOfferMode = false; - component.IsInReceiveMode = false; - component.Hand = null; - component.Target = null; - - Dirty(uid, component); - } - - public bool IsInOfferMode(EntityUid? entity, OfferingItemComponent? component = null) - { - return entity != null && Resolve(entity.Value, ref component, false) && component.IsInOfferMode; - } -} diff --git a/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl b/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl index 021585ce776..f76d1c04784 100644 --- a/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl +++ b/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl @@ -136,7 +136,7 @@ ui-options-function-examine-entity = Examine ui-options-function-swap-hands = Swap hands ui-options-function-move-stored-item = Move stored item ui-options-function-rotate-stored-item = Rotate stored item -ui-options-function-offering-item = Offer something +ui-options-function-offer-item = Offer something ui-options-static-storage-ui = Lock storage window to hotbar ui-options-function-smart-equip-backpack = Smart-equip to backpack diff --git a/Resources/Locale/en-US/interaction/offer-item-system.txt b/Resources/Locale/en-US/interaction/offer-item-system.txt new file mode 100644 index 00000000000..9ab9ebd124b --- /dev/null +++ b/Resources/Locale/en-US/interaction/offer-item-system.txt @@ -0,0 +1,3 @@ +offer-item-holding-out = You're holding out a {THE($item)}. +offer-item-pull-back = You're pull back a {THE($item)}. +offer-item-empty-hand = There's nothing in your hand to offer! \ No newline at end of file diff --git a/Resources/Locale/en-US/interaction/offering-item-system.txt b/Resources/Locale/en-US/interaction/offering-item-system.txt deleted file mode 100644 index 6ca5d243fda..00000000000 --- a/Resources/Locale/en-US/interaction/offering-item-system.txt +++ /dev/null @@ -1,3 +0,0 @@ -offering-item-holding-out = You're holding out a {THE($item)}. -offering-item-pull-back = You're pull back a {THE($item)}. -offering-item-empty-hand = There's nothing in your hand to offer! \ No newline at end of file diff --git a/Resources/Prototypes/Alerts/alerts.yml b/Resources/Prototypes/Alerts/alerts.yml index 49fec2e020c..5ab3b3eef40 100644 --- a/Resources/Prototypes/Alerts/alerts.yml +++ b/Resources/Prototypes/Alerts/alerts.yml @@ -24,7 +24,7 @@ - category: Thirst - alertType: Magboots - alertType: Pacified - - alertType: Offering + - alertType: Offer - type: alert id: LowOxygen @@ -152,11 +152,11 @@ description: alerts-buckled-desc - type: alert - id: Offering - onClick: !type:AcceptingOffer { } - icons: [ /Textures/Interface/Alerts/Offering_item/Offering_item.png ] - name: alerts-offering-name - description: alerts-offering-desc + id: Offer + onClick: !type:AcceptOffer { } + icons: [ /Textures/Interface/Alerts/Offer_item/Offer_item.png ] + name: alerts-offer-name + description: alerts-offer-desc - type: alert id: HumanCrit diff --git a/Resources/Prototypes/Entities/Mobs/Species/base.yml b/Resources/Prototypes/Entities/Mobs/Species/base.yml index 540ec9cf7fd..c94d0fae27c 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/base.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/base.yml @@ -309,7 +309,7 @@ Asphyxiation: -1.0 - type: FireVisuals alternateState: Standing - - type: OfferingItem + - type: OfferItem - type: entity save: false diff --git a/Resources/Textures/Interface/Alerts/Offering_item/offering_item.png b/Resources/Textures/Interface/Alerts/Offer_item/offer_item.png similarity index 100% rename from Resources/Textures/Interface/Alerts/Offering_item/offering_item.png rename to Resources/Textures/Interface/Alerts/Offer_item/offer_item.png diff --git a/Resources/keybinds.yml b/Resources/keybinds.yml index 4b4e0356a6c..7368169a8dc 100644 --- a/Resources/keybinds.yml +++ b/Resources/keybinds.yml @@ -255,9 +255,10 @@ binds: type: State key: V mod1: Shift -- function: OfferingItem +- function: OfferItem type: State key: V + mod1: Control - function: ShowDebugConsole type: State key: Tilde