]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Mind Swap Fix (#33553)
authorActiveMammmoth <140334666+ActiveMammmoth@users.noreply.github.com>
Tue, 4 Feb 2025 16:25:54 +0000 (11:25 -0500)
committerGitHub <noreply@github.com>
Tue, 4 Feb 2025 16:25:54 +0000 (17:25 +0100)
* 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

Content.Server/Store/Conditions/BuyerAntagCondition.cs
Content.Server/Store/Conditions/BuyerDepartmentCondition.cs
Content.Server/Store/Conditions/BuyerJobCondition.cs
Content.Server/Store/Conditions/BuyerSpeciesCondition.cs
Content.Server/Store/Systems/StoreSystem.cs
Content.Server/Traitor/Uplink/UplinkSystem.cs
Content.Shared/Store/Components/StoreComponent.cs
Resources/Prototypes/Magic/mindswap_spell.yml

index 4b1b6013eb83cef8623a450fafe6459f0f3189a3..0d1c33a61aa722a37621966f485944b77c1330f9 100644 (file)
@@ -27,13 +27,12 @@ public sealed partial class BuyerAntagCondition : ListingCondition
     public override bool Condition(ListingConditionArgs args)
     {
         var ent = args.EntityManager;
-        var minds = ent.System<SharedMindSystem>();
 
-        if (!minds.TryGetMind(args.Buyer, out var mindId, out var mind))
-            return true;
+        if (!ent.HasComponent<MindComponent>(args.Buyer))
+            return true; // inanimate objects don't have minds
 
         var roleSystem = ent.System<SharedRoleSystem>();
-        var roles = roleSystem.MindGetAllRoleInfo(mindId);
+        var roles = roleSystem.MindGetAllRoleInfo(args.Buyer);
 
         if (Blacklist != null)
         {
index 43c06efad3c1d8e9d656a69387a6eeb0d20c3b0b..ce2cb4707368ad7a32eda9e621061e04df6fbbab 100644 (file)
@@ -30,14 +30,12 @@ public sealed partial class BuyerDepartmentCondition : ListingCondition
         var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
 
         var ent = args.EntityManager;
-        var minds = ent.System<SharedMindSystem>();
 
-        // this is for things like surplus crate
-        if (!minds.TryGetMind(args.Buyer, out var mindId, out _))
-            return true;
+        if (!ent.TryGetComponent<MindComponent>(args.Buyer, out var _))
+            return true; // inanimate objects don't have minds
 
         var jobs = ent.System<SharedJobSystem>();
-        jobs.MindTryGetJob(mindId, out var job);
+        jobs.MindTryGetJob(args.Buyer, out var job);
 
         if (Blacklist != null && job != null)
         {
index 1ff4a97c33cea6fc57b17dbc26c49e79a1c302ea..eb452e0dcff64c9ac9a09ee7d76e0ef02083851f 100644 (file)
@@ -27,14 +27,12 @@ public sealed partial class BuyerJobCondition : ListingCondition
     public override bool Condition(ListingConditionArgs args)
     {
         var ent = args.EntityManager;
-        var minds = ent.System<SharedMindSystem>();
 
-        // this is for things like surplus crate
-        if (!minds.TryGetMind(args.Buyer, out var mindId, out _))
-            return true;
+        if (!ent.TryGetComponent<MindComponent>(args.Buyer, out var _))
+            return true; // inanimate objects don't have minds
 
         var jobs = ent.System<SharedJobSystem>();
-        jobs.MindTryGetJob(mindId, out var job);
+        jobs.MindTryGetJob(args.Buyer, out var job);
 
         if (Blacklist != null)
         {
index 1df4fce177f4791df8073bed3c4b023876478bc3..a4f1227eccf88daa17dc3b88feba62f04a4a00ca 100644 (file)
@@ -2,6 +2,7 @@ using Content.Shared.Humanoid;
 using Content.Shared.Store;
 using Content.Shared.Humanoid.Prototypes;
 using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
+using Content.Shared.Mind;
 
 namespace Content.Server.Store.Conditions;
 
@@ -27,7 +28,10 @@ public sealed partial class BuyerSpeciesCondition : ListingCondition
     {
         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
 
         if (Blacklist != null)
index 7bdf550301e64995f8bc224ef81d64b7d7f40753..a57895364dcc5fb6a97af4cfa0410d7510acced6 100644 (file)
@@ -10,6 +10,7 @@ using JetBrains.Annotations;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Utility;
 using System.Linq;
+using Content.Shared.Mind;
 
 namespace Content.Server.Store.Systems;
 
@@ -69,10 +70,13 @@ public sealed partial class StoreSystem : EntitySystem
         if (!component.OwnerOnly)
             return;
 
-        component.AccountOwner ??= args.User;
+        if (!_mind.TryGetMind(args.User, out var mind, out _))
+            return;
+
+        component.AccountOwner ??= mind;
         DebugTools.Assert(component.AccountOwner != null);
 
-        if (component.AccountOwner == args.User)
+        if (component.AccountOwner == mind)
             return;
 
         _popup.PopupEntity(Loc.GetString("store-not-account-owner", ("store", uid)), uid, args.User);
index 4c0a990b148b85e45ba016e20fa7c8dcebe29b94..f30d2d7b4c6736ae2a6620d272caab6909f3f177 100644 (file)
@@ -5,6 +5,7 @@ using Content.Shared.FixedPoint;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Implants;
 using Content.Shared.Inventory;
+using Content.Shared.Mind;
 using Content.Shared.PDA;
 using Content.Shared.Store;
 using Content.Shared.Store.Components;
@@ -19,6 +20,7 @@ public sealed class UplinkSystem : EntitySystem
     [Dependency] private readonly IPrototypeManager _proto = default!;
     [Dependency] private readonly StoreSystem _store = default!;
     [Dependency] private readonly SharedSubdermalImplantSystem _subdermalImplant = default!;
+    [Dependency] private readonly SharedMindSystem _mind = default!;
 
     [ValidatePrototypeId<CurrencyPrototype>]
     public const string TelecrystalCurrencyPrototype = "Telecrystal";
@@ -61,8 +63,12 @@ public sealed class UplinkSystem : EntitySystem
     /// </summary>
     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);
-        store.AccountOwner = user;
+
+        store.AccountOwner = mind;
 
         store.Balance.Clear();
         _store.TryAddCurrency(new Dictionary<string, FixedPoint2> { { TelecrystalCurrencyPrototype, balance } },
@@ -70,10 +76,10 @@ public sealed class UplinkSystem : EntitySystem
             store);
 
         var uplinkInitializedEvent = new StoreInitializedEvent(
-            TargetUser: user,
+            TargetUser: mind,
             Store: uplink,
             UseDiscounts: giveDiscounts,
-            Listings: _store.GetAvailableListings(user, uplink, store)
+            Listings: _store.GetAvailableListings(mind, uplink, store)
                 .ToArray());
         RaiseLocalEvent(ref uplinkInitializedEvent);
     }
index e5171dec418383761124f2603309b011d8f84cc0..19d13e6d052814625ce6051b822141372408e562 100644 (file)
@@ -37,10 +37,10 @@ public sealed partial class StoreComponent : Component
     public HashSet<ProtoId<CurrencyPrototype>> CurrencyWhitelist = new();
 
     /// <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.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public EntityUid? AccountOwner = null;
 
     /// <summary>
index 19b3d41e7078ad80a94f61f96ac30058c9a097f7..bc2a8d11be01814d762bdee5715c3aa4df3d2867 100644 (file)
@@ -9,6 +9,7 @@
     whitelist:
       components:
       - Body
+      - MindContainer
     canTargetSelf: false
     interactOnMiss: false
     sound: !type:SoundPathSpecifier