Re-organize all projects (#4166)
This commit is contained in:
32
Content.Client/CombatMode/ColoredScreenBorderOverlay.cs
Normal file
32
Content.Client/CombatMode/ColoredScreenBorderOverlay.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
#nullable enable
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.CombatMode
|
||||
{
|
||||
public class ColoredScreenBorderOverlay : Overlay
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
private readonly ShaderInstance _shader;
|
||||
|
||||
public ColoredScreenBorderOverlay()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_shader = _prototypeManager.Index<ShaderPrototype>("ColoredScreenBorder").Instance();
|
||||
}
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
{
|
||||
var worldHandle = args.WorldHandle;
|
||||
worldHandle.UseShader(_shader);
|
||||
var viewport = _eyeManager.GetWorldViewport();
|
||||
worldHandle.DrawRect(viewport, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
65
Content.Client/CombatMode/CombatModeComponent.cs
Normal file
65
Content.Client/CombatMode/CombatModeComponent.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Content.Client.HUD;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Targeting;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.CombatMode
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedCombatModeComponent))]
|
||||
public sealed class CombatModeComponent : SharedCombatModeComponent
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IGameHud _gameHud = default!;
|
||||
|
||||
public override bool IsInCombatMode
|
||||
{
|
||||
get => base.IsInCombatMode;
|
||||
set
|
||||
{
|
||||
base.IsInCombatMode = value;
|
||||
UpdateHud();
|
||||
}
|
||||
}
|
||||
|
||||
public override TargetingZone ActiveZone
|
||||
{
|
||||
get => base.ActiveZone;
|
||||
set
|
||||
{
|
||||
base.ActiveZone = value;
|
||||
UpdateHud();
|
||||
}
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
{
|
||||
base.HandleMessage(message, component);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case PlayerAttachedMsg _:
|
||||
_gameHud.CombatPanelVisible = true;
|
||||
UpdateHud();
|
||||
break;
|
||||
|
||||
case PlayerDetachedMsg _:
|
||||
_gameHud.CombatPanelVisible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateHud()
|
||||
{
|
||||
if (Owner != _playerManager.LocalPlayer?.ControlledEntity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_gameHud.TargetingZone = ActiveZone;
|
||||
}
|
||||
}
|
||||
}
|
||||
47
Content.Client/CombatMode/CombatModeSystem.cs
Normal file
47
Content.Client/CombatMode/CombatModeSystem.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Content.Client.HUD;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Targeting;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.CombatMode
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class CombatModeSystem : SharedCombatModeSystem
|
||||
{
|
||||
[Dependency] private readonly IGameHud _gameHud = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_gameHud.OnTargetingZoneChanged = OnTargetingZoneChanged;
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
CommandBinds.Unregister<CombatModeSystem>();
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
public bool IsInCombatMode()
|
||||
{
|
||||
var entity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (entity == null || !entity.TryGetComponent(out CombatModeComponent? combatMode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return combatMode.IsInCombatMode;
|
||||
}
|
||||
|
||||
private void OnTargetingZoneChanged(TargetingZone obj)
|
||||
{
|
||||
EntityManager.RaisePredictiveEvent(new CombatModeSystemMessages.SetTargetZoneMessage(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user