Skip to content

Commit

Permalink
extracted ShowDeviceNotRespondingPopup, reverted airlocks not opening…
Browse files Browse the repository at this point in the history
…/closing when ai wire was cut
  • Loading branch information
pa.pecherskij committed Sep 12, 2024
1 parent 7483434 commit 0b81947
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ private void OnAirlockBolt(EntityUid ent, DoorBoltComponent component, StationAi
{
if (component.BoltWireCut)
{
_popup.PopupClient(Loc.GetString("ai-device-not-responding"), args.User, PopupType.MediumCaution);
ShowDeviceNotRespondingPopup(args.User);
return;
}

var setResult = _doors.TrySetBoltDown((ent, component), args.Bolted, args.User, predicted: true);
if (!setResult)
{
_popup.PopupClient(Loc.GetString("ai-device-not-responding"), args.User, PopupType.MediumCaution);
ShowDeviceNotRespondingPopup(args.User);
}
}

Expand All @@ -45,7 +45,7 @@ private void OnAirlockEmergencyAccess(EntityUid ent, AirlockComponent component,
{
if (!PowerReceiver.IsPowered(ent))
{
_popup.PopupClient(Loc.GetString("ai-device-not-responding"), args.User, PopupType.MediumCaution);
ShowDeviceNotRespondingPopup(args.User);
return;
}

Expand All @@ -67,7 +67,7 @@ private void OnElectrified(EntityUid ent, ElectrifiedComponent component, Statio
|| !PowerReceiver.IsPowered(ent)
)
{
_popup.PopupClient(Loc.GetString("ai-device-not-responding"), args.User, PopupType.MediumCaution);
ShowDeviceNotRespondingPopup(args.User);
return;
}

Expand Down
25 changes: 18 additions & 7 deletions Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,22 @@ private void OnMessageAttempt(BoundUserInterfaceMessageAttempt ev)
if (whitelistComponent is { Enabled: false })
{
ev.Cancel();
_popup.PopupClient(Loc.GetString("ai-device-not-responding"), ev.Actor, PopupType.MediumCaution);
ShowDeviceNotRespondingPopup(ev.Actor);
}
}

private void OnHeldInteraction(Entity<StationAiHeldComponent> ent, ref InteractionAttemptEvent args)
{
// Cancel if it's not us or something with a whitelist.
args.Cancelled = ent.Owner != args.Target &&
args.Target != null &&
!HasComp<StationAiWhitelistComponent>(args.Target);
StationAiWhitelistComponent? whitelistComponent = null;
// Cancel if it's not us or something with a whitelist, or whitelist is disabled.
args.Cancelled = ent.Owner != args.Target
&& args.Target != null
&& (!TryComp(args.Target, out whitelistComponent)
|| !whitelistComponent.Enabled);
if (whitelistComponent is { Enabled: false })
{
ShowDeviceNotRespondingPopup(ent.Owner);
}
}

private void OnTargetVerbs(Entity<StationAiWhitelistComponent> ent, ref GetVerbsEvent<AlternativeVerb> args)
Expand All @@ -143,7 +149,7 @@ private void OnTargetVerbs(Entity<StationAiWhitelistComponent> ent, ref GetVerbs
var user = args.User;
if (!ent.Comp.Enabled)
{
_popup.PopupClient(Loc.GetString("ai-device-not-responding"), user, PopupType.MediumCaution);
ShowDeviceNotRespondingPopup(user);
return;
}

Expand All @@ -159,7 +165,7 @@ private void OnTargetVerbs(Entity<StationAiWhitelistComponent> ent, ref GetVerbs
// no need to show menu if device is not powered.
if (!PowerReceiver.IsPowered(ent.Owner))
{
_popup.PopupClient(Loc.GetString("ai-device-not-responding"), user, PopupType.MediumCaution);
ShowDeviceNotRespondingPopup(user);
return;
}
Expand All @@ -175,6 +181,11 @@ private void OnTargetVerbs(Entity<StationAiWhitelistComponent> ent, ref GetVerbs
};
args.Verbs.Add(verb);
}

private void ShowDeviceNotRespondingPopup(EntityUid toEntity)
{
_popup.PopupClient(Loc.GetString("ai-device-not-responding"), toEntity, PopupType.MediumCaution);
}
}

/// <summary>
Expand Down

0 comments on commit 0b81947

Please sign in to comment.