Merge remote-tracking branch 'upstream/stable' into ed-311-03-2025-upstream-2
# Conflicts: # Content.Client/Administration/AdminNameOverlay.cs # Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml # Content.Client/Guidebook/Controls/GuideReagentReaction.xaml # Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs # Content.Client/SubFloor/SubFloorHideSystem.cs # Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs # Content.Server/Antag/AntagSelectionSystem.cs # Content.Server/Cloning/CloningSystem.cs # Content.Server/GameTicking/Rules/Components/ParadoxCloneRuleComponent.cs # Content.Server/GameTicking/Rules/ParadoxCloneRuleSystem.cs # Content.Server/Roles/ParadoxCloneRoleComponent.cs # Content.Shared.Database/LogType.cs # Content.Shared/CCVar/CCVars.Interface.cs # Content.Shared/Cloning/CloningEvents.cs # Content.Shared/Cloning/CloningSettingsPrototype.cs # Content.Shared/Humanoid/NamingSystem.cs # Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs # Content.Shared/Light/Components/SunShadowCycleComponent.cs # Content.Shared/Storage/StorageComponent.cs # Resources/Changelog/Admin.yml # Resources/Changelog/Changelog.yml # Resources/Credits/GitHub.txt # Resources/Locale/en-US/paradox-clone/role.ftl # Resources/Maps/bagel.yml # Resources/Maps/loop.yml # Resources/Prototypes/Chemistry/mixing_types.yml # Resources/Prototypes/Datasets/Names/last.yml # Resources/Prototypes/Entities/Effects/puddle.yml # Resources/Prototypes/Entities/Mobs/Player/clone.yml # Resources/Prototypes/Entities/Mobs/Species/base.yml # Resources/Prototypes/Entities/Objects/Deliveries/deliveries_tables.yml # Resources/Prototypes/Entities/Objects/Devices/pda.yml # Resources/Prototypes/Entities/Objects/Tools/handheld_mass_scanner.yml # Resources/Prototypes/GameRules/events.yml # Resources/Prototypes/Maps/Pools/default.yml # Resources/Prototypes/Objectives/paradoxClone.yml # Resources/Prototypes/Reagents/Consumable/Drink/alcohol.yml # Resources/Textures/Clothing/Eyes/Glasses/jensen.rsi/equipped-EYES-arachnid.png
This commit is contained in:
@@ -11,6 +11,7 @@ using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Objectives.Systems;
|
||||
using Content.Shared.Players;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
@@ -18,7 +19,7 @@ using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Mind;
|
||||
|
||||
public abstract class SharedMindSystem : EntitySystem
|
||||
public abstract partial class SharedMindSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly INetManager _net = default!;
|
||||
@@ -26,6 +27,7 @@ public abstract class SharedMindSystem : EntitySystem
|
||||
[Dependency] private readonly SharedObjectivesSystem _objectives = default!;
|
||||
[Dependency] private readonly SharedPlayerSystem _player = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metadata = default!;
|
||||
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
|
||||
|
||||
[ViewVariables]
|
||||
protected readonly Dictionary<NetUserId, EntityUid> UserMinds = new();
|
||||
@@ -40,6 +42,8 @@ public abstract class SharedMindSystem : EntitySystem
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnReset);
|
||||
SubscribeLocalEvent<MindComponent, ComponentStartup>(OnMindStartup);
|
||||
SubscribeLocalEvent<MindComponent, EntityRenamedEvent>(OnRenamed);
|
||||
|
||||
InitializeRelay();
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
@@ -378,6 +382,16 @@ public abstract class SharedMindSystem : EntitySystem
|
||||
var title = Name(objective);
|
||||
_adminLogger.Add(LogType.Mind, LogImpact.Low, $"Objective {objective} ({title}) removed from the mind of {MindOwnerLoggingString(mind)}");
|
||||
mind.Objectives.Remove(objective);
|
||||
|
||||
// garbage collection - only delete the objective entity if no mind uses it anymore
|
||||
// This comes up for stuff like paradox clones where the objectives share the same entity
|
||||
var mindQuery = new AllEntityQueryEnumerator<MindComponent>();
|
||||
while (mindQuery.MoveNext(out _, out var queryComp))
|
||||
{
|
||||
if (queryComp.Objectives.Contains(objective))
|
||||
return true;
|
||||
}
|
||||
|
||||
Del(objective);
|
||||
return true;
|
||||
}
|
||||
@@ -409,6 +423,33 @@ public abstract class SharedMindSystem : EntitySystem
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies objectives from one mind to another, so that they are shared between two players.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only copies the reference to the objective entity, not the entity itself.
|
||||
/// This relies on the fact that objectives are never changed after spawning them.
|
||||
/// If someone ever changes that, they will have to address this.
|
||||
/// </remarks>
|
||||
/// <param name="source"> mind entity of the player to copy from </param>
|
||||
/// <param name="target"> mind entity of the player to copy to </param>
|
||||
/// <param name="except"> whitelist for objectives that should be copied </param>
|
||||
/// <param name="except"> blacklist for objectives that should not be copied </param>
|
||||
public void CopyObjectives(Entity<MindComponent?> source, Entity<MindComponent?> target, EntityWhitelist? whitelist = null, EntityWhitelist? blacklist = null)
|
||||
{
|
||||
if (!Resolve(source, ref source.Comp) || !Resolve(target, ref target.Comp))
|
||||
return;
|
||||
|
||||
foreach (var objective in source.Comp.Objectives)
|
||||
{
|
||||
if (target.Comp.Objectives.Contains(objective))
|
||||
continue; // target already has this objective
|
||||
|
||||
if (_whitelist.CheckBoth(objective, blacklist, whitelist))
|
||||
AddObjective(target, target.Comp, objective);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to find an objective that has the same prototype as the argument.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user