Reduce action blocker uses and add target entity to CanInteract (#6655)

This commit is contained in:
Leon Friedrich
2022-02-15 17:06:52 +13:00
committed by GitHub
parent 334568dad2
commit ad9ddf1552
60 changed files with 286 additions and 402 deletions

View File

@@ -184,11 +184,6 @@ namespace Content.Server.Disposal.Unit.EntitySystems
return;
}
if (!_actionBlockerSystem.CanInteract(player) || !_actionBlockerSystem.CanUse(player))
{
return;
}
switch (args.Button)
{
case SharedDisposalUnitComponent.UiButton.Eject:
@@ -241,11 +236,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
}
args.Handled = true;
if (IsValidInteraction(args))
{
component.Owner.GetUIOrNull(SharedDisposalUnitComponent.DisposalUnitUiKey.Key)?.Open(actor.PlayerSession);
}
component.Owner.GetUIOrNull(SharedDisposalUnitComponent.DisposalUnitUiKey.Key)?.Open(actor.PlayerSession);
}
private void HandleAfterInteractUsing(EntityUid uid, DisposalUnitComponent component, AfterInteractUsingEvent args)
@@ -439,30 +430,6 @@ namespace Content.Server.Disposal.Unit.EntitySystems
return state == SharedDisposalUnitComponent.PressureState.Ready && component.RecentlyEjected.Count == 0;
}
private bool IsValidInteraction(ITargetedInteractEventArgs eventArgs)
{
if (!Get<ActionBlockerSystem>().CanInteract(eventArgs.User))
{
eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("ui-disposal-unit-is-valid-interaction-cannot=interact"));
return false;
}
if (eventArgs.User.IsInContainer())
{
eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("ui-disposal-unit-is-valid-interaction-cannot-reach"));
return false;
}
// This popup message doesn't appear on clicks, even when code was seperate. Unsure why.
if (!EntityManager.HasComponent<HandsComponent>(eventArgs.User))
{
eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("ui-disposal-unit-is-valid-interaction-no-hands"));
return false;
}
return true;
}
public bool TryInsert(EntityUid unitId, EntityUid toInsertId, EntityUid userId, DisposalUnitComponent? unit = null)
{
if (!Resolve(unitId, ref unit))