Enable nullability in Content.Shared (#3626)
* Enable nullability in Content.Shared * Fix null errors in server * aye github i swear on me mom
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.GameObjects.Components.Movement;
|
||||
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -16,16 +14,14 @@ namespace Content.Shared.GameObjects.Components.Inventory
|
||||
{
|
||||
public abstract class SharedInventoryComponent : Component, IMoveSpeedModifier
|
||||
{
|
||||
// ReSharper disable UnassignedReadonlyField
|
||||
[Dependency] protected readonly IReflectionManager ReflectionManager;
|
||||
[Dependency] protected readonly IDynamicTypeFactory DynamicTypeFactory;
|
||||
// ReSharper restore UnassignedReadonlyField
|
||||
[Dependency] protected readonly IReflectionManager ReflectionManager = default!;
|
||||
[Dependency] protected readonly IDynamicTypeFactory DynamicTypeFactory = default!;
|
||||
|
||||
public sealed override string Name => "Inventory";
|
||||
public sealed override uint? NetID => ContentNetIDs.STORAGE;
|
||||
|
||||
[ViewVariables]
|
||||
protected Inventory InventoryInstance { get; private set; }
|
||||
protected Inventory InventoryInstance { get; private set; } = default!;
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("Template")]
|
||||
@@ -42,7 +38,7 @@ namespace Content.Shared.GameObjects.Components.Inventory
|
||||
{
|
||||
var type = ReflectionManager.LooseGetType(_templateName);
|
||||
DebugTools.Assert(type != null);
|
||||
InventoryInstance = DynamicTypeFactory.CreateInstance<Inventory>(type);
|
||||
InventoryInstance = DynamicTypeFactory.CreateInstance<Inventory>(type!);
|
||||
}
|
||||
|
||||
/// <returns>true if the item is equipped to an equip slot (NOT inside an equipped container
|
||||
|
||||
@@ -40,13 +40,13 @@ namespace Content.Shared.GameObjects.Components.Materials
|
||||
[DataDefinition]
|
||||
public class MaterialDataEntry : ISerializationHooks
|
||||
{
|
||||
public object Key;
|
||||
public object Key = default!;
|
||||
|
||||
[DataField("key")]
|
||||
public string StringKey;
|
||||
[DataField("key", required: true)]
|
||||
public string StringKey = default!;
|
||||
|
||||
[DataField("mat")]
|
||||
public string Value;
|
||||
[DataField("mat", required: true)]
|
||||
public string Value = default!;
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -22,10 +21,10 @@ namespace Content.Shared.GameObjects.Components
|
||||
{
|
||||
public float Pressure;
|
||||
public float Temperature;
|
||||
public GasEntry[] Gases;
|
||||
public string Error = string.Empty;
|
||||
public GasEntry[]? Gases;
|
||||
public string? Error;
|
||||
|
||||
public GasAnalyzerBoundUserInterfaceState(float pressure, float temperature, GasEntry[] gases, string error = null)
|
||||
public GasAnalyzerBoundUserInterfaceState(float pressure, float temperature, GasEntry[]? gases, string? error = null)
|
||||
{
|
||||
Pressure = pressure;
|
||||
Temperature = temperature;
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Content.Shared.GameObjects.Components
|
||||
return new StackComponentState(Count, MaxCount);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState is not StackComponentState cast)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user