Removed the StateBase scene, its functionality got moved back into Engine.
Changed all the dependencies inside GameScreenBase to protected so that derived classes can access them.
This commit is contained in:
@@ -27,56 +27,60 @@ namespace Content.Client.State
|
|||||||
// OH GOD.
|
// OH GOD.
|
||||||
// Ok actually it's fine.
|
// Ok actually it's fine.
|
||||||
// Instantiated dynamically through the StateManager, Dependencies will be resolved.
|
// Instantiated dynamically through the StateManager, Dependencies will be resolved.
|
||||||
public partial class GameScreenBase : StateBase
|
public partial class GameScreenBase : Robust.Client.State.State
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly IClientEntityManager _entityManager;
|
[Dependency] protected readonly IClientEntityManager EntityManager;
|
||||||
[Dependency] private readonly IInputManager _inputManager;
|
[Dependency] protected readonly IInputManager InputManager;
|
||||||
[Dependency] private readonly IPlayerManager _playerManager;
|
[Dependency] protected readonly IPlayerManager PlayerManager;
|
||||||
[Dependency] private readonly IEyeManager _eyeManager;
|
[Dependency] protected readonly IEyeManager EyeManager;
|
||||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
[Dependency] protected readonly IEntitySystemManager EntitySystemManager;
|
||||||
[Dependency] private readonly IGameTiming _timing;
|
[Dependency] protected readonly IGameTiming Timing;
|
||||||
[Dependency] private readonly IMapManager _mapManager;
|
[Dependency] protected readonly IMapManager MapManager;
|
||||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
|
[Dependency] protected readonly IUserInterfaceManager UserInterfaceManager;
|
||||||
|
[Dependency] protected readonly IConfigurationManager ConfigurationManager;
|
||||||
[Dependency] private readonly IConfigurationManager _configurationManager;
|
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
private IEntity _lastHoveredEntity;
|
private IEntity _lastHoveredEntity;
|
||||||
|
|
||||||
public override void Startup()
|
public override void Startup()
|
||||||
{
|
{
|
||||||
_inputManager.KeyBindStateChanged += OnKeyBindStateChanged;
|
InputManager.KeyBindStateChanged += OnKeyBindStateChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
{
|
{
|
||||||
_inputManager.KeyBindStateChanged -= OnKeyBindStateChanged;
|
InputManager.KeyBindStateChanged -= OnKeyBindStateChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FrameUpdate(FrameEventArgs e)
|
public override void FrameUpdate(FrameEventArgs e)
|
||||||
{
|
{
|
||||||
base.FrameUpdate(e);
|
base.FrameUpdate(e);
|
||||||
|
|
||||||
var mousePosWorld = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition);
|
// If there is no local player, there is no session, and therefore nothing to do here.
|
||||||
var entityToClick = _userInterfaceManager.CurrentlyHovered != null
|
var localPlayer = PlayerManager.LocalPlayer;
|
||||||
|
if (localPlayer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var mousePosWorld = EyeManager.ScreenToMap(InputManager.MouseScreenPosition);
|
||||||
|
var entityToClick = UserInterfaceManager.CurrentlyHovered != null
|
||||||
? null
|
? null
|
||||||
: GetEntityUnderPosition(mousePosWorld);
|
: GetEntityUnderPosition(mousePosWorld);
|
||||||
|
|
||||||
var inRange = false;
|
var inRange = false;
|
||||||
if (_playerManager.LocalPlayer.ControlledEntity != null && entityToClick != null)
|
if (localPlayer.ControlledEntity != null && entityToClick != null)
|
||||||
{
|
{
|
||||||
var playerPos = _playerManager.LocalPlayer.ControlledEntity.Transform.MapPosition;
|
var playerPos = localPlayer.ControlledEntity.Transform.MapPosition;
|
||||||
var entityPos = entityToClick.Transform.MapPosition;
|
var entityPos = entityToClick.Transform.MapPosition;
|
||||||
inRange = _entitySystemManager.GetEntitySystem<SharedInteractionSystem>()
|
inRange = EntitySystemManager.GetEntitySystem<SharedInteractionSystem>()
|
||||||
.InRangeUnobstructed(playerPos, entityPos,
|
.InRangeUnobstructed(playerPos, entityPos,
|
||||||
predicate: entity =>
|
predicate: entity =>
|
||||||
entity == _playerManager.LocalPlayer.ControlledEntity || entity == entityToClick,
|
entity == localPlayer.ControlledEntity || entity == entityToClick,
|
||||||
ignoreInsideBlocker: true);
|
ignoreInsideBlocker: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
InteractionOutlineComponent outline;
|
InteractionOutlineComponent outline;
|
||||||
if(!_configurationManager.GetCVar<bool>("outline.enabled"))
|
if(!ConfigurationManager.GetCVar<bool>("outline.enabled"))
|
||||||
{
|
{
|
||||||
if(entityToClick != null && entityToClick.TryGetComponent(out outline))
|
if(entityToClick != null && entityToClick.TryGetComponent(out outline))
|
||||||
{
|
{
|
||||||
@@ -117,13 +121,13 @@ namespace Content.Client.State
|
|||||||
|
|
||||||
public IList<IEntity> GetEntitiesUnderPosition(GridCoordinates coordinates)
|
public IList<IEntity> GetEntitiesUnderPosition(GridCoordinates coordinates)
|
||||||
{
|
{
|
||||||
return GetEntitiesUnderPosition(coordinates.ToMap(_mapManager));
|
return GetEntitiesUnderPosition(coordinates.ToMap(MapManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<IEntity> GetEntitiesUnderPosition(MapCoordinates coordinates)
|
public IList<IEntity> GetEntitiesUnderPosition(MapCoordinates coordinates)
|
||||||
{
|
{
|
||||||
// Find all the entities intersecting our click
|
// Find all the entities intersecting our click
|
||||||
var entities = _entityManager.GetEntitiesIntersecting(coordinates.MapId,
|
var entities = EntityManager.GetEntitiesIntersecting(coordinates.MapId,
|
||||||
Box2.CenteredAround(coordinates.Position, (1, 1)));
|
Box2.CenteredAround(coordinates.Position, (1, 1)));
|
||||||
|
|
||||||
// Check the entities against whether or not we can click them
|
// Check the entities against whether or not we can click them
|
||||||
@@ -204,23 +208,25 @@ namespace Content.Client.State
|
|||||||
/// <param name="args">Event data values for a bound key state change.</param>
|
/// <param name="args">Event data values for a bound key state change.</param>
|
||||||
private void OnKeyBindStateChanged(BoundKeyEventArgs args)
|
private void OnKeyBindStateChanged(BoundKeyEventArgs args)
|
||||||
{
|
{
|
||||||
var inputSys = _entitySystemManager.GetEntitySystem<InputSystem>();
|
// If there is no InputSystem, then there is nothing to forward to, and nothing to do here.
|
||||||
|
if(!EntitySystemManager.TryGetEntitySystem(out InputSystem inputSys))
|
||||||
|
return;
|
||||||
|
|
||||||
var func = args.Function;
|
var func = args.Function;
|
||||||
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(func);
|
var funcId = InputManager.NetworkBindMap.KeyFunctionID(func);
|
||||||
|
|
||||||
var mousePosWorld = _eyeManager.ScreenToMap(args.PointerLocation);
|
var mousePosWorld = EyeManager.ScreenToMap(args.PointerLocation);
|
||||||
var entityToClick = GetEntityUnderPosition(mousePosWorld);
|
var entityToClick = GetEntityUnderPosition(mousePosWorld);
|
||||||
|
|
||||||
if (!_mapManager.TryFindGridAt(mousePosWorld, out var grid))
|
if (!MapManager.TryFindGridAt(mousePosWorld, out var grid))
|
||||||
grid = _mapManager.GetDefaultGrid(mousePosWorld.MapId);
|
grid = MapManager.GetDefaultGrid(mousePosWorld.MapId);
|
||||||
|
|
||||||
var message = new FullInputCmdMessage(_timing.CurTick, _timing.TickFraction, funcId, args.State,
|
var message = new FullInputCmdMessage(Timing.CurTick, Timing.TickFraction, funcId, args.State,
|
||||||
grid.MapToGrid(mousePosWorld), args.PointerLocation,
|
grid.MapToGrid(mousePosWorld), args.PointerLocation,
|
||||||
entityToClick?.Uid ?? EntityUid.Invalid);
|
entityToClick?.Uid ?? EntityUid.Invalid);
|
||||||
|
|
||||||
// client side command handlers will always be sent the local player session.
|
// client side command handlers will always be sent the local player session.
|
||||||
var session = _playerManager.LocalPlayer.Session;
|
var session = PlayerManager.LocalPlayer.Session;
|
||||||
inputSys.HandleInputCommand(session, func, message);
|
inputSys.HandleInputCommand(session, func, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Client.Interfaces;
|
using Content.Client.Interfaces;
|
||||||
using Content.Client.Interfaces.Chat;
|
using Content.Client.Interfaces.Chat;
|
||||||
@@ -26,7 +26,7 @@ using MathF = CannyFastMath.MathF;
|
|||||||
|
|
||||||
namespace Content.Client.State
|
namespace Content.Client.State
|
||||||
{
|
{
|
||||||
public class LobbyState : StateBase
|
public class LobbyState : Robust.Client.State.State
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly IBaseClient _baseClient;
|
[Dependency] private readonly IBaseClient _baseClient;
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
using Robust.Client.Interfaces.GameObjects;
|
|
||||||
using Robust.Client.Interfaces.Placement;
|
|
||||||
using Robust.Client.Player;
|
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Timing;
|
|
||||||
|
|
||||||
namespace Content.Client.State
|
|
||||||
{
|
|
||||||
public abstract class StateBase : Robust.Client.State.State
|
|
||||||
{
|
|
||||||
#pragma warning disable 649
|
|
||||||
[Dependency] private readonly IClientEntityManager _entityManager;
|
|
||||||
[Dependency] private readonly IComponentManager _componentManager;
|
|
||||||
[Dependency] private readonly IPlayerManager _playerManager;
|
|
||||||
[Dependency] private readonly IPlacementManager _placementManager;
|
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
public override void Update(FrameEventArgs e)
|
|
||||||
{
|
|
||||||
_componentManager.CullRemovedComponents();
|
|
||||||
_entityManager.Update(e.DeltaSeconds);
|
|
||||||
_playerManager.Update(e.DeltaSeconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void FrameUpdate(FrameEventArgs e)
|
|
||||||
{
|
|
||||||
_placementManager.FrameUpdate(e);
|
|
||||||
_entityManager.FrameUpdate(e.DeltaSeconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Submodule RobustToolbox updated: ede9795ba6...5e448f20c0
Reference in New Issue
Block a user