Added nullable to most Content.Shared files (#3238)
* Add nullable to some Content.Shared files. * Use [NotNullWhen(true)] * Undo adding now redundant !'s * Forgot one * Add a ton more nullable * You can guess * Fix some issues * It actually compiles now * Auto stash before merge of "null2" and "origin/master" * I lied * enable annotations -> enable * Revert ActionBlockerSystem.cs to original * Fix ActionBlockerSystem.cs * More nullable * Undo some added exclamation marks * Fix issues * Update Content.Shared/Maps/ContentTileDefinition.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Resolve some issues * Remove unused method * Fix more issues * Fix more issues * Fix more issues * Fix more issues * Fix issue, rollback SharedGhostComponent.cs * Update submodule * Fix issue, invert some if-statements to reduce nesting * Revert RobustToolbox * FIx things broken by merge * Some fixes - Replaced with string.Empty - Remove some exclamation marks - Revert file * Some fixes * Trivial #nullable enable * Fix null ables Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
@@ -24,7 +25,7 @@ namespace Content.Shared.Damage
|
||||
return DamageSystem.ClassToType[@class];
|
||||
}
|
||||
|
||||
public static Dictionary<DamageClass, T> ToNewDictionary<T>()
|
||||
public static Dictionary<DamageClass, T> ToNewDictionary<T>() where T : struct
|
||||
{
|
||||
return Enum.GetValues(typeof(DamageClass))
|
||||
.Cast<DamageClass>()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -15,9 +16,9 @@ namespace Content.Shared.Damage.DamageContainer
|
||||
public class DamageContainerPrototype : IPrototype
|
||||
{
|
||||
private bool _supportAll;
|
||||
private HashSet<DamageClass> _supportedClasses;
|
||||
private HashSet<DamageType> _supportedTypes;
|
||||
private string _id;
|
||||
private HashSet<DamageClass> _supportedClasses = new();
|
||||
private HashSet<DamageType> _supportedTypes = new();
|
||||
private string _id = string.Empty;
|
||||
|
||||
// TODO NET 5 IReadOnlySet
|
||||
[ViewVariables] public IReadOnlyCollection<DamageClass> SupportedClasses => _supportedClasses;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
@@ -29,7 +30,7 @@ namespace Content.Shared.Damage
|
||||
return DamageSystem.TypeToClass[type];
|
||||
}
|
||||
|
||||
public static Dictionary<DamageType, T> ToNewDictionary<T>()
|
||||
public static Dictionary<DamageType, T> ToNewDictionary<T>() where T : struct
|
||||
{
|
||||
return Enum.GetValues(typeof(DamageType))
|
||||
.Cast<DamageType>()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -32,7 +33,7 @@ namespace Content.Shared.Damage.ResistanceSet
|
||||
_resistances = data.Resistances;
|
||||
}
|
||||
|
||||
public string ID { get; }
|
||||
public string ID { get; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts input damage with the resistance set values.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -14,15 +15,15 @@ namespace Content.Shared.Damage.ResistanceSet
|
||||
[Serializable, NetSerializable]
|
||||
public class ResistanceSetPrototype : IPrototype
|
||||
{
|
||||
private Dictionary<DamageType, float> _coefficients;
|
||||
private Dictionary<DamageType, int> _flatReductions;
|
||||
private string _id;
|
||||
private Dictionary<DamageType, float> _coefficients = new();
|
||||
private Dictionary<DamageType, int> _flatReductions = new();
|
||||
private string _id = string.Empty;
|
||||
|
||||
[ViewVariables] public Dictionary<DamageType, float> Coefficients => _coefficients;
|
||||
|
||||
[ViewVariables] public Dictionary<DamageType, int> FlatReductions => _flatReductions;
|
||||
|
||||
[ViewVariables] public Dictionary<DamageType, ResistanceSetSettings> Resistances { get; private set; }
|
||||
[ViewVariables] public Dictionary<DamageType, ResistanceSetSettings> Resistances { get; private set; } = new();
|
||||
|
||||
[ViewVariables] public string ID => _id;
|
||||
|
||||
@@ -31,8 +32,8 @@ namespace Content.Shared.Damage.ResistanceSet
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
|
||||
serializer.DataField(ref _id, "id", string.Empty);
|
||||
serializer.DataField(ref _coefficients, "coefficients", null);
|
||||
serializer.DataField(ref _flatReductions, "flatReductions", null);
|
||||
serializer.DataField(ref _coefficients, "coefficients", new Dictionary<DamageType, float>());
|
||||
serializer.DataField(ref _flatReductions, "flatReductions", new Dictionary<DamageType, int>());
|
||||
|
||||
Resistances = new Dictionary<DamageType, ResistanceSetSettings>();
|
||||
foreach (var damageType in (DamageType[]) Enum.GetValues(typeof(DamageType)))
|
||||
|
||||
Reference in New Issue
Block a user