-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Port-Sacrificing
- Loading branch information
Showing
214 changed files
with
4,818 additions
and
500 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,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,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); | ||
} | ||
} |
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,114 @@ | ||
using Content.Shared.Shadowkin; | ||
using Content.Shared.CCVar; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Player; | ||
using Content.Shared.Humanoid; | ||
using Content.Shared.Abilities.Psionics; | ||
using Content.Client.Overlays; | ||
|
||
namespace Content.Client.Shadowkin; | ||
|
||
public sealed partial class ShadowkinSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IOverlayManager _overlayMan = default!; | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
[Dependency] private readonly ISharedPlayerManager _playerMan = default!; | ||
|
||
private ColorTintOverlay _overlay = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<ShadowkinComponent, ComponentInit>(OnInit); | ||
SubscribeLocalEvent<ShadowkinComponent, ComponentShutdown>(Onhutdown); | ||
SubscribeLocalEvent<ShadowkinComponent, LocalPlayerAttachedEvent>(OnPlayerAttached); | ||
SubscribeLocalEvent<ShadowkinComponent, LocalPlayerDetachedEvent>(OnPlayerDetached); | ||
|
||
Subs.CVar(_cfg, CCVars.NoVisionFilters, OnNoVisionFiltersChanged); | ||
|
||
_overlay = new(); | ||
} | ||
|
||
private void OnInit(EntityUid uid, ShadowkinComponent component, ComponentInit args) | ||
{ | ||
if (uid != _playerMan.LocalEntity | ||
|| _cfg.GetCVar(CCVars.NoVisionFilters)) | ||
return; | ||
|
||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void Onhutdown(EntityUid uid, ShadowkinComponent component, ComponentShutdown args) | ||
{ | ||
if (uid != _playerMan.LocalEntity) | ||
return; | ||
|
||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerAttached(EntityUid uid, ShadowkinComponent component, LocalPlayerAttachedEvent args) | ||
{ | ||
if (_cfg.GetCVar(CCVars.NoVisionFilters)) | ||
return; | ||
|
||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerDetached(EntityUid uid, ShadowkinComponent component, LocalPlayerDetachedEvent args) | ||
{ | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnNoVisionFiltersChanged(bool enabled) | ||
{ | ||
if (enabled) | ||
_overlayMan.RemoveOverlay(_overlay); | ||
else | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
|
||
if (_cfg.GetCVar(CCVars.NoVisionFilters)) | ||
return; | ||
|
||
var uid = _playerMan.LocalEntity; | ||
if (uid == null | ||
|| !TryComp<ShadowkinComponent>(uid, out var comp) | ||
|| !TryComp<HumanoidAppearanceComponent>(uid, out var humanoid)) | ||
return; | ||
|
||
// 1/3 = 0.333... | ||
// intensity = min + (power / max) | ||
// intensity = intensity / 0.333 | ||
// intensity = clamp intensity min, max | ||
|
||
var tintIntensity = 0.65f; | ||
if (TryComp<PsionicComponent>(uid, out var magic)) | ||
{ | ||
var min = 0.45f; | ||
var max = 0.75f; | ||
tintIntensity = Math.Clamp(min + (magic.Mana / magic.MaxMana) * 0.333f, min, max); | ||
} | ||
|
||
UpdateShader(new Vector3(humanoid.EyeColor.R, humanoid.EyeColor.G, humanoid.EyeColor.B), tintIntensity); | ||
} | ||
|
||
private void UpdateShader(Vector3? color, float? intensity) | ||
{ | ||
while (_overlayMan.HasOverlay<ColorTintOverlay>()) | ||
_overlayMan.RemoveOverlay(_overlay); | ||
|
||
if (color != null) | ||
_overlay.TintColor = color; | ||
if (intensity != null) | ||
_overlay.TintAmount = intensity; | ||
|
||
if (!_cfg.GetCVar(CCVars.NoVisionFilters)) | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Content.Server/Abilities/Psionics/Abilities/DarkSwapSystem.cs
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,58 @@ | ||
using Content.Shared.Abilities.Psionics; | ||
using Content.Shared.Actions.Events; | ||
using Content.Shared.Shadowkin; | ||
using Content.Shared.Physics; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Maps; | ||
using Robust.Server.GameObjects; | ||
|
||
namespace Content.Server.Abilities.Psionics | ||
{ | ||
public sealed class DarkSwapSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedPsionicAbilitiesSystem _psionics = default!; | ||
[Dependency] private readonly SharedPopupSystem _popup = default!; | ||
[Dependency] private readonly PhysicsSystem _physics = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<DarkSwapActionEvent>(OnPowerUsed); | ||
} | ||
|
||
private void OnPowerUsed(DarkSwapActionEvent args) | ||
{ | ||
if (TryComp<EtherealComponent>(args.Performer, out var ethereal)) | ||
{ | ||
var tileref = Transform(args.Performer).Coordinates.GetTileRef(); | ||
if (tileref != null | ||
&& _physics.GetEntitiesIntersectingBody(args.Performer, (int) CollisionGroup.Impassable).Count > 0) | ||
{ | ||
_popup.PopupEntity(Loc.GetString("revenant-in-solid"), args.Performer, args.Performer); | ||
return; | ||
} | ||
|
||
if (_psionics.OnAttemptPowerUse(args.Performer, "DarkSwap", args.ManaCost / 2, args.CheckInsulation)) | ||
{ | ||
RemComp(args.Performer, ethereal); | ||
args.Handled = true; | ||
} | ||
} | ||
else if (_psionics.OnAttemptPowerUse(args.Performer, "DarkSwap", args.ManaCost, args.CheckInsulation)) | ||
{ | ||
var newethereal = EnsureComp<EtherealComponent>(args.Performer); | ||
newethereal.Darken = true; | ||
|
||
SpawnAtPosition("ShadowkinShadow", Transform(args.Performer).Coordinates); | ||
SpawnAtPosition("EffectFlashShadowkinDarkSwapOn", Transform(args.Performer).Coordinates); | ||
|
||
args.Handled = true; | ||
} | ||
|
||
if (args.Handled) | ||
_psionics.LogPowerUsed(args.Performer, "DarkSwap", 0, 0); | ||
} | ||
} | ||
} | ||
|
||
|
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
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
Oops, something went wrong.