Mind Swap Fix (#33553)

* Stores owned by mind instead of body

* Requested changes, traitor uplink fixed

* Store, listings fixed and now use Entity<MindComponent>

* Removed duplicate code

* test change

* test change 2

* back to mind entityuid

* MilonPL requested minor changes

* ScarKy0 requested changes
This commit is contained in:
ActiveMammmoth
2025-02-04 11:25:54 -05:00
committed by GitHub
parent 1d5b01190d
commit 6a017ef17b
8 changed files with 32 additions and 22 deletions

View File

@@ -27,13 +27,12 @@ public sealed partial class BuyerAntagCondition : ListingCondition
public override bool Condition(ListingConditionArgs args) public override bool Condition(ListingConditionArgs args)
{ {
var ent = args.EntityManager; var ent = args.EntityManager;
var minds = ent.System<SharedMindSystem>();
if (!minds.TryGetMind(args.Buyer, out var mindId, out var mind)) if (!ent.HasComponent<MindComponent>(args.Buyer))
return true; return true; // inanimate objects don't have minds
var roleSystem = ent.System<SharedRoleSystem>(); var roleSystem = ent.System<SharedRoleSystem>();
var roles = roleSystem.MindGetAllRoleInfo(mindId); var roles = roleSystem.MindGetAllRoleInfo(args.Buyer);
if (Blacklist != null) if (Blacklist != null)
{ {

View File

@@ -30,14 +30,12 @@ public sealed partial class BuyerDepartmentCondition : ListingCondition
var prototypeManager = IoCManager.Resolve<IPrototypeManager>(); var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var ent = args.EntityManager; var ent = args.EntityManager;
var minds = ent.System<SharedMindSystem>();
// this is for things like surplus crate if (!ent.TryGetComponent<MindComponent>(args.Buyer, out var _))
if (!minds.TryGetMind(args.Buyer, out var mindId, out _)) return true; // inanimate objects don't have minds
return true;
var jobs = ent.System<SharedJobSystem>(); var jobs = ent.System<SharedJobSystem>();
jobs.MindTryGetJob(mindId, out var job); jobs.MindTryGetJob(args.Buyer, out var job);
if (Blacklist != null && job != null) if (Blacklist != null && job != null)
{ {

View File

@@ -27,14 +27,12 @@ public sealed partial class BuyerJobCondition : ListingCondition
public override bool Condition(ListingConditionArgs args) public override bool Condition(ListingConditionArgs args)
{ {
var ent = args.EntityManager; var ent = args.EntityManager;
var minds = ent.System<SharedMindSystem>();
// this is for things like surplus crate if (!ent.TryGetComponent<MindComponent>(args.Buyer, out var _))
if (!minds.TryGetMind(args.Buyer, out var mindId, out _)) return true; // inanimate objects don't have minds
return true;
var jobs = ent.System<SharedJobSystem>(); var jobs = ent.System<SharedJobSystem>();
jobs.MindTryGetJob(mindId, out var job); jobs.MindTryGetJob(args.Buyer, out var job);
if (Blacklist != null) if (Blacklist != null)
{ {

View File

@@ -2,6 +2,7 @@ using Content.Shared.Humanoid;
using Content.Shared.Store; using Content.Shared.Store;
using Content.Shared.Humanoid.Prototypes; using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
using Content.Shared.Mind;
namespace Content.Server.Store.Conditions; namespace Content.Server.Store.Conditions;
@@ -27,7 +28,10 @@ public sealed partial class BuyerSpeciesCondition : ListingCondition
{ {
var ent = args.EntityManager; var ent = args.EntityManager;
if (!ent.TryGetComponent<HumanoidAppearanceComponent>(args.Buyer, out var appearance)) if (!ent.TryGetComponent<MindComponent>(args.Buyer, out var mind))
return true; // needed to obtain body entityuid to check for humanoid appearance
if (!ent.TryGetComponent<HumanoidAppearanceComponent>(mind.OwnedEntity, out var appearance))
return true; // inanimate or non-humanoid entities should be handled elsewhere, main example being surplus crates return true; // inanimate or non-humanoid entities should be handled elsewhere, main example being surplus crates
if (Blacklist != null) if (Blacklist != null)

View File

@@ -10,6 +10,7 @@ using JetBrains.Annotations;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using System.Linq; using System.Linq;
using Content.Shared.Mind;
namespace Content.Server.Store.Systems; namespace Content.Server.Store.Systems;
@@ -69,10 +70,13 @@ public sealed partial class StoreSystem : EntitySystem
if (!component.OwnerOnly) if (!component.OwnerOnly)
return; return;
component.AccountOwner ??= args.User; if (!_mind.TryGetMind(args.User, out var mind, out _))
return;
component.AccountOwner ??= mind;
DebugTools.Assert(component.AccountOwner != null); DebugTools.Assert(component.AccountOwner != null);
if (component.AccountOwner == args.User) if (component.AccountOwner == mind)
return; return;
_popup.PopupEntity(Loc.GetString("store-not-account-owner", ("store", uid)), uid, args.User); _popup.PopupEntity(Loc.GetString("store-not-account-owner", ("store", uid)), uid, args.User);

View File

@@ -5,6 +5,7 @@ using Content.Shared.FixedPoint;
using Content.Shared.Hands.EntitySystems; using Content.Shared.Hands.EntitySystems;
using Content.Shared.Implants; using Content.Shared.Implants;
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Content.Shared.Mind;
using Content.Shared.PDA; using Content.Shared.PDA;
using Content.Shared.Store; using Content.Shared.Store;
using Content.Shared.Store.Components; using Content.Shared.Store.Components;
@@ -19,6 +20,7 @@ public sealed class UplinkSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _proto = default!; [Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly StoreSystem _store = default!; [Dependency] private readonly StoreSystem _store = default!;
[Dependency] private readonly SharedSubdermalImplantSystem _subdermalImplant = default!; [Dependency] private readonly SharedSubdermalImplantSystem _subdermalImplant = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[ValidatePrototypeId<CurrencyPrototype>] [ValidatePrototypeId<CurrencyPrototype>]
public const string TelecrystalCurrencyPrototype = "Telecrystal"; public const string TelecrystalCurrencyPrototype = "Telecrystal";
@@ -61,8 +63,12 @@ public sealed class UplinkSystem : EntitySystem
/// </summary> /// </summary>
private void SetUplink(EntityUid user, EntityUid uplink, FixedPoint2 balance, bool giveDiscounts) private void SetUplink(EntityUid user, EntityUid uplink, FixedPoint2 balance, bool giveDiscounts)
{ {
if (!_mind.TryGetMind(user, out var mind, out _))
return;
var store = EnsureComp<StoreComponent>(uplink); var store = EnsureComp<StoreComponent>(uplink);
store.AccountOwner = user;
store.AccountOwner = mind;
store.Balance.Clear(); store.Balance.Clear();
_store.TryAddCurrency(new Dictionary<string, FixedPoint2> { { TelecrystalCurrencyPrototype, balance } }, _store.TryAddCurrency(new Dictionary<string, FixedPoint2> { { TelecrystalCurrencyPrototype, balance } },
@@ -70,10 +76,10 @@ public sealed class UplinkSystem : EntitySystem
store); store);
var uplinkInitializedEvent = new StoreInitializedEvent( var uplinkInitializedEvent = new StoreInitializedEvent(
TargetUser: user, TargetUser: mind,
Store: uplink, Store: uplink,
UseDiscounts: giveDiscounts, UseDiscounts: giveDiscounts,
Listings: _store.GetAvailableListings(user, uplink, store) Listings: _store.GetAvailableListings(mind, uplink, store)
.ToArray()); .ToArray());
RaiseLocalEvent(ref uplinkInitializedEvent); RaiseLocalEvent(ref uplinkInitializedEvent);
} }

View File

@@ -37,10 +37,10 @@ public sealed partial class StoreComponent : Component
public HashSet<ProtoId<CurrencyPrototype>> CurrencyWhitelist = new(); public HashSet<ProtoId<CurrencyPrototype>> CurrencyWhitelist = new();
/// <summary> /// <summary>
/// The person who "owns" the store/account. Used if you want the listings to be fixed /// The person/mind who "owns" the store/account. Used if you want the listings to be fixed
/// regardless of who activated it. I.E. role specific items for uplinks. /// regardless of who activated it. I.E. role specific items for uplinks.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [DataField]
public EntityUid? AccountOwner = null; public EntityUid? AccountOwner = null;
/// <summary> /// <summary>

View File

@@ -9,6 +9,7 @@
whitelist: whitelist:
components: components:
- Body - Body
- MindContainer
canTargetSelf: false canTargetSelf: false
interactOnMiss: false interactOnMiss: false
sound: !type:SoundPathSpecifier sound: !type:SoundPathSpecifier