DoAfter & misc interaction fixes (#15144)

This commit is contained in:
Leon Friedrich
2023-04-05 12:19:28 +12:00
committed by GitHub
parent f254af53bb
commit b9b8180131
4 changed files with 38 additions and 36 deletions

View File

@@ -92,8 +92,20 @@ public sealed class EncryptionKeySystem : EntitySystem
if ( args.Handled || !TryComp<ContainerManagerComponent>(uid, out var storage))
return;
args.Handled = true;
if (HasComp<EncryptionKeyComponent>(args.Used))
{
args.Handled = true;
TryInsertKey(uid, component, args);
}
else if (TryComp<ToolComponent>(args.Used, out var tool) && tool.Qualities.Contains(component.KeysExtractionMethod))
{
args.Handled = true;
TryRemoveKey(uid, component, args, tool);
}
}
private void TryInsertKey(EntityUid uid, EncryptionKeyHolderComponent component, InteractUsingEvent args)
{
if (!component.KeysUnlocked)
{
if (_net.IsClient && _timing.IsFirstTimePredicted)
@@ -101,18 +113,6 @@ public sealed class EncryptionKeySystem : EntitySystem
return;
}
if (TryComp<EncryptionKeyComponent>(args.Used, out var key))
{
TryInsertKey(uid, component, args);
}
else
{
TryRemoveKey(uid, component, args);
}
}
private void TryInsertKey(EntityUid uid, EncryptionKeyHolderComponent component, InteractUsingEvent args)
{
if (TryComp<WiresPanelComponent>(uid, out var panel) && !panel.Open)
{
if (_net.IsClient && _timing.IsFirstTimePredicted)
@@ -137,10 +137,15 @@ public sealed class EncryptionKeySystem : EntitySystem
}
}
private void TryRemoveKey(EntityUid uid, EncryptionKeyHolderComponent component, InteractUsingEvent args)
private void TryRemoveKey(EntityUid uid, EncryptionKeyHolderComponent component, InteractUsingEvent args,
ToolComponent? tool)
{
if (!TryComp<ToolComponent>(args.Used, out var tool) || !tool.Qualities.Contains(component.KeysExtractionMethod))
if (!component.KeysUnlocked)
{
if (_net.IsClient && _timing.IsFirstTimePredicted)
_popup.PopupEntity(Loc.GetString("encryption-keys-are-locked"), uid, args.User);
return;
}
if (TryComp<WiresPanelComponent>(uid, out var panel) && !panel.Open)
{