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:
@@ -1,13 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using Content.Client.Chat;
|
||||
using Content.Client.Interfaces.Chat;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.Input;
|
||||
using Robust.Client.Interfaces.Input;
|
||||
using Robust.Client.Interfaces.State;
|
||||
using Robust.Client.Interfaces.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Client.State
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -12,6 +12,7 @@ using Robust.Client.Interfaces.UserInterface;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
Reference in New Issue
Block a user