Kick mines (real) (#8056)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
2f604ce05c
commit
ebfe5e888f
@@ -6,6 +6,7 @@ using Content.Client.Chat.Managers;
|
||||
using Content.Client.EscapeMenu;
|
||||
using Content.Client.Eui;
|
||||
using Content.Client.Flash;
|
||||
using Content.Client.GhostKick;
|
||||
using Content.Client.HUD;
|
||||
using Content.Client.Info;
|
||||
using Content.Client.Input;
|
||||
@@ -127,6 +128,7 @@ namespace Content.Client.Entry
|
||||
IoCManager.Resolve<ChangelogManager>().Initialize();
|
||||
IoCManager.Resolve<RulesManager>().Initialize();
|
||||
IoCManager.Resolve<ViewportManager>().Initialize();
|
||||
IoCManager.Resolve<GhostKickManager>().Initialize();
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
|
||||
@@ -321,6 +321,8 @@ namespace Content.Client.Entry
|
||||
"Armor",
|
||||
"AtmosMonitor",
|
||||
"AtmosAlarmable",
|
||||
"LandMine",
|
||||
"GhostKickUserOnTrigger",
|
||||
"FireAlarm",
|
||||
"AirAlarm",
|
||||
"RadarConsole",
|
||||
|
||||
40
Content.Client/GhostKick/GhostKickManager.cs
Normal file
40
Content.Client/GhostKick/GhostKickManager.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Content.Shared.GhostKick;
|
||||
using Robust.Client;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Client.GhostKick;
|
||||
|
||||
public sealed class GhostKickManager
|
||||
{
|
||||
private bool _fakeLossEnabled;
|
||||
|
||||
[Dependency] private readonly IBaseClient _baseClient = default!;
|
||||
[Dependency] private readonly IClientNetManager _netManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_netManager.RegisterNetMessage<MsgGhostKick>(RxCallback);
|
||||
|
||||
_baseClient.RunLevelChanged += BaseClientOnRunLevelChanged;
|
||||
}
|
||||
|
||||
private void BaseClientOnRunLevelChanged(object? sender, RunLevelChangedEventArgs e)
|
||||
{
|
||||
if (_fakeLossEnabled && e.OldLevel == ClientRunLevel.InGame)
|
||||
{
|
||||
_cfg.SetCVar(CVars.NetFakeLoss, 0);
|
||||
|
||||
_fakeLossEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void RxCallback(MsgGhostKick message)
|
||||
{
|
||||
_fakeLossEnabled = true;
|
||||
|
||||
_cfg.SetCVar(CVars.NetFakeLoss, 1);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Content.Client.Chat.Managers;
|
||||
using Content.Client.Clickable;
|
||||
using Content.Client.EscapeMenu;
|
||||
using Content.Client.Eui;
|
||||
using Content.Client.GhostKick;
|
||||
using Content.Client.HUD;
|
||||
using Content.Client.Info;
|
||||
using Content.Client.Items.Managers;
|
||||
@@ -43,6 +44,7 @@ namespace Content.Client.IoC
|
||||
IoCManager.Register<ViewportManager, ViewportManager>();
|
||||
IoCManager.Register<IGamePrototypeLoadManager, GamePrototypeLoadManager>();
|
||||
IoCManager.Register<NetworkResourceManager>();
|
||||
IoCManager.Register<GhostKickManager>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Popups
|
||||
{
|
||||
@@ -19,6 +18,7 @@ namespace Content.Client.Popups
|
||||
[Dependency] private readonly IInputManager _inputManager = default!;
|
||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
[Dependency] private readonly IMapManager _map = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly ExamineSystemShared _examineSystem = default!;
|
||||
|
||||
@@ -55,7 +55,13 @@ namespace Content.Client.Popups
|
||||
PopupMessage(message, _eyeManager.CoordinatesToScreen(transform.Coordinates), uid);
|
||||
}
|
||||
|
||||
public void PopupMessage(string message, ScreenCoordinates coordinates, EntityUid? entity = null)
|
||||
private void PopupMessage(string message, ScreenCoordinates coordinates, EntityUid? entity = null)
|
||||
{
|
||||
var mapCoords = _eyeManager.ScreenToMap(coordinates);
|
||||
PopupMessage(message, EntityCoordinates.FromMap(_map, mapCoords), entity);
|
||||
}
|
||||
|
||||
private void PopupMessage(string message, EntityCoordinates coordinates, EntityUid? entity = null)
|
||||
{
|
||||
var label = new PopupLabel(_eyeManager, EntityManager)
|
||||
{
|
||||
@@ -67,8 +73,7 @@ namespace Content.Client.Popups
|
||||
_userInterfaceManager.PopupRoot.AddChild(label);
|
||||
label.Measure(Vector2.Infinity);
|
||||
|
||||
var mapCoordinates = _eyeManager.ScreenToMap(coordinates.Position);
|
||||
label.InitialPos = mapCoordinates;
|
||||
label.InitialPos = coordinates;
|
||||
LayoutContainer.SetPosition(label, label.InitialPos.Position);
|
||||
_aliveLabels.Add(label);
|
||||
}
|
||||
@@ -161,7 +166,7 @@ namespace Content.Client.Popups
|
||||
continue;
|
||||
}
|
||||
|
||||
var otherPos = label.Entity != null ? Transform(label.Entity.Value).MapPosition : label.InitialPos;
|
||||
var otherPos = label.Entity != null ? Transform(label.Entity.Value).MapPosition : label.InitialPos.ToMap(EntityManager);
|
||||
|
||||
if (occluded && !ExamineSystemShared.InRangeUnOccluded(
|
||||
playerPos,
|
||||
@@ -188,7 +193,7 @@ namespace Content.Client.Popups
|
||||
/// <remarks>
|
||||
/// Yes that's right it's not technically MapCoordinates.
|
||||
/// </remarks>
|
||||
public MapCoordinates InitialPos { get; set; }
|
||||
public EntityCoordinates InitialPos { get; set; }
|
||||
public EntityUid? Entity { get; set; }
|
||||
|
||||
public PopupLabel(IEyeManager eyeManager, IEntityManager entityManager)
|
||||
@@ -204,11 +209,12 @@ namespace Content.Client.Popups
|
||||
{
|
||||
TotalTime += eventArgs.DeltaSeconds;
|
||||
|
||||
Vector2 position;
|
||||
ScreenCoordinates screenCoords;
|
||||
|
||||
if (Entity == null)
|
||||
position = _eyeManager.WorldToScreen(InitialPos.Position) / UIScale - DesiredSize / 2;
|
||||
screenCoords = _eyeManager.CoordinatesToScreen(InitialPos);
|
||||
else if (_entityManager.TryGetComponent(Entity.Value, out TransformComponent xform))
|
||||
position = (_eyeManager.CoordinatesToScreen(xform.Coordinates).Position / UIScale) - DesiredSize / 2;
|
||||
screenCoords = _eyeManager.CoordinatesToScreen(xform.Coordinates);
|
||||
else
|
||||
{
|
||||
// Entity has probably been deleted.
|
||||
@@ -217,6 +223,7 @@ namespace Content.Client.Popups
|
||||
return;
|
||||
}
|
||||
|
||||
var position = screenCoords.Position / UIScale - DesiredSize / 2;
|
||||
LayoutContainer.SetPosition(this, position - (0, 20 * (TotalTime * TotalTime + TotalTime)));
|
||||
|
||||
if (TotalTime > 0.5f)
|
||||
|
||||
Reference in New Issue
Block a user