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:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user