Adjust interaction ordering & interaction conditions (#6387)

This commit is contained in:
Leon Friedrich
2022-02-05 15:39:01 +13:00
committed by GitHub
parent 442d7dbf8e
commit dd61fb46ea
28 changed files with 88 additions and 167 deletions

View File

@@ -63,8 +63,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
// Interactions
SubscribeLocalEvent<DisposalUnitComponent, ActivateInWorldEvent>(HandleActivate);
SubscribeLocalEvent<DisposalUnitComponent, InteractHandEvent>(HandleInteractHand);
SubscribeLocalEvent<DisposalUnitComponent, InteractUsingEvent>(HandleInteractUsing);
SubscribeLocalEvent<DisposalUnitComponent, AfterInteractUsingEvent>(HandleAfterInteractUsing);
SubscribeLocalEvent<DisposalUnitComponent, DragDropEvent>(HandleDragDropOn);
SubscribeLocalEvent<DisposalUnitComponent, DestructionEventArgs>(HandleDestruction);
@@ -223,19 +222,11 @@ namespace Content.Server.Disposal.Unit.EntitySystems
}
}
private void HandleInteractHand(EntityUid uid, DisposalUnitComponent component, InteractHandEvent args)
private void HandleAfterInteractUsing(EntityUid uid, DisposalUnitComponent component, AfterInteractUsingEvent args)
{
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return;
if (args.Handled || !args.CanReach)
return;
// Duplicated code here, not sure how else to get actor inside to make UserInterface happy.
if (!IsValidInteraction(args)) return;
component.Owner.GetUIOrNull(SharedDisposalUnitComponent.DisposalUnitUiKey.Key)?.Open(actor.PlayerSession);
args.Handled = true;
}
private void HandleInteractUsing(EntityUid uid, DisposalUnitComponent component, InteractUsingEvent args)
{
if (!EntityManager.TryGetComponent(args.User, out HandsComponent? hands))
{
return;