MindSystem.cs 963 B

123456789101112131415161718192021222324252627
  1. using Content.Shared.Mind;
  2. namespace Content.Client.Mind;
  3. public sealed class MindSystem : SharedMindSystem
  4. {
  5. public override void Initialize()
  6. {
  7. base.Initialize();
  8. SubscribeLocalEvent<MindComponent, AfterAutoHandleStateEvent>(OnHandleState);
  9. }
  10. private void OnHandleState(EntityUid uid, MindComponent component, ref AfterAutoHandleStateEvent args)
  11. {
  12. // Because minds are generally not networked, there might be weird situations were a client thinks multiple
  13. // users share a mind? E.g., if an admin periodical gets sent all minds via some PVS override, but doesn't get
  14. // sent intermediate states? Not sure if this is actually possible, but better to be safe.
  15. foreach (var (user, mind) in UserMinds)
  16. {
  17. if (mind == uid)
  18. UserMinds.Remove(user);
  19. }
  20. if (component.UserId != null)
  21. UserMinds[component.UserId.Value] = uid;
  22. }
  23. }