DoAfter & misc interaction fixes (#15144)
This commit is contained in:
@@ -7,6 +7,7 @@ using Content.Shared.Construction;
|
|||||||
using Content.Shared.Construction.Steps;
|
using Content.Shared.Construction.Steps;
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Radio.EntitySystems;
|
||||||
using Content.Shared.Tools.Components;
|
using Content.Shared.Tools.Components;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
@@ -30,13 +31,20 @@ namespace Content.Server.Construction
|
|||||||
|
|
||||||
private void InitializeInteractions()
|
private void InitializeInteractions()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<ConstructionComponent, ConstructionInteractDoAfterEvent>(EnqueueEvent);
|
SubscribeLocalEvent<ConstructionComponent, ConstructionInteractDoAfterEvent>(OnDoAfterComplete);
|
||||||
|
|
||||||
// Event handling. Add your subscriptions here! Just make sure they're all handled by EnqueueEvent.
|
// Event handling. Add your subscriptions here! Just make sure they're all handled by EnqueueEvent.
|
||||||
SubscribeLocalEvent<ConstructionComponent, InteractUsingEvent>(EnqueueEvent, new []{typeof(AnchorableSystem)});
|
SubscribeLocalEvent<ConstructionComponent, InteractUsingEvent>(EnqueueEvent, new []{typeof(AnchorableSystem), typeof(EncryptionKeySystem)});
|
||||||
SubscribeLocalEvent<ConstructionComponent, OnTemperatureChangeEvent>(EnqueueEvent);
|
SubscribeLocalEvent<ConstructionComponent, OnTemperatureChangeEvent>(EnqueueEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDoAfterComplete(EntityUid uid, ConstructionComponent component, ConstructionInteractDoAfterEvent args)
|
||||||
|
{
|
||||||
|
component.DoAfter = null;
|
||||||
|
if (!args.Cancelled)
|
||||||
|
EnqueueEvent(uid, component, args);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Takes in an entity with <see cref="ConstructionComponent"/> and an object event, and handles any
|
/// Takes in an entity with <see cref="ConstructionComponent"/> and an object event, and handles any
|
||||||
/// possible construction interactions, depending on the construction's state.
|
/// possible construction interactions, depending on the construction's state.
|
||||||
@@ -223,11 +231,8 @@ namespace Content.Server.Construction
|
|||||||
// The DoAfter events can only perform special logic when we're not validating events.
|
// The DoAfter events can only perform special logic when we're not validating events.
|
||||||
if (ev is ConstructionInteractDoAfterEvent interactDoAfter)
|
if (ev is ConstructionInteractDoAfterEvent interactDoAfter)
|
||||||
{
|
{
|
||||||
if (!validation)
|
// cancelled events should not reach this point.
|
||||||
construction.DoAfter = null;
|
DebugTools.Assert(!interactDoAfter.Cancelled);
|
||||||
|
|
||||||
if (interactDoAfter.Cancelled)
|
|
||||||
return HandleResult.False;
|
|
||||||
|
|
||||||
ev = new InteractUsingEvent(
|
ev = new InteractUsingEvent(
|
||||||
interactDoAfter.User,
|
interactDoAfter.User,
|
||||||
@@ -256,12 +261,6 @@ namespace Content.Server.Construction
|
|||||||
if (ev is not InteractUsingEvent interactUsing)
|
if (ev is not InteractUsingEvent interactUsing)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (construction.DoAfter != null && !validation)
|
|
||||||
{
|
|
||||||
_doAfterSystem.Cancel(construction.DoAfter);
|
|
||||||
return HandleResult.False;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Sanity checks.
|
// TODO: Sanity checks.
|
||||||
|
|
||||||
user = interactUsing.User;
|
user = interactUsing.User;
|
||||||
@@ -343,12 +342,6 @@ namespace Content.Server.Construction
|
|||||||
if (ev is not InteractUsingEvent interactUsing)
|
if (ev is not InteractUsingEvent interactUsing)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (construction.DoAfter != null && !validation)
|
|
||||||
{
|
|
||||||
_doAfterSystem.Cancel(construction.DoAfter);
|
|
||||||
return HandleResult.False;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Sanity checks.
|
// TODO: Sanity checks.
|
||||||
|
|
||||||
user = interactUsing.User;
|
user = interactUsing.User;
|
||||||
|
|||||||
@@ -463,12 +463,16 @@ public sealed class WiresSystem : SharedWiresSystem
|
|||||||
_toolSystem.HasQuality(args.Used, "Pulsing", tool)))
|
_toolSystem.HasQuality(args.Used, "Pulsing", tool)))
|
||||||
{
|
{
|
||||||
if (TryComp(args.User, out ActorComponent? actor))
|
if (TryComp(args.User, out ActorComponent? actor))
|
||||||
|
{
|
||||||
_uiSystem.TryOpen(uid, WiresUiKey.Key, actor.PlayerSession);
|
_uiSystem.TryOpen(uid, WiresUiKey.Key, actor.PlayerSession);
|
||||||
|
args.Handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (_toolSystem.UseTool(args.Used, args.User, uid, ScrewTime, "Screwing", new WirePanelDoAfterEvent(), toolComponent: tool))
|
else if (_toolSystem.UseTool(args.Used, args.User, uid, ScrewTime, "Screwing", new WirePanelDoAfterEvent(), toolComponent: tool))
|
||||||
{
|
{
|
||||||
_adminLogger.Add(LogType.Action, LogImpact.Low,
|
_adminLogger.Add(LogType.Action, LogImpact.Low,
|
||||||
$"{ToPrettyString(args.User):user} is screwing {ToPrettyString(uid):target}'s {(panel.Open ? "open" : "closed")} maintenance panel at {Transform(uid).Coordinates:targetlocation}");
|
$"{ToPrettyString(args.User):user} is screwing {ToPrettyString(uid):target}'s {(panel.Open ? "open" : "closed")} maintenance panel at {Transform(uid).Coordinates:targetlocation}");
|
||||||
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,14 +245,14 @@ public sealed class ToggleableClothingSystem : EntitySystem
|
|||||||
|
|
||||||
var parent = Transform(target).ParentUid;
|
var parent = Transform(target).ParentUid;
|
||||||
if (component.Container.ContainedEntity == null)
|
if (component.Container.ContainedEntity == null)
|
||||||
_inventorySystem.TryUnequip(parent, component.Slot);
|
_inventorySystem.TryUnequip(user, parent, component.Slot);
|
||||||
else if (_inventorySystem.TryGetSlotEntity(parent, component.Slot, out var existing))
|
else if (_inventorySystem.TryGetSlotEntity(parent, component.Slot, out var existing))
|
||||||
{
|
{
|
||||||
_popupSystem.PopupEntity(Loc.GetString("toggleable-clothing-remove-first", ("entity", existing)),
|
_popupSystem.PopupEntity(Loc.GetString("toggleable-clothing-remove-first", ("entity", existing)),
|
||||||
user, user);
|
user, user);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_inventorySystem.TryEquip(parent, component.ClothingUid.Value, component.Slot);
|
_inventorySystem.TryEquip(user, parent, component.ClothingUid.Value, component.Slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGetActions(EntityUid uid, ToggleableClothingComponent component, GetItemActionsEvent args)
|
private void OnGetActions(EntityUid uid, ToggleableClothingComponent component, GetItemActionsEvent args)
|
||||||
|
|||||||
@@ -92,8 +92,20 @@ public sealed class EncryptionKeySystem : EntitySystem
|
|||||||
if ( args.Handled || !TryComp<ContainerManagerComponent>(uid, out var storage))
|
if ( args.Handled || !TryComp<ContainerManagerComponent>(uid, out var storage))
|
||||||
return;
|
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 (!component.KeysUnlocked)
|
||||||
{
|
{
|
||||||
if (_net.IsClient && _timing.IsFirstTimePredicted)
|
if (_net.IsClient && _timing.IsFirstTimePredicted)
|
||||||
@@ -101,18 +113,6 @@ public sealed class EncryptionKeySystem : EntitySystem
|
|||||||
return;
|
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 (TryComp<WiresPanelComponent>(uid, out var panel) && !panel.Open)
|
||||||
{
|
{
|
||||||
if (_net.IsClient && _timing.IsFirstTimePredicted)
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TryComp<WiresPanelComponent>(uid, out var panel) && !panel.Open)
|
if (TryComp<WiresPanelComponent>(uid, out var panel) && !panel.Open)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user