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
!_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));
}
{
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))
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
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);
}
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);
}
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);
var receiverTelephoneEntity = new Entity<TelephoneComponent>(receiver, receiverTelephone);
if (sourceTelephoneEntity == receiverTelephoneEntity ||
- receiverTelephone.UnlistedNumber ||
!_telephoneSystem.IsSourceAbleToReachReceiver(sourceTelephoneEntity, receiverTelephoneEntity))
continue;