Click Drag Functionality + Refactor Interaction Interfaces (#1125)

Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
Co-authored-by: ComicIronic <comicironic@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
chairbender
2020-07-06 14:27:03 -07:00
committed by GitHub
parent c019d428a7
commit b35333d366
184 changed files with 1792 additions and 895 deletions

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Content.Client.GameObjects.Components;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Client.GameObjects.EntitySystems;
using Robust.Client.Interfaces.GameObjects;
@@ -9,6 +9,7 @@ using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Client.Interfaces.Graphics.ClientEye;
using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.Interfaces.State;
using Robust.Client.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Input;
@@ -71,7 +72,7 @@ namespace Content.Client.State
.InRangeUnobstructed(playerPos, entityPos,
predicate: entity =>
entity == _playerManager.LocalPlayer.ControlledEntity || entity == entityToClick,
insideBlockerValid: true);
ignoreInsideBlocker: true);
}
InteractionOutlineComponent outline;
@@ -146,6 +147,25 @@ namespace Content.Client.State
return foundEntities.Select(a => a.clicked).ToList();
}
/// <summary>
/// Gets all entities intersecting the given position.
///
/// Static alternative to GetEntitiesUnderPosition to cut out
/// some of the boilerplate needed to get state manager and check the current state.
/// </summary>
/// <param name="stateManager">state manager to use to get the current game screen</param>
/// <param name="coordinates">coordinates to check</param>
/// <returns>the entities under the position, empty list if none found</returns>
public static IList<IEntity> GetEntitiesUnderPosition(IStateManager stateManager, GridCoordinates coordinates)
{
if (stateManager.CurrentState is GameScreenBase gameScreenBase)
{
return gameScreenBase.GetEntitiesUnderPosition(coordinates);
}
return ImmutableList<IEntity>.Empty;
}
internal class ClickableEntityComparer : IComparer<(IEntity clicked, int depth, uint renderOrder)>
{
public int Compare((IEntity clicked, int depth, uint renderOrder) x,