From df487ea4fe6a8117a7e6beca4df85bf5ec255720 Mon Sep 17 00:00:00 2001 From: chromiumboy <50505512+chromiumboy@users.noreply.github.com> Date: Thu, 2 Jan 2025 05:27:18 -0600 Subject: [PATCH] Bugfix for the AI player's eye getting stuck when their broadcast is interrupted (#34093) Initial commit --- Content.Server/Holopad/HolopadSystem.cs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Content.Server/Holopad/HolopadSystem.cs b/Content.Server/Holopad/HolopadSystem.cs index 4cf0bf4bfd..fabf642ad3 100644 --- a/Content.Server/Holopad/HolopadSystem.cs +++ b/Content.Server/Holopad/HolopadSystem.cs @@ -179,11 +179,15 @@ public sealed class HolopadSystem : SharedHolopadSystem // AI broadcasting if (TryComp(args.Actor, out var stationAiHeld)) { + // Link the AI to the holopad they are broadcasting from + LinkHolopadToUser(source, args.Actor); + if (!_stationAiSystem.TryGetStationAiCore((args.Actor, stationAiHeld), out var stationAiCore) || stationAiCore.Value.Comp.RemoteEntity == null || !TryComp(stationAiCore, out var stationAiCoreHolopad)) return; + // Execute the broadcast, but have it originate from the AI core ExecuteBroadcast((stationAiCore.Value, stationAiCoreHolopad), args.Actor); // Switch the AI's perspective from free roaming to the target holopad @@ -611,10 +615,25 @@ public sealed class HolopadSystem : SharedHolopadSystem DeleteHologram(entity.Comp.Hologram.Value, entity); if (entity.Comp.User != null) - UnlinkHolopadFromUser(entity, entity.Comp.User.Value); + { + // Check if the associated holopad user is an AI + if (TryComp(entity.Comp.User, out var stationAiHeld) && + _stationAiSystem.TryGetStationAiCore((entity.Comp.User.Value, stationAiHeld), out var stationAiCore)) + { + // Return the AI eye to free roaming + _stationAiSystem.SwitchRemoteEntityMode(stationAiCore.Value, true); + + // If the AI core is still broadcasting, end its calls + if (entity.Owner != stationAiCore.Value.Owner && + TryComp(stationAiCore, out var stationAiCoreTelephone) && + _telephoneSystem.IsTelephoneEngaged((stationAiCore.Value.Owner, stationAiCoreTelephone))) + { + _telephoneSystem.EndTelephoneCalls((stationAiCore.Value.Owner, stationAiCoreTelephone)); + } + } - if (TryComp(entity, out var stationAiCore)) - _stationAiSystem.SwitchRemoteEntityMode((entity.Owner, stationAiCore), true); + UnlinkHolopadFromUser(entity, entity.Comp.User.Value); + } Dirty(entity); } -- 2.51.2