From e74f9d944872f2d745b2500d55a53fa73d2ff52c Mon Sep 17 00:00:00 2001 From: Apopheosis Date: Sat, 30 Aug 2025 16:22:33 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D0=94=D1=83=D1=88=D0=B5=D0=B2=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BA=D0=BE=D0=BD=D1=82=D1=80=D0=B0=D0=BA=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SoulContractSystem/SoulContractSystem.cs | 68 +++++++++++++++++++ .../SoulContract/SoulContractComponent.cs | 25 +++++++ .../SoulContract/SoulContractDoAfterEvent.cs | 15 ++++ .../_Forge/SoulContract/soul_contract.yml | 11 +++ 4 files changed, 119 insertions(+) create mode 100644 Content.Server/_Forge/SoulContractSystem/SoulContractSystem.cs create mode 100644 Content.Shared/_Forge/SoulContract/SoulContractComponent.cs create mode 100644 Content.Shared/_Forge/SoulContract/SoulContractDoAfterEvent.cs create mode 100644 Resources/Prototypes/_Forge/SoulContract/soul_contract.yml diff --git a/Content.Server/_Forge/SoulContractSystem/SoulContractSystem.cs b/Content.Server/_Forge/SoulContractSystem/SoulContractSystem.cs new file mode 100644 index 000000000000..7387c18b8073 --- /dev/null +++ b/Content.Server/_Forge/SoulContractSystem/SoulContractSystem.cs @@ -0,0 +1,68 @@ +using Content.Server._NF.Bank; +using Content.Server.Store.Components; +using Content.Shared._Forge.SoulContract; +using Content.Shared.Body.Systems; +using Content.Shared.DoAfter; +using Content.Shared.Gibbing.Systems; +using Content.Shared.Interaction.Events; +using Content.Shared.Inventory; +using Content.Shared.Storage; +using static Content.Server.Power.Pow3r.PowerState; + +namespace Content.Server._Forge.SoulContractSystem +{ + public sealed class SoulContractSystem : EntitySystem + { + [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; + [Dependency] private readonly BankSystem _bank = default!; + [Dependency] private readonly InventorySystem _inventory = default!; + [Dependency] private readonly SharedBodySystem _bodySystem = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnUseInHand); + SubscribeLocalEvent(OnDoAfter); + } + + private void OnUseInHand(Entity entity, ref UseInHandEvent args) + { + var (uid, soulContract) = entity; + + var user = args.User; + + var doAfterArgs = new DoAfterArgs(EntityManager, + user, + soulContract.UseTime, + new SoulContractDoAfterEvent(), + eventTarget: uid) + { + BreakOnHandChange = false, + BreakOnMove = true, + BreakOnDamage = true, + MovementThreshold = 0.01f, + DistanceThreshold = 5, + NeedHand = true + }; + + _doAfterSystem.TryStartDoAfter(doAfterArgs); + } + + private void OnDoAfter(Entity entity, ref SoulContractDoAfterEvent args) + { + if (args.Cancelled || args.Handled || args.Args.Target == null) + return; + + Del(entity.Owner); + args.Handled = _bank.TryBankDeposit(args.Args.User, entity.Comp.Reward) && TryGib(entity, args.Args.User); + } + + private bool TryGib(Entity entity, EntityUid user) + { + var gibHashSet = _bodySystem.GibBody(user); + + return gibHashSet.Count > 0; + } + } +} diff --git a/Content.Shared/_Forge/SoulContract/SoulContractComponent.cs b/Content.Shared/_Forge/SoulContract/SoulContractComponent.cs new file mode 100644 index 000000000000..34e30934d636 --- /dev/null +++ b/Content.Shared/_Forge/SoulContract/SoulContractComponent.cs @@ -0,0 +1,25 @@ +using Content.Shared.DoAfter; +using Robust.Shared.Serialization; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Content.Shared._Forge.SoulContract +{ + [RegisterComponent] + public sealed partial class SoulContractComponent: Component + { + [DataField] + public int Reward; + + [DataField] + public TimeSpan UseTime = TimeSpan.FromSeconds(5); + } + + [Serializable, NetSerializable] + public sealed partial class SoulContractDoAfterEvent : SimpleDoAfterEvent + { + } +} diff --git a/Content.Shared/_Forge/SoulContract/SoulContractDoAfterEvent.cs b/Content.Shared/_Forge/SoulContract/SoulContractDoAfterEvent.cs new file mode 100644 index 000000000000..b87ea3e2c519 --- /dev/null +++ b/Content.Shared/_Forge/SoulContract/SoulContractDoAfterEvent.cs @@ -0,0 +1,15 @@ +using Content.Shared.DoAfter; +using Robust.Shared.Serialization; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Content.Server._Forge.SoulContractSystem +{ + [Serializable, NetSerializable] + public sealed partial class SoulContractDoAfterEvent: SimpleDoAfterEvent + { + } +} diff --git a/Resources/Prototypes/_Forge/SoulContract/soul_contract.yml b/Resources/Prototypes/_Forge/SoulContract/soul_contract.yml new file mode 100644 index 000000000000..506d1c79fcf2 --- /dev/null +++ b/Resources/Prototypes/_Forge/SoulContract/soul_contract.yml @@ -0,0 +1,11 @@ +- type: entity + name: soul contract + parent: BaseItem + id: SoulContract + description: На станции, даже ваша душа имеет цену + components: + - type: Sprite + sprite: Objects/Fun/Bikehorn.rsi + state: icon + - type: SoulContract + reward: 100000 From a75b20df88160fcb26fb786f47b8141b0728c2fd Mon Sep 17 00:00:00 2001 From: Apopheosis Date: Sat, 30 Aug 2025 17:44:56 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=A0=D0=B0=D0=BD=D0=B4=D0=BE=D0=BC=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=B4=D0=B5=D0=BD=D0=B5=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SoulContractSystem/SoulContractSystem.cs | 4 ++-- Content.Server/_NF/Bank/BankSystem.cs | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Content.Server/_Forge/SoulContractSystem/SoulContractSystem.cs b/Content.Server/_Forge/SoulContractSystem/SoulContractSystem.cs index 7387c18b8073..c298c4e3d04a 100644 --- a/Content.Server/_Forge/SoulContractSystem/SoulContractSystem.cs +++ b/Content.Server/_Forge/SoulContractSystem/SoulContractSystem.cs @@ -51,11 +51,11 @@ private void OnUseInHand(Entity entity, ref UseInHandEven private void OnDoAfter(Entity entity, ref SoulContractDoAfterEvent args) { - if (args.Cancelled || args.Handled || args.Args.Target == null) + if (args.Cancelled) return; Del(entity.Owner); - args.Handled = _bank.TryBankDeposit(args.Args.User, entity.Comp.Reward) && TryGib(entity, args.Args.User); + args.Handled = _bank.TryBankDeposit(args.Args.User, entity.Comp.Reward, true) && TryGib(entity, args.Args.User); } private bool TryGib(Entity entity, EntityUid user) diff --git a/Content.Server/_NF/Bank/BankSystem.cs b/Content.Server/_NF/Bank/BankSystem.cs index 6746b9de6f21..9e37f3ce5c76 100644 --- a/Content.Server/_NF/Bank/BankSystem.cs +++ b/Content.Server/_NF/Bank/BankSystem.cs @@ -8,6 +8,8 @@ using System.Diagnostics.CodeAnalysis; using Content.Shared._NF.Bank.Events; using Content.Shared.GameTicking; +using Robust.Shared.Network; +using System.Linq; namespace Content.Server._NF.Bank; @@ -102,7 +104,7 @@ public bool TryBankWithdraw(EntityUid mobUid, int amount) /// The UID that the bank account is connected to, typically the player controlled mob /// The amount of spesos to remove from the bank account /// true if the transaction was successful, false if it was not - public bool TryBankDeposit(EntityUid mobUid, int amount) + public bool TryBankDeposit(EntityUid mobUid, int amount, bool sendToRandomCharacter = false) { if (amount <= 0) { @@ -128,7 +130,18 @@ public bool TryBankDeposit(EntityUid mobUid, int amount) return false; } - if (prefs.SelectedCharacter is not HumanoidCharacterProfile profile) + var profile = prefs.SelectedCharacter as HumanoidCharacterProfile; + + if (sendToRandomCharacter) + { + Random rnd = new Random(); + int randomInt = rnd.Next(prefs.Characters.Count); + var randomProfile = (HumanoidCharacterProfile)prefs.Characters.ToList()[randomInt].Value; + + profile = randomProfile; + } + + if (profile is null) { _log.Info($"TryBankDeposit: {mobUid} has the wrong prefs type"); return false; From ba4f92697be5447c44a707bd6f18da1fa24d1f78 Mon Sep 17 00:00:00 2001 From: Apopheosis Date: Sat, 30 Aug 2025 17:51:20 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=9F=D0=BE=D0=BC=D0=B5=D1=82=D0=B8=D0=BB?= =?UTF-8?q?=20=D1=82=D0=B5=D0=B3=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Server/_NF/Bank/BankSystem.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Content.Server/_NF/Bank/BankSystem.cs b/Content.Server/_NF/Bank/BankSystem.cs index 9e37f3ce5c76..51816da1b652 100644 --- a/Content.Server/_NF/Bank/BankSystem.cs +++ b/Content.Server/_NF/Bank/BankSystem.cs @@ -129,7 +129,8 @@ public bool TryBankDeposit(EntityUid mobUid, int amount, bool sendToRandomCharac _log.Info($"TryBankDeposit: {mobUid} has no cached prefs"); return false; } - + // Forge-Механика + // Forge-Механика-start var profile = prefs.SelectedCharacter as HumanoidCharacterProfile; if (sendToRandomCharacter) @@ -142,6 +143,7 @@ public bool TryBankDeposit(EntityUid mobUid, int amount, bool sendToRandomCharac } if (profile is null) + // Forge-Механика-end { _log.Info($"TryBankDeposit: {mobUid} has the wrong prefs type"); return false; From d9b27fea4247cffd0d85b64951c9a99ade5397fb Mon Sep 17 00:00:00 2001 From: Apopheosis Date: Sat, 30 Aug 2025 17:53:06 +0300 Subject: [PATCH 4/4] =?UTF-8?q?SoulContract=20=D0=B2=D0=BC=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=BE=20=D0=BC=D0=B5=D1=85=D0=B0=D0=BD=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Server/_NF/Bank/BankSystem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Content.Server/_NF/Bank/BankSystem.cs b/Content.Server/_NF/Bank/BankSystem.cs index 51816da1b652..f8489051e33b 100644 --- a/Content.Server/_NF/Bank/BankSystem.cs +++ b/Content.Server/_NF/Bank/BankSystem.cs @@ -129,8 +129,8 @@ public bool TryBankDeposit(EntityUid mobUid, int amount, bool sendToRandomCharac _log.Info($"TryBankDeposit: {mobUid} has no cached prefs"); return false; } - // Forge-Механика - // Forge-Механика-start + // Forge-SoulContract + // Forge-SoulContract-start var profile = prefs.SelectedCharacter as HumanoidCharacterProfile; if (sendToRandomCharacter) @@ -143,7 +143,7 @@ public bool TryBankDeposit(EntityUid mobUid, int amount, bool sendToRandomCharac } if (profile is null) - // Forge-Механика-end + // Forge-SoulContract-end { _log.Info($"TryBankDeposit: {mobUid} has the wrong prefs type"); return false;