Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Bird, the Vulp and the Un-Cloneable #1316

Merged
merged 15 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Content.Client/DeltaV/Options/UI/Tabs/DeltaTab.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<tabs:DeltaTab xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:tabs="clr-namespace:Content.Client.DeltaV.Options.UI.Tabs"
xmlns:xNamespace="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Content.Client.Stylesheets">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Vertical" Margin="8 8 8 8" VerticalExpand="True">
<Label Text="{Loc 'ui-options-general-forknotice'}"
FontColorOverride="{xNamespace:Static s:StyleNano.ConcerningOrangeFore}"
StyleClasses="LabelKeyText"/>
<Label Text="{Loc 'ui-options-general-accessibility'}"
FontColorOverride="{xNamespace:Static s:StyleNano.NanoGold}"
StyleClasses="LabelKeyText"/>
<CheckBox Name="DisableFiltersCheckBox" Text="{Loc 'ui-options-no-filters'}" />
</BoxContainer>
<controls:StripeBack HasBottomEdge="False" HasMargins="False">
<Button Name="ApplyButton"
Text="{Loc 'ui-options-apply'}"
TextAlign="Center"
HorizontalAlignment="Right" />
</controls:StripeBack>
</BoxContainer>
</tabs:DeltaTab>
46 changes: 46 additions & 0 deletions Content.Client/DeltaV/Options/UI/Tabs/DeltaTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Content.Shared.DeltaV.CCVars;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;

namespace Content.Client.DeltaV.Options.UI.Tabs;

[GenerateTypedNameReferences]
public sealed partial class DeltaTab : Control
{
[Dependency] private readonly IConfigurationManager _cfg = default!;

public DeltaTab()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

DisableFiltersCheckBox.OnToggled += OnCheckBoxToggled;
DisableFiltersCheckBox.Pressed = _cfg.GetCVar(DCCVars.NoVisionFilters);

ApplyButton.OnPressed += OnApplyButtonPressed;
UpdateApplyButton();
}

private void OnCheckBoxToggled(BaseButton.ButtonToggledEventArgs args)
{
UpdateApplyButton();
}

private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
{
_cfg.SetCVar(DCCVars.NoVisionFilters, DisableFiltersCheckBox.Pressed);

_cfg.SaveToFile();
UpdateApplyButton();
}

private void UpdateApplyButton()
{
var isNoVisionFiltersSame = DisableFiltersCheckBox.Pressed == _cfg.GetCVar(DCCVars.NoVisionFilters);

ApplyButton.Disabled = isNoVisionFiltersSame;
}
}
23 changes: 15 additions & 8 deletions Content.Client/DeltaV/Overlays/UltraVisionOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Content.Shared.DeltaV.Abilities;
using Content.Shared.Abilities;

namespace Content.Client.DeltaV.Overlays;

Expand All @@ -23,22 +23,29 @@ public UltraVisionOverlay()
_ultraVisionShader = _prototypeManager.Index<ShaderPrototype>("UltraVision").Instance().Duplicate();
}

protected override bool BeforeDraw(in OverlayDrawArgs args)
{
if (_playerManager.LocalEntity is not { Valid: true } player
|| !_entityManager.HasComponent<UltraVisionComponent>(player))
{
return false;
}

return base.BeforeDraw(in args);
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture == null)
if (ScreenTexture is null)
return;
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player)
return;
if (!_entityManager.HasComponent<UltraVisionComponent>(player))
return;

_ultraVisionShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);

_ultraVisionShader.SetParameter("SCREEN_TEXTURE", ScreenTexture);

var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
worldHandle.SetTransform(Matrix3.Identity);
worldHandle.UseShader(_ultraVisionShader);
worldHandle.DrawRect(viewport, Color.White);
worldHandle.UseShader(null); // important - as of writing, construction overlay breaks without this
}
}
36 changes: 33 additions & 3 deletions Content.Client/DeltaV/Overlays/UltraVisionSystem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
using Content.Shared.DeltaV.Abilities;
using Content.Shared.Abilities;
using Content.Shared.DeltaV.CCVars;
using Robust.Client.Graphics;
using Robust.Shared.Configuration;
using Robust.Shared.Player;

namespace Content.Client.DeltaV.Overlays;

public sealed partial class UltraVisionSystem : EntitySystem
{
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly ISharedPlayerManager _playerMan = default!;

private UltraVisionOverlay _overlay = default!;

Expand All @@ -15,17 +20,42 @@ public override void Initialize()

SubscribeLocalEvent<UltraVisionComponent, ComponentInit>(OnUltraVisionInit);
SubscribeLocalEvent<UltraVisionComponent, ComponentShutdown>(OnUltraVisionShutdown);

SubscribeLocalEvent<UltraVisionComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<UltraVisionComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

Subs.CVar(_cfg, DCCVars.NoVisionFilters, OnNoVisionFiltersChanged);

_overlay = new();
}

private void OnUltraVisionInit(EntityUid uid, UltraVisionComponent component, ComponentInit args)
{
_overlayMan.AddOverlay(_overlay);
if (uid == _playerMan.LocalEntity && !_cfg.GetCVar(DCCVars.NoVisionFilters))
_overlayMan.AddOverlay(_overlay);
}

private void OnUltraVisionShutdown(EntityUid uid, UltraVisionComponent component, ComponentShutdown args)
{
if (uid == _playerMan.LocalEntity)
_overlayMan.RemoveOverlay(_overlay);
}

private void OnPlayerAttached(EntityUid uid, UltraVisionComponent component, LocalPlayerAttachedEvent args)
{
if (!_cfg.GetCVar(DCCVars.NoVisionFilters))
_overlayMan.AddOverlay(_overlay);
}

private void OnPlayerDetached(EntityUid uid, UltraVisionComponent component, LocalPlayerDetachedEvent args)
{
_overlayMan.RemoveOverlay(_overlay);
}

private void OnNoVisionFiltersChanged(bool enabled)
{
if (enabled)
_overlayMan.RemoveOverlay(_overlay);
else
_overlayMan.AddOverlay(_overlay);
}
}
51 changes: 51 additions & 0 deletions Content.Client/Nyanotrasen/Overlays/DogVisionOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Content.Shared.Abilities;

namespace Content.Client.Nyanotrasen.Overlays;

public sealed partial class DogVisionOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] IEntityManager _entityManager = default!;


public override bool RequestScreenTexture => true;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _dogVisionShader;

public DogVisionOverlay()
{
IoCManager.InjectDependencies(this);
_dogVisionShader = _prototypeManager.Index<ShaderPrototype>("DogVision").Instance().Duplicate();
}

protected override bool BeforeDraw(in OverlayDrawArgs args)
{
if (_playerManager.LocalEntity is not { Valid: true } player
|| !_entityManager.HasComponent<DogVisionComponent>(player))
{
return false;
}

return base.BeforeDraw(in args);
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture is null)
return;

_dogVisionShader.SetParameter("SCREEN_TEXTURE", ScreenTexture);

var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
worldHandle.SetTransform(Matrix3.Identity);
worldHandle.UseShader(_dogVisionShader);
worldHandle.DrawRect(viewport, Color.White);
worldHandle.UseShader(null); // important - as of writing, construction overlay breaks without this
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using Content.Shared.Abilities;
using Robust.Client.GameObjects;
using Content.Shared.DeltaV.CCVars;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Player;

namespace Content.Client.Nyanotrasen.Overlays;
public sealed class DogVisionSystem : EntitySystem

public sealed partial class DogVisionSystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly ISharedPlayerManager _playerMan = default!;

private DogVisionOverlay _overlay = default!;

Expand All @@ -18,34 +20,42 @@ public override void Initialize()

SubscribeLocalEvent<DogVisionComponent, ComponentInit>(OnDogVisionInit);
SubscribeLocalEvent<DogVisionComponent, ComponentShutdown>(OnDogVisionShutdown);

SubscribeLocalEvent<DogVisionComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<DogVisionComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

Subs.CVar(_cfg, DCCVars.NoVisionFilters, OnNoVisionFiltersChanged);

_overlay = new();
}

private void OnPlayerAttached(EntityUid uid, DogVisionComponent component, LocalPlayerAttachedEvent args)
private void OnDogVisionInit(EntityUid uid, DogVisionComponent component, ComponentInit args)
{
_overlayMan.AddOverlay(_overlay);
if (uid == _playerMan.LocalEntity && !_cfg.GetCVar(DCCVars.NoVisionFilters))
_overlayMan.AddOverlay(_overlay);
}

private void OnPlayerDetached(EntityUid uid, DogVisionComponent component, LocalPlayerDetachedEvent args)
private void OnDogVisionShutdown(EntityUid uid, DogVisionComponent component, ComponentShutdown args)
{
_overlayMan.RemoveOverlay(_overlay);
if (uid == _playerMan.LocalEntity)
_overlayMan.RemoveOverlay(_overlay);
}

private void OnDogVisionInit(EntityUid uid, DogVisionComponent component, ComponentInit args)
private void OnPlayerAttached(EntityUid uid, DogVisionComponent component, LocalPlayerAttachedEvent args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
if (!_cfg.GetCVar(DCCVars.NoVisionFilters))
_overlayMan.AddOverlay(_overlay);
}

private void OnDogVisionShutdown(EntityUid uid, DogVisionComponent component, ComponentShutdown args)
private void OnPlayerDetached(EntityUid uid, DogVisionComponent component, LocalPlayerDetachedEvent args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
{
_overlayMan.RemoveOverlay(_overlay);
}

private void OnNoVisionFiltersChanged(bool enabled)
{
if (enabled)
_overlayMan.RemoveOverlay(_overlay);
}
else
_overlayMan.AddOverlay(_overlay);
}
}
45 changes: 0 additions & 45 deletions Content.Client/Nyanotrasen/Overlays/Overlays/DogVisionOverlay.cs

This file was deleted.

2 changes: 2 additions & 0 deletions Content.Client/Options/UI/OptionsMenu.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:tabs="clr-namespace:Content.Client.Options.UI.Tabs"
xmlns:dtabs="clr-namespace:Content.Client.DeltaV.Options.UI.Tabs"
Title="{Loc 'ui-options-title'}"
MinSize="800 450">
<TabContainer Name="Tabs" Access="Public">
Expand All @@ -8,5 +9,6 @@
<tabs:KeyRebindTab Name="KeyRebindTab" />
<tabs:AudioTab Name="AudioTab" />
<tabs:NetworkTab Name="NetworkTab" />
<dtabs:DeltaTab Name="ExtraTab" />
</TabContainer>
</DefaultWindow>
1 change: 1 addition & 0 deletions Content.Client/Options/UI/OptionsMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public OptionsMenu()
Tabs.SetTabTitle(2, Loc.GetString("ui-options-tab-controls"));
Tabs.SetTabTitle(3, Loc.GetString("ui-options-tab-audio"));
Tabs.SetTabTitle(4, Loc.GetString("ui-options-tab-network"));
Tabs.SetTabTitle(5, Loc.GetString("ui-options-tab-extra")); // Extra settings

UpdateTabs();
}
Expand Down
13 changes: 13 additions & 0 deletions Content.Server/Cloning/CloningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponen
if (_configManager.GetCVar(CCVars.BiomassEasyMode))
cloningCost = (int) Math.Round(cloningCost * EasyModeCloningCost);

// Check if they have the uncloneable trait
if (TryComp<UncloneableComponent>(bodyToClone, out _))
{
if (clonePod.ConnectedConsole != null)
{
_chatSystem.TrySendInGameICMessage(clonePod.ConnectedConsole.Value,
Loc.GetString("cloning-console-uncloneable-trait-error"),
InGameICChatType.Speak, false);
}

return false;
}

// biomass checks
var biomassAmount = _material.GetMaterialAmount(uid, clonePod.RequiredMaterial);

Expand Down
Loading
Loading