-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
243 changed files
with
5,558 additions
and
772 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using Content.Shared.Chapel; | ||
|
||
namespace Content.Client.Chapel; | ||
|
||
public sealed class SacrificialAltarSystem : SharedSacrificialAltarSystem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Prototypes; | ||
using Content.Shared.Shadowkin; | ||
|
||
namespace Content.Client.Overlays; | ||
|
||
/// <summary> | ||
/// A simple overlay that applies a colored tint to the screen. | ||
/// </summary> | ||
public sealed class ColorTintOverlay : Overlay | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
[Dependency] private readonly IPlayerManager _player = default!; | ||
[Dependency] IEntityManager _entityManager = default!; | ||
|
||
public override bool RequestScreenTexture => true; | ||
public override OverlaySpace Space => OverlaySpace.WorldSpace; | ||
private readonly ShaderInstance _shader; | ||
|
||
/// <summary> | ||
/// The color to tint the screen to as RGB on a scale of 0-1. | ||
/// </summary> | ||
public Vector3? TintColor = null; | ||
/// <summary> | ||
/// The percent to tint the screen by on a scale of 0-1. | ||
/// </summary> | ||
public float? TintAmount = null; | ||
|
||
public ColorTintOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
_shader = _prototype.Index<ShaderPrototype>("ColorTint").InstanceUnique(); | ||
} | ||
|
||
protected override bool BeforeDraw(in OverlayDrawArgs args) | ||
{ | ||
if (_player.LocalEntity is not { Valid: true } player | ||
|| !_entityManager.HasComponent<ShadowkinComponent>(player)) | ||
return false; | ||
|
||
return base.BeforeDraw(in args); | ||
} | ||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (ScreenTexture is null) | ||
return; | ||
|
||
_shader.SetParameter("SCREEN_TEXTURE", ScreenTexture); | ||
if (TintColor != null) | ||
_shader.SetParameter("tint_color", (Vector3) TintColor); | ||
if (TintAmount != null) | ||
_shader.SetParameter("tint_amount", (float) TintAmount); | ||
|
||
var worldHandle = args.WorldHandle; | ||
var viewport = args.WorldBounds; | ||
worldHandle.SetTransform(Matrix3.Identity); | ||
worldHandle.UseShader(_shader); | ||
worldHandle.DrawRect(viewport, Color.White); | ||
worldHandle.UseShader(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Prototypes; | ||
using Content.Shared.Shadowkin; | ||
|
||
namespace Content.Client.Overlays; | ||
|
||
public sealed class EtherealOverlay : Overlay | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
[Dependency] private readonly IPlayerManager _player = default!; | ||
[Dependency] IEntityManager _entityManager = default!; | ||
|
||
public override bool RequestScreenTexture => true; | ||
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV; | ||
private readonly ShaderInstance _shader; | ||
|
||
public EtherealOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
_shader = _prototype.Index<ShaderPrototype>("Ethereal").InstanceUnique(); | ||
} | ||
|
||
protected override bool BeforeDraw(in OverlayDrawArgs args) | ||
{ | ||
if (_player.LocalEntity is not { Valid: true } player | ||
|| !_entityManager.HasComponent<EtherealComponent>(player)) | ||
return false; | ||
|
||
return base.BeforeDraw(in args); | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (ScreenTexture is null) | ||
return; | ||
|
||
_shader.SetParameter("SCREEN_TEXTURE", ScreenTexture); | ||
|
||
var worldHandle = args.WorldHandle; | ||
var viewport = args.WorldBounds; | ||
worldHandle.SetTransform(Matrix3.Identity); | ||
worldHandle.UseShader(_shader); | ||
worldHandle.DrawRect(viewport, Color.White); | ||
worldHandle.UseShader(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
using System.Numerics; | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.Construction.Prototypes; | ||
using Content.Shared.RadialSelector; | ||
using JetBrains.Annotations; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Input; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Shared.Prototypes; | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
namespace Content.Client.RadialSelector; | ||
|
||
[UsedImplicitly] | ||
public sealed class RadialSelectorMenuBUI : BoundUserInterface | ||
{ | ||
[Dependency] private readonly IClyde _displayManager = default!; | ||
[Dependency] private readonly IInputManager _inputManager = default!; | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
[Dependency] private readonly IPrototypeManager _protoManager = default!; | ||
|
||
private readonly SpriteSystem _spriteSystem; | ||
|
||
private readonly RadialMenu _menu; | ||
|
||
// Used to clearing on state changing | ||
private readonly HashSet<RadialContainer> _cachedContainers = new(); | ||
|
||
private bool _openCentered; | ||
|
||
public RadialSelectorMenuBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
_spriteSystem = _entManager.System<SpriteSystem>(); | ||
_menu = new RadialMenu | ||
{ | ||
HorizontalExpand = true, | ||
VerticalExpand = true, | ||
BackButtonStyleClass = "RadialMenuBackButton", | ||
CloseButtonStyleClass = "RadialMenuCloseButton" | ||
}; | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
_menu.OnClose += Close; | ||
|
||
if (_openCentered) | ||
_menu.OpenCentered(); | ||
else | ||
_menu.OpenCenteredAt(_inputManager.MouseScreenPosition.Position / _displayManager.ScreenSize); | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
|
||
if (state is not RadialSelectorState radialSelectorState) | ||
return; | ||
|
||
ClearExistingContainers(); | ||
CreateMenu(radialSelectorState.Entries); | ||
_openCentered = radialSelectorState.OpenCentered; | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
if (disposing) | ||
_menu.Dispose(); | ||
} | ||
|
||
private void CreateMenu(List<RadialSelectorEntry> entries, string parentCategory = "") | ||
{ | ||
var container = new RadialContainer | ||
{ | ||
Name = !string.IsNullOrEmpty(parentCategory) ? parentCategory : "Main", | ||
Radius = 48f + 24f * MathF.Log(entries.Count), | ||
}; | ||
|
||
_menu.AddChild(container); | ||
_cachedContainers.Add(container); | ||
|
||
foreach (var entry in entries) | ||
{ | ||
if (entry.Category != null) | ||
{ | ||
var button = CreateButton(entry.Category.Name, _spriteSystem.Frame0(entry.Category.Icon)); | ||
button.TargetLayer = entry.Category.Name; | ||
CreateMenu(entry.Category.Entries, entry.Category.Name); | ||
container.AddChild(button); | ||
} | ||
else if (entry.Prototype != null) | ||
{ | ||
var name = GetName(entry.Prototype); | ||
var icon = GetIcon(entry); | ||
if (icon is null) | ||
return; | ||
|
||
var button = CreateButton(name, icon); | ||
button.OnButtonUp += _ => | ||
{ | ||
var msg = new RadialSelectorSelectedMessage(entry.Prototype); | ||
SendPredictedMessage(msg); | ||
}; | ||
|
||
container.AddChild(button); | ||
} | ||
} | ||
} | ||
|
||
private string GetName(string proto) | ||
{ | ||
if (_protoManager.TryIndex(proto, out var prototype)) | ||
return prototype.Name; | ||
if (_protoManager.TryIndex(proto, out ConstructionPrototype? constructionPrototype)) | ||
return constructionPrototype.Name; | ||
return proto; | ||
} | ||
|
||
private Texture? GetIcon(RadialSelectorEntry entry) | ||
{ | ||
if (_protoManager.TryIndex(entry.Prototype!, out var prototype)) | ||
return _spriteSystem.Frame0(prototype); | ||
|
||
if (_protoManager.TryIndex(entry.Prototype!, out ConstructionPrototype? constructionProto)) | ||
return _spriteSystem.Frame0(constructionProto.Icon); | ||
|
||
if (entry.Icon is not null) | ||
return _spriteSystem.Frame0(entry.Icon); | ||
|
||
// No icons provided and no icons found in prototypes. There's nothing we can do. | ||
return null; | ||
} | ||
|
||
private RadialMenuTextureButton CreateButton(string name, Texture icon) | ||
{ | ||
var itemSize = new Vector2(64f, 64f); | ||
var button = new RadialMenuTextureButton | ||
{ | ||
ToolTip = Loc.GetString(name), | ||
StyleClasses = { "RadialMenuButton" }, | ||
SetSize = itemSize | ||
}; | ||
|
||
var iconScale = itemSize / icon.Size; | ||
var texture = new TextureRect | ||
{ | ||
VerticalAlignment = Control.VAlignment.Center, | ||
HorizontalAlignment = Control.HAlignment.Center, | ||
Texture = icon, | ||
TextureScale = iconScale | ||
}; | ||
|
||
button.AddChild(texture); | ||
return button; | ||
} | ||
|
||
private void ClearExistingContainers() | ||
{ | ||
foreach (var container in _cachedContainers) | ||
_menu.RemoveChild(container); | ||
|
||
_cachedContainers.Clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Content.Shared.Shadowkin; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Player; | ||
using Content.Client.Overlays; | ||
|
||
namespace Content.Client.Shadowkin; | ||
|
||
public sealed partial class EtherealSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IOverlayManager _overlayMan = default!; | ||
[Dependency] private readonly ISharedPlayerManager _playerMan = default!; | ||
|
||
private EtherealOverlay _overlay = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<EtherealComponent, ComponentInit>(OnInit); | ||
SubscribeLocalEvent<EtherealComponent, ComponentShutdown>(Onhutdown); | ||
SubscribeLocalEvent<EtherealComponent, LocalPlayerAttachedEvent>(OnPlayerAttached); | ||
SubscribeLocalEvent<EtherealComponent, LocalPlayerDetachedEvent>(OnPlayerDetached); | ||
|
||
_overlay = new(); | ||
} | ||
|
||
private void OnInit(EntityUid uid, EtherealComponent component, ComponentInit args) | ||
{ | ||
if (uid != _playerMan.LocalEntity) | ||
return; | ||
|
||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void Onhutdown(EntityUid uid, EtherealComponent component, ComponentShutdown args) | ||
{ | ||
if (uid != _playerMan.LocalEntity) | ||
return; | ||
|
||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerAttached(EntityUid uid, EtherealComponent component, LocalPlayerAttachedEvent args) | ||
{ | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerDetached(EntityUid uid, EtherealComponent component, LocalPlayerDetachedEvent args) | ||
{ | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
} |
Oops, something went wrong.