Enable nullable in ReactionPrototype & ReagentPrototype (#3005)

* Enable nullable in ReactionPrototype & ReagentPrototype

* Remove unecessary sets

* Fix updates branch

* Review fixes

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2021-01-14 23:40:10 -06:00
committed by GitHub
parent 3079ddd962
commit 138cdaba5b
3 changed files with 29 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.Chemistry;
@@ -18,16 +19,16 @@ namespace Content.Shared.Chemistry
{
[Dependency] private readonly IModuleManager _moduleManager = default!;
private string _id;
private string _name;
private string _description;
private string _physicalDescription;
private string _id = default!;
private string _name = default!;
private string _description = default!;
private string _physicalDescription = default!;
private Color _substanceColor;
private string _spritePath;
private List<IMetabolizable> _metabolism;
private List<ITileReaction> _tileReactions;
private List<IPlantMetabolizable> _plantMetabolism;
private float _customPlantMetabolism = 1f;
private string _spritePath = default!;
private List<IMetabolizable> _metabolism = default!;
private List<ITileReaction> _tileReactions = default!;
private List<IPlantMetabolizable> _plantMetabolism = default!;
private float _customPlantMetabolism;
public string ID => _id;
public string Name => _name;
@@ -60,15 +61,17 @@ namespace Content.Shared.Chemistry
if (_moduleManager.IsServerModule)
{
//Implementations of the needed interfaces are currently server-only, so they cannot be read on client
serializer.DataField(ref _metabolism, "metabolism", new List<IMetabolizable> { new DefaultMetabolizable() });
serializer.DataField(ref _tileReactions, "tileReactions", new List<ITileReaction> { });
serializer.DataField(ref _plantMetabolism, "plantMetabolism", new List<IPlantMetabolizable> { });
}
else
{
//ensure the following fields cannot null since they can only be serialized on server right now
_metabolism = new List<IMetabolizable> { new DefaultMetabolizable() };
_tileReactions = new List<ITileReaction>(0);
_plantMetabolism = new List<IPlantMetabolizable>(0);
_tileReactions = new();
_plantMetabolism = new();
}
}