Enable nullability in Content.Server (#3685)
This commit is contained in:
@@ -3,9 +3,7 @@ using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.GameObjects.Components
|
||||
@@ -16,19 +14,14 @@ namespace Content.Server.GameObjects.Components
|
||||
public override string Name => "RandomSpriteColor";
|
||||
|
||||
[DataField("selected")]
|
||||
private string _selectedColor;
|
||||
private string? _selectedColor;
|
||||
[DataField("state")]
|
||||
private string _baseState = "error";
|
||||
|
||||
[DataField("colors")] private Dictionary<string, Color> _colors = new();
|
||||
[DataField("colors")] private readonly Dictionary<string, Color> _colors = new();
|
||||
|
||||
void IMapInit.MapInit()
|
||||
{
|
||||
if (_colors == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
_selectedColor = random.Pick(_colors.Keys);
|
||||
UpdateColor();
|
||||
@@ -43,7 +36,7 @@ namespace Content.Server.GameObjects.Components
|
||||
|
||||
private void UpdateColor()
|
||||
{
|
||||
if (Owner.TryGetComponent(out SpriteComponent spriteComponent) && _colors != null && _selectedColor != null)
|
||||
if (Owner.TryGetComponent(out SpriteComponent? spriteComponent) && _selectedColor != null)
|
||||
{
|
||||
spriteComponent.LayerSetState(0, _baseState);
|
||||
spriteComponent.LayerSetColor(0, _colors[_selectedColor]);
|
||||
|
||||
Reference in New Issue
Block a user