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:
@@ -3,8 +3,6 @@ using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Atmos
|
||||
{
|
||||
@@ -13,12 +11,15 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
{
|
||||
[DataField("fireStackAlternateState")]
|
||||
private int _fireStackAlternateState = 3;
|
||||
|
||||
[DataField("normalState")]
|
||||
private string _normalState;
|
||||
private string? _normalState;
|
||||
|
||||
[DataField("alternateState")]
|
||||
private string _alternateState;
|
||||
private string? _alternateState;
|
||||
|
||||
[DataField("sprite")]
|
||||
private string _sprite;
|
||||
private string? _sprite;
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
{
|
||||
@@ -49,7 +50,11 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
|
||||
sprite.LayerSetRSI(FireVisualLayers.Fire, _sprite);
|
||||
if (_sprite != null)
|
||||
{
|
||||
sprite.LayerSetRSI(FireVisualLayers.Fire, _sprite);
|
||||
}
|
||||
|
||||
sprite.LayerSetVisible(FireVisualLayers.Fire, onFire);
|
||||
|
||||
if(fireStacks > _fireStackAlternateState && !string.IsNullOrEmpty(_alternateState))
|
||||
|
||||
@@ -10,13 +10,13 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
{
|
||||
}
|
||||
|
||||
private GasAnalyzerWindow _menu;
|
||||
private GasAnalyzerWindow? _menu;
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_menu = new GasAnalyzerWindow(this);
|
||||
|
||||
_menu = new GasAnalyzerWindow(this);
|
||||
_menu.OnClose += Close;
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
@@ -24,7 +24,8 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
_menu.Populate((GasAnalyzerBoundUserInterfaceState) state);
|
||||
|
||||
_menu?.Populate((GasAnalyzerBoundUserInterfaceState) state);
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
@@ -35,10 +36,8 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_menu?.Dispose();
|
||||
if (disposing) _menu?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Client.Utility;
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -22,7 +21,7 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
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)
|
||||
return;
|
||||
@@ -55,15 +54,17 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
}
|
||||
|
||||
_parent._uiUpdateNeeded = false;
|
||||
|
||||
var color = _parent.Danger switch
|
||||
{
|
||||
GasAnalyzerDanger.Warning => "orange",
|
||||
GasAnalyzerDanger.Hazard => "red",
|
||||
_ => "green",
|
||||
};
|
||||
|
||||
_label.SetMarkup(Loc.GetString("Pressure: [color={0}]{1}[/color]",
|
||||
color,
|
||||
Enum.GetName(typeof(GasAnalyzerDanger), _parent.Danger)));
|
||||
_parent.Danger));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Atmos
|
||||
{
|
||||
@@ -11,9 +9,9 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
public class GasAnalyzerVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[DataField("state_off")]
|
||||
private string _stateOff;
|
||||
private string? _stateOff;
|
||||
[DataField("state_working")]
|
||||
private string _stateWorking;
|
||||
private string? _stateWorking;
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
@@ -24,7 +22,7 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
return;
|
||||
}
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite))
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -39,8 +37,6 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
case GasAnalyzerVisualState.Working:
|
||||
sprite.LayerSetState(0, _stateWorking);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.Components.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
using Content.Shared.GameObjects.Components.Atmos;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Atmos
|
||||
{
|
||||
public class GasCanisterVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[DataField("stateConnected")]
|
||||
private string _stateConnected;
|
||||
private string? _stateConnected;
|
||||
|
||||
[DataField("pressureStates")]
|
||||
private string[] _statePressure = new string[] {"", "", "", ""};
|
||||
|
||||
@@ -20,11 +19,14 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
|
||||
var sprite = entity.GetComponent<ISpriteComponent>();
|
||||
|
||||
sprite.LayerMapSet(Layers.ConnectedToPort, sprite.AddLayerState(_stateConnected));
|
||||
sprite.LayerSetVisible(Layers.ConnectedToPort, false);
|
||||
if (_stateConnected != null)
|
||||
{
|
||||
sprite.LayerMapSet(Layers.ConnectedToPort, sprite.AddLayerState(_stateConnected));
|
||||
sprite.LayerSetVisible(Layers.ConnectedToPort, false);
|
||||
|
||||
sprite.LayerMapSet(Layers.PressureLight, sprite.AddLayerState(_stateConnected));
|
||||
sprite.LayerSetShader(Layers.PressureLight, "unshaded");
|
||||
sprite.LayerMapSet(Layers.PressureLight, sprite.AddLayerState(_stateConnected));
|
||||
sprite.LayerSetShader(Layers.PressureLight, "unshaded");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
@@ -36,7 +38,7 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
return;
|
||||
}
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite))
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.GameObjects.Components.Atmos;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Content.Shared.GameObjects.Components.Atmos;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Atmos
|
||||
{
|
||||
@@ -49,7 +49,7 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
Children =
|
||||
{
|
||||
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)}),
|
||||
(EditLabelBtn = new Button()),
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.Components.Atmos;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return;
|
||||
if (!entity.TryGetComponent(out ISpriteComponent? sprite)) return;
|
||||
|
||||
sprite.LayerMapReserveBlank(Layer.PumpEnabled);
|
||||
var pumpEnabledLayer = sprite.LayerMapGet(Layer.PumpEnabled);
|
||||
@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
|
||||
{
|
||||
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;
|
||||
|
||||
var pumpEnabledLayer = sprite.LayerMapGet(Layer.PumpEnabled);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return;
|
||||
if (!entity.TryGetComponent(out ISpriteComponent? sprite)) return;
|
||||
|
||||
sprite.LayerMapReserveBlank(Layer.SiphonEnabled);
|
||||
var layer = sprite.LayerMapGet(Layer.SiphonEnabled);
|
||||
@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
|
||||
{
|
||||
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;
|
||||
|
||||
var layer = sprite.LayerMapGet(Layer.SiphonEnabled);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
if (!entity.TryGetComponent(out ISpriteComponent sprite)) return;
|
||||
if (!entity.TryGetComponent(out ISpriteComponent? sprite)) return;
|
||||
|
||||
sprite.LayerMapReserveBlank(Layer.VentEnabled);
|
||||
var layer = sprite.LayerMapGet(Layer.VentEnabled);
|
||||
@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.Components.Atmos.Piping
|
||||
{
|
||||
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;
|
||||
|
||||
var layer = sprite.LayerMapGet(Layer.VentEnabled);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Content.Client.GameObjects.Components.Atmos
|
||||
[DataField("animation_state")]
|
||||
private string _state = "chempuff";
|
||||
|
||||
private Animation VaporFlick;
|
||||
private Animation VaporFlick = default!;
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user