]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Minor fixes for the holopad (#33969)
authorchromiumboy <50505512+chromiumboy@users.noreply.github.com>
Fri, 20 Dec 2024 10:51:00 +0000 (04:51 -0600)
committerGitHub <noreply@github.com>
Fri, 20 Dec 2024 10:51:00 +0000 (13:51 +0300)
Initial commit

Content.Server/Holopad/HolopadSystem.cs
Content.Server/Telephone/TelephoneSystem.cs
Content.Shared/Telephone/TelephoneComponent.cs
Resources/Locale/en-US/holopad/holopad.ftl

index 549bacc1a84feac121becd380418e8a0a426ee3d..fce71a2cd1599a7d3264836ca54df19b8217c318 100644 (file)
@@ -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<TelephoneComponent>(stationAiCore, out var telephone) &&
-            telephone.CurrentState != TelephoneState.EndingCall && telephone.CurrentState != TelephoneState.Idle)
+        if (TryComp<TelephoneComponent>(stationAiCore, out var telephone))
             _telephoneSystem.EndTelephoneCalls((stationAiCore.Value, telephone));
     }
 
@@ -215,7 +213,8 @@ public sealed class HolopadSystem : SharedHolopadSystem
         {
             var receiver = new Entity<TelephoneComponent>(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<HolopadComponent> entity, ref ComponentShutdown args)
     {
+        if (TryComp<TelephoneComponent>(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<StationAiCoreComponent>(entity, out var stationAiCore))
-        {
             _stationAiSystem.SwitchRemoteEntityMode((entity.Owner, stationAiCore), true);
 
-            if (TryComp<TelephoneComponent>(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<TelephoneComponent>(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<TelephoneComponent>(receiver, receiverTelephone);
 
             if (sourceTelephoneEntity == receiverTelephoneEntity ||
-                receiverTelephone.UnlistedNumber ||
                 !_telephoneSystem.IsSourceAbleToReachReceiver(sourceTelephoneEntity, receiverTelephoneEntity))
                 continue;
 
index b81a72ad230aab7415dbd202cb89eaca1e008301..d4398c76d3f487f9bc604b97f89754c9e9e0e292 100644 (file)
@@ -194,7 +194,7 @@ public sealed class TelephoneSystem : SharedTelephoneSystem
 
     private bool TryCallTelephone(Entity<TelephoneComponent> source, Entity<TelephoneComponent> receiver, EntityUid user, TelephoneCallOptions? options = null)
     {
-        if (!IsSourceAbleToReachReceiver(source, receiver))
+        if (!IsSourceAbleToReachReceiver(source, receiver) && options?.IgnoreRange != true)
             return false;
 
         if (IsTelephoneEngaged(receiver) &&
index 733ddfbdce2e51e839d038ec43fab0c9eeb2100b..530748f4d37492762f2b17b125bee601214d5467 100644 (file)
@@ -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'
index 47c5fbe25cf3954c66233a17229367b75845cad1..9e3401dd4b977ab7ccf0ee825b9d8cd36bd0d3da 100644 (file)
@@ -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