From c41f20706ecda1445d3ec4ac49ebe0684e32bc4c Mon Sep 17 00:00:00 2001 From: Red <96445749+TheShuEd@users.noreply.github.com> Date: Tue, 3 Jun 2025 18:12:44 +0300 Subject: [PATCH] +rep (#1376) --- .../Trading/CP14TradingPlatformSystem.cs | 4 ++-- .../Trading/CP14AddGlobalReputationSpecial.cs | 24 +++++++++++++++++++ .../CP14SharedTradingPlatformSystem.cs | 14 +++++++++++ .../_CP14/Roles/Jobs/Traders/merchant.yml | 2 ++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Content.Shared/_CP14/Trading/CP14AddGlobalReputationSpecial.cs diff --git a/Content.Server/_CP14/Trading/CP14TradingPlatformSystem.cs b/Content.Server/_CP14/Trading/CP14TradingPlatformSystem.cs index 803e77a113..37a76c1f6d 100644 --- a/Content.Server/_CP14/Trading/CP14TradingPlatformSystem.cs +++ b/Content.Server/_CP14/Trading/CP14TradingPlatformSystem.cs @@ -118,8 +118,8 @@ public sealed partial class CP14TradingPlatformSystem : CP14SharedTradingPlatfor if (indexedPosition.Service is not null) indexedPosition.Service.Buy(EntityManager, Proto, platform); - user.Comp.Reputation[indexedPosition.Faction] += (float)price / 100; - Dirty(user); + + AddReputation(user, indexedPosition.Faction, (float)price / 100); _audio.PlayPvs(platform.Comp.BuySound, Transform(platform).Coordinates); diff --git a/Content.Shared/_CP14/Trading/CP14AddGlobalReputationSpecial.cs b/Content.Shared/_CP14/Trading/CP14AddGlobalReputationSpecial.cs new file mode 100644 index 0000000000..4e04bf5ef4 --- /dev/null +++ b/Content.Shared/_CP14/Trading/CP14AddGlobalReputationSpecial.cs @@ -0,0 +1,24 @@ +using Content.Shared._CP14.Trading.Prototypes; +using Content.Shared._CP14.Trading.Systems; +using Content.Shared.Roles; +using Robust.Shared.Prototypes; + +namespace Content.Shared._CP14.Trading; + +public sealed partial class CP14AddGlobalReputationSpecial : JobSpecial +{ + [DataField] + public float Reputation = 1f; + + public override void AfterEquip(EntityUid mob) + { + var entMan = IoCManager.Resolve(); + var protoMan = IoCManager.Resolve(); + var tradeSys = entMan.System(); + + foreach (var faction in protoMan.EnumeratePrototypes()) + { + tradeSys.AddReputation(mob, faction, Reputation); + } + } +} diff --git a/Content.Shared/_CP14/Trading/Systems/CP14SharedTradingPlatformSystem.cs b/Content.Shared/_CP14/Trading/Systems/CP14SharedTradingPlatformSystem.cs index 00581a9061..4f99f67f77 100644 --- a/Content.Shared/_CP14/Trading/Systems/CP14SharedTradingPlatformSystem.cs +++ b/Content.Shared/_CP14/Trading/Systems/CP14SharedTradingPlatformSystem.cs @@ -79,6 +79,20 @@ public abstract partial class CP14SharedTradingPlatformSystem : EntitySystem return true; } + + public void AddReputation(Entity user, + ProtoId faction, float rep) + { + if (!Resolve(user.Owner, ref user.Comp, false)) + return; + + if (!user.Comp.Reputation.ContainsKey(faction)) + user.Comp.Reputation.Add(faction, rep); + else + user.Comp.Reputation[faction] += rep; + + Dirty(user); + } } [Serializable, NetSerializable] diff --git a/Resources/Prototypes/_CP14/Roles/Jobs/Traders/merchant.yml b/Resources/Prototypes/_CP14/Roles/Jobs/Traders/merchant.yml index b9360edf23..f62212e0cc 100644 --- a/Resources/Prototypes/_CP14/Roles/Jobs/Traders/merchant.yml +++ b/Resources/Prototypes/_CP14/Roles/Jobs/Traders/merchant.yml @@ -10,6 +10,8 @@ requirements: - !type:OverallPlaytimeRequirement time: 3600 # 1 hours + special: + - !type:CP14AddGlobalReputationSpecial - type: startingGear id: CP14MerchantGear