Skip to content

Commit

Permalink
Merge branch 'master' into Port-Sacrificing
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus authored Oct 20, 2024
2 parents e202128 + 5c91d23 commit 0344064
Show file tree
Hide file tree
Showing 214 changed files with 4,818 additions and 500 deletions.
63 changes: 63 additions & 0 deletions Content.Client/Overlays/ColorTintOverlay.cs
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);
}
}
48 changes: 48 additions & 0 deletions Content.Client/Overlays/EtherealOverlay.cs
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);
}
}
52 changes: 52 additions & 0 deletions Content.Client/Shadowkin/EtherealSystem.cs
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);
}
}
114 changes: 114 additions & 0 deletions Content.Client/Shadowkin/ShadowkinSystem.cs
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 Content.Server/Abilities/Psionics/Abilities/DarkSwapSystem.cs
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);
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public override void Initialize()

private void OnPowerUsed(DispelPowerActionEvent args)
{
if (!_psionics.OnAttemptPowerUse(args.Performer, "dispel"))
return;

var ev = new DispelledEvent();
RaiseLocalEvent(args.Target, ev, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override void Initialize()

private void OnPowerUsed(EntityUid uid, PsionicComponent component, PsionicHealOtherPowerActionEvent args)
{
if (component.DoAfter is not null)
if (!_psionics.OnAttemptPowerUse(args.Performer, args.PowerName))
return;

args.ModifiedAmplification = _psionics.ModifiedAmplification(uid, component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public override void Initialize()

private void OnPowerUsed(EntityUid uid, MetapsionicPowerComponent component, MetapsionicPowerActionEvent args)
{
if (!_psionics.OnAttemptPowerUse(args.Performer, "metapsionic pulse"))
return;

foreach (var entity in _lookup.GetEntitiesInRange(uid, component.Range))
{
if (HasComp<PsionicComponent>(entity) && entity != uid && !HasComp<PsionicInsulationComponent>(entity) &&
Expand Down
Loading

0 comments on commit 0344064

Please sign in to comment.