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:
Visne
2021-02-27 04:12:09 +01:00
committed by GitHub
parent 2f45e5e044
commit 9b94d5c195
377 changed files with 1048 additions and 646 deletions

View File

@@ -14,7 +14,7 @@ namespace Content.Client.GameObjects.Components.Buckle
public override bool Buckled => _buckled; public override bool Buckled => _buckled;
public override bool TryBuckle(IEntity user, IEntity to) public override bool TryBuckle(IEntity? user, IEntity to)
{ {
// TODO: Prediction // TODO: Prediction
return false; return false;

View File

@@ -1,5 +1,4 @@
using System; using System;
using Content.Shared.GameObjects.Components.Observer;
using Content.Shared.GameObjects.Components.Observer.GhostRoles; using Content.Shared.GameObjects.Components.Observer.GhostRoles;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;

View File

@@ -119,15 +119,23 @@ namespace Content.Client.GameObjects.EntitySystems
private bool OnUseMouseDown(in PointerInputCmdHandler.PointerInputCmdArgs args) private bool OnUseMouseDown(in PointerInputCmdHandler.PointerInputCmdArgs args)
{ {
var dragger = args.Session?.AttachedEntity; if (args.Session?.AttachedEntity == null)
{
return false;
}
var dragger = args.Session.AttachedEntity;
// cancel any current dragging if there is one (shouldn't be because they would've had to have lifted // cancel any current dragging if there is one (shouldn't be because they would've had to have lifted
// the mouse, canceling the drag, but just being cautious) // the mouse, canceling the drag, but just being cautious)
_dragDropHelper.EndDrag(); _dragDropHelper.EndDrag();
// possibly initiating a drag // possibly initiating a drag
// check if the clicked entity is draggable // check if the clicked entity is draggable
if (EntityManager.TryGetEntity(args.EntityUid, out var entity)) if (!EntityManager.TryGetEntity(args.EntityUid, out var entity))
{ {
return false;
}
// check if the entity is reachable // check if the entity is reachable
if (!_interactionSystem.InRangeUnobstructed(dragger, entity)) if (!_interactionSystem.InRangeUnobstructed(dragger, entity))
{ {
@@ -138,29 +146,33 @@ namespace Content.Client.GameObjects.EntitySystems
foreach (var draggable in entity.GetAllComponents<IDraggable>()) foreach (var draggable in entity.GetAllComponents<IDraggable>())
{ {
var dragEventArgs = new StartDragDropEventArgs(dragger, entity); var dragEventArgs = new StartDragDropEventArgs(dragger, entity);
if (draggable.CanStartDrag(dragEventArgs))
if (!draggable.CanStartDrag(dragEventArgs))
{ {
continue;
}
_draggables.Add(draggable); _draggables.Add(draggable);
canDrag = true; canDrag = true;
} }
if (!canDrag)
{
return false;
} }
if (canDrag)
{
// wait to initiate a drag // wait to initiate a drag
_dragDropHelper.MouseDown(entity); _dragDropHelper.MouseDown(entity);
_dragger = dragger; _dragger = dragger;
_mouseDownTime = 0; _mouseDownTime = 0;
// don't want anything else to process the click, // don't want anything else to process the click,
// but we will save the event so we can "re-play" it if this drag does // but we will save the event so we can "re-play" it if this drag does
// not turn into an actual drag so the click can be handled normally // not turn into an actual drag so the click can be handled normally
_savedMouseDown = args; _savedMouseDown = args;
}
return canDrag; return true;
}
return false;
} }
private bool OnBeginDrag() private bool OnBeginDrag()
@@ -384,7 +396,7 @@ namespace Content.Client.GameObjects.EntitySystems
var valid = (bool?) null; var valid = (bool?) null;
// check if it's able to be dropped on by current dragged entity // check if it's able to be dropped on by current dragged entity
var dropArgs = new DragDropEventArgs(_dragger, pvsEntity.Transform.Coordinates, _dragDropHelper.Dragged, pvsEntity); var dropArgs = new DragDropEventArgs(_dragger!, pvsEntity.Transform.Coordinates, _dragDropHelper.Dragged, pvsEntity);
foreach (var comp in pvsEntity.GetAllComponents<IDragDropOn>()) foreach (var comp in pvsEntity.GetAllComponents<IDragDropOn>())
{ {

View File

@@ -238,7 +238,7 @@ namespace Content.Server.GameObjects.Components.Buckle
return true; return true;
} }
public override bool TryBuckle(IEntity user, IEntity to) public override bool TryBuckle(IEntity? user, IEntity to)
{ {
if (!CanBuckle(user, to, out var strap)) if (!CanBuckle(user, to, out var strap))
{ {

View File

@@ -222,7 +222,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
if (beaker == null) if (beaker == null)
{ {
return new ReagentDispenserBoundUserInterfaceState(Powered, false, ReagentUnit.New(0), ReagentUnit.New(0), return new ReagentDispenserBoundUserInterfaceState(Powered, false, ReagentUnit.New(0), ReagentUnit.New(0),
"", Inventory, Owner.Name, null, _dispenseAmount); string.Empty, Inventory, Owner.Name, null, _dispenseAmount);
} }
var solution = beaker.GetComponent<SolutionContainerComponent>(); var solution = beaker.GetComponent<SolutionContainerComponent>();

View File

@@ -95,10 +95,10 @@ namespace Content.Server.GameObjects.Components.Disposal
private readonly List<string> _targetList = new(); private readonly List<string> _targetList = new();
[ViewVariables] [ViewVariables]
private string _target = ""; private string? _target;
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
private string _tag = ""; private string _tag = string.Empty;
[ViewVariables] [ViewVariables]
public bool Powered => public bool Powered =>
@@ -288,6 +288,11 @@ namespace Content.Server.GameObjects.Components.Disposal
_container.Remove(entity); _container.Remove(entity);
} }
if (_target == null)
{
return false;
}
var holder = CreateTaggedHolder(entities, _target); var holder = CreateTaggedHolder(entities, _target);
entryComponent.TryInsert(holder); entryComponent.TryInsert(holder);
@@ -441,7 +446,7 @@ namespace Content.Server.GameObjects.Components.Disposal
} }
} }
if (obj.Message is UiTargetUpdateMessage tagMessage && TagRegex.IsMatch(tagMessage.Target)) if (obj.Message is UiTargetUpdateMessage tagMessage && TagRegex.IsMatch(tagMessage.Target ?? string.Empty))
{ {
_target = tagMessage.Target; _target = tagMessage.Target;
} }
@@ -714,6 +719,11 @@ namespace Content.Server.GameObjects.Components.Disposal
bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs) bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs)
{ {
if (eventArgs.User == null)
{
return false;
}
if (!eventArgs.User.TryGetComponent(out IActorComponent? actor)) if (!eventArgs.User.TryGetComponent(out IActorComponent? actor))
{ {
return false; return false;

View File

@@ -76,6 +76,11 @@ namespace Content.Server.GameObjects.Components.GUI
public override bool Drop(DragDropEventArgs args) public override bool Drop(DragDropEventArgs args)
{ {
if (args.User == null)
{
return false;
}
if (!args.User.TryGetComponent(out IActorComponent? actor)) return false; if (!args.User.TryGetComponent(out IActorComponent? actor)) return false;
OpenUserInterface(actor.playerSession); OpenUserInterface(actor.playerSession);

View File

@@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -1,3 +1,4 @@
#nullable enable
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -26,11 +27,11 @@ namespace Content.Shared.Access
Name = Loc.GetString(Name); Name = Loc.GetString(Name);
} }
public string ID { get; private set; } public string ID { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// The player-visible name of the access level, in the ID card console and such. /// The player-visible name of the access level, in the ID card console and such.
/// </summary> /// </summary>
public string Name { get; private set; } public string Name { get; private set; } = string.Empty;
} }
} }

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic; #nullable enable
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
@@ -14,12 +16,11 @@ namespace Content.Shared.Actions
[Dependency] [Dependency]
private readonly IPrototypeManager _prototypeManager = default!; private readonly IPrototypeManager _prototypeManager = default!;
private Dictionary<ActionType, ActionPrototype> _typeToAction; private readonly Dictionary<ActionType, ActionPrototype> _typeToAction = new();
private Dictionary<ItemActionType, ItemActionPrototype> _typeToItemAction; private readonly Dictionary<ItemActionType, ItemActionPrototype> _typeToItemAction = new();
public void Initialize() public void Initialize()
{ {
_typeToAction = new Dictionary<ActionType, ActionPrototype>();
foreach (var action in _prototypeManager.EnumeratePrototypes<ActionPrototype>()) foreach (var action in _prototypeManager.EnumeratePrototypes<ActionPrototype>())
{ {
if (!_typeToAction.TryAdd(action.ActionType, action)) if (!_typeToAction.TryAdd(action.ActionType, action))
@@ -30,7 +31,6 @@ namespace Content.Shared.Actions
} }
} }
_typeToItemAction = new Dictionary<ItemActionType, ItemActionPrototype>();
foreach (var action in _prototypeManager.EnumeratePrototypes<ItemActionPrototype>()) foreach (var action in _prototypeManager.EnumeratePrototypes<ItemActionPrototype>())
{ {
if (!_typeToItemAction.TryAdd(action.ActionType, action)) if (!_typeToItemAction.TryAdd(action.ActionType, action))
@@ -53,7 +53,7 @@ namespace Content.Shared.Actions
/// Tries to get the action of the indicated type /// Tries to get the action of the indicated type
/// </summary> /// </summary>
/// <returns>true if found</returns> /// <returns>true if found</returns>
public bool TryGet(ActionType actionType, out ActionPrototype action) public bool TryGet(ActionType actionType, [NotNullWhen(true)] out ActionPrototype? action)
{ {
return _typeToAction.TryGetValue(actionType, out action); return _typeToAction.TryGetValue(actionType, out action);
} }
@@ -62,7 +62,7 @@ namespace Content.Shared.Actions
/// Tries to get the item action of the indicated type /// Tries to get the item action of the indicated type
/// </summary> /// </summary>
/// <returns>true if found</returns> /// <returns>true if found</returns>
public bool TryGet(ItemActionType actionType, out ItemActionPrototype action) public bool TryGet(ItemActionType actionType, [NotNullWhen(true)] out ItemActionPrototype? action)
{ {
return _typeToItemAction.TryGetValue(actionType, out action); return _typeToItemAction.TryGetValue(actionType, out action);
} }

View File

@@ -1,4 +1,5 @@
using Content.Shared.Interfaces; #nullable enable
using Content.Shared.Interfaces;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -24,28 +25,28 @@ namespace Content.Shared.Actions
/// action. Null if this is not an Instant ActionBehaviorType. /// action. Null if this is not an Instant ActionBehaviorType.
/// Will be null on client side if the behavior is not in Content.Client. /// Will be null on client side if the behavior is not in Content.Client.
/// </summary> /// </summary>
public IInstantAction InstantAction { get; private set; } public IInstantAction InstantAction { get; private set; } = default!;
/// <summary> /// <summary>
/// The IToggleAction that should be invoked when performing this /// The IToggleAction that should be invoked when performing this
/// action. Null if this is not a Toggle ActionBehaviorType. /// action. Null if this is not a Toggle ActionBehaviorType.
/// Will be null on client side if the behavior is not in Content.Client. /// Will be null on client side if the behavior is not in Content.Client.
/// </summary> /// </summary>
public IToggleAction ToggleAction { get; private set; } public IToggleAction ToggleAction { get; private set; } = default!;
/// <summary> /// <summary>
/// The ITargetEntityAction that should be invoked when performing this /// The ITargetEntityAction that should be invoked when performing this
/// action. Null if this is not a TargetEntity ActionBehaviorType. /// action. Null if this is not a TargetEntity ActionBehaviorType.
/// Will be null on client side if the behavior is not in Content.Client. /// Will be null on client side if the behavior is not in Content.Client.
/// </summary> /// </summary>
public ITargetEntityAction TargetEntityAction { get; private set; } public ITargetEntityAction TargetEntityAction { get; private set; } = default!;
/// <summary> /// <summary>
/// The ITargetPointAction that should be invoked when performing this /// The ITargetPointAction that should be invoked when performing this
/// action. Null if this is not a TargetPoint ActionBehaviorType. /// action. Null if this is not a TargetPoint ActionBehaviorType.
/// Will be null on client side if the behavior is not in Content.Client. /// Will be null on client side if the behavior is not in Content.Client.
/// </summary> /// </summary>
public ITargetPointAction TargetPointAction { get; private set; } public ITargetPointAction TargetPointAction { get; private set; } = default!;
public override void LoadFrom(YamlMappingNode mapping) public override void LoadFrom(YamlMappingNode mapping)
{ {
@@ -61,7 +62,7 @@ namespace Content.Shared.Actions
// TODO: Split this class into server/client after RobustToolbox#1405 // TODO: Split this class into server/client after RobustToolbox#1405
if (IoCManager.Resolve<IModuleManager>().IsClientModule) return; if (IoCManager.Resolve<IModuleManager>().IsClientModule) return;
IActionBehavior behavior = null; IActionBehavior? behavior = null;
serializer.DataField(ref behavior, "behavior", null); serializer.DataField(ref behavior, "behavior", null);
switch (behavior) switch (behavior)
{ {

View File

@@ -1,4 +1,5 @@
namespace Content.Shared.Actions #nullable enable
namespace Content.Shared.Actions
{ {
/// <summary> /// <summary>
/// Every possible action. Corresponds to actionType in action prototypes. /// Every possible action. Corresponds to actionType in action prototypes.

View File

@@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -15,41 +16,41 @@ namespace Content.Shared.Actions
/// </summary> /// </summary>
public abstract class BaseActionPrototype : IPrototype public abstract class BaseActionPrototype : IPrototype
{ {
public string ID { get; private set; } public string ID { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// Icon representing this action in the UI. /// Icon representing this action in the UI.
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
public SpriteSpecifier Icon { get; private set; } public SpriteSpecifier Icon { get; private set; } = SpriteSpecifier.Invalid;
/// <summary> /// <summary>
/// For toggle actions only, icon to show when toggled on. If omitted, /// For toggle actions only, icon to show when toggled on. If omitted,
/// the action will simply be highlighted when turned on. /// the action will simply be highlighted when turned on.
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
public SpriteSpecifier IconOn { get; private set; } public SpriteSpecifier IconOn { get; private set; } = SpriteSpecifier.Invalid;
/// <summary> /// <summary>
/// Name to show in UI. Accepts formatting. /// Name to show in UI. Accepts formatting.
/// </summary> /// </summary>
public FormattedMessage Name { get; private set; } public FormattedMessage Name { get; private set; } = new();
/// <summary> /// <summary>
/// Description to show in UI. Accepts formatting. /// Description to show in UI. Accepts formatting.
/// </summary> /// </summary>
public FormattedMessage Description { get; private set; } public FormattedMessage Description { get; private set; } = new();
/// <summary> /// <summary>
/// Requirements message to show in UI. Accepts formatting, but generally should be avoided /// Requirements message to show in UI. Accepts formatting, but generally should be avoided
/// so the requirements message isn't too prominent in the tooltip. /// so the requirements message isn't too prominent in the tooltip.
/// </summary> /// </summary>
public string Requires { get; private set; } public string Requires { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// The type of behavior this action has. This is valid clientside and serverside. /// The type of behavior this action has. This is valid clientside and serverside.
/// </summary> /// </summary>
public BehaviorType BehaviorType { get; protected set; } public BehaviorType BehaviorType { get; protected set; } = BehaviorType.None;
/// <summary> /// <summary>
/// For targetpoint or targetentity actions, if this is true the action will remain /// For targetpoint or targetentity actions, if this is true the action will remain
@@ -73,12 +74,12 @@ namespace Content.Shared.Actions
/// <summary> /// <summary>
/// Filters that can be used to filter this item in action menu. /// Filters that can be used to filter this item in action menu.
/// </summary> /// </summary>
public IEnumerable<string> Filters { get; private set; } public IEnumerable<string> Filters { get; private set; } = new List<string>();
/// <summary> /// <summary>
/// Keywords that can be used to search this item in action menu. /// Keywords that can be used to search this item in action menu.
/// </summary> /// </summary>
public IEnumerable<string> Keywords { get; private set; } public IEnumerable<string> Keywords { get; private set; } = new List<string>();
/// <summary> /// <summary>
/// True if this is an action that requires selecting a target /// True if this is an action that requires selecting a target
@@ -99,7 +100,7 @@ namespace Content.Shared.Actions
serializer.DataReadFunction("description", string.Empty, serializer.DataReadFunction("description", string.Empty,
s => Description = FormattedMessage.FromMarkup(s)); s => Description = FormattedMessage.FromMarkup(s));
serializer.DataField(this, x => x.Requires,"requires", null); serializer.DataField(this, x => x.Requires,"requires", string.Empty);
serializer.DataField(this, x => x.Icon,"icon", SpriteSpecifier.Invalid); serializer.DataField(this, x => x.Icon,"icon", SpriteSpecifier.Invalid);
serializer.DataField(this, x => x.IconOn,"iconOn", SpriteSpecifier.Invalid); serializer.DataField(this, x => x.IconOn,"iconOn", SpriteSpecifier.Invalid);

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Content.Shared.GameObjects.Components.Mobs; using Content.Shared.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -27,7 +28,7 @@ namespace Content.Shared.Actions
/// <summary> /// <summary>
/// Actions component of the performer. /// Actions component of the performer.
/// </summary> /// </summary>
public readonly SharedActionsComponent PerformerActions; public readonly SharedActionsComponent? PerformerActions;
public ActionEventArgs(IEntity performer, ActionType actionType) public ActionEventArgs(IEntity performer, ActionType actionType)
{ {

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
namespace Content.Shared.Actions namespace Content.Shared.Actions
{ {

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
namespace Content.Shared.Actions namespace Content.Shared.Actions
{ {

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Content.Shared.GameObjects.Components.Mobs; using Content.Shared.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -34,7 +35,7 @@ namespace Content.Shared.Actions
/// <summary> /// <summary>
/// Item actions component of the item. /// Item actions component of the item.
/// </summary> /// </summary>
public readonly ItemActionsComponent ItemActions; public readonly ItemActionsComponent? ItemActions;
public ItemActionEventArgs(IEntity performer, IEntity item, ItemActionType actionType) public ItemActionEventArgs(IEntity performer, IEntity item, ItemActionType actionType)
{ {

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
namespace Content.Shared.Actions namespace Content.Shared.Actions
{ {

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
namespace Content.Shared.Actions namespace Content.Shared.Actions
{ {

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;
namespace Content.Shared.Actions namespace Content.Shared.Actions

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;
namespace Content.Shared.Actions namespace Content.Shared.Actions

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
namespace Content.Shared.Actions namespace Content.Shared.Actions
{ {

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
namespace Content.Shared.Actions namespace Content.Shared.Actions
{ {

View File

@@ -1,4 +1,5 @@
using Content.Shared.Interfaces; #nullable enable
using Content.Shared.Interfaces;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -26,28 +27,28 @@ namespace Content.Shared.Actions
/// action. Null if this is not an Instant ActionBehaviorType. /// action. Null if this is not an Instant ActionBehaviorType.
/// Will be null on client side if the behavior is not in Content.Client. /// Will be null on client side if the behavior is not in Content.Client.
/// </summary> /// </summary>
public IInstantItemAction InstantAction { get; private set; } public IInstantItemAction InstantAction { get; private set; } = default!;
/// <summary> /// <summary>
/// The IToggleItemAction that should be invoked when performing this /// The IToggleItemAction that should be invoked when performing this
/// action. Null if this is not a Toggle ActionBehaviorType. /// action. Null if this is not a Toggle ActionBehaviorType.
/// Will be null on client side if the behavior is not in Content.Client. /// Will be null on client side if the behavior is not in Content.Client.
/// </summary> /// </summary>
public IToggleItemAction ToggleAction { get; private set; } public IToggleItemAction ToggleAction { get; private set; } = default!;
/// <summary> /// <summary>
/// The ITargetEntityItemAction that should be invoked when performing this /// The ITargetEntityItemAction that should be invoked when performing this
/// action. Null if this is not a TargetEntity ActionBehaviorType. /// action. Null if this is not a TargetEntity ActionBehaviorType.
/// Will be null on client side if the behavior is not in Content.Client. /// Will be null on client side if the behavior is not in Content.Client.
/// </summary> /// </summary>
public ITargetEntityItemAction TargetEntityAction { get; private set; } public ITargetEntityItemAction TargetEntityAction { get; private set; } = default!;
/// <summary> /// <summary>
/// The ITargetPointItemAction that should be invoked when performing this /// The ITargetPointItemAction that should be invoked when performing this
/// action. Null if this is not a TargetPoint ActionBehaviorType. /// action. Null if this is not a TargetPoint ActionBehaviorType.
/// Will be null on client side if the behavior is not in Content.Client. /// Will be null on client side if the behavior is not in Content.Client.
/// </summary> /// </summary>
public ITargetPointItemAction TargetPointAction { get; private set; } public ITargetPointItemAction TargetPointAction { get; private set; } = default!;
public override void LoadFrom(YamlMappingNode mapping) public override void LoadFrom(YamlMappingNode mapping)
{ {
@@ -65,7 +66,7 @@ namespace Content.Shared.Actions
// TODO: Split this class into server/client after RobustToolbox#1405 // TODO: Split this class into server/client after RobustToolbox#1405
if (IoCManager.Resolve<IModuleManager>().IsClientModule) return; if (IoCManager.Resolve<IModuleManager>().IsClientModule) return;
IItemActionBehavior behavior = null; IItemActionBehavior? behavior = null;
serializer.DataField(ref behavior, "behavior", null); serializer.DataField(ref behavior, "behavior", null);
switch (behavior) switch (behavior)
{ {

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Content.Shared.Chemistry; using Content.Shared.Chemistry;
using Content.Shared.Eui; using Content.Shared.Eui;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -25,7 +26,7 @@ namespace Content.Shared.Administration
{ {
public bool CloseAfter; public bool CloseAfter;
public ReagentUnit Amount; public ReagentUnit Amount;
public string ReagentId; public string ReagentId = string.Empty;
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
namespace Content.Shared.Administration namespace Content.Shared.Administration
{ {

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;

View File

@@ -1,4 +1,5 @@
using Lidgren.Network; #nullable enable
using Lidgren.Network;
using Robust.Shared.Network; using Robust.Shared.Network;
namespace Content.Shared.Administration.AdminMenu namespace Content.Shared.Administration.AdminMenu

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Eui; using Content.Shared.Eui;
using Robust.Shared.Network; using Robust.Shared.Network;
@@ -11,15 +12,15 @@ namespace Content.Shared.Administration
{ {
public bool IsLoading; public bool IsLoading;
public AdminData[] Admins; public AdminData[] Admins = Array.Empty<AdminData>();
public Dictionary<int, AdminRankData> AdminRanks; public Dictionary<int, AdminRankData> AdminRanks = new();
[Serializable, NetSerializable] [Serializable, NetSerializable]
public struct AdminData public struct AdminData
{ {
public NetUserId UserId; public NetUserId UserId;
public string UserName; public string? UserName;
public string Title; public string? Title;
public AdminFlags PosFlags; public AdminFlags PosFlags;
public AdminFlags NegFlags; public AdminFlags NegFlags;
public int? RankId; public int? RankId;
@@ -43,8 +44,8 @@ namespace Content.Shared.Administration
[Serializable, NetSerializable] [Serializable, NetSerializable]
public sealed class AddAdmin : EuiMessageBase public sealed class AddAdmin : EuiMessageBase
{ {
public string UserNameOrId; public string UserNameOrId = string.Empty;
public string Title; public string? Title;
public AdminFlags PosFlags; public AdminFlags PosFlags;
public AdminFlags NegFlags; public AdminFlags NegFlags;
public int? RankId; public int? RankId;
@@ -60,7 +61,7 @@ namespace Content.Shared.Administration
public sealed class UpdateAdmin : EuiMessageBase public sealed class UpdateAdmin : EuiMessageBase
{ {
public NetUserId UserId; public NetUserId UserId;
public string Title; public string? Title;
public AdminFlags PosFlags; public AdminFlags PosFlags;
public AdminFlags NegFlags; public AdminFlags NegFlags;
public int? RankId; public int? RankId;
@@ -70,7 +71,7 @@ namespace Content.Shared.Administration
[Serializable, NetSerializable] [Serializable, NetSerializable]
public sealed class AddAdminRank : EuiMessageBase public sealed class AddAdminRank : EuiMessageBase
{ {
public string Name; public string Name = string.Empty;
public AdminFlags Flags; public AdminFlags Flags;
} }
@@ -85,7 +86,7 @@ namespace Content.Shared.Administration
{ {
public int Id; public int Id;
public string Name; public string Name = string.Empty;
public AdminFlags Flags; public AdminFlags Flags;
} }
} }

View File

@@ -1,3 +1,4 @@
#nullable enable
using Content.Shared.Eui; using Content.Shared.Eui;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using System; using System;

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic; #nullable enable
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -13,12 +15,10 @@ namespace Content.Shared.Alert
[Dependency] [Dependency]
private readonly IPrototypeManager _prototypeManager = default!; private readonly IPrototypeManager _prototypeManager = default!;
private Dictionary<AlertType, AlertPrototype> _typeToAlert; private readonly Dictionary<AlertType, AlertPrototype> _typeToAlert = new();
public void Initialize() public void Initialize()
{ {
_typeToAlert = new Dictionary<AlertType, AlertPrototype>();
foreach (var alert in _prototypeManager.EnumeratePrototypes<AlertPrototype>()) foreach (var alert in _prototypeManager.EnumeratePrototypes<AlertPrototype>())
{ {
if (!_typeToAlert.TryAdd(alert.AlertType, alert)) if (!_typeToAlert.TryAdd(alert.AlertType, alert))
@@ -34,7 +34,7 @@ namespace Content.Shared.Alert
/// Tries to get the alert of the indicated type /// Tries to get the alert of the indicated type
/// </summary> /// </summary>
/// <returns>true if found</returns> /// <returns>true if found</returns>
public bool TryGet(AlertType alertType, out AlertPrototype alert) public bool TryGet(AlertType alertType, [NotNullWhen(true)] out AlertPrototype? alert)
{ {
return _typeToAlert.TryGetValue(alertType, out alert); return _typeToAlert.TryGetValue(alertType, out alert);
} }

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; #nullable enable
using System.Collections.Generic;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -12,7 +13,7 @@ namespace Content.Shared.Alert
[Prototype("alertOrder")] [Prototype("alertOrder")]
public class AlertOrderPrototype : IPrototype, IComparer<AlertPrototype> public class AlertOrderPrototype : IPrototype, IComparer<AlertPrototype>
{ {
public string ID { get; private set; } public string ID { get; private set; } = string.Empty;
private readonly Dictionary<AlertType, int> _typeToIdx = new(); private readonly Dictionary<AlertType, int> _typeToIdx = new();
private readonly Dictionary<AlertCategory, int> _categoryToIdx = new(); private readonly Dictionary<AlertCategory, int> _categoryToIdx = new();
@@ -23,7 +24,7 @@ namespace Content.Shared.Alert
serializer.DataField(this, x => x.ID, "id", string.Empty); serializer.DataField(this, x => x.ID, "id", string.Empty);
if (!mapping.TryGetNode("order", out YamlSequenceNode orderMapping)) return; if (!mapping.TryGetNode("order", out YamlSequenceNode? orderMapping)) return;
var i = 0; var i = 0;
foreach (var entryYaml in orderMapping) foreach (var entryYaml in orderMapping)
@@ -56,7 +57,7 @@ namespace Content.Shared.Alert
return -1; return -1;
} }
public int Compare(AlertPrototype x, AlertPrototype y) public int Compare(AlertPrototype? x, AlertPrototype? y)
{ {
if ((x == null) && (y == null)) return 0; if ((x == null) && (y == null)) return 0;
if (x == null) return 1; if (x == null) return 1;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Globalization; using System.Globalization;
using Content.Shared.Interfaces; using Content.Shared.Interfaces;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -17,7 +18,7 @@ namespace Content.Shared.Alert
[Prototype("alert")] [Prototype("alert")]
public class AlertPrototype : IPrototype public class AlertPrototype : IPrototype
{ {
public string ID { get; private set; } public string ID { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// Type of alert, no 2 alert prototypes should have the same one. /// Type of alert, no 2 alert prototypes should have the same one.
@@ -31,17 +32,17 @@ namespace Content.Shared.Alert
/// to get the correct icon path for a particular severity level. /// to get the correct icon path for a particular severity level.
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
public SpriteSpecifier Icon { get; private set; } public SpriteSpecifier Icon { get; private set; } = SpriteSpecifier.Invalid;
/// <summary> /// <summary>
/// Name to show in tooltip window. Accepts formatting. /// Name to show in tooltip window. Accepts formatting.
/// </summary> /// </summary>
public FormattedMessage Name { get; private set; } public FormattedMessage Name { get; private set; } = new();
/// <summary> /// <summary>
/// Description to show in tooltip window. Accepts formatting. /// Description to show in tooltip window. Accepts formatting.
/// </summary> /// </summary>
public FormattedMessage Description { get; private set; } public FormattedMessage Description { get; private set; } = new();
/// <summary> /// <summary>
/// Category the alert belongs to. Only one alert of a given category /// Category the alert belongs to. Only one alert of a given category
@@ -85,7 +86,7 @@ namespace Content.Shared.Alert
/// Defines what to do when the alert is clicked. /// Defines what to do when the alert is clicked.
/// This will always be null on clientside. /// This will always be null on clientside.
/// </summary> /// </summary>
public IAlertClick OnClick { get; private set; } public IAlertClick? OnClick { get; private set; }
public void LoadFrom(YamlMappingNode mapping) public void LoadFrom(YamlMappingNode mapping)
{ {
@@ -198,7 +199,7 @@ namespace Content.Shared.Alert
return AlertType == other.AlertType && AlertCategory == other.AlertCategory; return AlertType == other.AlertType && AlertCategory == other.AlertCategory;
} }
public override bool Equals(object obj) public override bool Equals(object? obj)
{ {
return obj is AlertKey other && Equals(other); return obj is AlertKey other && Equals(other);
} }

View File

@@ -1,4 +1,5 @@
namespace Content.Shared.Alert #nullable enable
namespace Content.Shared.Alert
{ {
/// <summary> /// <summary>
/// Every category of alert. Corresponds to category field in alert prototypes defined in YML /// Every category of alert. Corresponds to category field in alert prototypes defined in YML

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.Arcade namespace Content.Shared.Arcade

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.Arcade namespace Content.Shared.Arcade

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,3 +1,4 @@
#nullable enable
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using System; using System;

View File

@@ -1,4 +1,6 @@
using Robust.Shared.Prototypes; #nullable enable
using System;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using YamlDotNet.RepresentationModel; using YamlDotNet.RepresentationModel;
@@ -7,12 +9,12 @@ namespace Content.Shared.Atmos
[Prototype("gas")] [Prototype("gas")]
public class GasPrototype : IPrototype public class GasPrototype : IPrototype
{ {
public string Name { get; private set; } public string Name { get; private set; } = string.Empty;
// TODO: Control gas amount necessary for overlay to appear // TODO: Control gas amount necessary for overlay to appear
// TODO: Add interfaces for gas behaviours e.g. breathing, burning // TODO: Add interfaces for gas behaviours e.g. breathing, burning
public string ID { get; private set; } public string ID { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// Specific heat for gas. /// Specific heat for gas.
@@ -43,25 +45,25 @@ namespace Content.Shared.Atmos
/// <summary> /// <summary>
/// If this reagent is in gas form, this is the path to the overlay that will be used to make the gas visible. /// If this reagent is in gas form, this is the path to the overlay that will be used to make the gas visible.
/// </summary> /// </summary>
public string GasOverlayTexture { get; private set; } public string GasOverlayTexture { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// If this reagent is in gas form, this will be the path to the RSI sprite that will be used to make the gas visible. /// If this reagent is in gas form, this will be the path to the RSI sprite that will be used to make the gas visible.
/// </summary> /// </summary>
public string GasOverlayState { get; set; } public string GasOverlayState { get; set; } = string.Empty;
/// <summary> /// <summary>
/// State for the gas RSI overlay. /// State for the gas RSI overlay.
/// </summary> /// </summary>
public string GasOverlaySprite { get; set; } public string GasOverlaySprite { get; set; } = string.Empty;
/// <summary> /// <summary>
/// Path to the tile overlay used when this gas appears visible. /// Path to the tile overlay used when this gas appears visible.
/// </summary> /// </summary>
public string OverlayPath { get; private set; } public string OverlayPath { get; private set; } = string.Empty;
public string Color { get; private set; } public string Color { get; private set; } = string.Empty;
public void LoadFrom(YamlMappingNode mapping) public void LoadFrom(YamlMappingNode mapping)
{ {

View File

@@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.IoC; using Robust.Shared.IoC;

View File

@@ -1,4 +1,6 @@
#nullable enable
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel; using YamlDotNet.RepresentationModel;
@@ -8,21 +10,20 @@ namespace Content.Shared.Audio
[Prototype("soundCollection")] [Prototype("soundCollection")]
public sealed class SoundCollectionPrototype : IPrototype public sealed class SoundCollectionPrototype : IPrototype
{ {
public string ID { get; private set; } public string ID { get; private set; } = string.Empty;
public IReadOnlyList<string> PickFiles { get; private set; } public List<string> PickFiles { get; private set; } = new();
public void LoadFrom(YamlMappingNode mapping) public void LoadFrom(YamlMappingNode mapping)
{ {
ID = mapping.GetNode("id").AsString(); ID = mapping.GetNode("id").AsString();
var pickFiles = new List<string>(); // In the unlikely case the method gets called twice
PickFiles.Clear();
foreach (var file in mapping.GetNode<YamlSequenceNode>("files")) foreach (var file in mapping.GetNode<YamlSequenceNode>("files"))
{ {
pickFiles.Add(file.AsString()); PickFiles.Add(file.AsString());
} }
PickFiles = pickFiles;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
#nullable enable
using Robust.Shared; using Robust.Shared;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;

View File

@@ -1,3 +1,4 @@
#nullable enable
using System; using System;
namespace Content.Shared.Chat namespace Content.Shared.Chat

View File

@@ -1,3 +1,4 @@
#nullable enable
using Lidgren.Network; using Lidgren.Network;
using Robust.Shared.Network; using Robust.Shared.Network;

View File

@@ -1,3 +1,4 @@
#nullable enable
using JetBrains.Annotations; using JetBrains.Annotations;
using Lidgren.Network; using Lidgren.Network;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -28,12 +29,12 @@ namespace Content.Shared.Chat
/// <summary> /// <summary>
/// The actual message contents. /// The actual message contents.
/// </summary> /// </summary>
public string Message { get; set; } public string Message { get; set; } = string.Empty;
/// <summary> /// <summary>
/// What to "wrap" the message contents with. Example is stuff like 'Joe says: "{0}"' /// What to "wrap" the message contents with. Example is stuff like 'Joe says: "{0}"'
/// </summary> /// </summary>
public string MessageWrap { get; set; } public string MessageWrap { get; set; } = string.Empty;
/// <summary> /// <summary>
/// The sending entity. /// The sending entity.

View File

@@ -1,4 +1,5 @@
using Content.Shared.Interfaces.Chemistry; #nullable enable
using Content.Shared.Interfaces.Chemistry;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
@@ -204,7 +205,7 @@ namespace Content.Shared.Chemistry
return reagent < min ? min : reagent > max ? max : reagent; return reagent < min ? min : reagent > max ? max : reagent;
} }
public override readonly bool Equals(object obj) public override readonly bool Equals(object? obj)
{ {
return obj is ReagentUnit unit && return obj is ReagentUnit unit &&
_value == unit._value; _value == unit._value;

View File

@@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@@ -278,12 +279,13 @@ namespace Content.Shared.Chemistry
Color mixColor = default; Color mixColor = default;
var runningTotalQuantity = ReagentUnit.New(0); var runningTotalQuantity = ReagentUnit.New(0);
var protoManager = IoCManager.Resolve<IPrototypeManager>();
foreach (var reagent in Contents) foreach (var reagent in Contents)
{ {
runningTotalQuantity += reagent.Quantity; runningTotalQuantity += reagent.Quantity;
if (!IoCManager.Resolve<IPrototypeManager>().TryIndex(reagent.ReagentId, out ReagentPrototype proto)) if (!protoManager.TryIndex(reagent.ReagentId, out ReagentPrototype? proto))
{ {
continue; continue;
} }
@@ -322,7 +324,7 @@ namespace Content.Shared.Chemistry
foreach (var (reagentId, quantity) in _contents.ToArray()) foreach (var (reagentId, quantity) in _contents.ToArray())
{ {
if (!proto.TryIndex(reagentId, out ReagentPrototype reagent)) if (!proto.TryIndex(reagentId, out ReagentPrototype? reagent))
continue; continue;
var removedAmount = reagent.ReactionEntity(entity, method, quantity); var removedAmount = reagent.ReactionEntity(entity, method, quantity);

View File

@@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using Content.Shared.GameObjects.Components.Chemistry; using Content.Shared.GameObjects.Components.Chemistry;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,3 +1,4 @@
#nullable enable
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -6,8 +7,8 @@ namespace Content.Shared.Construction
{ {
public abstract class ArbitraryInsertConstructionGraphStep : EntityInsertConstructionGraphStep public abstract class ArbitraryInsertConstructionGraphStep : EntityInsertConstructionGraphStep
{ {
public string Name { get; private set; } public string Name { get; private set; } = string.Empty;
public SpriteSpecifier Icon { get; private set; } public SpriteSpecifier Icon { get; private set; } = SpriteSpecifier.Invalid;
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {

View File

@@ -1,3 +1,4 @@
#nullable enable
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -7,7 +8,7 @@ namespace Content.Shared.Construction
{ {
public class ComponentConstructionGraphStep : ArbitraryInsertConstructionGraphStep public class ComponentConstructionGraphStep : ArbitraryInsertConstructionGraphStep
{ {
public string Component { get; private set; } public string Component { get; private set; } = string.Empty;
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {

View File

@@ -1,4 +1,5 @@
using Content.Shared.GameObjects.Components; #nullable enable
using Content.Shared.GameObjects.Components;
using Content.Shared.Maps; using Content.Shared.Maps;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -1,4 +1,5 @@
using Content.Shared.GameObjects.Components; #nullable enable
using Content.Shared.GameObjects.Components;
using Content.Shared.Maps; using Content.Shared.Maps;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -1,3 +1,4 @@
#nullable enable
using Content.Shared.Maps; using Content.Shared.Maps;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -1,4 +1,5 @@
using Content.Shared.Maps; #nullable enable
using Content.Shared.Maps;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
@@ -12,11 +13,11 @@ namespace Content.Shared.Construction.ConstructionConditions
public class TileType : IConstructionCondition public class TileType : IConstructionCondition
{ {
public List<string> TargetTiles { get; private set; } public List<string> TargetTiles { get; private set; } = new();
void IExposeData.ExposeData(ObjectSerializer serializer) void IExposeData.ExposeData(ObjectSerializer serializer)
{ {
serializer.DataField(this, x => x.TargetTiles, "targets", null); serializer.DataField(this, x => x.TargetTiles, "targets", new List<string>());
} }
public bool Condition(IEntity user, EntityCoordinates location, Direction direction) public bool Condition(IEntity user, EntityCoordinates location, Direction direction)

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Interfaces; using Content.Shared.Interfaces;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -13,11 +14,11 @@ namespace Content.Shared.Construction
public class ConstructionGraphEdge : IExposeData public class ConstructionGraphEdge : IExposeData
{ {
private List<ConstructionGraphStep> _steps = new(); private List<ConstructionGraphStep> _steps = new();
private List<IEdgeCondition> _conditions; private List<IEdgeCondition> _conditions = new();
private List<IGraphAction> _completed; private List<IGraphAction> _completed = new();
[ViewVariables] [ViewVariables]
public string Target { get; private set; } public string Target { get; private set; } = string.Empty;
[ViewVariables] [ViewVariables]
public IReadOnlyList<IEdgeCondition> Conditions => _conditions; public IReadOnlyList<IEdgeCondition> Conditions => _conditions;
@@ -48,7 +49,7 @@ namespace Content.Shared.Construction
var serializer = YamlObjectSerializer.NewReader(mapping); var serializer = YamlObjectSerializer.NewReader(mapping);
InternalExposeData(serializer); InternalExposeData(serializer);
if (!mapping.TryGetNode("steps", out YamlSequenceNode stepsMapping)) return; if (!mapping.TryGetNode("steps", out YamlSequenceNode? stepsMapping)) return;
foreach (var yamlNode in stepsMapping) foreach (var yamlNode in stepsMapping)
{ {

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Interfaces; using Content.Shared.Interfaces;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -10,7 +11,7 @@ namespace Content.Shared.Construction
[Serializable] [Serializable]
public abstract class ConstructionGraphStep : IExposeData public abstract class ConstructionGraphStep : IExposeData
{ {
private List<IGraphAction> _completed; private List<IGraphAction> _completed = new();
public float DoAfter { get; private set; } public float DoAfter { get; private set; }
public IReadOnlyList<IGraphAction> Completed => _completed; public IReadOnlyList<IGraphAction> Completed => _completed;

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; #nullable enable
using System.Collections.Generic;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -9,50 +10,50 @@ namespace Content.Shared.Construction
[Prototype("construction")] [Prototype("construction")]
public class ConstructionPrototype : IPrototype public class ConstructionPrototype : IPrototype
{ {
private List<IConstructionCondition> _conditions; private List<IConstructionCondition> _conditions = new();
/// <summary> /// <summary>
/// Friendly name displayed in the construction GUI. /// Friendly name displayed in the construction GUI.
/// </summary> /// </summary>
public string Name { get; private set; } public string Name { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// "Useful" description displayed in the construction GUI. /// "Useful" description displayed in the construction GUI.
/// </summary> /// </summary>
public string Description { get; private set; } public string Description { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// The <see cref="ConstructionGraphPrototype"/> this construction will be using. /// The <see cref="ConstructionGraphPrototype"/> this construction will be using.
/// </summary> /// </summary>
public string Graph { get; private set; } public string Graph { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// The target <see cref="ConstructionGraphNode"/> this construction will guide the user to. /// The target <see cref="ConstructionGraphNode"/> this construction will guide the user to.
/// </summary> /// </summary>
public string TargetNode { get; private set; } public string TargetNode { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// The starting <see cref="ConstructionGraphNode"/> this construction will start at. /// The starting <see cref="ConstructionGraphNode"/> this construction will start at.
/// </summary> /// </summary>
public string StartNode { get; private set; } public string StartNode { get; private set; } = string.Empty;
/// <summary> /// <summary>
/// Texture path inside the construction GUI. /// Texture path inside the construction GUI.
/// </summary> /// </summary>
public SpriteSpecifier Icon { get; private set; } public SpriteSpecifier Icon { get; private set; } = SpriteSpecifier.Invalid;
/// <summary> /// <summary>
/// If you can start building or complete steps on impassable terrain. /// If you can start building or complete steps on impassable terrain.
/// </summary> /// </summary>
public bool CanBuildInImpassable { get; private set; } public bool CanBuildInImpassable { get; private set; }
public string Category { get; private set; } public string Category { get; private set; } = string.Empty;
public ConstructionType Type { get; private set; } public ConstructionType Type { get; private set; } = ConstructionType.Structure;
public string ID { get; private set; } public string ID { get; private set; } = string.Empty;
public string PlacementMode { get; private set; } public string PlacementMode { get; private set; } = "PlaceFree";
/// <summary> /// <summary>
/// Whether this construction can be constructed rotated or not. /// Whether this construction can be constructed rotated or not.

View File

@@ -1,11 +1,12 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.Construction namespace Content.Shared.Construction
{ {
public abstract class EntityInsertConstructionGraphStep : ConstructionGraphStep public abstract class EntityInsertConstructionGraphStep : ConstructionGraphStep
{ {
public string Store { get; private set; } public string Store { get; private set; } = string.Empty;
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {

View File

@@ -1,4 +1,5 @@
using System.Threading.Tasks; #nullable enable
using System.Threading.Tasks;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; #nullable enable
using System.Collections.Generic;
using System.IO; using System.IO;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel; using YamlDotNet.RepresentationModel;
@@ -11,7 +12,7 @@ namespace Content.Shared.Construction
public void LoadFrom(YamlMappingNode mapping) public void LoadFrom(YamlMappingNode mapping)
{ {
if (!mapping.TryGetNode("steps", out YamlSequenceNode steps)) return; if (!mapping.TryGetNode("steps", out YamlSequenceNode? steps)) return;
foreach (var node in steps) foreach (var node in steps)
{ {

View File

@@ -1,3 +1,4 @@
#nullable enable
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -7,7 +8,7 @@ namespace Content.Shared.Construction
{ {
public class PrototypeConstructionGraphStep : ArbitraryInsertConstructionGraphStep public class PrototypeConstructionGraphStep : ArbitraryInsertConstructionGraphStep
{ {
public string Prototype { get; private set; } public string Prototype { get; private set; } = string.Empty;
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {

View File

@@ -1,4 +1,5 @@
using Content.Shared.GameObjects.Components.Interactable; #nullable enable
using Content.Shared.GameObjects.Components.Interactable;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -9,7 +10,7 @@ namespace Content.Shared.Construction
{ {
public ToolQuality Tool { get; private set; } public ToolQuality Tool { get; private set; }
public float Fuel { get; private set; } public float Fuel { get; private set; }
public string ExamineOverride { get; private set; } public string ExamineOverride { get; private set; } = string.Empty;
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;
@@ -24,7 +25,7 @@ namespace Content.Shared.Damage
return DamageSystem.ClassToType[@class]; 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)) return Enum.GetValues(typeof(DamageClass))
.Cast<DamageClass>() .Cast<DamageClass>()

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -15,9 +16,9 @@ namespace Content.Shared.Damage.DamageContainer
public class DamageContainerPrototype : IPrototype public class DamageContainerPrototype : IPrototype
{ {
private bool _supportAll; private bool _supportAll;
private HashSet<DamageClass> _supportedClasses; private HashSet<DamageClass> _supportedClasses = new();
private HashSet<DamageType> _supportedTypes; private HashSet<DamageType> _supportedTypes = new();
private string _id; private string _id = string.Empty;
// TODO NET 5 IReadOnlySet // TODO NET 5 IReadOnlySet
[ViewVariables] public IReadOnlyCollection<DamageClass> SupportedClasses => _supportedClasses; [ViewVariables] public IReadOnlyCollection<DamageClass> SupportedClasses => _supportedClasses;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Shared.GameObjects.EntitySystems; using Content.Shared.GameObjects.EntitySystems;
@@ -29,7 +30,7 @@ namespace Content.Shared.Damage
return DamageSystem.TypeToClass[type]; 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)) return Enum.GetValues(typeof(DamageType))
.Cast<DamageType>() .Cast<DamageType>()

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -32,7 +33,7 @@ namespace Content.Shared.Damage.ResistanceSet
_resistances = data.Resistances; _resistances = data.Resistances;
} }
public string ID { get; } public string ID { get; } = string.Empty;
/// <summary> /// <summary>
/// Adjusts input damage with the resistance set values. /// Adjusts input damage with the resistance set values.

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -14,15 +15,15 @@ namespace Content.Shared.Damage.ResistanceSet
[Serializable, NetSerializable] [Serializable, NetSerializable]
public class ResistanceSetPrototype : IPrototype public class ResistanceSetPrototype : IPrototype
{ {
private Dictionary<DamageType, float> _coefficients; private Dictionary<DamageType, float> _coefficients = new();
private Dictionary<DamageType, int> _flatReductions; private Dictionary<DamageType, int> _flatReductions = new();
private string _id; private string _id = string.Empty;
[ViewVariables] public Dictionary<DamageType, float> Coefficients => _coefficients; [ViewVariables] public Dictionary<DamageType, float> Coefficients => _coefficients;
[ViewVariables] public Dictionary<DamageType, int> FlatReductions => _flatReductions; [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; [ViewVariables] public string ID => _id;
@@ -31,8 +32,8 @@ namespace Content.Shared.Damage.ResistanceSet
var serializer = YamlObjectSerializer.NewReader(mapping); var serializer = YamlObjectSerializer.NewReader(mapping);
serializer.DataField(ref _id, "id", string.Empty); serializer.DataField(ref _id, "id", string.Empty);
serializer.DataField(ref _coefficients, "coefficients", null); serializer.DataField(ref _coefficients, "coefficients", new Dictionary<DamageType, float>());
serializer.DataField(ref _flatReductions, "flatReductions", null); serializer.DataField(ref _flatReductions, "flatReductions", new Dictionary<DamageType, int>());
Resistances = new Dictionary<DamageType, ResistanceSetSettings>(); Resistances = new Dictionary<DamageType, ResistanceSetSettings>();
foreach (var damageType in (DamageType[]) Enum.GetValues(typeof(DamageType))) foreach (var damageType in (DamageType[]) Enum.GetValues(typeof(DamageType)))

View File

@@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Chemistry; using Content.Shared.Chemistry;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
namespace Content.Shared.Eui namespace Content.Shared.Eui
{ {

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.Eui namespace Content.Shared.Eui

View File

@@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -49,16 +50,16 @@ namespace Content.Shared.GameObjects.Components.Access
public readonly bool IsPrivilegedIdAuthorized; public readonly bool IsPrivilegedIdAuthorized;
public readonly bool IsTargetIdPresent; public readonly bool IsTargetIdPresent;
public readonly string TargetIdName; public readonly string TargetIdName;
public readonly string TargetIdFullName; public readonly string? TargetIdFullName;
public readonly string TargetIdJobTitle; public readonly string? TargetIdJobTitle;
public readonly string[] TargetIdAccessList; public readonly string[]? TargetIdAccessList;
public IdCardConsoleBoundUserInterfaceState(bool isPrivilegedIdPresent, public IdCardConsoleBoundUserInterfaceState(bool isPrivilegedIdPresent,
bool isPrivilegedIdAuthorized, bool isPrivilegedIdAuthorized,
bool isTargetIdPresent, bool isTargetIdPresent,
string targetIdFullName, string? targetIdFullName,
string targetIdJobTitle, string? targetIdJobTitle,
string[] targetIdAccessList, string privilegedIdName, string targetIdName) string[]? targetIdAccessList, string privilegedIdName, string targetIdName)
{ {
IsPrivilegedIdPresent = isPrivilegedIdPresent; IsPrivilegedIdPresent = isPrivilegedIdPresent;
IsPrivilegedIdAuthorized = isPrivilegedIdAuthorized; IsPrivilegedIdAuthorized = isPrivilegedIdAuthorized;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -12,9 +13,9 @@ namespace Content.Shared.GameObjects.Components.ActionBlocking
[Serializable, NetSerializable] [Serializable, NetSerializable]
protected sealed class HandcuffedComponentState : ComponentState protected sealed class HandcuffedComponentState : ComponentState
{ {
public string IconState { get; } public string? IconState { get; }
public HandcuffedComponentState(string iconState) : base(ContentNetIDs.HANDCUFFS) public HandcuffedComponentState(string? iconState) : base(ContentNetIDs.HANDCUFFS)
{ {
IconState = iconState; IconState = iconState;
} }

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Objectives; using Content.Shared.Objectives;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
namespace Content.Shared.GameObjects.Components.Atmos.GasTank namespace Content.Shared.GameObjects.Components.Atmos.GasTank
{ {

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos.GasTank namespace Content.Shared.GameObjects.Components.Atmos.GasTank

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,4 +1,5 @@
using Robust.Shared.Serialization; #nullable enable
using Robust.Shared.Serialization;
using System; using System;
namespace Content.Shared.GameObjects.Components.Atmos namespace Content.Shared.GameObjects.Components.Atmos

View File

@@ -1,4 +1,4 @@
#nullable enable annotations #nullable enable
using System; using System;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,3 +1,4 @@
#nullable enable
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using System; using System;

View File

@@ -1,3 +1,4 @@
#nullable enable
using System; using System;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos namespace Content.Shared.GameObjects.Components.Atmos

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Atmos namespace Content.Shared.GameObjects.Components.Atmos

View File

@@ -1,4 +1,5 @@
using Content.Shared.Chemistry; #nullable enable
using Content.Shared.Chemistry;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
namespace Content.Shared.GameObjects.Components.Body.Networks namespace Content.Shared.GameObjects.Components.Body.Networks

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Body.Part namespace Content.Shared.GameObjects.Components.Body.Part

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Body.Part namespace Content.Shared.GameObjects.Components.Body.Part

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Body.Part namespace Content.Shared.GameObjects.Components.Body.Part

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
namespace Content.Shared.GameObjects.Components.Body.Part namespace Content.Shared.GameObjects.Components.Body.Part

View File

@@ -1,4 +1,6 @@
namespace Content.Shared.GameObjects.Components.Body.Part #nullable enable
namespace Content.Shared.GameObjects.Components.Body.Part
{ {
/// <summary> /// <summary>
/// Defines a component as being capable of containing parts. /// Defines a component as being capable of containing parts.

View File

@@ -1,4 +1,5 @@
using System; #nullable enable
using System;
namespace Content.Shared.GameObjects.Components.Body.Part namespace Content.Shared.GameObjects.Components.Body.Part
{ {

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Body.Part.Property namespace Content.Shared.GameObjects.Components.Body.Part.Property

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Body.Part.Property namespace Content.Shared.GameObjects.Components.Body.Part.Property

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
namespace Content.Shared.GameObjects.Components.Body.Part.Property namespace Content.Shared.GameObjects.Components.Body.Part.Property
{ {

View File

@@ -1,4 +1,5 @@
using Robust.Shared.GameObjects; #nullable enable
using Robust.Shared.GameObjects;
namespace Content.Shared.GameObjects.Components.Body.Part.Property namespace Content.Shared.GameObjects.Components.Body.Part.Property
{ {

Some files were not shown because too many files have changed in this diff Show More