This commit is contained in:
Red
2025-06-03 18:12:44 +03:00
committed by GitHub
parent f47c94fc08
commit c41f20706e
4 changed files with 42 additions and 2 deletions

View File

@@ -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<IEntityManager>();
var protoMan = IoCManager.Resolve<IPrototypeManager>();
var tradeSys = entMan.System<CP14SharedTradingPlatformSystem>();
foreach (var faction in protoMan.EnumeratePrototypes<CP14TradingFactionPrototype>())
{
tradeSys.AddReputation(mob, faction, Reputation);
}
}
}

View File

@@ -79,6 +79,20 @@ public abstract partial class CP14SharedTradingPlatformSystem : EntitySystem
return true;
}
public void AddReputation(Entity<CP14TradingReputationComponent?> user,
ProtoId<CP14TradingFactionPrototype> 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]