From 39600f9516bbb6e53fd2ccda3a13855195629086 Mon Sep 17 00:00:00 2001 From: chromiumboy <50505512+chromiumboy@users.noreply.github.com> Date: Fri, 20 Dec 2024 04:51:00 -0600 Subject: [PATCH] Minor fixes for the holopad (#33969) Initial commit --- Content.Server/Holopad/HolopadSystem.cs | 30 +++++++++---------- Content.Server/Telephone/TelephoneSystem.cs | 2 +- .../Telephone/TelephoneComponent.cs | 1 + Resources/Locale/en-US/holopad/holopad.ftl | 1 + 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Content.Server/Holopad/HolopadSystem.cs b/Content.Server/Holopad/HolopadSystem.cs index 549bacc1a8..fce71a2cd1 100644 --- a/Content.Server/Holopad/HolopadSystem.cs +++ b/Content.Server/Holopad/HolopadSystem.cs @@ -151,8 +151,7 @@ public sealed class HolopadSystem : SharedHolopadSystem if (IsHolopadControlLocked(entity, args.Actor)) return; - if (entityTelephone.CurrentState != TelephoneState.EndingCall && entityTelephone.CurrentState != TelephoneState.Idle) - _telephoneSystem.EndTelephoneCalls((entity, entityTelephone)); + _telephoneSystem.EndTelephoneCalls((entity, entityTelephone)); // If the user is an AI, end all calls originating from its // associated core to ensure that any broadcasts will end @@ -160,8 +159,7 @@ public sealed class HolopadSystem : SharedHolopadSystem !_stationAiSystem.TryGetStationAiCore((args.Actor, stationAiHeld), out var stationAiCore)) return; - if (TryComp(stationAiCore, out var telephone) && - telephone.CurrentState != TelephoneState.EndingCall && telephone.CurrentState != TelephoneState.Idle) + if (TryComp(stationAiCore, out var telephone)) _telephoneSystem.EndTelephoneCalls((stationAiCore.Value, telephone)); } @@ -215,7 +213,8 @@ public sealed class HolopadSystem : SharedHolopadSystem { var receiver = new Entity(receiverUid, receiverTelephone); - if (!_telephoneSystem.IsSourceAbleToReachReceiver(source, receiver)) + // Check if the core can reach the call source, rather than the other way around + if (!_telephoneSystem.IsSourceAbleToReachReceiver(receiver, source)) continue; if (_telephoneSystem.IsTelephoneEngaged(receiver)) @@ -230,10 +229,9 @@ public sealed class HolopadSystem : SharedHolopadSystem LinkHolopadToUser(entity, args.Actor); } - if (!reachableAiCores.Any()) - return; - - _telephoneSystem.BroadcastCallToTelephones(source, reachableAiCores, args.Actor); + // Ignore range so that holopads that ignore other devices on the same grid can request the AI + var options = new TelephoneCallOptions { IgnoreRange = true }; + _telephoneSystem.BroadcastCallToTelephones(source, reachableAiCores, args.Actor, options); } #endregion @@ -354,6 +352,9 @@ public sealed class HolopadSystem : SharedHolopadSystem private void OnHolopadShutdown(Entity entity, ref ComponentShutdown args) { + if (TryComp(entity, out var telphone) && _telephoneSystem.IsTelephoneEngaged((entity.Owner, telphone))) + _telephoneSystem.EndTelephoneCalls((entity, telphone)); + ShutDownHolopad(entity); SetHolopadAmbientState(entity, false); } @@ -610,14 +611,8 @@ public sealed class HolopadSystem : SharedHolopadSystem UnlinkHolopadFromUser(entity, entity.Comp.User.Value); if (TryComp(entity, out var stationAiCore)) - { _stationAiSystem.SwitchRemoteEntityMode((entity.Owner, stationAiCore), true); - if (TryComp(entity, out var stationAiCoreTelphone) && - stationAiCoreTelphone.CurrentState != TelephoneState.EndingCall && stationAiCoreTelphone.CurrentState != TelephoneState.Idle) - _telephoneSystem.EndTelephoneCalls((entity, stationAiCoreTelphone)); - } - Dirty(entity); } @@ -668,8 +663,12 @@ public sealed class HolopadSystem : SharedHolopadSystem var source = new Entity(stationAiCore.Value, stationAiTelephone); + // Check if the AI is unable to activate the projector (unlikely this will ever pass; its just a safeguard) if (!_telephoneSystem.IsSourceInRangeOfReceiver(source, receiver)) + { + _popupSystem.PopupEntity(Loc.GetString("holopad-ai-is-unable-to-activate-projector"), receiver, user); return; + } // Terminate any calls that the core is hosting and immediately connect to the receiver _telephoneSystem.TerminateTelephoneCalls(source); @@ -714,7 +713,6 @@ public sealed class HolopadSystem : SharedHolopadSystem var receiverTelephoneEntity = new Entity(receiver, receiverTelephone); if (sourceTelephoneEntity == receiverTelephoneEntity || - receiverTelephone.UnlistedNumber || !_telephoneSystem.IsSourceAbleToReachReceiver(sourceTelephoneEntity, receiverTelephoneEntity)) continue; diff --git a/Content.Server/Telephone/TelephoneSystem.cs b/Content.Server/Telephone/TelephoneSystem.cs index b81a72ad23..d4398c76d3 100644 --- a/Content.Server/Telephone/TelephoneSystem.cs +++ b/Content.Server/Telephone/TelephoneSystem.cs @@ -194,7 +194,7 @@ public sealed class TelephoneSystem : SharedTelephoneSystem private bool TryCallTelephone(Entity source, Entity receiver, EntityUid user, TelephoneCallOptions? options = null) { - if (!IsSourceAbleToReachReceiver(source, receiver)) + if (!IsSourceAbleToReachReceiver(source, receiver) && options?.IgnoreRange != true) return false; if (IsTelephoneEngaged(receiver) && diff --git a/Content.Shared/Telephone/TelephoneComponent.cs b/Content.Shared/Telephone/TelephoneComponent.cs index 733ddfbdce..530748f4d3 100644 --- a/Content.Shared/Telephone/TelephoneComponent.cs +++ b/Content.Shared/Telephone/TelephoneComponent.cs @@ -181,6 +181,7 @@ public readonly record struct TelephoneMessageReceivedEvent(string Message, MsgC [Serializable, NetSerializable] public struct TelephoneCallOptions { + public bool IgnoreRange; // The source can always reach its target public bool ForceConnect; // The source immediately starts a call with the receiver, potentially interrupting a call that is already in progress public bool ForceJoin; // The source smoothly joins a call in progress, or starts a normal call with the receiver if there is none public bool MuteSource; // Chatter from the source is not transmitted - could be used for eavesdropping when combined with 'ForceJoin' diff --git a/Resources/Locale/en-US/holopad/holopad.ftl b/Resources/Locale/en-US/holopad/holopad.ftl index 47c5fbe25c..9e3401dd4b 100644 --- a/Resources/Locale/en-US/holopad/holopad.ftl +++ b/Resources/Locale/en-US/holopad/holopad.ftl @@ -39,6 +39,7 @@ holopad-hologram-name = hologram of {THE($name)} # Holopad actions holopad-activate-projector-verb = Activate holopad projector holopad-ai-is-unable-to-reach-holopad = You are unable to interface with the source of the call, it is too far from your core. +holopad-ai-is-unable-to-activate-projector = You are unable to activate the holopad's projector, it is too far from your core. # Mapping prototypes # General -- 2.51.2