Enable nullability in Content.Client (#3257)

* Enable nullability in Content.Client

* Remove #nullable enable

* Merge fixes

* Remove Debug.Assert

* Merge fixes

* Fix build

* Fix build
This commit is contained in:
DrSmugleaf
2021-03-10 14:48:29 +01:00
committed by GitHub
parent 4f9bd4e802
commit 902aa128c2
270 changed files with 1774 additions and 1550 deletions

View File

@@ -7,8 +7,6 @@ using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Network; using Robust.Shared.Network;
#nullable enable
namespace Content.Client.Administration namespace Content.Client.Administration
{ {
public class ClientAdminManager : IClientAdminManager, IClientConGroupImplementation, IPostInjectInit public class ClientAdminManager : IClientAdminManager, IClientConGroupImplementation, IPostInjectInit

View File

@@ -1,8 +1,6 @@
using System; using System;
using Content.Shared.Administration; using Content.Shared.Administration;
#nullable enable
namespace Content.Client.Administration namespace Content.Client.Administration
{ {
/// <summary> /// <summary>

View File

@@ -1,32 +1,31 @@
using System;
using Robust.Client.Animations; using Robust.Client.Animations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.Animations; using Robust.Shared.Animations;
using Robust.Shared.GameObjects;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using System;
using Robust.Shared.GameObjects;
namespace Content.Client.Animations namespace Content.Client.Animations
{ {
public static class ReusableAnimations public static class ReusableAnimations
{ {
public static void AnimateEntityPickup(IEntity entity, EntityCoordinates initialPosition, Vector2 finalPosition) public static void AnimateEntityPickup(IEntity entity, EntityCoordinates initialPosition, Vector2 finalPosition)
{ {
var animatableClone = entity.EntityManager.SpawnEntity("clientsideclone", initialPosition); var animatableClone = entity.EntityManager.SpawnEntity("clientsideclone", initialPosition);
animatableClone.Name = entity.Name; animatableClone.Name = entity.Name;
if(!entity.TryGetComponent(out SpriteComponent sprite0)) if (!entity.TryGetComponent(out SpriteComponent? sprite0))
{ {
Logger.Error($"Entity ({0}) couldn't be animated for pickup since it doesn't have a {1}!", entity.Name, nameof(SpriteComponent)); Logger.Error("Entity ({0}) couldn't be animated for pickup since it doesn't have a {1}!", entity.Name, nameof(SpriteComponent));
return; return;
} }
var sprite = animatableClone.GetComponent<SpriteComponent>(); var sprite = animatableClone.GetComponent<SpriteComponent>();
sprite.CopyFrom(sprite0); sprite.CopyFrom(sprite0);
var animations = animatableClone.GetComponent<AnimationPlayerComponent>(); var animations = animatableClone.GetComponent<AnimationPlayerComponent>();
animations.AnimationCompleted += (s) => { animations.AnimationCompleted += (_) => {
animatableClone.Delete(); animatableClone.Delete();
}; };
@@ -42,13 +41,12 @@ namespace Content.Client.Animations
InterpolationMode = AnimationInterpolationMode.Linear, InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames = KeyFrames =
{ {
new AnimationTrackComponentProperty.KeyFrame(initialPosition.Position, 0), new AnimationTrackProperty.KeyFrame(initialPosition.Position, 0),
new AnimationTrackComponentProperty.KeyFrame(finalPosition, 0.125f) new AnimationTrackProperty.KeyFrame(finalPosition, 0.125f)
} }
} }
} }
}, "fancy_pickup_anim"); }, "fancy_pickup_anim");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Content.Client.GameObjects.Components.Arcade; using Content.Client.GameObjects.Components.Arcade;
@@ -29,27 +29,27 @@ namespace Content.Client.Arcade
private readonly PanelContainer _mainPanel; private readonly PanelContainer _mainPanel;
private VBoxContainer _gameRootContainer; private VBoxContainer _gameRootContainer;
private GridContainer _gameGrid; private GridContainer _gameGrid = default!;
private GridContainer _nextBlockGrid; private GridContainer _nextBlockGrid = default!;
private GridContainer _holdBlockGrid; private GridContainer _holdBlockGrid = default!;
private Label _pointsLabel; private readonly Label _pointsLabel;
private Label _levelLabel; private readonly Label _levelLabel;
private Button _pauseButton; private readonly Button _pauseButton;
private PanelContainer _menuRootContainer; private readonly PanelContainer _menuRootContainer;
private Button _unpauseButton; private readonly Button _unpauseButton;
private Control _unpauseButtonMargin; private readonly Control _unpauseButtonMargin;
private Button _newGameButton; private readonly Button _newGameButton;
private Button _scoreBoardButton; private readonly Button _scoreBoardButton;
private PanelContainer _gameOverRootContainer; private readonly PanelContainer _gameOverRootContainer;
private Label _finalScoreLabel; private readonly Label _finalScoreLabel;
private Button _finalNewGameButton; private readonly Button _finalNewGameButton;
private PanelContainer _highscoresRootContainer; private readonly PanelContainer _highscoresRootContainer;
private Label _localHighscoresLabel; private readonly Label _localHighscoresLabel;
private Label _globalHighscoresLabel; private readonly Label _globalHighscoresLabel;
private Button _highscoreBackButton; private readonly Button _highscoreBackButton;
private bool _isPlayer = false; private bool _isPlayer = false;
private bool _gameOver = false; private bool _gameOver = false;
@@ -64,23 +64,193 @@ namespace Content.Client.Arcade
_mainPanel = new PanelContainer(); _mainPanel = new PanelContainer();
SetupGameMenu(backgroundTexture); #region Game Menu
// building the game container
_gameRootContainer = new VBoxContainer();
_levelLabel = new Label
{
Align = Label.AlignMode.Center,
HorizontalExpand = true
};
_gameRootContainer.AddChild(_levelLabel);
_gameRootContainer.AddChild(new Control
{
MinSize = new Vector2(1,5)
});
_pointsLabel = new Label
{
Align = Label.AlignMode.Center,
HorizontalExpand = true
};
_gameRootContainer.AddChild(_pointsLabel);
_gameRootContainer.AddChild(new Control
{
MinSize = new Vector2(1,10)
});
var gameBox = new HBoxContainer();
gameBox.AddChild(SetupHoldBox(backgroundTexture));
gameBox.AddChild(new Control
{
MinSize = new Vector2(10,1)
});
gameBox.AddChild(SetupGameGrid(backgroundTexture));
gameBox.AddChild(new Control
{
MinSize = new Vector2(10,1)
});
gameBox.AddChild(SetupNextBox(backgroundTexture));
_gameRootContainer.AddChild(gameBox);
_gameRootContainer.AddChild(new Control
{
MinSize = new Vector2(1,10)
});
_pauseButton = new Button
{
Text = Loc.GetString("Pause"),
TextAlign = Label.AlignMode.Center
};
_pauseButton.OnPressed += (e) => TryPause();
_gameRootContainer.AddChild(_pauseButton);
#endregion
_mainPanel.AddChild(_gameRootContainer); _mainPanel.AddChild(_gameRootContainer);
SetupPauseMenu(backgroundTexture); #region Pause Menu
var pauseRootBack = new StyleBoxTexture
SetupGameoverScreen(backgroundTexture);
SetupHighScoreScreen(backgroundTexture);
Contents.AddChild(_mainPanel);
CanKeyboardFocus = true;
}
private void SetupHighScoreScreen(Texture backgroundTexture)
{ {
Texture = backgroundTexture,
Modulate = OverlayShadowColor
};
pauseRootBack.SetPatchMargin(StyleBox.Margin.All, 10);
_menuRootContainer = new PanelContainer
{
PanelOverride = pauseRootBack,
VerticalAlignment = VAlignment.Center,
HorizontalAlignment = HAlignment.Center
};
var pauseInnerBack = new StyleBoxTexture
{
Texture = backgroundTexture,
Modulate = OverlayBackgroundColor
};
pauseInnerBack.SetPatchMargin(StyleBox.Margin.All, 10);
var pauseMenuInnerPanel = new PanelContainer
{
PanelOverride = pauseInnerBack,
VerticalAlignment = VAlignment.Center,
HorizontalAlignment = HAlignment.Center
};
_menuRootContainer.AddChild(pauseMenuInnerPanel);
var pauseMenuContainer = new VBoxContainer
{
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center
};
_newGameButton = new Button
{
Text = Loc.GetString("New Game"),
TextAlign = Label.AlignMode.Center
};
_newGameButton.OnPressed += (e) =>
{
_owner.SendAction(BlockGamePlayerAction.NewGame);
};
pauseMenuContainer.AddChild(_newGameButton);
pauseMenuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
_scoreBoardButton = new Button
{
Text = Loc.GetString("Scoreboard"),
TextAlign = Label.AlignMode.Center
};
_scoreBoardButton.OnPressed += (e) => _owner.SendAction(BlockGamePlayerAction.ShowHighscores);
pauseMenuContainer.AddChild(_scoreBoardButton);
_unpauseButtonMargin = new Control {MinSize = new Vector2(1, 10), Visible = false};
pauseMenuContainer.AddChild(_unpauseButtonMargin);
_unpauseButton = new Button
{
Text = Loc.GetString("Unpause"),
TextAlign = Label.AlignMode.Center,
Visible = false
};
_unpauseButton.OnPressed += (e) =>
{
_owner.SendAction(BlockGamePlayerAction.Unpause);
};
pauseMenuContainer.AddChild(_unpauseButton);
pauseMenuInnerPanel.AddChild(pauseMenuContainer);
#endregion
#region Gameover Screen
var gameOverRootBack = new StyleBoxTexture
{
Texture = backgroundTexture,
Modulate = OverlayShadowColor
};
gameOverRootBack.SetPatchMargin(StyleBox.Margin.All, 10);
_gameOverRootContainer = new PanelContainer
{
PanelOverride = gameOverRootBack,
VerticalAlignment = VAlignment.Center,
HorizontalAlignment = HAlignment.Center
};
var gameOverInnerBack = new StyleBoxTexture
{
Texture = backgroundTexture,
Modulate = OverlayBackgroundColor
};
gameOverInnerBack.SetPatchMargin(StyleBox.Margin.All, 10);
var gameOverMenuInnerPanel = new PanelContainer
{
PanelOverride = gameOverInnerBack,
VerticalAlignment = VAlignment.Center,
HorizontalAlignment = HAlignment.Center
};
_gameOverRootContainer.AddChild(gameOverMenuInnerPanel);
var gameOverMenuContainer = new VBoxContainer
{
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center
};
gameOverMenuContainer.AddChild(new Label{Text = Loc.GetString("Gameover!"),Align = Label.AlignMode.Center});
gameOverMenuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
_finalScoreLabel = new Label{Align = Label.AlignMode.Center};
gameOverMenuContainer.AddChild(_finalScoreLabel);
gameOverMenuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
_finalNewGameButton = new Button
{
Text = Loc.GetString("New Game"),
TextAlign = Label.AlignMode.Center
};
_finalNewGameButton.OnPressed += (e) =>
{
_owner.SendAction(BlockGamePlayerAction.NewGame);
};
gameOverMenuContainer.AddChild(_finalNewGameButton);
gameOverMenuInnerPanel.AddChild(gameOverMenuContainer);
#endregion
#region High Score Screen
var rootBack = new StyleBoxTexture var rootBack = new StyleBoxTexture
{ {
Texture = backgroundTexture, Texture = backgroundTexture,
@@ -143,138 +313,11 @@ namespace Content.Client.Arcade
menuContainer.AddChild(_highscoreBackButton); menuContainer.AddChild(_highscoreBackButton);
menuInnerPanel.AddChild(menuContainer); menuInnerPanel.AddChild(menuContainer);
} #endregion
private void SetupGameoverScreen(Texture backgroundTexture) Contents.AddChild(_mainPanel);
{
var rootBack = new StyleBoxTexture
{
Texture = backgroundTexture,
Modulate = OverlayShadowColor
};
rootBack.SetPatchMargin(StyleBox.Margin.All, 10);
_gameOverRootContainer = new PanelContainer
{
PanelOverride = rootBack,
VerticalAlignment = VAlignment.Center,
HorizontalAlignment = HAlignment.Center
};
var innerBack = new StyleBoxTexture CanKeyboardFocus = true;
{
Texture = backgroundTexture,
Modulate = OverlayBackgroundColor
};
innerBack.SetPatchMargin(StyleBox.Margin.All, 10);
var menuInnerPanel = new PanelContainer
{
PanelOverride = innerBack,
VerticalAlignment = VAlignment.Center,
HorizontalAlignment = HAlignment.Center
};
_gameOverRootContainer.AddChild(menuInnerPanel);
var menuContainer = new VBoxContainer
{
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center
};
menuContainer.AddChild(new Label{Text = Loc.GetString("Gameover!"),Align = Label.AlignMode.Center});
menuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
_finalScoreLabel = new Label{Align = Label.AlignMode.Center};
menuContainer.AddChild(_finalScoreLabel);
menuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
_finalNewGameButton = new Button
{
Text = Loc.GetString("New Game"),
TextAlign = Label.AlignMode.Center
};
_finalNewGameButton.OnPressed += (e) =>
{
_owner.SendAction(BlockGamePlayerAction.NewGame);
};
menuContainer.AddChild(_finalNewGameButton);
menuInnerPanel.AddChild(menuContainer);
}
private void SetupPauseMenu(Texture backgroundTexture)
{
var rootBack = new StyleBoxTexture
{
Texture = backgroundTexture,
Modulate = OverlayShadowColor
};
rootBack.SetPatchMargin(StyleBox.Margin.All, 10);
_menuRootContainer = new PanelContainer
{
PanelOverride = rootBack,
VerticalAlignment = VAlignment.Center,
HorizontalAlignment = HAlignment.Center
};
var innerBack = new StyleBoxTexture
{
Texture = backgroundTexture,
Modulate = OverlayBackgroundColor
};
innerBack.SetPatchMargin(StyleBox.Margin.All, 10);
var menuInnerPanel = new PanelContainer
{
PanelOverride = innerBack,
VerticalAlignment = VAlignment.Center,
HorizontalAlignment = HAlignment.Center
};
_menuRootContainer.AddChild(menuInnerPanel);
var menuContainer = new VBoxContainer
{
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center
};
_newGameButton = new Button
{
Text = Loc.GetString("New Game"),
TextAlign = Label.AlignMode.Center
};
_newGameButton.OnPressed += (e) =>
{
_owner.SendAction(BlockGamePlayerAction.NewGame);
};
menuContainer.AddChild(_newGameButton);
menuContainer.AddChild(new Control{MinSize = new Vector2(1,10)});
_scoreBoardButton = new Button
{
Text = Loc.GetString("Scoreboard"),
TextAlign = Label.AlignMode.Center
};
_scoreBoardButton.OnPressed += (e) => _owner.SendAction(BlockGamePlayerAction.ShowHighscores);
menuContainer.AddChild(_scoreBoardButton);
_unpauseButtonMargin = new Control {MinSize = new Vector2(1, 10), Visible = false};
menuContainer.AddChild(_unpauseButtonMargin);
_unpauseButton = new Button
{
Text = Loc.GetString("Unpause"),
TextAlign = Label.AlignMode.Center,
Visible = false
};
_unpauseButton.OnPressed += (e) =>
{
_owner.SendAction(BlockGamePlayerAction.Unpause);
};
menuContainer.AddChild(_unpauseButton);
menuInnerPanel.AddChild(menuContainer);
} }
public void SetUsability(bool isPlayer) public void SetUsability(bool isPlayer)
@@ -293,62 +336,6 @@ namespace Content.Client.Arcade
_highscoreBackButton.Disabled = !_isPlayer; _highscoreBackButton.Disabled = !_isPlayer;
} }
private void SetupGameMenu(Texture backgroundTexture)
{
// building the game container
_gameRootContainer = new VBoxContainer();
_levelLabel = new Label
{
Align = Label.AlignMode.Center,
HorizontalExpand = true
};
_gameRootContainer.AddChild(_levelLabel);
_gameRootContainer.AddChild(new Control
{
MinSize = new Vector2(1,5)
});
_pointsLabel = new Label
{
Align = Label.AlignMode.Center,
HorizontalExpand = true
};
_gameRootContainer.AddChild(_pointsLabel);
_gameRootContainer.AddChild(new Control
{
MinSize = new Vector2(1,10)
});
var gameBox = new HBoxContainer();
gameBox.AddChild(SetupHoldBox(backgroundTexture));
gameBox.AddChild(new Control
{
MinSize = new Vector2(10,1)
});
gameBox.AddChild(SetupGameGrid(backgroundTexture));
gameBox.AddChild(new Control
{
MinSize = new Vector2(10,1)
});
gameBox.AddChild(SetupNextBox(backgroundTexture));
_gameRootContainer.AddChild(gameBox);
_gameRootContainer.AddChild(new Control
{
MinSize = new Vector2(1,10)
});
_pauseButton = new Button
{
Text = Loc.GetString("Pause"),
TextAlign = Label.AlignMode.Center
};
_pauseButton.OnPressed += (e) => TryPause();
_gameRootContainer.AddChild(_pauseButton);
}
private Control SetupGameGrid(Texture panelTex) private Control SetupGameGrid(Texture panelTex)
{ {
_gameGrid = new GridContainer _gameGrid = new GridContainer
@@ -541,17 +528,16 @@ namespace Content.Client.Arcade
{ {
var localHighscoreText = new StringBuilder(Loc.GetString("Station\n")); var localHighscoreText = new StringBuilder(Loc.GetString("Station\n"));
var globalHighscoreText = new StringBuilder(Loc.GetString("Nanotrasen:\n")); var globalHighscoreText = new StringBuilder(Loc.GetString("Nanotrasen:\n"));
for (int i = 0; i < 5; i++)
{
if (localHighscores.Count > i)
localHighscoreText.AppendLine(Loc.GetString("#{0}: {1} - {2}", i + 1, localHighscores[i].Name, localHighscores[i].Score));
else
localHighscoreText.AppendLine(Loc.GetString("#{0}: ??? - 0", i + 1));
if (globalHighscores.Count > i) for (var i = 0; i < 5; i++)
globalHighscoreText.AppendLine(Loc.GetString("#{0}: {1} - {2}", i + 1, globalHighscores[i].Name, globalHighscores[i].Score)); {
else localHighscoreText.AppendLine(localHighscores.Count > i
globalHighscoreText.AppendLine(Loc.GetString("#{0}: ??? - 0", i + 1)); ? Loc.GetString("#{0}: {1} - {2}", i + 1, localHighscores[i].Name, localHighscores[i].Score)
: Loc.GetString("#{0}: ??? - 0", i + 1));
globalHighscoreText.AppendLine(globalHighscores.Count > i
? Loc.GetString("#{0}: {1} - {2}", i + 1, globalHighscores[i].Name, globalHighscores[i].Score)
: Loc.GetString("#{0}: ??? - 0", i + 1));
} }
_localHighscoresLabel.Text = localHighscoreText.ToString(); _localHighscoresLabel.Text = localHighscoreText.ToString();

View File

@@ -28,7 +28,7 @@ namespace Content.Client.Chat
/// <summary> /// <summary>
/// Default formatting string for the ClientChatConsole. /// Default formatting string for the ClientChatConsole.
/// </summary> /// </summary>
public string DefaultChatFormat { get; set; } public string DefaultChatFormat { get; set; } = string.Empty;
public bool ReleaseFocusOnEnter { get; set; } = true; public bool ReleaseFocusOnEnter { get; set; } = true;
@@ -136,9 +136,9 @@ namespace Content.Client.Chat
} }
} }
public event TextSubmitHandler TextSubmitted; public event TextSubmitHandler? TextSubmitted;
public event FilterToggledHandler FilterToggled; public event FilterToggledHandler? FilterToggled;
public void AddLine(string message, ChatChannel channel, Color color) public void AddLine(string message, ChatChannel channel, Color color)
{ {

View File

@@ -18,8 +18,6 @@ using Robust.Shared.Network;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.Utility; using Robust.Shared.Utility;
#nullable enable
namespace Content.Client.Chat namespace Content.Client.Chat
{ {
internal sealed class ChatManager : IChatManager, IPostInjectInit internal sealed class ChatManager : IChatManager, IPostInjectInit

View File

@@ -1,4 +1,3 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;

View File

@@ -5,6 +5,6 @@ namespace Content.Client
{ {
public sealed class ClientModuleTestingCallbacks : SharedModuleTestingCallbacks public sealed class ClientModuleTestingCallbacks : SharedModuleTestingCallbacks
{ {
public Action ClientBeforeIoC { get; set; } public Action? ClientBeforeIoC { get; set; }
} }
} }

View File

@@ -1,4 +1,3 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Client.Interfaces; using Content.Client.Interfaces;

View File

@@ -19,9 +19,10 @@ namespace Content.Client
{ {
[Dependency] private readonly IClientNetManager _netManager = default!; [Dependency] private readonly IClientNetManager _netManager = default!;
public event Action OnServerDataLoaded; public event Action? OnServerDataLoaded;
public GameSettings Settings { get; private set; }
public PlayerPreferences Preferences { get; private set; } public GameSettings Settings { get; private set; } = default!;
public PlayerPreferences Preferences { get; private set; } = default!;
public void Initialize() public void Initialize()
{ {

View File

@@ -58,7 +58,7 @@ namespace Content.Client.Commands
foreach (var component in components) foreach (var component in components)
{ {
if (component.Owner.TryGetComponent(out ISpriteComponent sprite)) if (component.Owner.TryGetComponent(out ISpriteComponent? sprite))
{ {
sprite.DrawDepth = (int) DrawDepth.Overlays; sprite.DrawDepth = (int) DrawDepth.Overlays;
} }

View File

@@ -21,7 +21,7 @@ namespace Content.Client.Commands
foreach (var mechanism in mechanisms) foreach (var mechanism in mechanisms)
{ {
if (!mechanism.Owner.TryGetComponent(out SpriteComponent sprite)) if (!mechanism.Owner.TryGetComponent(out SpriteComponent? sprite))
{ {
continue; continue;
} }

View File

@@ -23,7 +23,7 @@ namespace Content.Client.Commands
foreach (var mechanism in mechanisms) foreach (var mechanism in mechanisms)
{ {
if (mechanism.Owner.TryGetComponent(out SpriteComponent sprite)) if (mechanism.Owner.TryGetComponent(out SpriteComponent? sprite))
{ {
sprite.ContainerOccluded = false; sprite.ContainerOccluded = false;
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;

View File

@@ -1,5 +1,4 @@
#nullable enable using System.Collections.Generic;
using System.Collections.Generic;
using Content.Client.GameObjects.Components.Construction; using Content.Client.GameObjects.Components.Construction;
using Content.Client.GameObjects.EntitySystems; using Content.Client.GameObjects.EntitySystems;
using Content.Shared.Construction; using Content.Shared.Construction;
@@ -41,7 +40,7 @@ namespace Content.Client.Construction
{ {
if (entity.TryGetComponent(out ConstructionGhostComponent? ghost)) if (entity.TryGetComponent(out ConstructionGhostComponent? ghost))
{ {
_constructionSystem.ClearGhost(ghost.GhostID); _constructionSystem.ClearGhost(ghost.GhostId);
} }
return true; return true;
} }

View File

@@ -9,6 +9,7 @@
<OutputPath>..\bin\Content.Client\</OutputPath> <OutputPath>..\bin\Content.Client\</OutputPath>
<OutputType Condition="'$(FullRelease)' != 'True'">Exe</OutputType> <OutputType Condition="'$(FullRelease)' != 'True'">Exe</OutputType>
<WarningsAsErrors>nullable</WarningsAsErrors> <WarningsAsErrors>nullable</WarningsAsErrors>
<Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" /> <Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
<ItemGroup> <ItemGroup>

View File

@@ -3,6 +3,7 @@ using Content.Client.Administration;
using Content.Client.Changelog; using Content.Client.Changelog;
using Content.Client.Eui; using Content.Client.Eui;
using Content.Client.GameObjects.Components.Actor; using Content.Client.GameObjects.Components.Actor;
using Content.Client.Graphics.Overlays;
using Content.Client.Input; using Content.Client.Input;
using Content.Client.Interfaces; using Content.Client.Interfaces;
using Content.Client.Interfaces.Chat; using Content.Client.Interfaces.Chat;
@@ -14,9 +15,9 @@ using Content.Client.StationEvents;
using Content.Client.UserInterface; using Content.Client.UserInterface;
using Content.Client.UserInterface.AdminMenu; using Content.Client.UserInterface.AdminMenu;
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
using Content.Client.Graphics.Overlays;
using Content.Client.Voting; using Content.Client.Voting;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Alert;
using Content.Shared.GameObjects.Components; using Content.Shared.GameObjects.Components;
using Content.Shared.GameObjects.Components.Cargo; using Content.Shared.GameObjects.Components.Cargo;
using Content.Shared.GameObjects.Components.Chemistry.ChemMaster; using Content.Shared.GameObjects.Components.Chemistry.ChemMaster;
@@ -27,7 +28,6 @@ using Content.Shared.GameObjects.Components.Power.AME;
using Content.Shared.GameObjects.Components.Research; using Content.Shared.GameObjects.Components.Research;
using Content.Shared.GameObjects.Components.VendingMachines; using Content.Shared.GameObjects.Components.VendingMachines;
using Content.Shared.Kitchen; using Content.Shared.Kitchen;
using Content.Shared.Alert;
using Robust.Client; using Robust.Client;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Input; using Robust.Client.Input;
@@ -105,7 +105,7 @@ namespace Content.Client
_escapeMenuOwner.Initialize(); _escapeMenuOwner.Initialize();
_baseClient.PlayerJoinedServer += (sender, args) => _baseClient.PlayerJoinedServer += (_, _) =>
{ {
IoCManager.Resolve<IMapManager>().CreateNewMapEntity(MapId.Nullspace); IoCManager.Resolve<IMapManager>().CreateNewMapEntity(MapId.Nullspace);
}; };
@@ -116,11 +116,14 @@ namespace Content.Client
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="args"></param> /// <param name="args"></param>
public void SubscribePlayerAttachmentEvents(object sender, EventArgs args) public void SubscribePlayerAttachmentEvents(object? sender, EventArgs args)
{
if (_playerManager.LocalPlayer != null)
{ {
_playerManager.LocalPlayer.EntityAttached += AttachPlayerToEntity; _playerManager.LocalPlayer.EntityAttached += AttachPlayerToEntity;
_playerManager.LocalPlayer.EntityDetached += DetachPlayerFromEntity; _playerManager.LocalPlayer.EntityDetached += DetachPlayerFromEntity;
} }
}
/// <summary> /// <summary>
/// Add the character interface master which combines all character interfaces into one window /// Add the character interface master which combines all character interfaces into one window
@@ -171,7 +174,7 @@ namespace Content.Client
IoCManager.Resolve<ActionManager>().Initialize(); IoCManager.Resolve<ActionManager>().Initialize();
IoCManager.Resolve<IVoteManager>().Initialize(); IoCManager.Resolve<IVoteManager>().Initialize();
_baseClient.RunLevelChanged += (sender, args) => _baseClient.RunLevelChanged += (_, args) =>
{ {
if (args.NewLevel == ClientRunLevel.Initialize) if (args.NewLevel == ClientRunLevel.Initialize)
{ {

View File

@@ -16,7 +16,7 @@ namespace Content.Client
[Dependency] private readonly IStateManager _stateManager = default!; [Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IGameHud _gameHud = default!; [Dependency] private readonly IGameHud _gameHud = default!;
private EscapeMenu _escapeMenu; private EscapeMenu? _escapeMenu;
public void Initialize() public void Initialize()
{ {
@@ -35,12 +35,12 @@ namespace Content.Client
_escapeMenu.OnClose += () => _gameHud.EscapeButtonDown = false; _escapeMenu.OnClose += () => _gameHud.EscapeButtonDown = false;
_inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, _inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu,
InputCmdHandler.FromDelegate(s => Enabled())); InputCmdHandler.FromDelegate(_ => Enabled()));
} }
else if (obj.OldState is GameScreenBase) else if (obj.OldState is GameScreenBase)
{ {
// Switched FROM GameScreen. // Switched FROM GameScreen.
_escapeMenu.Dispose(); _escapeMenu?.Dispose();
_escapeMenu = null; _escapeMenu = null;
_inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, null); _inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, null);
@@ -49,7 +49,7 @@ namespace Content.Client
private void Enabled() private void Enabled()
{ {
if (_escapeMenu.IsOpen) if (_escapeMenu != null && _escapeMenu.IsOpen)
{ {
if (_escapeMenu.IsAtFront()) if (_escapeMenu.IsAtFront())
{ {
@@ -71,12 +71,12 @@ namespace Content.Client
if (value) if (value)
{ {
_gameHud.EscapeButtonDown = true; _gameHud.EscapeButtonDown = true;
_escapeMenu.OpenCentered(); _escapeMenu?.OpenCentered();
} }
else else
{ {
_gameHud.EscapeButtonDown = false; _gameHud.EscapeButtonDown = false;
_escapeMenu.Close(); _escapeMenu?.Close();
} }
} }
} }

View File

@@ -3,8 +3,6 @@ using Content.Shared.Network.NetMessages;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Network; using Robust.Shared.Network;
#nullable enable
namespace Content.Client.Eui namespace Content.Client.Eui
{ {
public abstract class BaseEui public abstract class BaseEui

View File

@@ -5,8 +5,6 @@ using Robust.Shared.IoC;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Reflection; using Robust.Shared.Reflection;
#nullable enable
namespace Content.Client.Eui namespace Content.Client.Eui
{ {
public sealed class EuiManager public sealed class EuiManager

View File

@@ -15,14 +15,13 @@ namespace Content.Client.GameObjects.Components.Access
{ {
} }
private IdCardConsoleWindow _window; private IdCardConsoleWindow? _window;
protected override void Open() protected override void Open()
{ {
base.Open(); base.Open();
_window = new IdCardConsoleWindow(this, _prototypeManager); _window = new IdCardConsoleWindow(this, _prototypeManager) {Title = Owner.Owner.Name};
_window.Title = Owner.Owner.Name;
_window.OnClose += Close; _window.OnClose += Close;
_window.OpenCentered(); _window.OpenCentered();
} }
@@ -31,7 +30,7 @@ namespace Content.Client.GameObjects.Components.Access
{ {
base.UpdateState(state); base.UpdateState(state);
var castState = (IdCardConsoleBoundUserInterfaceState) state; var castState = (IdCardConsoleBoundUserInterfaceState) state;
_window.UpdateState(castState); _window?.UpdateState(castState);
} }
public void ButtonPressed(UiButton button) public void ButtonPressed(UiButton button)

View File

@@ -31,8 +31,8 @@ namespace Content.Client.GameObjects.Components.Access
private readonly Dictionary<string, Button> _accessButtons = new(); private readonly Dictionary<string, Button> _accessButtons = new();
private string _lastFullName; private string? _lastFullName;
private string _lastJobTitle; private string? _lastJobTitle;
public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, IPrototypeManager prototypeManager) public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, IPrototypeManager prototypeManager)
{ {
@@ -165,7 +165,7 @@ namespace Content.Client.GameObjects.Components.Access
_fullNameLineEdit.Editable = interfaceEnabled; _fullNameLineEdit.Editable = interfaceEnabled;
if (!fullNameDirty) if (!fullNameDirty)
{ {
_fullNameLineEdit.Text = state.TargetIdFullName; _fullNameLineEdit.Text = state.TargetIdFullName ?? "";
} }
_fullNameSaveButton.Disabled = !interfaceEnabled || !fullNameDirty; _fullNameSaveButton.Disabled = !interfaceEnabled || !fullNameDirty;
@@ -174,7 +174,7 @@ namespace Content.Client.GameObjects.Components.Access
_jobTitleLineEdit.Editable = interfaceEnabled; _jobTitleLineEdit.Editable = interfaceEnabled;
if (!jobTitleDirty) if (!jobTitleDirty)
{ {
_jobTitleLineEdit.Text = state.TargetIdJobTitle; _jobTitleLineEdit.Text = state.TargetIdJobTitle ?? "";
} }
_jobTitleSaveButton.Disabled = !interfaceEnabled || !jobTitleDirty; _jobTitleSaveButton.Disabled = !interfaceEnabled || !jobTitleDirty;
@@ -184,7 +184,7 @@ namespace Content.Client.GameObjects.Components.Access
button.Disabled = !interfaceEnabled; button.Disabled = !interfaceEnabled;
if (interfaceEnabled) if (interfaceEnabled)
{ {
button.Pressed = state.TargetIdAccessList.Contains(accessName); button.Pressed = state.TargetIdAccessList?.Contains(accessName) ?? false;
} }
} }

View File

@@ -1,5 +1,4 @@
#nullable enable using Content.Shared.GameObjects.Components.ActionBlocking;
using Content.Shared.GameObjects.Components.ActionBlocking;
using Content.Shared.Preferences.Appearance; using Content.Shared.Preferences.Appearance;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;

View File

@@ -1,5 +1,4 @@
#nullable enable using Content.Shared.GameObjects.Components.ActionBlocking;
using Content.Shared.GameObjects.Components.ActionBlocking;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -1,4 +1,3 @@
#nullable enable
using Content.Client.GameObjects.Components.Mobs; using Content.Client.GameObjects.Components.Mobs;
using Content.Client.UserInterface; using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
@@ -91,7 +90,7 @@ namespace Content.Client.GameObjects.Components.Actor
} }
}); });
AddChild(new Placeholder(resourceCache) AddChild(new Placeholder()
{ {
PlaceholderText = Loc.GetString("Health & status effects") PlaceholderText = Loc.GetString("Health & status effects")
}); });
@@ -104,7 +103,7 @@ namespace Content.Client.GameObjects.Components.Actor
ObjectivesContainer = new VBoxContainer(); ObjectivesContainer = new VBoxContainer();
AddChild(ObjectivesContainer); AddChild(ObjectivesContainer);
AddChild(new Placeholder(resourceCache) AddChild(new Placeholder()
{ {
PlaceholderText = Loc.GetString("Antagonist Roles") PlaceholderText = Loc.GetString("Antagonist Roles")
}); });

View File

@@ -29,9 +29,9 @@ namespace Content.Client.GameObjects.Components.Actor
/// <remarks> /// <remarks>
/// Null if it would otherwise be empty. /// Null if it would otherwise be empty.
/// </remarks> /// </remarks>
public SS14Window Window { get; private set; } public CharacterWindow? Window { get; private set; }
private List<ICharacterUI> _uiComponents; private List<ICharacterUI>? _uiComponents;
/// <summary> /// <summary>
/// Create the window with all character UIs and bind it to a keypress /// Create the window with all character UIs and bind it to a keypress
@@ -58,11 +58,14 @@ namespace Content.Client.GameObjects.Components.Actor
{ {
base.OnRemove(); base.OnRemove();
if (_uiComponents != null)
{
foreach (var component in _uiComponents) foreach (var component in _uiComponents)
{ {
// Make sure these don't get deleted when the window is disposed. // Make sure these don't get deleted when the window is disposed.
component.Scene.Orphan(); component.Scene.Orphan();
} }
}
_uiComponents = null; _uiComponents = null;
@@ -73,7 +76,7 @@ namespace Content.Client.GameObjects.Components.Actor
inputMgr.SetInputCommand(ContentKeyFunctions.OpenCharacterMenu, null); inputMgr.SetInputCommand(ContentKeyFunctions.OpenCharacterMenu, null);
} }
public override void HandleMessage(ComponentMessage message, IComponent component) public override void HandleMessage(ComponentMessage message, IComponent? component)
{ {
base.HandleMessage(message, component); base.HandleMessage(message, component);

View File

@@ -1,6 +1,5 @@
using Content.Client.Arcade; using Content.Client.Arcade;
using Content.Shared.Arcade; using Content.Shared.Arcade;
using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -8,9 +7,9 @@ namespace Content.Client.GameObjects.Components.Arcade
{ {
public class BlockGameBoundUserInterface : BoundUserInterface public class BlockGameBoundUserInterface : BoundUserInterface
{ {
private BlockGameMenu _menu; private BlockGameMenu? _menu;
public BlockGameBoundUserInterface([NotNull] ClientUserInterfaceComponent owner, [NotNull] object uiKey) : base(owner, uiKey) public BlockGameBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{ {
} }

View File

@@ -1,26 +1,25 @@
using Content.Client.Arcade; using Content.Client.Arcade;
using Content.Shared.GameObjects.Components.Arcade;
using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using static Content.Shared.GameObjects.Components.Arcade.SharedSpaceVillainArcadeComponent;
namespace Content.Client.GameObjects.Components.Arcade namespace Content.Client.GameObjects.Components.Arcade
{ {
public class SpaceVillainArcadeBoundUserInterface : BoundUserInterface public class SpaceVillainArcadeBoundUserInterface : BoundUserInterface
{ {
[ViewVariables] private SpaceVillainArcadeMenu _menu; [ViewVariables] private SpaceVillainArcadeMenu? _menu;
//public SharedSpaceVillainArcadeComponent SpaceVillainArcade; //public SharedSpaceVillainArcadeComponent SpaceVillainArcade;
public SpaceVillainArcadeBoundUserInterface([NotNull] ClientUserInterfaceComponent owner, [NotNull] object uiKey) : base(owner, uiKey) public SpaceVillainArcadeBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{ {
SendAction(SharedSpaceVillainArcadeComponent.PlayerAction.RequestData); SendAction(PlayerAction.RequestData);
} }
public void SendAction(SharedSpaceVillainArcadeComponent.PlayerAction action) public void SendAction(PlayerAction action)
{ {
SendMessage(new SharedSpaceVillainArcadeComponent.SpaceVillainArcadePlayerActionMessage(action)); SendMessage(new SpaceVillainArcadePlayerActionMessage(action));
} }
protected override void Open() protected override void Open()
@@ -42,16 +41,14 @@ namespace Content.Client.GameObjects.Components.Arcade
protected override void ReceiveMessage(BoundUserInterfaceMessage message) protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{ {
if(message is SharedSpaceVillainArcadeComponent.SpaceVillainArcadeDataUpdateMessage msg) _menu.UpdateInfo(msg); if (message is SpaceVillainArcadeDataUpdateMessage msg) _menu?.UpdateInfo(msg);
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); base.Dispose(disposing);
if (!disposing)
return;
_menu?.Dispose(); if (disposing) _menu?.Dispose();
} }
} }
} }

View File

@@ -3,8 +3,6 @@ using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Atmos namespace Content.Client.GameObjects.Components.Atmos
{ {
@@ -13,12 +11,15 @@ namespace Content.Client.GameObjects.Components.Atmos
{ {
[DataField("fireStackAlternateState")] [DataField("fireStackAlternateState")]
private int _fireStackAlternateState = 3; private int _fireStackAlternateState = 3;
[DataField("normalState")] [DataField("normalState")]
private string _normalState; private string? _normalState;
[DataField("alternateState")] [DataField("alternateState")]
private string _alternateState; private string? _alternateState;
[DataField("sprite")] [DataField("sprite")]
private string _sprite; private string? _sprite;
public override void InitializeEntity(IEntity entity) public override void InitializeEntity(IEntity entity)
{ {
@@ -49,7 +50,11 @@ namespace Content.Client.GameObjects.Components.Atmos
{ {
var sprite = component.Owner.GetComponent<ISpriteComponent>(); var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (_sprite != null)
{
sprite.LayerSetRSI(FireVisualLayers.Fire, _sprite); sprite.LayerSetRSI(FireVisualLayers.Fire, _sprite);
}
sprite.LayerSetVisible(FireVisualLayers.Fire, onFire); sprite.LayerSetVisible(FireVisualLayers.Fire, onFire);
if(fireStacks > _fireStackAlternateState && !string.IsNullOrEmpty(_alternateState)) if(fireStacks > _fireStackAlternateState && !string.IsNullOrEmpty(_alternateState))

View File

@@ -10,13 +10,13 @@ namespace Content.Client.GameObjects.Components.Atmos
{ {
} }
private GasAnalyzerWindow _menu; private GasAnalyzerWindow? _menu;
protected override void Open() protected override void Open()
{ {
base.Open(); base.Open();
_menu = new GasAnalyzerWindow(this);
_menu = new GasAnalyzerWindow(this);
_menu.OnClose += Close; _menu.OnClose += Close;
_menu.OpenCentered(); _menu.OpenCentered();
} }
@@ -24,7 +24,8 @@ namespace Content.Client.GameObjects.Components.Atmos
protected override void UpdateState(BoundUserInterfaceState state) protected override void UpdateState(BoundUserInterfaceState state)
{ {
base.UpdateState(state); base.UpdateState(state);
_menu.Populate((GasAnalyzerBoundUserInterfaceState) state);
_menu?.Populate((GasAnalyzerBoundUserInterfaceState) state);
} }
public void Refresh() public void Refresh()
@@ -35,10 +36,8 @@ namespace Content.Client.GameObjects.Components.Atmos
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); base.Dispose(disposing);
if (!disposing)
return;
_menu?.Dispose(); if (disposing) _menu?.Dispose();
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using Content.Client.UserInterface.Stylesheets;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared.GameObjects.Components; using Content.Shared.GameObjects.Components;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
@@ -22,7 +21,7 @@ namespace Content.Client.GameObjects.Components.Atmos
return new StatusControl(this); return new StatusControl(this);
} }
public override void HandleComponentState(ComponentState curState, ComponentState nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
if (curState is not GasAnalyzerComponentState state) if (curState is not GasAnalyzerComponentState state)
return; return;
@@ -55,15 +54,17 @@ namespace Content.Client.GameObjects.Components.Atmos
} }
_parent._uiUpdateNeeded = false; _parent._uiUpdateNeeded = false;
var color = _parent.Danger switch var color = _parent.Danger switch
{ {
GasAnalyzerDanger.Warning => "orange", GasAnalyzerDanger.Warning => "orange",
GasAnalyzerDanger.Hazard => "red", GasAnalyzerDanger.Hazard => "red",
_ => "green", _ => "green",
}; };
_label.SetMarkup(Loc.GetString("Pressure: [color={0}]{1}[/color]", _label.SetMarkup(Loc.GetString("Pressure: [color={0}]{1}[/color]",
color, color,
Enum.GetName(typeof(GasAnalyzerDanger), _parent.Danger))); _parent.Danger));
} }
} }
} }

View File

@@ -2,8 +2,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Atmos namespace Content.Client.GameObjects.Components.Atmos
{ {
@@ -11,9 +9,9 @@ namespace Content.Client.GameObjects.Components.Atmos
public class GasAnalyzerVisualizer : AppearanceVisualizer public class GasAnalyzerVisualizer : AppearanceVisualizer
{ {
[DataField("state_off")] [DataField("state_off")]
private string _stateOff; private string? _stateOff;
[DataField("state_working")] [DataField("state_working")]
private string _stateWorking; private string? _stateWorking;
public override void OnChangeData(AppearanceComponent component) public override void OnChangeData(AppearanceComponent component)
{ {
@@ -24,7 +22,7 @@ namespace Content.Client.GameObjects.Components.Atmos
return; return;
} }
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite))
{ {
return; return;
} }
@@ -39,8 +37,6 @@ namespace Content.Client.GameObjects.Components.Atmos
case GasAnalyzerVisualState.Working: case GasAnalyzerVisualState.Working:
sprite.LayerSetState(0, _stateWorking); sprite.LayerSetState(0, _stateWorking);
break; break;
default:
break;
} }
} }
} }

View File

@@ -1,6 +1,5 @@
#nullable enable using Content.Shared.GameObjects.Components.Atmos;
using JetBrains.Annotations; using JetBrains.Annotations;
using Content.Shared.GameObjects.Components.Atmos;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;

View File

@@ -2,15 +2,14 @@
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Atmos namespace Content.Client.GameObjects.Components.Atmos
{ {
public class GasCanisterVisualizer : AppearanceVisualizer public class GasCanisterVisualizer : AppearanceVisualizer
{ {
[DataField("stateConnected")] [DataField("stateConnected")]
private string _stateConnected; private string? _stateConnected;
[DataField("pressureStates")] [DataField("pressureStates")]
private string[] _statePressure = new string[] {"", "", "", ""}; private string[] _statePressure = new string[] {"", "", "", ""};
@@ -20,12 +19,15 @@ namespace Content.Client.GameObjects.Components.Atmos
var sprite = entity.GetComponent<ISpriteComponent>(); var sprite = entity.GetComponent<ISpriteComponent>();
if (_stateConnected != null)
{
sprite.LayerMapSet(Layers.ConnectedToPort, sprite.AddLayerState(_stateConnected)); sprite.LayerMapSet(Layers.ConnectedToPort, sprite.AddLayerState(_stateConnected));
sprite.LayerSetVisible(Layers.ConnectedToPort, false); sprite.LayerSetVisible(Layers.ConnectedToPort, false);
sprite.LayerMapSet(Layers.PressureLight, sprite.AddLayerState(_stateConnected)); sprite.LayerMapSet(Layers.PressureLight, sprite.AddLayerState(_stateConnected));
sprite.LayerSetShader(Layers.PressureLight, "unshaded"); sprite.LayerSetShader(Layers.PressureLight, "unshaded");
} }
}
public override void OnChangeData(AppearanceComponent component) public override void OnChangeData(AppearanceComponent component)
{ {
@@ -36,7 +38,7 @@ namespace Content.Client.GameObjects.Components.Atmos
return; return;
} }
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite))
{ {
return; return;
} }

View File

@@ -1,10 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Shared.GameObjects.Components.Atmos;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Content.Shared.GameObjects.Components.Atmos;
namespace Content.Client.GameObjects.Components.Atmos namespace Content.Client.GameObjects.Components.Atmos
{ {
@@ -49,7 +49,7 @@ namespace Content.Client.GameObjects.Components.Atmos
Children = Children =
{ {
new Label(){ Text = Loc.GetString("Label: ") }, new Label(){ Text = Loc.GetString("Label: ") },
(LabelInput = new LineEdit() { Text = Name, Editable = false, (LabelInput = new LineEdit() { Text = Name ?? "", Editable = false,
MinSize = new Vector2(200, 30)}), MinSize = new Vector2(200, 30)}),
(EditLabelBtn = new Button()), (EditLabelBtn = new Button()),
} }

View File

@@ -1,4 +1,3 @@
#nullable enable
using Content.Shared.GameObjects.Components.Atmos; using Content.Shared.GameObjects.Components.Atmos;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;

View File

@@ -16,7 +16,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
{ {
base.InitializeEntity(entity); base.InitializeEntity(entity);
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return; if (!entity.TryGetComponent(out ISpriteComponent? sprite)) return;
sprite.LayerMapReserveBlank(Layer.PumpEnabled); sprite.LayerMapReserveBlank(Layer.PumpEnabled);
var pumpEnabledLayer = sprite.LayerMapGet(Layer.PumpEnabled); var pumpEnabledLayer = sprite.LayerMapGet(Layer.PumpEnabled);
@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
{ {
base.OnChangeData(component); base.OnChangeData(component);
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) return; if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite)) return;
if (!component.TryGetData(PumpVisuals.VisualState, out PumpVisualState pumpVisualState)) return; if (!component.TryGetData(PumpVisuals.VisualState, out PumpVisualState pumpVisualState)) return;
var pumpEnabledLayer = sprite.LayerMapGet(Layer.PumpEnabled); var pumpEnabledLayer = sprite.LayerMapGet(Layer.PumpEnabled);

View File

@@ -16,7 +16,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
{ {
base.InitializeEntity(entity); base.InitializeEntity(entity);
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return; if (!entity.TryGetComponent(out ISpriteComponent? sprite)) return;
sprite.LayerMapReserveBlank(Layer.SiphonEnabled); sprite.LayerMapReserveBlank(Layer.SiphonEnabled);
var layer = sprite.LayerMapGet(Layer.SiphonEnabled); var layer = sprite.LayerMapGet(Layer.SiphonEnabled);
@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
{ {
base.OnChangeData(component); base.OnChangeData(component);
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) return; if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite)) return;
if (!component.TryGetData(SiphonVisuals.VisualState, out SiphonVisualState siphonVisualState)) return; if (!component.TryGetData(SiphonVisuals.VisualState, out SiphonVisualState siphonVisualState)) return;
var layer = sprite.LayerMapGet(Layer.SiphonEnabled); var layer = sprite.LayerMapGet(Layer.SiphonEnabled);

View File

@@ -16,7 +16,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
{ {
base.InitializeEntity(entity); base.InitializeEntity(entity);
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return; if (!entity.TryGetComponent(out ISpriteComponent? sprite)) return;
sprite.LayerMapReserveBlank(Layer.VentEnabled); sprite.LayerMapReserveBlank(Layer.VentEnabled);
var layer = sprite.LayerMapGet(Layer.VentEnabled); var layer = sprite.LayerMapGet(Layer.VentEnabled);
@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
{ {
base.OnChangeData(component); base.OnChangeData(component);
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) return; if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite)) return;
if (!component.TryGetData(VentVisuals.VisualState, out VentVisualState ventVisualState)) return; if (!component.TryGetData(VentVisuals.VisualState, out VentVisualState ventVisualState)) return;
var layer = sprite.LayerMapGet(Layer.VentEnabled); var layer = sprite.LayerMapGet(Layer.VentEnabled);

View File

@@ -20,7 +20,7 @@ namespace Content.Client.GameObjects.Components.Atmos
[DataField("animation_state")] [DataField("animation_state")]
private string _state = "chempuff"; private string _state = "chempuff";
private Animation VaporFlick; private Animation VaporFlick = default!;
void ISerializationHooks.AfterDeserialization() void ISerializationHooks.AfterDeserialization()
{ {

View File

@@ -1,5 +1,4 @@
#nullable enable using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.Interfaces.GameObjects.Components; using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -1,5 +1,4 @@
#nullable enable using Content.Shared.GameObjects.Components.Body.Mechanism;
using Content.Shared.GameObjects.Components.Body.Mechanism;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
namespace Content.Client.GameObjects.Components.Body.Mechanism namespace Content.Client.GameObjects.Components.Body.Mechanism

View File

@@ -1,5 +1,4 @@
#nullable enable using Content.Shared.GameObjects.Components.Body.Part;
using Content.Shared.GameObjects.Components.Body.Part;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
namespace Content.Client.GameObjects.Components.Body.Part namespace Content.Client.GameObjects.Components.Body.Part

View File

@@ -11,10 +11,10 @@ namespace Content.Client.GameObjects.Components.Body.Scanner
public class BodyScannerBoundUserInterface : BoundUserInterface public class BodyScannerBoundUserInterface : BoundUserInterface
{ {
[ViewVariables] [ViewVariables]
private BodyScannerDisplay _display; private BodyScannerDisplay? _display;
[ViewVariables] [ViewVariables]
private IEntity _entity; private IEntity? _entity;
public BodyScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { } public BodyScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { }
@@ -40,7 +40,7 @@ namespace Content.Client.GameObjects.Components.Body.Scanner
throw new ArgumentException($"Received an invalid entity with id {scannerState.Uid} for body scanner with id {Owner.Owner.Uid} at {Owner.Owner.Transform.MapPosition}"); throw new ArgumentException($"Received an invalid entity with id {scannerState.Uid} for body scanner with id {Owner.Owner.Uid} at {Owner.Owner.Transform.MapPosition}");
} }
_display.UpdateDisplay(_entity); _display?.UpdateDisplay(_entity);
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)

View File

@@ -1,5 +1,4 @@
#nullable enable using System.Linq;
using System.Linq;
using Content.Shared.GameObjects.Components.Body; using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Body.Mechanism; using Content.Shared.GameObjects.Components.Body.Mechanism;
using Content.Shared.GameObjects.Components.Body.Part; using Content.Shared.GameObjects.Components.Body.Part;

View File

@@ -1,5 +1,4 @@
#nullable enable using Content.Shared.GameObjects.Components.Body.Surgery;
using Content.Shared.GameObjects.Components.Body.Surgery;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -13,7 +13,7 @@ namespace Content.Client.GameObjects.Components.Body.Surgery
public delegate void OptionSelectedCallback(int selectedOptionData); public delegate void OptionSelectedCallback(int selectedOptionData);
private readonly VBoxContainer _optionsBox; private readonly VBoxContainer _optionsBox;
private OptionSelectedCallback _optionSelectedCallback; private OptionSelectedCallback? _optionSelectedCallback;
public SurgeryWindow() public SurgeryWindow()
{ {
@@ -65,7 +65,7 @@ namespace Content.Client.GameObjects.Components.Body.Surgery
{ {
if (args.Button.Parent is SurgeryButton surgery) if (args.Button.Parent is SurgeryButton surgery)
{ {
_optionSelectedCallback(surgery.CallbackData); _optionSelectedCallback?.Invoke(surgery.CallbackData);
} }
} }
} }

View File

@@ -32,7 +32,7 @@ namespace Content.Client.GameObjects.Components.Buckle
{ {
var sprite = component.Owner.GetComponent<ISpriteComponent>(); var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent animation)) if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent? animation))
{ {
sprite.Rotation = rotation; sprite.Rotation = rotation;
return; return;

View File

@@ -2,35 +2,43 @@
using Content.Shared.GameObjects.Components.Cargo; using Content.Shared.GameObjects.Components.Cargo;
using Content.Shared.Prototypes.Cargo; using Content.Shared.Prototypes.Cargo;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using static Content.Shared.GameObjects.Components.Cargo.SharedCargoConsoleComponent;
using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.GameObjects.Components.Cargo namespace Content.Client.GameObjects.Components.Cargo
{ {
public class CargoConsoleBoundUserInterface : BoundUserInterface public class CargoConsoleBoundUserInterface : BoundUserInterface
{ {
[ViewVariables] [ViewVariables]
private CargoConsoleMenu _menu; private CargoConsoleMenu? _menu;
[ViewVariables]
private CargoConsoleOrderMenu _orderMenu;
[ViewVariables] [ViewVariables]
public GalacticMarketComponent Market { get; private set; } private CargoConsoleOrderMenu? _orderMenu;
[ViewVariables] [ViewVariables]
public CargoOrderDatabaseComponent Orders { get; private set; } public GalacticMarketComponent? Market { get; private set; }
[ViewVariables]
public CargoOrderDatabaseComponent? Orders { get; private set; }
[ViewVariables] [ViewVariables]
public bool RequestOnly { get; private set; } public bool RequestOnly { get; private set; }
[ViewVariables] [ViewVariables]
public int BankId { get; private set; } public int BankId { get; private set; }
[ViewVariables] [ViewVariables]
public string BankName { get; private set; } public string? BankName { get; private set; }
[ViewVariables] [ViewVariables]
public int BankBalance { get; private set; } public int BankBalance { get; private set; }
[ViewVariables] [ViewVariables]
public (int CurrentCapacity, int MaxCapacity) ShuttleCapacity { get; private set; } public (int CurrentCapacity, int MaxCapacity) ShuttleCapacity { get; private set; }
private CargoProductPrototype _product; private CargoProductPrototype? _product;
public CargoConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) public CargoConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{ {
@@ -40,8 +48,8 @@ namespace Content.Client.GameObjects.Components.Cargo
{ {
base.Open(); base.Open();
if (!Owner.Owner.TryGetComponent(out GalacticMarketComponent market) if (!Owner.Owner.TryGetComponent(out GalacticMarketComponent? market) ||
|| !Owner.Owner.TryGetComponent(out CargoOrderDatabaseComponent orders)) return; !Owner.Owner.TryGetComponent(out CargoOrderDatabaseComponent? orders)) return;
Market = market; Market = market;
Orders = orders; Orders = orders;
@@ -57,23 +65,23 @@ namespace Content.Client.GameObjects.Components.Cargo
Market.OnDatabaseUpdated += _menu.PopulateCategories; Market.OnDatabaseUpdated += _menu.PopulateCategories;
Orders.OnDatabaseUpdated += _menu.PopulateOrders; Orders.OnDatabaseUpdated += _menu.PopulateOrders;
_menu.CallShuttleButton.OnPressed += (args) => _menu.CallShuttleButton.OnPressed += (_) =>
{ {
SendMessage(new SharedCargoConsoleComponent.CargoConsoleShuttleMessage()); SendMessage(new CargoConsoleShuttleMessage());
}; };
_menu.OnItemSelected += (args) => _menu.OnItemSelected += (args) =>
{ {
if (args.Button.Parent is not CargoProductRow row) if (args.Button.Parent is not CargoProductRow row)
return; return;
_product = row.Product; _product = row.Product;
_orderMenu.Requester.Text = null; _orderMenu.Requester.Text = "";
_orderMenu.Reason.Text = null; _orderMenu.Reason.Text = "";
_orderMenu.Amount.Value = 1; _orderMenu.Amount.Value = 1;
_orderMenu.OpenCentered(); _orderMenu.OpenCentered();
}; };
_menu.OnOrderApproved += ApproveOrder; _menu.OnOrderApproved += ApproveOrder;
_menu.OnOrderCanceled += RemoveOrder; _menu.OnOrderCanceled += RemoveOrder;
_orderMenu.SubmitButton.OnPressed += (args) => _orderMenu.SubmitButton.OnPressed += (_) =>
{ {
AddOrder(); AddOrder();
_orderMenu.Close(); _orderMenu.Close();
@@ -92,47 +100,63 @@ namespace Content.Client.GameObjects.Components.Cargo
if (RequestOnly != cState.RequestOnly) if (RequestOnly != cState.RequestOnly)
{ {
RequestOnly = cState.RequestOnly; RequestOnly = cState.RequestOnly;
_menu.UpdateRequestOnly(); _menu?.UpdateRequestOnly();
} }
BankId = cState.BankId; BankId = cState.BankId;
BankName = cState.BankName; BankName = cState.BankName;
BankBalance = cState.BankBalance; BankBalance = cState.BankBalance;
ShuttleCapacity = cState.ShuttleCapacity; ShuttleCapacity = cState.ShuttleCapacity;
_menu.UpdateCargoCapacity(); _menu?.UpdateCargoCapacity();
_menu.UpdateBankData(); _menu?.UpdateBankData();
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); base.Dispose(disposing);
if (!disposing) return; if (!disposing) return;
if (Market != null && _menu != null)
{
Market.OnDatabaseUpdated -= _menu.PopulateProducts; Market.OnDatabaseUpdated -= _menu.PopulateProducts;
Market.OnDatabaseUpdated -= _menu.PopulateCategories; Market.OnDatabaseUpdated -= _menu.PopulateCategories;
}
if (Orders != null && _menu != null)
{
Orders.OnDatabaseUpdated -= _menu.PopulateOrders; Orders.OnDatabaseUpdated -= _menu.PopulateOrders;
}
_menu?.Dispose(); _menu?.Dispose();
_orderMenu?.Dispose(); _orderMenu?.Dispose();
} }
internal void AddOrder() private void AddOrder()
{ {
SendMessage(new SharedCargoConsoleComponent.CargoConsoleAddOrderMessage(_orderMenu.Requester.Text, SendMessage(new CargoConsoleAddOrderMessage(
_orderMenu.Reason.Text, _product.ID, _orderMenu.Amount.Value)); _orderMenu?.Requester.Text ?? "",
_orderMenu?.Reason.Text ?? "",
_product?.ID ?? "",
_orderMenu?.Amount.Value ?? 0));
} }
internal void RemoveOrder(BaseButton.ButtonEventArgs args) private void RemoveOrder(ButtonEventArgs args)
{ {
if (args.Button.Parent.Parent is not CargoOrderRow row) if (args.Button.Parent?.Parent is not CargoOrderRow row || row.Order == null)
return; return;
SendMessage(new SharedCargoConsoleComponent.CargoConsoleRemoveOrderMessage(row.Order.OrderNumber));
SendMessage(new CargoConsoleRemoveOrderMessage(row.Order.OrderNumber));
} }
internal void ApproveOrder(BaseButton.ButtonEventArgs args) private void ApproveOrder(ButtonEventArgs args)
{ {
if (args.Button.Parent.Parent is not CargoOrderRow row) if (args.Button.Parent?.Parent is not CargoOrderRow row || row.Order == null)
return; return;
if (ShuttleCapacity.CurrentCapacity == ShuttleCapacity.MaxCapacity) if (ShuttleCapacity.CurrentCapacity == ShuttleCapacity.MaxCapacity)
return; return;
SendMessage(new SharedCargoConsoleComponent.CargoConsoleApproveOrderMessage(row.Order.OrderNumber));
SendMessage(new CargoConsoleApproveOrderMessage(row.Order.OrderNumber));
_menu?.UpdateCargoCapacity(); _menu?.UpdateCargoCapacity();
} }
} }

View File

@@ -15,7 +15,7 @@ namespace Content.Client.GameObjects.Components.Cargo
/// <summary> /// <summary>
/// Event called when the database is updated. /// Event called when the database is updated.
/// </summary> /// </summary>
public event Action OnDatabaseUpdated; public event Action? OnDatabaseUpdated;
// TODO add account selector menu // TODO add account selector menu
@@ -37,7 +37,7 @@ namespace Content.Client.GameObjects.Components.Cargo
_orders.Add(order); _orders.Add(order);
} }
public override void HandleComponentState(ComponentState curState, ComponentState nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
base.HandleComponentState(curState, nextState); base.HandleComponentState(curState, nextState);
if (curState is not CargoOrderDatabaseState state) if (curState is not CargoOrderDatabaseState state)

View File

@@ -15,9 +15,9 @@ namespace Content.Client.GameObjects.Components.Cargo
/// <summary> /// <summary>
/// Event called when the database is updated. /// Event called when the database is updated.
/// </summary> /// </summary>
public event Action OnDatabaseUpdated; public event Action? OnDatabaseUpdated;
public override void HandleComponentState(ComponentState curState, ComponentState nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
base.HandleComponentState(curState, nextState); base.HandleComponentState(curState, nextState);
if (curState is not GalacticMarketState state) if (curState is not GalacticMarketState state)
@@ -25,7 +25,7 @@ namespace Content.Client.GameObjects.Components.Cargo
_productIds.Clear(); _productIds.Clear();
foreach (var productId in state.Products) foreach (var productId in state.Products)
{ {
if (!_prototypeManager.TryIndex(productId, out CargoProductPrototype product)) if (!_prototypeManager.TryIndex(productId, out CargoProductPrototype? product))
continue; continue;
_products.Add(product); _products.Add(product);
} }

View File

@@ -1,4 +1,3 @@
#nullable enable
using Content.Shared.GameObjects.Components.Chemistry.ReagentDispenser; using Content.Shared.GameObjects.Components.Chemistry.ReagentDispenser;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;

View File

@@ -13,6 +13,7 @@ using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using static Content.Shared.GameObjects.Components.Chemistry.ChemMaster.SharedChemMasterComponent; using static Content.Shared.GameObjects.Components.Chemistry.ChemMaster.SharedChemMasterComponent;
using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{ {
@@ -38,7 +39,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
public bool BufferModeTransfer = true; public bool BufferModeTransfer = true;
public event Action<BaseButton.ButtonEventArgs, ChemButton> OnChemButtonPressed; public event Action<ButtonEventArgs, ChemButton>? OnChemButtonPressed;
public HBoxContainer PillInfo { get; set; } public HBoxContainer PillInfo { get; set; }
public HBoxContainer BottleInfo { get; set; } public HBoxContainer BottleInfo { get; set; }
@@ -331,7 +332,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{ {
var name = Loc.GetString("Unknown reagent"); var name = Loc.GetString("Unknown reagent");
//Try to the prototype for the given reagent. This gives us it's name. //Try to the prototype for the given reagent. This gives us it's name.
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto)) if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype? proto))
{ {
name = proto.Name; name = proto.Name;
} }
@@ -386,7 +387,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{ {
var name = Loc.GetString("Unknown reagent"); var name = Loc.GetString("Unknown reagent");
//Try to the prototype for the given reagent. This gives us it's name. //Try to the prototype for the given reagent. This gives us it's name.
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto)) if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype? proto))
{ {
name = proto.Name; name = proto.Name;
} }

View File

@@ -1,5 +1,4 @@
#nullable enable using System;
using System;
using Content.Shared.GameObjects.Components.Chemistry; using Content.Shared.GameObjects.Components.Chemistry;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.Animations; using Robust.Client.Animations;

View File

@@ -9,8 +9,6 @@ using Robust.Shared.Localization;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
#nullable enable
namespace Content.Client.GameObjects.Components.Chemistry namespace Content.Client.GameObjects.Components.Chemistry
{ {
[RegisterComponent] [RegisterComponent]

View File

@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.Components.Chemistry
void IItemStatus.DestroyControl(Control control) { } void IItemStatus.DestroyControl(Control control) { }
//Handle net updates //Handle net updates
public override void HandleComponentState(ComponentState curState, ComponentState nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
if (curState is not InjectorComponentState state) if (curState is not InjectorComponentState state)
{ {

View File

@@ -16,12 +16,11 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
[UsedImplicitly] [UsedImplicitly]
public class ReagentDispenserBoundUserInterface : BoundUserInterface public class ReagentDispenserBoundUserInterface : BoundUserInterface
{ {
private ReagentDispenserWindow _window; private ReagentDispenserWindow? _window;
private ReagentDispenserBoundUserInterfaceState _lastState; private ReagentDispenserBoundUserInterfaceState? _lastState;
public ReagentDispenserBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) public ReagentDispenserBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{ {
} }
/// <summary> /// <summary>
@@ -80,8 +79,14 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
/// <param name="inventory">A list of the reagents which can be dispensed.</param> /// <param name="inventory">A list of the reagents which can be dispensed.</param>
private void UpdateReagentsList(List<ReagentDispenserInventoryEntry> inventory) private void UpdateReagentsList(List<ReagentDispenserInventoryEntry> inventory)
{ {
if (_window == null)
{
return;
}
_window.UpdateReagentsList(inventory); _window.UpdateReagentsList(inventory);
for (int i = 0; i < _window.ChemicalList.Children.Count(); i++)
for (var i = 0; i < _window.ChemicalList.Children.Count(); i++)
{ {
var button = (Button)_window.ChemicalList.Children.ElementAt(i); var button = (Button)_window.ChemicalList.Children.ElementAt(i);
var i1 = i; var i1 = i;

View File

@@ -157,7 +157,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
foreach (var entry in inventory) foreach (var entry in inventory)
{ {
if (_prototypeManager.TryIndex(entry.ID, out ReagentPrototype proto)) if (_prototypeManager.TryIndex(entry.ID, out ReagentPrototype? proto))
{ {
ChemicalList.AddChild(new Button {Text = proto.Name}); ChemicalList.AddChild(new Button {Text = proto.Name});
} }
@@ -253,8 +253,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
/// </summary> /// </summary>
/// <param name="state">State data for the dispenser.</param> /// <param name="state">State data for the dispenser.</param>
/// <param name="highlightedReagentId">Prototype id of the reagent whose dispense button is currently being mouse hovered.</param> /// <param name="highlightedReagentId">Prototype id of the reagent whose dispense button is currently being mouse hovered.</param>
public void UpdateContainerInfo(ReagentDispenserBoundUserInterfaceState state, public void UpdateContainerInfo(ReagentDispenserBoundUserInterfaceState state, string highlightedReagentId = "")
string highlightedReagentId = null)
{ {
ContainerInfo.Children.Clear(); ContainerInfo.Children.Clear();
@@ -286,7 +285,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
{ {
var name = Loc.GetString("Unknown reagent"); var name = Loc.GetString("Unknown reagent");
//Try to the prototype for the given reagent. This gives us it's name. //Try to the prototype for the given reagent. This gives us it's name.
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto)) if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype? proto))
{ {
name = proto.Name; name = proto.Name;
} }

View File

@@ -1,5 +1,4 @@
#nullable enable using Content.Shared.GameObjects.Components.Chemistry;
using Content.Shared.GameObjects.Components.Chemistry;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.Maths; using Robust.Shared.Maths;

View File

@@ -1,4 +1,3 @@
#nullable enable
using Content.Shared.GameObjects.Components.Chemistry; using Content.Shared.GameObjects.Components.Chemistry;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -1,4 +1,3 @@
#nullable enable
using System; using System;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;

View File

@@ -13,7 +13,7 @@ namespace Content.Client.GameObjects.Components.CloningPod
{ {
} }
private CloningPodWindow _window; private CloningPodWindow? _window;
protected override void Open() protected override void Open()
{ {
@@ -39,7 +39,8 @@ namespace Content.Client.GameObjects.Components.CloningPod
protected override void UpdateState(BoundUserInterfaceState state) protected override void UpdateState(BoundUserInterfaceState state)
{ {
base.UpdateState(state); base.UpdateState(state);
_window.Populate((CloningPodBoundUserInterfaceState) state);
_window?.Populate((CloningPodBoundUserInterfaceState) state);
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)

View File

@@ -1,5 +1,4 @@
#nullable enable using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;

View File

@@ -1,5 +1,4 @@
#nullable enable using Content.Client.GameObjects.Components.HUD.Inventory;
using Content.Client.GameObjects.Components.HUD.Inventory;
using Content.Client.GameObjects.Components.Items; using Content.Client.GameObjects.Components.Items;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Inventory; using Content.Shared.GameObjects.Components.Inventory;
@@ -70,6 +69,12 @@ namespace Content.Client.GameObjects.Components.Clothing
} }
var rsi = GetRSI(); var rsi = GetRSI();
if (rsi == null)
{
return null;
}
var prefix = ClothingEquippedPrefix ?? EquippedPrefix; var prefix = ClothingEquippedPrefix ?? EquippedPrefix;
var stateId = prefix != null ? $"{prefix}-equipped-{slot}" : $"equipped-{slot}"; var stateId = prefix != null ? $"{prefix}-equipped-{slot}" : $"equipped-{slot}";
if (rsi.TryGetState(stateId, out _)) if (rsi.TryGetState(stateId, out _))

View File

@@ -1,5 +1,4 @@
#nullable enable using System;
using System;
using Content.Client.Command; using Content.Client.Command;
using Content.Shared.GameObjects.Components.Command; using Content.Shared.GameObjects.Components.Command;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;

View File

@@ -4,17 +4,17 @@ using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using static Content.Shared.GameObjects.Components.SharedConfigurationComponent; using static Content.Shared.GameObjects.Components.SharedConfigurationComponent;
namespace Content.Client.GameObjects.Components.Wires namespace Content.Client.GameObjects.Components.Configuration
{ {
public class ConfigurationBoundUserInterface : BoundUserInterface public class ConfigurationBoundUserInterface : BoundUserInterface
{ {
public Regex Validation { get; internal set; } public Regex? Validation { get; internal set; }
public ConfigurationBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) public ConfigurationBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{ {
} }
private ConfigurationMenu _menu; private ConfigurationMenu? _menu;
protected override void Open() protected override void Open()
{ {
@@ -28,12 +28,19 @@ namespace Content.Client.GameObjects.Components.Wires
protected override void UpdateState(BoundUserInterfaceState state) protected override void UpdateState(BoundUserInterfaceState state)
{ {
base.UpdateState(state); base.UpdateState(state);
_menu.Populate(state as ConfigurationBoundUserInterfaceState);
if (state is not ConfigurationBoundUserInterfaceState configurationState)
{
return;
}
_menu?.Populate(configurationState);
} }
protected override void ReceiveMessage(BoundUserInterfaceMessage message) protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{ {
base.ReceiveMessage(message); base.ReceiveMessage(message);
if (message is ValidationUpdateMessage msg) if (message is ValidationUpdateMessage msg)
{ {
Validation = new Regex(msg.ValidationString, RegexOptions.Compiled); Validation = new Regex(msg.ValidationString, RegexOptions.Compiled);
@@ -49,8 +56,11 @@ namespace Content.Client.GameObjects.Components.Wires
{ {
base.Dispose(disposing); base.Dispose(disposing);
if (disposing && _menu != null)
{
_menu.OnClose -= Close; _menu.OnClose -= Close;
_menu.Close(); _menu.Close();
} }
} }
}
} }

View File

@@ -7,7 +7,7 @@ using Robust.Shared.Maths;
using static Content.Shared.GameObjects.Components.SharedConfigurationComponent; using static Content.Shared.GameObjects.Components.SharedConfigurationComponent;
using static Robust.Client.UserInterface.Controls.BaseButton; using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.GameObjects.Components.Wires namespace Content.Client.GameObjects.Components.Configuration
{ {
public class ConfigurationMenu : SS14Window public class ConfigurationMenu : SS14Window
{ {

View File

@@ -16,14 +16,16 @@ namespace Content.Client.GameObjects.Components.Construction
public override string Name => "ConstructionGhost"; public override string Name => "ConstructionGhost";
[ViewVariables] public ConstructionPrototype Prototype { get; set; } [ViewVariables] public ConstructionPrototype? Prototype { get; set; }
[ViewVariables] public int GhostID { get; set; } [ViewVariables] public int GhostId { get; set; }
void IExamine.Examine(FormattedMessage message, bool inDetailsRange) void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{ {
if (Prototype == null) return;
message.AddMarkup(Loc.GetString("Building: [color=cyan]{0}[/color]\n", Prototype.Name)); message.AddMarkup(Loc.GetString("Building: [color=cyan]{0}[/color]\n", Prototype.Name));
if (!_prototypeManager.TryIndex(Prototype.Graph, out ConstructionGraphPrototype graph)) return; if (!_prototypeManager.TryIndex(Prototype.Graph, out ConstructionGraphPrototype? graph)) return;
var startNode = graph.Nodes[Prototype.StartNode]; var startNode = graph.Nodes[Prototype.StartNode];
var path = graph.Path(Prototype.StartNode, Prototype.TargetNode); var path = graph.Path(Prototype.StartNode, Prototype.TargetNode);
var edge = startNode.GetEdge(path[0].Name); var edge = startNode.GetEdge(path[0].Name);

View File

@@ -4,8 +4,6 @@ using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Conveyor namespace Content.Client.GameObjects.Components.Conveyor
{ {
@@ -13,15 +11,17 @@ namespace Content.Client.GameObjects.Components.Conveyor
public class ConveyorVisualizer : AppearanceVisualizer public class ConveyorVisualizer : AppearanceVisualizer
{ {
[DataField("state_running")] [DataField("state_running")]
private string _stateRunning; private string? _stateRunning;
[DataField("state_stopped")] [DataField("state_stopped")]
private string _stateStopped; private string? _stateStopped;
[DataField("state_reversed")] [DataField("state_reversed")]
private string _stateReversed; private string? _stateReversed;
private void ChangeState(AppearanceComponent appearance) private void ChangeState(AppearanceComponent appearance)
{ {
if (!appearance.Owner.TryGetComponent(out ISpriteComponent sprite)) if (!appearance.Owner.TryGetComponent(out ISpriteComponent? sprite))
{ {
return; return;
} }

View File

@@ -3,8 +3,6 @@ using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Conveyor namespace Content.Client.GameObjects.Components.Conveyor
{ {
@@ -12,15 +10,17 @@ namespace Content.Client.GameObjects.Components.Conveyor
public class TwoWayLeverVisualizer : AppearanceVisualizer public class TwoWayLeverVisualizer : AppearanceVisualizer
{ {
[DataField("state_forward")] [DataField("state_forward")]
private string _stateForward; private string? _stateForward;
[DataField("state_off")] [DataField("state_off")]
private string _stateOff; private string? _stateOff;
[DataField("state_reversed")] [DataField("state_reversed")]
private string _stateReversed; private string? _stateReversed;
private void ChangeState(AppearanceComponent appearance) private void ChangeState(AppearanceComponent appearance)
{ {
if (!appearance.Owner.TryGetComponent(out ISpriteComponent sprite)) if (!appearance.Owner.TryGetComponent(out ISpriteComponent? sprite))
{ {
return; return;
} }

View File

@@ -1,9 +1,9 @@
using Content.Shared.GameObjects.Components; using System.Linq;
using Robust.Shared.IoC; using Content.Shared.GameObjects.Components;
using Robust.Shared.Prototypes;
using System.Linq;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Client.GameObjects.Components.Crayon namespace Content.Client.GameObjects.Components.Crayon
{ {
@@ -13,7 +13,7 @@ namespace Content.Client.GameObjects.Components.Crayon
{ {
} }
private CrayonWindow _menu; private CrayonWindow? _menu;
protected override void Open() protected override void Open()
{ {
@@ -31,7 +31,8 @@ namespace Content.Client.GameObjects.Components.Crayon
protected override void UpdateState(BoundUserInterfaceState state) protected override void UpdateState(BoundUserInterfaceState state)
{ {
base.UpdateState(state); base.UpdateState(state);
_menu.UpdateState((CrayonBoundUserInterfaceState) state);
_menu?.UpdateState((CrayonBoundUserInterfaceState) state);
} }
public void Select(string state) public void Select(string state)
@@ -43,7 +44,10 @@ namespace Content.Client.GameObjects.Components.Crayon
{ {
base.Dispose(disposing); base.Dispose(disposing);
_menu.Close(); if (disposing)
{
_menu?.Close();
}
} }
} }
} }

View File

@@ -24,7 +24,7 @@ namespace Content.Client.GameObjects.Components.Crayon
return new StatusControl(this); return new StatusControl(this);
} }
public override void HandleComponentState(ComponentState curState, ComponentState nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
if (curState is not CrayonComponentState state) if (curState is not CrayonComponentState state)
return; return;

View File

@@ -1,4 +1,5 @@
using Content.Client.UserInterface.Stylesheets; using System.Collections.Generic;
using Content.Client.UserInterface.Stylesheets;
using Content.Shared.GameObjects.Components; using Content.Shared.GameObjects.Components;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
@@ -7,7 +8,7 @@ using Robust.Client.Utility;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using System.Collections.Generic; using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.GameObjects.Components.Crayon namespace Content.Client.GameObjects.Components.Crayon
{ {
@@ -16,8 +17,8 @@ namespace Content.Client.GameObjects.Components.Crayon
public CrayonBoundUserInterface Owner { get; } public CrayonBoundUserInterface Owner { get; }
private readonly LineEdit _search; private readonly LineEdit _search;
private readonly GridContainer _grid; private readonly GridContainer _grid;
private Dictionary<string, Texture> _decals; private Dictionary<string, Texture>? _decals;
private string _selected; private string? _selected;
private Color _color; private Color _color;
public CrayonWindow(CrayonBoundUserInterface owner) public CrayonWindow(CrayonBoundUserInterface owner)
@@ -30,7 +31,7 @@ namespace Content.Client.GameObjects.Components.Crayon
Contents.AddChild(vbox); Contents.AddChild(vbox);
_search = new LineEdit(); _search = new LineEdit();
_search.OnTextChanged += (e) => RefreshList(); _search.OnTextChanged += (_) => RefreshList();
vbox.AddChild(_search); vbox.AddChild(_search);
_grid = new GridContainer() _grid = new GridContainer()
@@ -68,7 +69,7 @@ namespace Content.Client.GameObjects.Components.Crayon
ToolTip = decal, ToolTip = decal,
Modulate = _color Modulate = _color
}; };
button.OnPressed += Button_OnPressed; button.OnPressed += ButtonOnPressed;
if (_selected == decal) if (_selected == decal)
{ {
var panelContainer = new PanelContainer() var panelContainer = new PanelContainer()
@@ -91,12 +92,15 @@ namespace Content.Client.GameObjects.Components.Crayon
} }
} }
private void Button_OnPressed(BaseButton.ButtonEventArgs obj) private void ButtonOnPressed(ButtonEventArgs obj)
{
if (obj.Button.Name != null)
{ {
Owner.Select(obj.Button.Name); Owner.Select(obj.Button.Name);
_selected = obj.Button.Name; _selected = obj.Button.Name;
RefreshList(); RefreshList();
} }
}
public void UpdateState(CrayonBoundUserInterfaceState state) public void UpdateState(CrayonBoundUserInterfaceState state)
{ {

View File

@@ -1,5 +1,4 @@
#nullable enable using JetBrains.Annotations;
using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -1,5 +1,4 @@
#nullable enable using JetBrains.Annotations;
using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using static Content.Shared.GameObjects.Components.Disposal.SharedDisposalRouterComponent; using static Content.Shared.GameObjects.Components.Disposal.SharedDisposalRouterComponent;

View File

@@ -1,5 +1,4 @@
#nullable enable using JetBrains.Annotations;
using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using static Content.Shared.GameObjects.Components.Disposal.SharedDisposalTaggerComponent; using static Content.Shared.GameObjects.Components.Disposal.SharedDisposalTaggerComponent;

View File

@@ -1,5 +1,4 @@
#nullable enable using JetBrains.Annotations;
using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using static Content.Shared.GameObjects.Components.Disposal.SharedDisposalUnitComponent; using static Content.Shared.GameObjects.Components.Disposal.SharedDisposalUnitComponent;

View File

@@ -15,36 +15,36 @@ namespace Content.Client.GameObjects.Components.Disposal
private const string AnimationKey = "disposal_unit_animation"; private const string AnimationKey = "disposal_unit_animation";
[DataField("state_anchored", required: true)] [DataField("state_anchored", required: true)]
private string _stateAnchored; private string? _stateAnchored;
[DataField("state_unanchored", required: true)] [DataField("state_unanchored", required: true)]
private string _stateUnAnchored; private string? _stateUnAnchored;
[DataField("state_charging", required: true)] [DataField("state_charging", required: true)]
private string _stateCharging; private string? _stateCharging;
[DataField("overlay_charging", required: true)] [DataField("overlay_charging", required: true)]
private string _overlayCharging; private string? _overlayCharging;
[DataField("overlay_ready", required: true)] [DataField("overlay_ready", required: true)]
private string _overlayReady; private string? _overlayReady;
[DataField("overlay_full", required: true)] [DataField("overlay_full", required: true)]
private string _overlayFull; private string? _overlayFull;
[DataField("overlay_engaged", required: true)] [DataField("overlay_engaged", required: true)]
private string _overlayEngaged; private string? _overlayEngaged;
[DataField("state_flush", required: true)] [DataField("state_flush", required: true)]
private string _stateFlush; private string? _stateFlush;
[DataField("flush_sound", required: true)] [DataField("flush_sound", required: true)]
private string _flushSound; private string? _flushSound;
[DataField("flush_time", required: true)] [DataField("flush_time", required: true)]
private float _flushTime; private float _flushTime;
private Animation _flushAnimation; private Animation _flushAnimation = default!;
void ISerializationHooks.AfterDeserialization() void ISerializationHooks.AfterDeserialization()
{ {
@@ -57,8 +57,12 @@ namespace Content.Client.GameObjects.Components.Disposal
var sound = new AnimationTrackPlaySound(); var sound = new AnimationTrackPlaySound();
_flushAnimation.AnimationTracks.Add(sound); _flushAnimation.AnimationTracks.Add(sound);
if (_flushSound != null)
{
sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_flushSound, 0)); sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_flushSound, 0));
} }
}
private void ChangeState(AppearanceComponent appearance) private void ChangeState(AppearanceComponent appearance)
{ {
@@ -67,7 +71,7 @@ namespace Content.Client.GameObjects.Components.Disposal
return; return;
} }
if (!appearance.Owner.TryGetComponent(out ISpriteComponent sprite)) if (!appearance.Owner.TryGetComponent(out ISpriteComponent? sprite))
{ {
return; return;
} }

View File

@@ -4,8 +4,6 @@ using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Disposal namespace Content.Client.GameObjects.Components.Disposal
{ {
@@ -13,15 +11,17 @@ namespace Content.Client.GameObjects.Components.Disposal
public class DisposalVisualizer : AppearanceVisualizer public class DisposalVisualizer : AppearanceVisualizer
{ {
[DataField("state_free")] [DataField("state_free")]
private string _stateFree; private string? _stateFree;
[DataField("state_anchored")] [DataField("state_anchored")]
private string _stateAnchored; private string? _stateAnchored;
[DataField("state_broken")] [DataField("state_broken")]
private string _stateBroken; private string? _stateBroken;
private void ChangeState(AppearanceComponent appearance) private void ChangeState(AppearanceComponent appearance)
{ {
if (!appearance.Owner.TryGetComponent(out ISpriteComponent sprite)) if (!appearance.Owner.TryGetComponent(out ISpriteComponent? sprite))
{ {
return; return;
} }

View File

@@ -1,4 +1,3 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Client.GameObjects.EntitySystems.DoAfter; using Content.Client.GameObjects.EntitySystems.DoAfter;

View File

@@ -1,4 +1,3 @@
#nullable enable
using System; using System;
using Content.Client.GameObjects.Components.Wires; using Content.Client.GameObjects.Components.Wires;
using Content.Shared.Audio; using Content.Shared.Audio;

View File

@@ -1,9 +1,7 @@
#nullable enable using System;
using Content.Shared.GameObjects.Components.Doors; using Content.Shared.GameObjects.Components.Doors;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.ViewVariables;
using System;
namespace Content.Client.GameObjects.Components.Doors namespace Content.Client.GameObjects.Components.Doors
{ {

View File

@@ -2,8 +2,6 @@ using Content.Shared.GameObjects.Components.Explosion;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Explosion namespace Content.Client.GameObjects.Components.Explosion
{ {
@@ -12,7 +10,7 @@ namespace Content.Client.GameObjects.Components.Explosion
public class ClusterFlashVisualizer : AppearanceVisualizer public class ClusterFlashVisualizer : AppearanceVisualizer
{ {
[DataField("state")] [DataField("state")]
private string _state; private string? _state;
public override void OnChangeData(AppearanceComponent component) public override void OnChangeData(AppearanceComponent component)
{ {

View File

@@ -53,9 +53,8 @@ namespace Content.Client.GameObjects.Components
} }
}; };
private Action<string> _radiatingCallback; private Action<string>? _radiatingCallback;
private Action<string> _blinkingCallback; private Action<string>? _blinkingCallback;
public override void OnChangeData(AppearanceComponent component) public override void OnChangeData(AppearanceComponent component)
{ {

View File

@@ -2,8 +2,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Fluids namespace Content.Client.GameObjects.Components.Fluids
{ {
@@ -11,9 +9,9 @@ namespace Content.Client.GameObjects.Components.Fluids
public class SprayVisualizer : AppearanceVisualizer public class SprayVisualizer : AppearanceVisualizer
{ {
[DataField("safety_on_state")] [DataField("safety_on_state")]
private string _safetyOnState; private string? _safetyOnState;
[DataField("safety_off_state")] [DataField("safety_off_state")]
private string _safetyOffState; private string? _safetyOffState;
public override void OnChangeData(AppearanceComponent component) public override void OnChangeData(AppearanceComponent component)
{ {

View File

@@ -1,4 +1,5 @@
using Content.Shared.GameObjects.Components.Gravity; using Content.Shared.GameObjects.Components.Gravity;
using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
@@ -9,9 +10,10 @@ using Robust.Shared.Maths;
namespace Content.Client.GameObjects.Components.Gravity namespace Content.Client.GameObjects.Components.Gravity
{ {
public class GravityGeneratorBoundUserInterface: BoundUserInterface [UsedImplicitly]
public class GravityGeneratorBoundUserInterface : BoundUserInterface
{ {
private GravityGeneratorWindow _window; private GravityGeneratorWindow? _window;
public bool IsOn; public bool IsOn;
@@ -28,7 +30,7 @@ namespace Content.Client.GameObjects.Components.Gravity
_window = new GravityGeneratorWindow(this); _window = new GravityGeneratorWindow(this);
_window.Switch.OnPressed += (args) => _window.Switch.OnPressed += (_) =>
{ {
SendMessage(new SharedGravityGeneratorComponent.SwitchGeneratorMessage(!IsOn)); SendMessage(new SharedGravityGeneratorComponent.SwitchGeneratorMessage(!IsOn));
SendMessage(new SharedGravityGeneratorComponent.GeneratorStatusRequestMessage()); SendMessage(new SharedGravityGeneratorComponent.GeneratorStatusRequestMessage());
@@ -43,7 +45,7 @@ namespace Content.Client.GameObjects.Components.Gravity
var castState = (SharedGravityGeneratorComponent.GeneratorState) state; var castState = (SharedGravityGeneratorComponent.GeneratorState) state;
IsOn = castState.On; IsOn = castState.On;
_window.UpdateButton(); _window?.UpdateButton();
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
@@ -63,11 +65,11 @@ namespace Content.Client.GameObjects.Components.Gravity
public GravityGeneratorBoundUserInterface Owner; public GravityGeneratorBoundUserInterface Owner;
public GravityGeneratorWindow(GravityGeneratorBoundUserInterface gravityGeneratorInterface = null) public GravityGeneratorWindow(GravityGeneratorBoundUserInterface ui)
{ {
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
Owner = gravityGeneratorInterface; Owner = ui;
Title = Loc.GetString("Gravity Generator Control"); Title = Loc.GetString("Gravity Generator Control");

View File

@@ -1,5 +1,4 @@
#nullable enable using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Content.Client.GameObjects.Components.Clothing; using Content.Client.GameObjects.Components.Clothing;
@@ -268,7 +267,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
} }
} }
public bool TryGetSlot(Slots slot, out IEntity? item) public bool TryGetSlot(Slots slot, [NotNullWhen(true)] out IEntity? item)
{ {
return _slots.TryGetValue(slot, out item); return _slots.TryGetValue(slot, out item);
} }

View File

@@ -25,13 +25,13 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
private readonly Dictionary<Slots, List<ItemSlotButton>> _inventoryButtons private readonly Dictionary<Slots, List<ItemSlotButton>> _inventoryButtons
= new(); = new();
private ItemSlotButton _hudButtonPocket1; private ItemSlotButton _hudButtonPocket1 = default!;
private ItemSlotButton _hudButtonPocket2; private ItemSlotButton _hudButtonPocket2 = default!;
private ItemSlotButton _hudButtonBelt; private ItemSlotButton _hudButtonBelt = default!;
private ItemSlotButton _hudButtonBack; private ItemSlotButton _hudButtonBack = default!;
private ItemSlotButton _hudButtonId; private ItemSlotButton _hudButtonId = default!;
private Control _rightQuickButtonsContainer; private Control _rightQuickButtonsContainer = default!;
private Control _leftQuickButtonsContainer; private Control _leftQuickButtonsContainer = default!;
public HumanInventoryInterfaceController(ClientInventoryComponent owner) : base(owner) public HumanInventoryInterfaceController(ClientInventoryComponent owner) : base(owner)
{ {
@@ -47,7 +47,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{ {
button.OnPressed = (e) => AddToInventory(e, slot); button.OnPressed = (e) => AddToInventory(e, slot);
button.OnStoragePressed = (e) => OpenStorage(e, slot); button.OnStoragePressed = (e) => OpenStorage(e, slot);
button.OnHover = (e) => RequestItemHover(slot); button.OnHover = (_) => RequestItemHover(slot);
_inventoryButtons.Add(slot, new List<ItemSlotButton> {button}); _inventoryButtons.Add(slot, new List<ItemSlotButton> {button});
} }
@@ -59,7 +59,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{ {
OnPressed = (e) => AddToInventory(e, slot), OnPressed = (e) => AddToInventory(e, slot),
OnStoragePressed = (e) => OpenStorage(e, slot), OnStoragePressed = (e) => OpenStorage(e, slot),
OnHover = (e) => RequestItemHover(slot) OnHover = (_) => RequestItemHover(slot)
}; };
_inventoryButtons[slot].Add(variable); _inventoryButtons[slot].Add(variable);
} }
@@ -93,8 +93,8 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
}; };
} }
public override SS14Window Window => _window; public override SS14Window? Window => _window;
private HumanInventoryWindow _window; private HumanInventoryWindow? _window;
public override IEnumerable<ItemSlotButton> GetItemSlotButtons(Slots slot) public override IEnumerable<ItemSlotButton> GetItemSlotButtons(Slots slot)
{ {
@@ -152,7 +152,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
protected override void HandleInventoryKeybind(GUIBoundKeyEventArgs args, Slots slot) protected override void HandleInventoryKeybind(GUIBoundKeyEventArgs args, Slots slot)
{ {
if (!_inventoryButtons.TryGetValue(slot, out var buttons)) if (!_inventoryButtons.ContainsKey(slot))
return; return;
if (!Owner.TryGetSlot(slot, out var item)) if (!Owner.TryGetSlot(slot, out var item))
return; return;

View File

@@ -22,10 +22,9 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
public virtual void Initialize() public virtual void Initialize()
{ {
} }
public abstract SS14Window Window { get; } public abstract SS14Window? Window { get; }
protected ClientInventoryComponent Owner { get; } protected ClientInventoryComponent Owner { get; }
public virtual void PlayerAttached() public virtual void PlayerAttached()
@@ -35,11 +34,11 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{ {
if (b) if (b)
{ {
Window.Open(); Window?.Open();
} }
else else
{ {
Window.Close(); Window?.Close();
} }
}; };
} }
@@ -47,7 +46,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
public virtual void PlayerDetached() public virtual void PlayerDetached()
{ {
GameHud.InventoryButtonVisible = false; GameHud.InventoryButtonVisible = false;
Window.Close(); Window?.Close();
} }
public virtual void Dispose() public virtual void Dispose()

View File

@@ -13,12 +13,12 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
[UsedImplicitly] [UsedImplicitly]
public class StrippableBoundUserInterface : BoundUserInterface public class StrippableBoundUserInterface : BoundUserInterface
{ {
public Dictionary<Slots, string> Inventory { get; private set; } public Dictionary<Slots, string>? Inventory { get; private set; }
public Dictionary<string, string> Hands { get; private set; } public Dictionary<string, string>? Hands { get; private set; }
public Dictionary<EntityUid, string> Handcuffs { get; private set; } public Dictionary<EntityUid, string>? Handcuffs { get; private set; }
[ViewVariables] [ViewVariables]
private StrippingMenu _strippingMenu; private StrippingMenu? _strippingMenu;
public StrippableBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) public StrippableBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{ {
@@ -41,7 +41,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
if (!disposing) if (!disposing)
return; return;
_strippingMenu.Dispose(); _strippingMenu?.Dispose();
} }
private void UpdateMenu() private void UpdateMenu()

View File

@@ -21,7 +21,7 @@ namespace Content.Client.GameObjects.Components
return new StatusControl(this); return new StatusControl(this);
} }
public override void HandleComponentState(ComponentState curState, ComponentState nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
base.HandleComponentState(curState, nextState); base.HandleComponentState(curState, nextState);
@@ -40,12 +40,12 @@ namespace Content.Client.GameObjects.Components
private float _timer; private float _timer;
private static readonly StyleBoxFlat _styleBoxLit = new() private static readonly StyleBoxFlat StyleBoxLit = new()
{ {
BackgroundColor = Color.Green BackgroundColor = Color.Green
}; };
private static readonly StyleBoxFlat _styleBoxUnlit = new() private static readonly StyleBoxFlat StyleBoxUnlit = new()
{ {
BackgroundColor = Color.Black BackgroundColor = Color.Black
}; };
@@ -88,22 +88,22 @@ namespace Content.Client.GameObjects.Components
{ {
if (level == 0) if (level == 0)
{ {
_sections[0].PanelOverride = _styleBoxUnlit; _sections[0].PanelOverride = StyleBoxUnlit;
} }
else if (level == 1) else if (level == 1)
{ {
// Flash the last light. // Flash the last light.
_sections[0].PanelOverride = _timer > TimerCycle / 2 ? _styleBoxLit : _styleBoxUnlit; _sections[0].PanelOverride = _timer > TimerCycle / 2 ? StyleBoxLit : StyleBoxUnlit;
} }
else else
{ {
_sections[0].PanelOverride = _styleBoxLit; _sections[0].PanelOverride = StyleBoxLit;
} }
continue; continue;
} }
_sections[i].PanelOverride = level >= i + 2 ? _styleBoxLit : _styleBoxUnlit; _sections[i].PanelOverride = level >= i + 2 ? StyleBoxLit : StyleBoxUnlit;
} }
} }
} }

View File

@@ -6,8 +6,6 @@ using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using static Robust.Client.GameObjects.SpriteComponent; using static Robust.Client.GameObjects.SpriteComponent;
@@ -27,28 +25,28 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
[RegisterComponent] [RegisterComponent]
public class IconSmoothComponent : Component public class IconSmoothComponent : Component
{ {
[DataField("key")]
private string _smoothKey = default;
[DataField("base")]
private string _stateBase = "";
[DataField("mode")] [DataField("mode")]
private IconSmoothingMode _mode = IconSmoothingMode.Corners; private IconSmoothingMode _mode = IconSmoothingMode.Corners;
public override string Name => "IconSmooth"; public override string Name => "IconSmooth";
internal ISpriteComponent Sprite { get; private set; } internal ISpriteComponent? Sprite { get; private set; }
internal SnapGridComponent SnapGrid { get; private set; }
internal SnapGridComponent? SnapGrid { get; private set; }
private (GridId, Vector2i) _lastPosition; private (GridId, Vector2i) _lastPosition;
/// <summary> /// <summary>
/// We will smooth with other objects with the same key. /// We will smooth with other objects with the same key.
/// </summary> /// </summary>
public string SmoothKey => _smoothKey; [field: DataField("key")]
public string? SmoothKey { get; }
/// <summary> /// <summary>
/// Prepended to the RSI state. /// Prepended to the RSI state.
/// </summary> /// </summary>
public string StateBase => _stateBase; [field: DataField("base")]
public string StateBase { get; } = string.Empty;
/// <summary> /// <summary>
/// Mode that controls how the icon should be selected. /// Mode that controls how the icon should be selected.
@@ -73,12 +71,18 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
{ {
base.Startup(); base.Startup();
if (SnapGrid != null)
{
SnapGrid.OnPositionChanged += SnapGridOnPositionChanged; SnapGrid.OnPositionChanged += SnapGridOnPositionChanged;
// ensures lastposition initial value is populated on spawn. Just calling // ensures lastposition initial value is populated on spawn. Just calling
// the hook here would cause a dirty event to fire needlessly // the hook here would cause a dirty event to fire needlessly
_lastPosition = (Owner.Transform.GridID, SnapGrid.Position); _lastPosition = (Owner.Transform.GridID, SnapGrid.Position);
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner,null, SnapGrid.Offset, Mode)); Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner,null, SnapGrid.Offset, Mode));
if (Mode == IconSmoothingMode.Corners) }
if (Sprite != null && Mode == IconSmoothingMode.Corners)
{ {
var state0 = $"{StateBase}0"; var state0 = $"{StateBase}0";
Sprite.LayerMapSet(CornerLayers.SE, Sprite.AddLayerState(state0)); Sprite.LayerMapSet(CornerLayers.SE, Sprite.AddLayerState(state0));
@@ -111,6 +115,11 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
private void CalculateNewSpriteCardinal() private void CalculateNewSpriteCardinal()
{ {
if (SnapGrid == null || Sprite == null)
{
return;
}
var dirs = CardinalConnectDirs.None; var dirs = CardinalConnectDirs.None;
if (MatchingEntity(SnapGrid.GetInDir(Direction.North))) if (MatchingEntity(SnapGrid.GetInDir(Direction.North)))
@@ -127,6 +136,11 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
private void CalculateNewSpriteCorners() private void CalculateNewSpriteCorners()
{ {
if (Sprite == null)
{
return;
}
var (cornerNE, cornerNW, cornerSW, cornerSE) = CalculateCornerFill(); var (cornerNE, cornerNW, cornerSW, cornerSE) = CalculateCornerFill();
Sprite.LayerSetState(CornerLayers.NE, $"{StateBase}{(int) cornerNE}"); Sprite.LayerSetState(CornerLayers.NE, $"{StateBase}{(int) cornerNE}");
@@ -137,6 +151,11 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
protected (CornerFill ne, CornerFill nw, CornerFill sw, CornerFill se) CalculateCornerFill() protected (CornerFill ne, CornerFill nw, CornerFill sw, CornerFill se) CalculateCornerFill()
{ {
if (SnapGrid == null)
{
return (CornerFill.None, CornerFill.None, CornerFill.None, CornerFill.None);
}
var n = MatchingEntity(SnapGrid.GetInDir(Direction.North)); var n = MatchingEntity(SnapGrid.GetInDir(Direction.North));
var ne = MatchingEntity(SnapGrid.GetInDir(Direction.NorthEast)); var ne = MatchingEntity(SnapGrid.GetInDir(Direction.NorthEast));
var e = MatchingEntity(SnapGrid.GetInDir(Direction.East)); var e = MatchingEntity(SnapGrid.GetInDir(Direction.East));
@@ -215,22 +234,28 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
{ {
base.Shutdown(); base.Shutdown();
if (SnapGrid != null)
{
SnapGrid.OnPositionChanged -= SnapGridOnPositionChanged; SnapGrid.OnPositionChanged -= SnapGridOnPositionChanged;
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode)); Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode));
} }
}
private void SnapGridOnPositionChanged() private void SnapGridOnPositionChanged()
{
if (SnapGrid != null)
{ {
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode)); Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode));
_lastPosition = (Owner.Transform.GridID, SnapGrid.Position); _lastPosition = (Owner.Transform.GridID, SnapGrid.Position);
} }
}
[System.Diagnostics.Contracts.Pure] [System.Diagnostics.Contracts.Pure]
protected bool MatchingEntity(IEnumerable<IEntity> candidates) protected bool MatchingEntity(IEnumerable<IEntity> candidates)
{ {
foreach (var entity in candidates) foreach (var entity in candidates)
{ {
if (!entity.TryGetComponent(out IconSmoothComponent other)) if (!entity.TryGetComponent(out IconSmoothComponent? other))
{ {
continue; continue;
} }

View File

@@ -7,9 +7,9 @@ namespace Content.Client.GameObjects.Components.Instruments
public class InstrumentBoundUserInterface : BoundUserInterface public class InstrumentBoundUserInterface : BoundUserInterface
{ {
[ViewVariables] [ViewVariables]
private InstrumentMenu _instrumentMenu; private InstrumentMenu? _instrumentMenu;
public InstrumentComponent Instrument { get; set; } public InstrumentComponent? Instrument { get; set; }
public InstrumentBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) public InstrumentBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{ {

View File

@@ -1,4 +1,3 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@@ -5,8 +5,6 @@ using Content.Shared.GameObjects.Components.Interactable;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -27,7 +25,7 @@ namespace Content.Client.GameObjects.Components.Interactable
public override string Name => "MultiTool"; public override string Name => "MultiTool";
public override uint? NetID => ContentNetIDs.MULTITOOLS; public override uint? NetID => ContentNetIDs.MULTITOOLS;
public override void HandleComponentState(ComponentState curState, ComponentState nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
base.HandleComponentState(curState, nextState); base.HandleComponentState(curState, nextState);

View File

@@ -7,7 +7,6 @@ using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -26,7 +25,7 @@ namespace Content.Client.GameObjects.Components.Interactable
[ViewVariables] public bool Activated { get; private set; } [ViewVariables] public bool Activated { get; private set; }
[ViewVariables] public override ToolQuality Qualities => _behavior; [ViewVariables] public override ToolQuality Qualities => _behavior;
public override void HandleComponentState(ComponentState curState, ComponentState nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
base.HandleComponentState(curState, nextState); base.HandleComponentState(curState, nextState);

View File

@@ -16,8 +16,8 @@ namespace Content.Client.GameObjects.Components
public override string Name => "InteractionOutline"; public override string Name => "InteractionOutline";
private ShaderInstance _selectionShaderInstance; private ShaderInstance? _selectionShaderInstance;
private ShaderInstance _selectionShaderInRangeInstance; private ShaderInstance? _selectionShaderInRangeInstance;
/// <inheritdoc /> /// <inheritdoc />
public override void Initialize() public override void Initialize()
@@ -30,7 +30,7 @@ namespace Content.Client.GameObjects.Components
public void OnMouseEnter(bool inInteractionRange) public void OnMouseEnter(bool inInteractionRange)
{ {
if (Owner.TryGetComponent(out ISpriteComponent sprite)) if (Owner.TryGetComponent(out ISpriteComponent? sprite))
{ {
sprite.PostShader = inInteractionRange ? _selectionShaderInRangeInstance : _selectionShaderInstance; sprite.PostShader = inInteractionRange ? _selectionShaderInRangeInstance : _selectionShaderInstance;
sprite.RenderOrder = Owner.EntityManager.CurrentTick.Value; sprite.RenderOrder = Owner.EntityManager.CurrentTick.Value;
@@ -39,7 +39,7 @@ namespace Content.Client.GameObjects.Components
public void OnMouseLeave() public void OnMouseLeave()
{ {
if (Owner.TryGetComponent(out ISpriteComponent sprite)) if (Owner.TryGetComponent(out ISpriteComponent? sprite))
{ {
sprite.PostShader = null; sprite.PostShader = null;
sprite.RenderOrder = 0; sprite.RenderOrder = 0;
@@ -48,7 +48,7 @@ namespace Content.Client.GameObjects.Components
public void UpdateInRange(bool inInteractionRange) public void UpdateInRange(bool inInteractionRange)
{ {
if (Owner.TryGetComponent(out ISpriteComponent sprite)) if (Owner.TryGetComponent(out ISpriteComponent? sprite))
{ {
sprite.PostShader = inInteractionRange ? _selectionShaderInRangeInstance : _selectionShaderInstance; sprite.PostShader = inInteractionRange ? _selectionShaderInRangeInstance : _selectionShaderInstance;
} }

View File

@@ -1,4 +1,3 @@
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;

View File

@@ -8,8 +8,6 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -27,38 +25,43 @@ namespace Content.Client.GameObjects.Components.Items
[ViewVariables] [ViewVariables]
[DataField("sprite")] [DataField("sprite")]
protected ResourcePath RsiPath; protected ResourcePath? RsiPath;
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("color")] [DataField("color")]
protected Color Color = Color.White; protected Color Color = Color.White;
[DataField("HeldPrefix")] [DataField("HeldPrefix")]
private string _equippedPrefix; private string? _equippedPrefix;
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public string EquippedPrefix public string? EquippedPrefix
{ {
get => _equippedPrefix; get => _equippedPrefix;
set set
{ {
_equippedPrefix = value; _equippedPrefix = value;
if (!Owner.TryGetContainer(out IContainer container)) return;
if(container.Owner.TryGetComponent(out HandsComponent hands)) if (!Owner.TryGetContainer(out var container))
return;
if (container.Owner.TryGetComponent(out HandsComponent? hands))
hands.RefreshInHands(); hands.RefreshInHands();
} }
} }
public (RSI rsi, RSI.StateId stateId, Color color)? GetInHandStateInfo(HandLocation hand) public (RSI rsi, RSI.StateId stateId, Color color)? GetInHandStateInfo(HandLocation hand)
{ {
if (RsiPath == null) var rsi = GetRSI();
if (rsi == null)
{ {
return null; return null;
} }
var handName = hand.ToString().ToLowerInvariant(); var handName = hand.ToString().ToLowerInvariant();
var rsi = GetRSI();
var stateId = EquippedPrefix != null ? $"{EquippedPrefix}-inhand-{handName}" : $"inhand-{handName}"; var stateId = EquippedPrefix != null ? $"{EquippedPrefix}-inhand-{handName}" : $"inhand-{handName}";
if (rsi.TryGetState(stateId, out _)) if (rsi.TryGetState(stateId, out _))
{ {
return (rsi, stateId, Color); return (rsi, stateId, Color);
@@ -67,18 +70,22 @@ namespace Content.Client.GameObjects.Components.Items
return null; return null;
} }
protected RSI GetRSI() protected RSI? GetRSI()
{ {
if (RsiPath == null)
{
return null;
}
return _resourceCache.GetResource<RSIResource>(SharedSpriteComponent.TextureRoot / RsiPath).RSI; return _resourceCache.GetResource<RSIResource>(SharedSpriteComponent.TextureRoot / RsiPath).RSI;
} }
public override void HandleComponentState(ComponentState curState, ComponentState nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
if(curState == null) if (curState is not ItemComponentState state)
return; return;
var itemComponentState = (ItemComponentState)curState; EquippedPrefix = state.EquippedPrefix;
EquippedPrefix = itemComponentState.EquippedPrefix;
} }
bool IDraggable.CanDrop(CanDropEventArgs args) bool IDraggable.CanDrop(CanDropEventArgs args)

View File

@@ -13,6 +13,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.GameObjects.Components.Kitchen namespace Content.Client.GameObjects.Components.Kitchen
{ {
@@ -22,7 +23,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
[Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private MicrowaveMenu _menu; private MicrowaveMenu? _menu;
private readonly Dictionary<int, EntityUid> _solids = new(); private readonly Dictionary<int, EntityUid> _solids = new();
private readonly Dictionary<int, Solution.ReagentQuantity> _reagents =new(); private readonly Dictionary<int, Solution.ReagentQuantity> _reagents =new();
@@ -38,8 +39,8 @@ namespace Content.Client.GameObjects.Components.Kitchen
_menu = new MicrowaveMenu(this); _menu = new MicrowaveMenu(this);
_menu.OpenCentered(); _menu.OpenCentered();
_menu.OnClose += Close; _menu.OnClose += Close;
_menu.StartButton.OnPressed += args => SendMessage(new SharedMicrowaveComponent.MicrowaveStartCookMessage()); _menu.StartButton.OnPressed += _ => SendMessage(new SharedMicrowaveComponent.MicrowaveStartCookMessage());
_menu.EjectButton.OnPressed += args => SendMessage(new SharedMicrowaveComponent.MicrowaveEjectMessage()); _menu.EjectButton.OnPressed += _ => SendMessage(new SharedMicrowaveComponent.MicrowaveEjectMessage());
_menu.IngredientsList.OnItemSelected += args => _menu.IngredientsList.OnItemSelected += args =>
{ {
SendMessage(new SharedMicrowaveComponent.MicrowaveEjectSolidIndexedMessage(_solids[args.ItemIndex])); SendMessage(new SharedMicrowaveComponent.MicrowaveEjectSolidIndexedMessage(_solids[args.ItemIndex]));
@@ -55,20 +56,20 @@ namespace Content.Client.GameObjects.Components.Kitchen
_menu.OnCookTimeSelected += (args,buttonIndex) => _menu.OnCookTimeSelected += (args,buttonIndex) =>
{ {
var actualButton = (MicrowaveMenu.MicrowaveCookTimeButton) args.Button ; var actualButton = (MicrowaveMenu.MicrowaveCookTimeButton) args.Button ;
var newTime = actualButton.CookTime;
SendMessage(new SharedMicrowaveComponent.MicrowaveSelectCookTimeMessage(buttonIndex,actualButton.CookTime)); SendMessage(new SharedMicrowaveComponent.MicrowaveSelectCookTimeMessage(buttonIndex,actualButton.CookTime));
}; };
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); base.Dispose(disposing);
if (!disposing) if (!disposing)
{ {
return; return;
} }
_solids?.Clear();
_solids.Clear();
_menu?.Dispose(); _menu?.Dispose();
} }
@@ -80,25 +81,35 @@ namespace Content.Client.GameObjects.Components.Kitchen
{ {
return; return;
} }
_menu.ToggleBusyDisableOverlayPanel(cState.IsMicrowaveBusy);
_menu?.ToggleBusyDisableOverlayPanel(cState.IsMicrowaveBusy);
RefreshContentsDisplay(cState.ReagentQuantities, cState.ContainedSolids); RefreshContentsDisplay(cState.ReagentQuantities, cState.ContainedSolids);
if (_menu != null)
{
var currentlySelectedTimeButton = (Button) _menu.CookTimeButtonVbox.GetChild(cState.ActiveButtonIndex); var currentlySelectedTimeButton = (Button) _menu.CookTimeButtonVbox.GetChild(cState.ActiveButtonIndex);
currentlySelectedTimeButton.Pressed = true; currentlySelectedTimeButton.Pressed = true;
var label = cState.ActiveButtonIndex <= 0 ? Loc.GetString("INSTANT") : cState.CurrentCookTime.ToString(); var label = cState.ActiveButtonIndex <= 0 ? Loc.GetString("INSTANT") : cState.CurrentCookTime.ToString();
_menu._cookTimeInfoLabel.Text = $"{Loc.GetString("COOK TIME")}: {label}"; _menu._cookTimeInfoLabel.Text = $"{Loc.GetString("COOK TIME")}: {label}";
} }
}
private void RefreshContentsDisplay(Solution.ReagentQuantity[] reagents, EntityUid[] containedSolids) private void RefreshContentsDisplay(Solution.ReagentQuantity[] reagents, EntityUid[] containedSolids)
{ {
_reagents.Clear(); _reagents.Clear();
if (_menu == null) return;
_menu.IngredientsListReagents.Clear(); _menu.IngredientsListReagents.Clear();
for (var i = 0; i < reagents.Length; i++) for (var i = 0; i < reagents.Length; i++)
{ {
_prototypeManager.TryIndex(reagents[i].ReagentId, out ReagentPrototype proto); if (_prototypeManager.TryIndex(reagents[i].ReagentId, out ReagentPrototype? proto))
{
var reagentAdded = _menu.IngredientsListReagents.AddItem($"{reagents[i].Quantity} {proto.Name}"); var reagentAdded = _menu.IngredientsListReagents.AddItem($"{reagents[i].Quantity} {proto.Name}");
var reagentIndex = _menu.IngredientsListReagents.IndexOf(reagentAdded); var reagentIndex = _menu.IngredientsListReagents.IndexOf(reagentAdded);
_reagents.Add(reagentIndex, reagents[i]); _reagents.Add(reagentIndex, reagents[i]);
} }
}
_solids.Clear(); _solids.Clear();
_menu.IngredientsList.Clear(); _menu.IngredientsList.Clear();
@@ -108,31 +119,34 @@ namespace Content.Client.GameObjects.Components.Kitchen
{ {
return; return;
} }
if (entity.Deleted) if (entity.Deleted)
{ {
continue; continue;
} }
Texture texture; Texture? texture;
if (entity.TryGetComponent(out IconComponent iconComponent)) if (entity.TryGetComponent(out IconComponent? iconComponent))
{ {
texture = iconComponent.Icon?.Default; texture = iconComponent.Icon?.Default;
}else if (entity.TryGetComponent(out SpriteComponent spriteComponent)) }
else if (entity.TryGetComponent(out SpriteComponent? spriteComponent))
{ {
texture = spriteComponent.Icon?.Default; texture = spriteComponent.Icon?.Default;
}else{continue;} }
else
{
continue;
}
var solidItem = _menu.IngredientsList.AddItem(entity.Name, texture); var solidItem = _menu.IngredientsList.AddItem(entity.Name, texture);
var solidIndex = _menu.IngredientsList.IndexOf(solidItem); var solidIndex = _menu.IngredientsList.IndexOf(solidItem);
_solids.Add(solidIndex, containedSolids[j]); _solids.Add(solidIndex, containedSolids[j]);
} }
} }
public class MicrowaveMenu : SS14Window public class MicrowaveMenu : SS14Window
{ {
public class MicrowaveCookTimeButton : Button public class MicrowaveCookTimeButton : Button
{ {
public uint CookTime; public uint CookTime;
@@ -141,7 +155,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
private MicrowaveBoundUserInterface Owner { get; set; } private MicrowaveBoundUserInterface Owner { get; set; }
public event Action<BaseButton.ButtonEventArgs, int> OnCookTimeSelected; public event Action<ButtonEventArgs, int>? OnCookTimeSelected;
public Button StartButton { get; } public Button StartButton { get; }
public Button EjectButton { get; } public Button EjectButton { get; }
@@ -149,19 +163,19 @@ namespace Content.Client.GameObjects.Components.Kitchen
public PanelContainer TimerFacePlate { get; } public PanelContainer TimerFacePlate { get; }
public ButtonGroup CookTimeButtonGroup { get; } public ButtonGroup CookTimeButtonGroup { get; }
public VBoxContainer CookTimeButtonVbox { get; } public VBoxContainer CookTimeButtonVbox { get; }
private VBoxContainer ButtonGridContainer { get; } private VBoxContainer ButtonGridContainer { get; }
private PanelContainer DisableCookingPanelOverlay { get; } private PanelContainer DisableCookingPanelOverlay { get; }
public ItemList IngredientsList { get; } public ItemList IngredientsList { get; }
public ItemList IngredientsListReagents { get; } public ItemList IngredientsListReagents { get; }
public Label _cookTimeInfoLabel { get; } public Label _cookTimeInfoLabel { get; }
public MicrowaveMenu(MicrowaveBoundUserInterface owner = null) public MicrowaveMenu(MicrowaveBoundUserInterface owner)
{ {
SetSize = MinSize = (512, 256); SetSize = MinSize = (512, 256);
@@ -246,7 +260,6 @@ namespace Content.Client.GameObjects.Components.Kitchen
Align = BoxContainer.AlignMode.Center, Align = BoxContainer.AlignMode.Center,
}; };
var index = 0; var index = 0;
for (var i = 0; i <= 6; i++) for (var i = 0; i <= 6; i++)
{ {
@@ -270,7 +283,6 @@ namespace Content.Client.GameObjects.Components.Kitchen
var cookTimeOneSecondButton = (Button) CookTimeButtonVbox.GetChild(0); var cookTimeOneSecondButton = (Button) CookTimeButtonVbox.GetChild(0);
cookTimeOneSecondButton.Pressed = true; cookTimeOneSecondButton.Pressed = true;
_cookTimeInfoLabel = new Label _cookTimeInfoLabel = new Label
{ {
Text = Loc.GetString("COOK TIME: 1"), Text = Loc.GetString("COOK TIME: 1"),

Some files were not shown because too many files have changed in this diff Show More