Tweaks for the holopad (#33928)

* Initial commit

* AIs get a warning when trying to answer long distance calls

* Better handling of ending telephone calls

* Fixed issue with duplicated holopad window when an AI answers a summons

* Changed how ranges are handled, added the bluespace holopad

* Bug fixes

* More bug fixes

* More bug fixes

* Update Resources/Prototypes/Entities/Structures/Machines/holopad.yml

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Resources/Prototypes/Entities/Structures/Machines/holopad.yml

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
chromiumboy
2024-12-19 11:20:20 -06:00
committed by GitHub
parent 25980d8888
commit 209c1769ee
6 changed files with 105 additions and 34 deletions

View File

@@ -277,6 +277,10 @@ public sealed class TelephoneSystem : SharedTelephoneSystem
public void EndTelephoneCalls(Entity<TelephoneComponent> entity)
{
// No need to end any calls if the telephone is already ending a call
if (entity.Comp.CurrentState == TelephoneState.EndingCall)
return;
HandleEndingTelephoneCalls(entity, TelephoneState.EndingCall);
var ev = new TelephoneCallEndedEvent();
@@ -285,14 +289,15 @@ public sealed class TelephoneSystem : SharedTelephoneSystem
public void TerminateTelephoneCalls(Entity<TelephoneComponent> entity)
{
// No need to terminate any calls if the telephone is idle
if (entity.Comp.CurrentState == TelephoneState.Idle)
return;
HandleEndingTelephoneCalls(entity, TelephoneState.Idle);
}
private void HandleEndingTelephoneCalls(Entity<TelephoneComponent> entity, TelephoneState newState)
{
if (entity.Comp.CurrentState == newState)
return;
foreach (var linkedTelephone in entity.Comp.LinkedTelephones)
{
if (!linkedTelephone.Comp.LinkedTelephones.Remove(entity))
@@ -431,23 +436,26 @@ public sealed class TelephoneSystem : SharedTelephoneSystem
public bool IsSourceInRangeOfReceiver(Entity<TelephoneComponent> source, Entity<TelephoneComponent> receiver)
{
// Check if the source and receiver have compatible transmision / reception bandwidths
if (!source.Comp.CompatibleRanges.Contains(receiver.Comp.TransmissionRange))
return false;
var sourceXform = Transform(source);
var receiverXform = Transform(receiver);
// Check if we should ignore a device thats on the same grid
if (source.Comp.IgnoreTelephonesOnSameGrid &&
source.Comp.TransmissionRange != TelephoneRange.Grid &&
receiverXform.GridUid == sourceXform.GridUid)
return false;
switch (source.Comp.TransmissionRange)
{
case TelephoneRange.Grid:
return sourceXform.GridUid != null &&
receiverXform.GridUid == sourceXform.GridUid &&
receiver.Comp.TransmissionRange != TelephoneRange.Long;
return sourceXform.GridUid == receiverXform.GridUid;
case TelephoneRange.Map:
return sourceXform.MapID == receiverXform.MapID &&
receiver.Comp.TransmissionRange != TelephoneRange.Long;
case TelephoneRange.Long:
return sourceXform.MapID != receiverXform.MapID &&
receiver.Comp.TransmissionRange == TelephoneRange.Long;
return sourceXform.MapID == receiverXform.MapID;
case TelephoneRange.Unlimited:
return true;