Skip to content

Commit

Permalink
Port PR42 files directly
Browse files Browse the repository at this point in the history
  • Loading branch information
vaketola committed Nov 6, 2023
1 parent a4b6ce7 commit 530dcde
Show file tree
Hide file tree
Showing 150 changed files with 3,779 additions and 43 deletions.
7 changes: 6 additions & 1 deletion Content.Client/Chat/Managers/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ public void SendMessage(string text, ChatSelectChannel channel)
_consoleHost.ExecuteCommand($"tsay \"{CommandParsing.Escape(str)}\"");
break;

// Parkstation - Shadowkin chat
case ChatSelectChannel.Empathy:
_consoleHost.ExecuteCommand($"esay \"{CommandParsing.Escape(str)}\"");
break;

default:
throw new ArgumentOutOfRangeException(nameof(channel), channel, null);
}
}
//Nyano - Summary: fires off the update permissions script.
//Nyano - Summary: fires off the update permissions script.
public void UpdatePermissions()
{
PermissionsUpdated?.Invoke();
Expand Down
33 changes: 33 additions & 0 deletions Content.Client/SimpleStation14/Chat/ShadowkinChatUpdateSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Content.Client.Chat.Managers;
using Robust.Client.Player;
using Content.Shared.SimpleStation14.Species.Shadowkin.Components;

namespace Content.Client.SimpleStation14.Chat
{
public sealed class ShadowkinChatUpdateSystem : EntitySystem
{
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<EmpathyChatComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<EmpathyChatComponent, ComponentRemove>(OnRemove);
}

public EmpathyChatComponent? Player => CompOrNull<EmpathyChatComponent>(_playerManager.LocalPlayer?.ControlledEntity);
public bool IsShadowkin => Player != null;

private void OnInit(EntityUid uid, EmpathyChatComponent component, ComponentInit args)
{
_chatManager.UpdatePermissions();
}

private void OnRemove(EntityUid uid, EmpathyChatComponent component, ComponentRemove args)
{
_chatManager.UpdatePermissions();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;

namespace Content.Client.SimpleStation14.Overlays.Shaders;

/// <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] private readonly IEntityManager _entity = 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;
/// <summary>
/// Component required to be on the entity to tint the screen.
/// </summary>
public Component? Comp = null;

public ColorTintOverlay()
{
IoCManager.InjectDependencies(this);

_shader = _prototype.Index<ShaderPrototype>("ColorTint").InstanceUnique();
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture == null ||
_player.LocalPlayer?.ControlledEntity is not { Valid: true } player ||
Comp != null && !_entity.HasComponent(player, Comp.GetType()))
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);
}
}
37 changes: 37 additions & 0 deletions Content.Client/SimpleStation14/Overlays/Shaders/EtherealOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;

namespace Content.Client.SimpleStation14.Overlays.Shaders;

public sealed class EtherealOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IPlayerManager _player = 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 void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture == null) return;
if (_player.LocalPlayer?.ControlledEntity is not { Valid: true } player) 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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using Content.Shared.Humanoid;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;

namespace Content.Client.SimpleStation14.Overlays.Shaders;

public sealed class IgnoreHumanoidWithComponentOverlay : Overlay
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;

public List<Component> IgnoredComponents = new();
public List<Component> AllowAnywayComponents = new();
private readonly List<EntityUid> _nonVisibleList = new();

public IgnoreHumanoidWithComponentOverlay()
{
IoCManager.InjectDependencies(this);
}

protected override void Draw(in OverlayDrawArgs args)
{
var spriteQuery = _entityManager.GetEntityQuery<SpriteComponent>();

foreach (var humanoid in _entityManager.EntityQuery<HumanoidAppearanceComponent>(true))
{
if (_playerManager.LocalPlayer?.ControlledEntity == humanoid.Owner)
continue;

var cont = true;
foreach (var comp in IgnoredComponents)
{
if (!_entityManager.HasComponent(humanoid.Owner, comp.GetType()))
continue;

cont = false;
break;
}
foreach (var comp in AllowAnywayComponents)
{
if (!_entityManager.HasComponent(humanoid.Owner, comp.GetType()))
continue;

cont = true;
break;
}
if (cont)
{
Reset(humanoid.Owner);
continue;
}


if (!spriteQuery.TryGetComponent(humanoid.Owner, out var sprite))
continue;

if (!sprite.Visible || _nonVisibleList.Contains(humanoid.Owner))
continue;

sprite.Visible = false;
_nonVisibleList.Add(humanoid.Owner);
}

foreach (var humanoid in _nonVisibleList.ToArray())
{
if (!_entityManager.Deleted(humanoid))
continue;

_nonVisibleList.Remove(humanoid);
}
}


public void Reset()
{
foreach (var humanoid in _nonVisibleList.ToArray())
{
_nonVisibleList.Remove(humanoid);

if (_entityManager.TryGetComponent<SpriteComponent>(humanoid, out var sprite))
sprite.Visible = true;
}
}

public void Reset(EntityUid entity)
{
if (!_nonVisibleList.Contains(entity))
return;

_nonVisibleList.Remove(entity);

if (_entityManager.TryGetComponent<SpriteComponent>(entity, out var sprite))
sprite.Visible = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Content.Client.SimpleStation14.Overlays;
using Content.Client.SimpleStation14.Overlays.Shaders;
using Content.Shared.SimpleStation14.Species.Shadowkin.Components;
using Robust.Client.GameObjects;
using Content.Shared.Humanoid;

namespace Content.Client.SimpleStation14.Species.Shadowkin.Systems;

public sealed class ShadowkinDarkSwappedSystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IOverlayManager _overlay = default!;

private IgnoreHumanoidWithComponentOverlay _ignoreOverlay = default!;
private EtherealOverlay _etherealOverlay = default!;

public override void Initialize()
{
base.Initialize();

_ignoreOverlay = new IgnoreHumanoidWithComponentOverlay();
_ignoreOverlay.IgnoredComponents.Add(new HumanoidAppearanceComponent());
_ignoreOverlay.AllowAnywayComponents.Add(new ShadowkinDarkSwappedComponent());
_etherealOverlay = new EtherealOverlay();

SubscribeLocalEvent<ShadowkinDarkSwappedComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<ShadowkinDarkSwappedComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<ShadowkinDarkSwappedComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<ShadowkinDarkSwappedComponent, PlayerDetachedEvent>(OnPlayerDetached);
}


private void OnStartup(EntityUid uid, ShadowkinDarkSwappedComponent component, ComponentStartup args)
{
if (_player.LocalPlayer?.ControlledEntity != uid)
return;

AddOverlay();
}

private void OnShutdown(EntityUid uid, ShadowkinDarkSwappedComponent component, ComponentShutdown args)
{
if (_player.LocalPlayer?.ControlledEntity != uid)
return;

RemoveOverlay();
}

private void OnPlayerAttached(EntityUid uid, ShadowkinDarkSwappedComponent component, PlayerAttachedEvent args)
{
AddOverlay();
}

private void OnPlayerDetached(EntityUid uid, ShadowkinDarkSwappedComponent component, PlayerDetachedEvent args)
{
RemoveOverlay();
}


private void AddOverlay()
{
_overlay.AddOverlay(_ignoreOverlay);
_overlay.AddOverlay(_etherealOverlay);
}

private void RemoveOverlay()
{
_ignoreOverlay.Reset();
_overlay.RemoveOverlay(_ignoreOverlay);
_overlay.RemoveOverlay(_etherealOverlay);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Content.Shared.SimpleStation14.Species.Shadowkin.Events;
using Content.Shared.SimpleStation14.Species.Shadowkin.Components;
using Robust.Client.GameObjects;
using Content.Shared.Humanoid;

namespace Content.Client.SimpleStation14.Species.Shadowkin.Systems;

public sealed class ShadowkinBlackeyeSystem : EntitySystem
{
[Dependency] private readonly IEntityManager _entity = default!;

public override void Initialize()
{
base.Initialize();

SubscribeNetworkEvent<ShadowkinBlackeyeEvent>(OnBlackeye);

SubscribeLocalEvent<ShadowkinComponent, ComponentInit>(OnInit);
}

private void OnBlackeye(ShadowkinBlackeyeEvent ev)
{
SetColor(ev.Uid, Color.Black);
}


private void OnInit(EntityUid uid, ShadowkinComponent component, ComponentInit args)
{
if (!_entity.TryGetComponent<SpriteComponent>(uid, out var sprite) ||
!sprite.LayerMapTryGet(HumanoidVisualLayers.Eyes, out var index) ||
!sprite.TryGetLayer(index, out var layer))
return;

// Blackeye if none of the RGB values are greater than 75
if (layer.Color.R * 255 < 75 && layer.Color.G * 255 < 75 && layer.Color.B * 255 < 75)
{
RaiseNetworkEvent(new ShadowkinBlackeyeEvent(uid, false));
}
}


private void SetColor(EntityUid uid, Color color)
{
if (!_entity.TryGetComponent<SpriteComponent>(uid, out var sprite) ||
!sprite.LayerMapTryGet(HumanoidVisualLayers.Eyes, out var index) ||
!sprite.TryGetLayer(index, out var layer))
return;

sprite.LayerSetColor(index, color);
}
}
Loading

0 comments on commit 530dcde

Please sign in to comment.