Minor fixes for the holopad (#33969)

Initial commit
This commit is contained in:
chromiumboy
2024-12-20 04:51:00 -06:00
committed by GitHub
parent 7f2907a93a
commit 39600f9516
4 changed files with 17 additions and 17 deletions

View 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;

View 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) &&

View 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'

View 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