mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Enable nullable reference types on Robust.Shared and fix all warnings. (#1109)
This commit is contained in:
committed by
GitHub
parent
12ea903c98
commit
ec0f4b35f7
@@ -16,10 +16,10 @@ namespace Robust.Shared.Asynchronous
|
||||
_runtimeLog = runtimeLog;
|
||||
}
|
||||
|
||||
private readonly ConcurrentQueue<(SendOrPostCallback d, object state)> _pending
|
||||
= new ConcurrentQueue<(SendOrPostCallback, object)>();
|
||||
private readonly ConcurrentQueue<(SendOrPostCallback d, object? state)> _pending
|
||||
= new ConcurrentQueue<(SendOrPostCallback, object?)>();
|
||||
|
||||
public override void Send(SendOrPostCallback d, object state)
|
||||
public override void Send(SendOrPostCallback d, object? state)
|
||||
{
|
||||
if (Current != this)
|
||||
{
|
||||
@@ -32,7 +32,7 @@ namespace Robust.Shared.Asynchronous
|
||||
d(state);
|
||||
}
|
||||
|
||||
public override void Post(SendOrPostCallback d, object state)
|
||||
public override void Post(SendOrPostCallback d, object? state)
|
||||
{
|
||||
_pending.Enqueue((d, state));
|
||||
}
|
||||
|
||||
@@ -7,11 +7,9 @@ namespace Robust.Shared.Asynchronous
|
||||
{
|
||||
internal sealed class TaskManager : ITaskManager
|
||||
{
|
||||
private RobustSynchronizationContext _mainThreadContext;
|
||||
private RobustSynchronizationContext _mainThreadContext = default!;
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IRuntimeLog _runtimeLog;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IRuntimeLog _runtimeLog = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
@@ -31,7 +29,7 @@ namespace Robust.Shared.Asynchronous
|
||||
|
||||
private static readonly SendOrPostCallback _runCallback = o =>
|
||||
{
|
||||
((Action)o)();
|
||||
((Action?)o)?.Invoke();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,15 +13,14 @@ namespace Robust.Shared.Configuration
|
||||
public class ConfigurationManager : IConfigurationManager
|
||||
{
|
||||
private const char TABLE_DELIMITER = '.';
|
||||
private readonly Dictionary<string, ConfigVar> _configVars;
|
||||
private string _configFile;
|
||||
private readonly Dictionary<string, ConfigVar> _configVars = new Dictionary<string, ConfigVar>();
|
||||
private string? _configFile;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new ConfigurationManager.
|
||||
/// </summary>
|
||||
public ConfigurationManager()
|
||||
{
|
||||
_configVars = new Dictionary<string, ConfigVar>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -71,7 +70,7 @@ namespace Robust.Shared.Configuration
|
||||
else // this is a key, add CVar
|
||||
{
|
||||
// if the CVar has already been registered
|
||||
if (_configVars.TryGetValue(tablePath, out ConfigVar cfgVar))
|
||||
if (_configVars.TryGetValue(tablePath, out var cfgVar))
|
||||
{
|
||||
// overwrite the value with the saved one
|
||||
cfgVar.Value = TypeConvert(obj);
|
||||
@@ -170,14 +169,14 @@ namespace Robust.Shared.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterCVar<T>(string name, T defaultValue, CVar flags = CVar.NONE, Action<T> onValueChanged = null)
|
||||
public void RegisterCVar<T>(string name, T defaultValue, CVar flags = CVar.NONE, Action<T>? onValueChanged = null)
|
||||
{
|
||||
Action<object> valueChangedDelegate = null;
|
||||
Action<object>? valueChangedDelegate = null;
|
||||
if (onValueChanged != null)
|
||||
{
|
||||
valueChangedDelegate = v => onValueChanged((T) v);
|
||||
}
|
||||
if (_configVars.TryGetValue(name, out ConfigVar cVar))
|
||||
if (_configVars.TryGetValue(name, out var cVar))
|
||||
{
|
||||
if (cVar.Registered)
|
||||
Logger.ErrorS("cfg", $"The variable '{name}' has already been registered.");
|
||||
@@ -206,14 +205,14 @@ namespace Robust.Shared.Configuration
|
||||
/// <inheritdoc />
|
||||
public bool IsCVarRegistered(string name)
|
||||
{
|
||||
return _configVars.TryGetValue(name, out ConfigVar cVar) && cVar.Registered;
|
||||
return _configVars.TryGetValue(name, out var cVar) && cVar.Registered;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetCVar(string name, object value)
|
||||
{
|
||||
//TODO: Make flags work, required non-derpy net system.
|
||||
if (_configVars.TryGetValue(name, out ConfigVar cVar) && cVar.Registered)
|
||||
if (_configVars.TryGetValue(name, out var cVar) && cVar.Registered)
|
||||
{
|
||||
if (!Equals(cVar.Value, value))
|
||||
{
|
||||
@@ -232,9 +231,9 @@ namespace Robust.Shared.Configuration
|
||||
/// <inheritdoc />
|
||||
public T GetCVar<T>(string name)
|
||||
{
|
||||
if (_configVars.TryGetValue(name, out ConfigVar cVar) && cVar.Registered)
|
||||
if (_configVars.TryGetValue(name, out var cVar) && cVar.Registered)
|
||||
//TODO: Make flags work, required non-derpy net system.
|
||||
return (T)(cVar.OverrideValueParsed ?? cVar.Value ?? cVar.DefaultValue);
|
||||
return (T)(cVar.OverrideValueParsed ?? cVar.Value ?? cVar.DefaultValue)!;
|
||||
|
||||
throw new InvalidConfigurationException($"Trying to get unregistered variable '{name}'");
|
||||
}
|
||||
@@ -266,7 +265,7 @@ namespace Robust.Shared.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
private object ParseOverrideValue(string value, Type type)
|
||||
private object ParseOverrideValue(string value, Type? type)
|
||||
{
|
||||
if (type == typeof(int))
|
||||
{
|
||||
@@ -327,7 +326,7 @@ namespace Robust.Shared.Configuration
|
||||
/// everything after is the CVar name in the TOML document.</param>
|
||||
/// <param name="defaultValue">The default value of this CVar.</param>
|
||||
/// <param name="flags">Optional flags to modify the behavior of this CVar.</param>
|
||||
public ConfigVar(string name, object defaultValue, CVar flags)
|
||||
public ConfigVar(string name, object? defaultValue, CVar flags)
|
||||
{
|
||||
Name = name;
|
||||
DefaultValue = defaultValue;
|
||||
@@ -342,7 +341,7 @@ namespace Robust.Shared.Configuration
|
||||
/// <summary>
|
||||
/// The default value of this CVar.
|
||||
/// </summary>
|
||||
public object DefaultValue { get; set; }
|
||||
public object? DefaultValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional flags to modify the behavior of this CVar.
|
||||
@@ -352,7 +351,7 @@ namespace Robust.Shared.Configuration
|
||||
/// <summary>
|
||||
/// The current value of this CVar.
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
public object? Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Has this CVar been registered in code?
|
||||
@@ -362,13 +361,13 @@ namespace Robust.Shared.Configuration
|
||||
/// <summary>
|
||||
/// Invoked when the value of this CVar is changed.
|
||||
/// </summary>
|
||||
public Action<object> ValueChanged { get; set; }
|
||||
public Action<object>? ValueChanged { get; set; }
|
||||
|
||||
// We don't know what the type of the var is until it's registered.
|
||||
// So we can't actually parse them until then.
|
||||
// So we keep the raw string around.
|
||||
public string OverrideValue { get; set; }
|
||||
public object OverrideValueParsed { get; set; }
|
||||
public string? OverrideValue { get; set; }
|
||||
public object? OverrideValueParsed { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace Robust.Shared.Console
|
||||
{
|
||||
public int Index { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
public List<string> Commands { get; set; }
|
||||
public List<string>? Commands { get; set; }
|
||||
|
||||
// NOTE: When adding special permissions, do NOT forget to add it to MsgConGroupUpdate!!
|
||||
public bool CanViewVar { get; set; }
|
||||
|
||||
@@ -3,6 +3,8 @@ using Lidgren.Network;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Robust.Shared.Console
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -16,7 +17,7 @@ namespace Robust.Shared.Containers
|
||||
/// <returns>If the entity is inside of a container.</returns>
|
||||
public static bool IsInContainer(IEntity entity)
|
||||
{
|
||||
DebugTools.Assert(entity != null);
|
||||
DebugTools.AssertNotNull(entity);
|
||||
DebugTools.Assert(!entity.Deleted);
|
||||
|
||||
// Notice the recursion starts at the Owner of the passed in entity, this
|
||||
@@ -34,9 +35,9 @@ namespace Robust.Shared.Containers
|
||||
/// <param name="entity">Entity that might be inside a container.</param>
|
||||
/// <param name="manager">The container manager that this entity is inside of.</param>
|
||||
/// <returns>If a container manager was found.</returns>
|
||||
public static bool TryGetContainerMan(IEntity entity, out IContainerManager manager)
|
||||
public static bool TryGetContainerMan(IEntity entity, [NotNullWhen(true)] out IContainerManager? manager)
|
||||
{
|
||||
DebugTools.Assert(entity != null);
|
||||
DebugTools.AssertNotNull(entity);
|
||||
DebugTools.Assert(!entity.Deleted);
|
||||
|
||||
if (entity.Transform.Parent != null && TryGetManagerComp(entity.Transform.Parent.Owner, out manager) && manager.ContainsEntity(entity))
|
||||
@@ -52,9 +53,9 @@ namespace Robust.Shared.Containers
|
||||
/// <param name="entity">Entity that might be inside a container.</param>
|
||||
/// <param name="container">The container that this entity is inside of.</param>
|
||||
/// <returns>If a container was found.</returns>
|
||||
public static bool TryGetContainer(IEntity entity, out IContainer container)
|
||||
public static bool TryGetContainer(IEntity entity, [NotNullWhen(true)] out IContainer? container)
|
||||
{
|
||||
DebugTools.Assert(entity != null);
|
||||
DebugTools.AssertNotNull(entity);
|
||||
DebugTools.Assert(!entity.Deleted);
|
||||
|
||||
if (TryGetContainerMan(entity, out var manager))
|
||||
@@ -64,9 +65,9 @@ namespace Robust.Shared.Containers
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool TryGetManagerComp(IEntity entity, out IContainerManager manager)
|
||||
private static bool TryGetManagerComp(IEntity entity, [NotNullWhen(true)] out IContainerManager? manager)
|
||||
{
|
||||
DebugTools.Assert(entity != null);
|
||||
DebugTools.AssertNotNull(entity);
|
||||
DebugTools.Assert(!entity.Deleted);
|
||||
|
||||
if (entity.TryGetComponent(out manager))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Robust.Shared.Interfaces.Log;
|
||||
@@ -37,7 +38,7 @@ namespace Robust.Shared.ContentPack
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetFile(ResourcePath relPath, out Stream stream)
|
||||
public bool TryGetFile(ResourcePath relPath, [NotNullWhen(true)] out Stream? stream)
|
||||
{
|
||||
var path = GetPath(relPath);
|
||||
if (!File.Exists(path))
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Robust.Shared.ContentPack
|
||||
/// </summary>
|
||||
public abstract class GameShared : IDisposable
|
||||
{
|
||||
protected ModuleTestingCallbacks TestingCallbacks { get; private set; }
|
||||
protected ModuleTestingCallbacks? TestingCallbacks { get; private set; }
|
||||
|
||||
public void SetTestingCallbacks(ModuleTestingCallbacks testingCallbacks)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -23,7 +24,7 @@ namespace Robust.Shared.ContentPack
|
||||
/// <param name="relPath">Relative path from the root directory.</param>
|
||||
/// <param name="stream"></param>
|
||||
/// <returns>A stream of the file loaded into memory.</returns>
|
||||
bool TryGetFile(ResourcePath relPath, out Stream stream);
|
||||
bool TryGetFile(ResourcePath relPath, [NotNullWhen(true)] out Stream? stream);
|
||||
|
||||
/// <summary>
|
||||
/// Recursively finds all files in a directory and all sub directories.
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Robust.Shared.ContentPack
|
||||
/// <typeparam name="T">The type of the entry point to search for.</typeparam>
|
||||
/// <param name="assembly">Byte array of the assembly.</param>
|
||||
/// <param name="symbols">Optional byte array of the debug symbols.</param>
|
||||
void LoadGameAssembly<T>(Stream assembly, Stream symbols = null)
|
||||
void LoadGameAssembly<T>(Stream assembly, Stream? symbols = null)
|
||||
where T : GameShared;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -58,13 +58,11 @@ namespace Robust.Shared.ContentPack
|
||||
/// </summary>
|
||||
internal class ModLoader : IModLoader, IDisposable
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager;
|
||||
[Dependency] private readonly IResourceManager _resourceManager;
|
||||
[Dependency] private readonly ILogManager _logManager;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
|
||||
[Dependency] private readonly IResourceManager _resourceManager = default!;
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
|
||||
private ModuleTestingCallbacks _testingCallbacks;
|
||||
private ModuleTestingCallbacks? _testingCallbacks;
|
||||
|
||||
/// <summary>
|
||||
/// Loaded assemblies.
|
||||
@@ -96,7 +94,7 @@ namespace Robust.Shared.ContentPack
|
||||
_useLoadContext = useLoadContext;
|
||||
}
|
||||
|
||||
public virtual void LoadGameAssembly<T>(Stream assembly, Stream symbols = null)
|
||||
public virtual void LoadGameAssembly<T>(Stream assembly, Stream? symbols = null)
|
||||
where T : GameShared
|
||||
{
|
||||
// TODO: Re-enable type check when it's not just a giant pain in the butt.
|
||||
@@ -148,7 +146,7 @@ namespace Robust.Shared.ContentPack
|
||||
|
||||
protected void InitMod<T>(Assembly assembly) where T : GameShared
|
||||
{
|
||||
var mod = new ModInfo {GameAssembly = assembly};
|
||||
var mod = new ModInfo(assembly);
|
||||
|
||||
_reflectionManager.LoadAssemblies(mod.GameAssembly);
|
||||
|
||||
@@ -159,8 +157,11 @@ namespace Robust.Shared.ContentPack
|
||||
|
||||
foreach (var entryPoint in entryPoints)
|
||||
{
|
||||
var entryPointInstance = (T) Activator.CreateInstance(entryPoint);
|
||||
entryPointInstance.SetTestingCallbacks(_testingCallbacks);
|
||||
var entryPointInstance = (T) Activator.CreateInstance(entryPoint)!;
|
||||
if (_testingCallbacks != null)
|
||||
{
|
||||
entryPointInstance.SetTestingCallbacks(_testingCallbacks);
|
||||
}
|
||||
mod.EntryPoints.Add(entryPointInstance);
|
||||
}
|
||||
|
||||
@@ -268,7 +269,7 @@ namespace Robust.Shared.ContentPack
|
||||
_testingCallbacks = testingCallbacks;
|
||||
}
|
||||
|
||||
private Assembly ResolvingAssembly(AssemblyLoadContext context, AssemblyName name)
|
||||
private Assembly? ResolvingAssembly(AssemblyLoadContext context, AssemblyName name)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -321,12 +322,13 @@ namespace Robust.Shared.ContentPack
|
||||
/// </summary>
|
||||
private class ModInfo
|
||||
{
|
||||
public ModInfo()
|
||||
public ModInfo(Assembly gameAssembly)
|
||||
{
|
||||
GameAssembly = gameAssembly;
|
||||
EntryPoints = new List<GameShared>();
|
||||
}
|
||||
|
||||
public Assembly GameAssembly { get; set; }
|
||||
public Assembly GameAssembly { get; }
|
||||
public List<GameShared> EntryPoints { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using Robust.Shared.Log;
|
||||
@@ -14,7 +15,7 @@ namespace Robust.Shared.ContentPack
|
||||
class PackLoader : IContentRoot
|
||||
{
|
||||
private readonly FileInfo _pack;
|
||||
private ZipFile _zip;
|
||||
private ZipFile _zip = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
@@ -35,7 +36,7 @@ namespace Robust.Shared.ContentPack
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetFile(ResourcePath relPath, out Stream stream)
|
||||
public bool TryGetFile(ResourcePath relPath, [NotNullWhen(true)] out Stream? stream)
|
||||
{
|
||||
var entry = _zip.GetEntry(relPath.ToRootedPath().ToString());
|
||||
|
||||
@@ -63,9 +64,9 @@ namespace Robust.Shared.ContentPack
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ResourcePath> FindFiles(ResourcePath path)
|
||||
{
|
||||
foreach (ZipEntry zipEntry in _zip)
|
||||
foreach (var o in _zip)
|
||||
{
|
||||
if (zipEntry.IsFile && zipEntry.Name.StartsWith(path.ToRootedPath().ToString()))
|
||||
if (o is ZipEntry zipEntry && zipEntry.IsFile && zipEntry.Name.StartsWith(path.ToRootedPath().ToString()))
|
||||
yield return new ResourcePath(zipEntry.Name).ToRelativePath();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,18 @@ namespace Robust.Shared.ContentPack
|
||||
// TODO: remove this shitty hack, either through making it less hardcoded into shared,
|
||||
// or by making our file structure less spaghetti somehow.
|
||||
var assembly = typeof(PathHelpers).Assembly;
|
||||
if (assembly.CodeBase == null)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot find path of executable.");
|
||||
}
|
||||
|
||||
var pathUri = new Uri(assembly.CodeBase);
|
||||
var path = pathUri.LocalPath;
|
||||
if (pathUri.Fragment != "")
|
||||
{
|
||||
path += pathUri.Fragment;
|
||||
}
|
||||
return Path.GetDirectoryName(path);
|
||||
return Path.GetDirectoryName(path)!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -22,7 +23,7 @@ namespace Robust.Shared.ContentPack
|
||||
// Nothing to do here I'm pretty sure.
|
||||
}
|
||||
|
||||
public bool TryGetFile(ResourcePath relPath, out Stream stream)
|
||||
public bool TryGetFile(ResourcePath relPath, [NotNullWhen(true)] out Stream? stream)
|
||||
{
|
||||
if (relPath == _resourcePath)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
@@ -16,10 +17,7 @@ namespace Robust.Shared.ContentPack
|
||||
/// </summary>
|
||||
internal partial class ResourceManager : IResourceManagerInternal
|
||||
{
|
||||
[Dependency]
|
||||
#pragma warning disable 649
|
||||
private readonly IConfigurationManager _config;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IConfigurationManager _config = default!;
|
||||
|
||||
private readonly ReaderWriterLockSlim _contentRootsLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
@@ -35,7 +33,7 @@ namespace Robust.Shared.ContentPack
|
||||
new Regex("[<>:\"|?*\0\\x01-\\x1f]", RegexOptions.IgnoreCase);
|
||||
|
||||
/// <inheritdoc />
|
||||
public IWritableDirProvider UserData { get; private set; }
|
||||
public IWritableDirProvider UserData { get; private set; } = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Initialize(string userData)
|
||||
@@ -68,7 +66,7 @@ namespace Robust.Shared.ContentPack
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void MountContentPack(string pack, ResourcePath prefix = null)
|
||||
public void MountContentPack(string pack, ResourcePath? prefix = null)
|
||||
{
|
||||
if (prefix == null)
|
||||
{
|
||||
@@ -104,7 +102,7 @@ namespace Robust.Shared.ContentPack
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void MountContentDirectory(string path, ResourcePath prefix = null)
|
||||
public void MountContentDirectory(string path, ResourcePath? prefix = null)
|
||||
{
|
||||
if (prefix == null)
|
||||
{
|
||||
@@ -154,13 +152,13 @@ namespace Robust.Shared.ContentPack
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryContentFileRead(string path, out Stream fileStream)
|
||||
public bool TryContentFileRead(string path, [NotNullWhen(true)] out Stream? fileStream)
|
||||
{
|
||||
return TryContentFileRead(new ResourcePath(path), out fileStream);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryContentFileRead(ResourcePath path, out Stream fileStream)
|
||||
public bool TryContentFileRead(ResourcePath path, [NotNullWhen(true)] out Stream? fileStream)
|
||||
{
|
||||
if (path == null)
|
||||
{
|
||||
@@ -264,7 +262,7 @@ namespace Robust.Shared.ContentPack
|
||||
}
|
||||
|
||||
// TODO: Remove this when/if we can get Godot to load from not-the-filesystem.
|
||||
public bool TryGetDiskFilePath(ResourcePath path, out string diskPath)
|
||||
public bool TryGetDiskFilePath(ResourcePath path, [NotNullWhen(true)] out string? diskPath)
|
||||
{
|
||||
// loop over each root trying to get the file
|
||||
_contentRootsLock.EnterReadLock();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Interfaces.Resources;
|
||||
@@ -17,7 +18,7 @@ namespace Robust.Shared.ContentPack
|
||||
private readonly DirectoryNode _rootDirectoryNode = new DirectoryNode();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string RootDir => null;
|
||||
public string? RootDir => null;
|
||||
|
||||
public void CreateDir(ResourcePath path)
|
||||
{
|
||||
@@ -105,7 +106,7 @@ namespace Robust.Shared.ContentPack
|
||||
throw new ArgumentException("There is a directory at that location.");
|
||||
}
|
||||
|
||||
var fileNode = (FileNode) maybeFileNode;
|
||||
var fileNode = (FileNode) maybeFileNode!;
|
||||
|
||||
switch (fileMode)
|
||||
{
|
||||
@@ -192,7 +193,7 @@ namespace Robust.Shared.ContentPack
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
private bool TryGetNodeAt(ResourcePath path, out INode node)
|
||||
private bool TryGetNodeAt(ResourcePath path, [NotNullWhen(true)] out INode? node)
|
||||
{
|
||||
if (!path.IsRooted)
|
||||
{
|
||||
|
||||
@@ -28,6 +28,11 @@ namespace Robust.Shared
|
||||
{
|
||||
var assemblyDir = Path.GetDirectoryName(assembly.Location);
|
||||
|
||||
if (assemblyDir == null)
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
string libName;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
|
||||
@@ -4,10 +4,10 @@ namespace Robust.Shared.Enums
|
||||
{
|
||||
public class PlacementInformation
|
||||
{
|
||||
public string EntityType { get; set; }
|
||||
public string? EntityType { get; set; }
|
||||
public bool IsTile { get; set; }
|
||||
public EntityUid MobUid { get; set; }
|
||||
public string PlacementOption { get; set; }
|
||||
public string? PlacementOption { get; set; }
|
||||
public int Range { get; set; }
|
||||
public ushort TileType { get; set; }
|
||||
public int Uses { get; set; } = 1;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
@@ -15,7 +16,7 @@ namespace Robust.Shared.Exceptions
|
||||
|
||||
public int ExceptionCount => exceptions.Values.Sum(l => l.Count);
|
||||
|
||||
public void LogException(Exception exception, string catcher=null)
|
||||
public void LogException(Exception exception, string? catcher=null)
|
||||
{
|
||||
if (!exceptions.TryGetValue(exception.GetType(), out var list))
|
||||
{
|
||||
@@ -52,9 +53,12 @@ namespace Robust.Shared.Exceptions
|
||||
if (e.Data.Count > 0)
|
||||
{
|
||||
ret.AppendLine("Additional data:");
|
||||
foreach (var x in e.Data.Keys)
|
||||
foreach (var x in e.Data)
|
||||
{
|
||||
ret.AppendLine($"{x}: {e.Data[x]}");
|
||||
if (x is DictionaryEntry entry)
|
||||
{
|
||||
ret.AppendLine($"{entry.Key}: {entry.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,9 +70,9 @@ namespace Robust.Shared.Exceptions
|
||||
{
|
||||
public Exception Exception { get; }
|
||||
public DateTime Time { get; }
|
||||
public string Catcher { get; }
|
||||
public string? Catcher { get; }
|
||||
|
||||
public LoggedException(Exception exception, DateTime time, string catcher)
|
||||
public LoggedException(Exception exception, DateTime time, string? catcher)
|
||||
{
|
||||
Exception = exception;
|
||||
Time = time;
|
||||
@@ -88,7 +92,7 @@ namespace Robust.Shared.Exceptions
|
||||
{
|
||||
int ExceptionCount { get; }
|
||||
|
||||
void LogException(Exception exception, string catcher=null);
|
||||
void LogException(Exception exception, string? catcher=null);
|
||||
|
||||
string Display();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Robust.Shared.Exceptions
|
||||
/// <summary>
|
||||
/// The name of the type argument that had invalid data.
|
||||
/// </summary>
|
||||
public readonly string TypeArgumentName;
|
||||
public readonly string? TypeArgumentName;
|
||||
|
||||
public TypeArgumentException()
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public IEntity Owner { get; set; }
|
||||
public IEntity Owner { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// True if this entity is a client-only entity.
|
||||
@@ -188,7 +188,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// </summary>
|
||||
/// <param name="message">Message to send.</param>
|
||||
/// <param name="channel">Network channel to send the message over. If null, broadcast to all channels.</param>
|
||||
protected void SendNetworkMessage(ComponentMessage message, INetChannel channel = null)
|
||||
protected void SendNetworkMessage(ComponentMessage message, INetChannel? channel = null)
|
||||
{
|
||||
Owner.SendNetworkMessage(this, message, channel);
|
||||
}
|
||||
@@ -197,7 +197,7 @@ namespace Robust.Shared.GameObjects
|
||||
public virtual void HandleMessage(ComponentMessage message, IComponent component) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession session = null) { }
|
||||
public virtual void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual ComponentState GetComponentState()
|
||||
@@ -209,7 +209,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void HandleComponentState(ComponentState curState, ComponentState nextState) { }
|
||||
public virtual void HandleComponentState(ComponentState? curState, ComponentState? nextState) { }
|
||||
|
||||
// these two methods clear the LastModifiedTick/CreationTick to mark it as "not different from prototype load".
|
||||
// This is used as optimization in the game state system to avoid sending redundant component data.
|
||||
|
||||
@@ -11,10 +11,8 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
public class ComponentFactory : IComponentFactory
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IDynamicTypeFactory _typeFactory;
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IDynamicTypeFactory _typeFactory = default!;
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
|
||||
|
||||
private class ComponentRegistration : IComponentRegistration
|
||||
{
|
||||
@@ -80,7 +78,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
// Create a dummy to be able to fetch instance properties like name.
|
||||
// Not clean but sadly C# doesn't have static virtual members.
|
||||
var dummy = (IComponent)Activator.CreateInstance(type);
|
||||
var dummy = (IComponent)Activator.CreateInstance(type)!;
|
||||
|
||||
var name = dummy.Name;
|
||||
var netID = dummy.NetID;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Exceptions;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
@@ -23,21 +24,19 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
private readonly List<Component> _deleteList = new List<Component>();
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IComponentFactory _componentFactory;
|
||||
[Dependency] private readonly IComponentFactory _componentFactory = default!;
|
||||
#if EXCEPTION_TOLERANCE
|
||||
[Dependency] private readonly IRuntimeLog _runtimeLog;
|
||||
[Dependency] private readonly IRuntimeLog _runtimeLog = default!;
|
||||
#endif
|
||||
#pragma warning restore 649
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<ComponentEventArgs> ComponentAdded;
|
||||
public event EventHandler<ComponentEventArgs>? ComponentAdded;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<ComponentEventArgs> ComponentRemoved;
|
||||
public event EventHandler<ComponentEventArgs>? ComponentRemoved;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<ComponentEventArgs> ComponentDeleted;
|
||||
public event EventHandler<ComponentEventArgs>? ComponentDeleted;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
@@ -151,14 +150,14 @@ namespace Robust.Shared.GameObjects
|
||||
public void RemoveComponent(EntityUid uid, Type type)
|
||||
{
|
||||
var component = GetComponent(uid, type);
|
||||
RemoveComponentDeferred(component as Component, false);
|
||||
RemoveComponentDeferred((Component) component, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void RemoveComponent(EntityUid uid, uint netId)
|
||||
{
|
||||
var comp = GetComponent(uid, netId);
|
||||
RemoveComponentDeferred(comp as Component, false);
|
||||
var component = GetComponent(uid, netId);
|
||||
RemoveComponentDeferred((Component) component, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -170,7 +169,7 @@ namespace Robust.Shared.GameObjects
|
||||
if (component.Owner == null || component.Owner.Uid != uid)
|
||||
throw new InvalidOperationException("Component is not owned by entity.");
|
||||
|
||||
RemoveComponentDeferred(component as Component, false);
|
||||
RemoveComponentDeferred((Component)component, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -366,7 +365,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetComponent<T>(EntityUid uid, out T component)
|
||||
public bool TryGetComponent<T>(EntityUid uid, [NotNullWhen(true)] out T component)
|
||||
{
|
||||
if (TryGetComponent(uid, typeof(T), out var comp))
|
||||
{
|
||||
@@ -374,12 +373,12 @@ namespace Robust.Shared.GameObjects
|
||||
return true;
|
||||
}
|
||||
|
||||
component = default;
|
||||
component = default!;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetComponent(EntityUid uid, Type type, out IComponent component)
|
||||
public bool TryGetComponent(EntityUid uid, Type type, [NotNullWhen(true)] out IComponent? component)
|
||||
{
|
||||
if (_dictComponents.TryGetValue(type, out var typeDict))
|
||||
{
|
||||
@@ -395,7 +394,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetComponent(EntityUid uid, uint netId, out IComponent component)
|
||||
public bool TryGetComponent(EntityUid uid, uint netId, [NotNullWhen(true)] out IComponent? component)
|
||||
{
|
||||
if (_netComponents.TryGetValue(uid, out var netDict))
|
||||
{
|
||||
|
||||
@@ -26,19 +26,19 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// The new parent of the transform.
|
||||
/// </summary>
|
||||
public IEntity NewParent { get; }
|
||||
public IEntity? NewParent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The old parent of the transform.
|
||||
/// </summary>
|
||||
public IEntity OldParent { get; }
|
||||
public IEntity? OldParent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="ParentChangedMessage"/>.
|
||||
/// </summary>
|
||||
/// <param name="newParent">The new parent of the transform.</param>
|
||||
/// <param name="oldParent">The old parent of the transform.</param>
|
||||
public ParentChangedMessage(IEntity newParent, IEntity oldParent)
|
||||
public ParentChangedMessage(IEntity? newParent, IEntity? oldParent)
|
||||
{
|
||||
NewParent = newParent;
|
||||
OldParent = oldParent;
|
||||
|
||||
@@ -14,9 +14,7 @@ namespace Robust.Shared.GameObjects.Components
|
||||
{
|
||||
public class CollidableComponent : Component, ICollidableComponent
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPhysicsManager _physicsManager;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IPhysicsManager _physicsManager = default!;
|
||||
|
||||
private bool _canCollide;
|
||||
private BodyStatus _status;
|
||||
@@ -53,7 +51,7 @@ namespace Robust.Shared.GameObjects.Components
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState == null)
|
||||
return;
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Robust.Shared.GameObjects
|
||||
return new OccluderComponentState(Enabled, BoundingBox);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState == null)
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Robust.Shared.GameObjects.Components.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
|
||||
|
||||
@@ -22,9 +22,7 @@ namespace Robust.Shared.GameObjects.Components.Map
|
||||
/// <inheritdoc cref="IMapGridComponent"/>
|
||||
internal class MapGridComponent : Component, IMapGridComponent
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IMapManager _mapManager;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
private GridId _gridIndex;
|
||||
@@ -71,7 +69,7 @@ namespace Robust.Shared.GameObjects.Components.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
|
||||
|
||||
@@ -15,16 +15,16 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// The in-game name of this entity.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
public string? Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The in-game description of this entity.
|
||||
/// </summary>
|
||||
public string Description { get; }
|
||||
public string? Description { get; }
|
||||
/// <summary>
|
||||
/// The prototype this entity was created from, if any.
|
||||
/// </summary>
|
||||
public string PrototypeId { get; }
|
||||
public string? PrototypeId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="MetaDataComponentState"/>.
|
||||
@@ -32,7 +32,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="name">The in-game name of this entity.</param>
|
||||
/// <param name="description">The in-game description of this entity.</param>
|
||||
/// <param name="prototypeId">The prototype this entity was created from, if any.</param>
|
||||
public MetaDataComponentState(string name, string description, string prototypeId)
|
||||
public MetaDataComponentState(string? name, string? description, string? prototypeId)
|
||||
: base(NetIDs.META_DATA)
|
||||
{
|
||||
Name = name;
|
||||
@@ -59,19 +59,17 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// The prototype this entity was created from, if any.
|
||||
/// </summary>
|
||||
EntityPrototype EntityPrototype { get; set; }
|
||||
EntityPrototype? EntityPrototype { get; set; }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IMetaDataComponent"/>
|
||||
internal class MetaDataComponent : Component, IMetaDataComponent
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IPrototypeManager _prototypes;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IPrototypeManager _prototypes = default!;
|
||||
|
||||
private string _entityName;
|
||||
private string _entityDescription;
|
||||
private EntityPrototype _entityPrototype;
|
||||
private string? _entityName;
|
||||
private string? _entityDescription;
|
||||
private EntityPrototype? _entityPrototype;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => "MetaData";
|
||||
@@ -91,7 +89,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
set
|
||||
{
|
||||
var newValue = value;
|
||||
string? newValue = value;
|
||||
if (_entityPrototype != null && _entityPrototype.Name == newValue)
|
||||
newValue = null;
|
||||
|
||||
@@ -115,7 +113,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
set
|
||||
{
|
||||
var newValue = value;
|
||||
string? newValue = value;
|
||||
if (_entityPrototype != null && _entityPrototype.Description == newValue)
|
||||
newValue = null;
|
||||
|
||||
@@ -129,7 +127,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public EntityPrototype EntityPrototype
|
||||
public EntityPrototype? EntityPrototype
|
||||
{
|
||||
get => _entityPrototype;
|
||||
set
|
||||
@@ -146,7 +144,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
|
||||
|
||||
@@ -60,15 +60,15 @@ namespace Robust.Shared.GameObjects.Components.Renderable
|
||||
[Serializable, NetSerializable]
|
||||
protected struct PrototypeLayerData : IExposeData
|
||||
{
|
||||
public string Shader;
|
||||
public string TexturePath;
|
||||
public string RsiPath;
|
||||
public string State;
|
||||
public string? Shader;
|
||||
public string? TexturePath;
|
||||
public string? RsiPath;
|
||||
public string? State;
|
||||
public Vector2 Scale;
|
||||
public Angle Rotation;
|
||||
public bool Visible;
|
||||
public Color Color;
|
||||
public List<string> MapKeys;
|
||||
public List<string>? MapKeys;
|
||||
|
||||
public static PrototypeLayerData New()
|
||||
{
|
||||
|
||||
@@ -21,11 +21,9 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
|
||||
private bool IsSet;
|
||||
private SnapGridOffset _offset = SnapGridOffset.Center;
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IMapManager _mapManager;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public event Action OnPositionChanged;
|
||||
public event Action? OnPositionChanged;
|
||||
|
||||
private GridId _lastGrid;
|
||||
public MapIndices Position { get; private set; }
|
||||
|
||||
@@ -35,11 +35,9 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
|
||||
[ViewVariables] private readonly SortedSet<EntityUid> _children = new SortedSet<EntityUid>();
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IMapManager _mapManager;
|
||||
[Dependency] private readonly IGameTiming _gameTiming;
|
||||
[Dependency] private readonly IEntityManager _entityManager;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => "Transform";
|
||||
@@ -67,7 +65,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
|
||||
// branch or leaf node
|
||||
if (_parent.IsValid())
|
||||
return Parent.GridID;
|
||||
return Parent!.GridID;
|
||||
|
||||
// Not on a grid
|
||||
return GridId.Invalid;
|
||||
@@ -101,7 +99,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
{
|
||||
if (_parent.IsValid())
|
||||
{
|
||||
return Parent.WorldRotation + GetLocalRotation();
|
||||
return Parent!.WorldRotation + GetLocalRotation();
|
||||
}
|
||||
|
||||
return GetLocalRotation();
|
||||
@@ -118,7 +116,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
/// Current parent entity of this entity.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public ITransformComponent Parent
|
||||
public ITransformComponent? Parent
|
||||
{
|
||||
get => !_parent.IsValid() ? null : Owner.EntityManager.GetEntity(_parent).Transform;
|
||||
set
|
||||
@@ -148,7 +146,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
{
|
||||
if (_parent.IsValid())
|
||||
{
|
||||
var parentMatrix = Parent.WorldMatrix;
|
||||
var parentMatrix = Parent!.WorldMatrix;
|
||||
var myMatrix = GetLocalMatrix();
|
||||
Matrix3.Multiply(ref myMatrix, ref parentMatrix, out var result);
|
||||
return result;
|
||||
@@ -165,7 +163,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
{
|
||||
if (_parent.IsValid())
|
||||
{
|
||||
var matP = Parent.InvWorldMatrix;
|
||||
var matP = Parent!.InvWorldMatrix;
|
||||
var myMatrix = GetLocalMatrixInv();
|
||||
Matrix3.Multiply(ref matP, ref myMatrix, out var result);
|
||||
return result;
|
||||
@@ -186,7 +184,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
if (_parent.IsValid())
|
||||
{
|
||||
// transform _position from parent coords to world coords
|
||||
var worldPos = Parent.WorldMatrix.Transform(GetLocalPosition());
|
||||
var worldPos = Parent!.WorldMatrix.Transform(GetLocalPosition());
|
||||
return new GridCoordinates(worldPos, GridID);
|
||||
}
|
||||
else
|
||||
@@ -212,7 +210,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
}
|
||||
|
||||
// world coords to parent coords
|
||||
var newPos = Parent.InvWorldMatrix.Transform(worldCoords);
|
||||
var newPos = Parent!.InvWorldMatrix.Transform(worldCoords);
|
||||
|
||||
// float rounding error guard, if the offset is less than 1mm ignore it
|
||||
if ((newPos - GetLocalPosition()).LengthSquared < 10.0E-3)
|
||||
@@ -243,7 +241,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
if (_parent.IsValid())
|
||||
{
|
||||
// parent coords to world coords
|
||||
return Parent.WorldMatrix.Transform(GetLocalPosition());
|
||||
return Parent!.WorldMatrix.Transform(GetLocalPosition());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -259,7 +257,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
}
|
||||
|
||||
// world coords to parent coords
|
||||
var newPos = Parent.InvWorldMatrix.Transform(value);
|
||||
var newPos = Parent!.InvWorldMatrix.Transform(value);
|
||||
|
||||
// float rounding error guard, if the offset is less than 1mm ignore it
|
||||
//if ((newPos - GetLocalPosition()).LengthSquared < 1.0E-3)
|
||||
@@ -327,7 +325,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
{
|
||||
// Note that _children is a SortedSet<EntityUid>,
|
||||
// so duplicate additions (which will happen) don't matter.
|
||||
((TransformComponent) Parent)._children.Add(Owner.Uid);
|
||||
((TransformComponent) Parent!)._children.Add(Owner.Uid);
|
||||
|
||||
MapID = Parent.MapID;
|
||||
}
|
||||
@@ -459,7 +457,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
}
|
||||
|
||||
var oldParent = Parent;
|
||||
var oldConcrete = (TransformComponent) oldParent;
|
||||
var oldConcrete = (TransformComponent?) oldParent;
|
||||
var uid = Owner.Uid;
|
||||
oldConcrete?._children.Remove(uid);
|
||||
var newConcrete = (TransformComponent) newParent;
|
||||
@@ -586,7 +584,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState != null)
|
||||
{
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Robust.Shared.GameObjects.Components.UserInterface
|
||||
|
||||
protected sealed class PrototypeData : IExposeData
|
||||
{
|
||||
public object UiKey { get; private set; }
|
||||
public string ClientType { get; private set; }
|
||||
public object UiKey { get; private set; } = default!;
|
||||
public string ClientType { get; private set; } = default!;
|
||||
|
||||
public void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
@@ -18,7 +19,7 @@ namespace Robust.Shared.GameObjects
|
||||
#region Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEntityManager EntityManager { get; private set; }
|
||||
public IEntityManager EntityManager { get; private set; } = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
@@ -26,7 +27,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public EntityPrototype Prototype
|
||||
public EntityPrototype? Prototype
|
||||
{
|
||||
get => MetaData.EntityPrototype;
|
||||
internal set => MetaData.EntityPrototype = value;
|
||||
@@ -73,12 +74,12 @@ namespace Robust.Shared.GameObjects
|
||||
[ViewVariables]
|
||||
public bool Deleted { get; private set; }
|
||||
|
||||
private ITransformComponent _transform;
|
||||
private ITransformComponent? _transform;
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public ITransformComponent Transform => _transform ?? (_transform = GetComponent<ITransformComponent>());
|
||||
|
||||
private IMetaDataComponent _metaData;
|
||||
private IMetaDataComponent? _metaData;
|
||||
|
||||
private bool _initializing;
|
||||
/// <inheritdoc />
|
||||
@@ -211,7 +212,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SendNetworkMessage(IComponent owner, ComponentMessage message, INetChannel channel = null)
|
||||
public void SendNetworkMessage(IComponent owner, ComponentMessage message, INetChannel? channel = null)
|
||||
{
|
||||
EntityManager.EntityNetManager.SendComponentNetworkMessage(channel, this, owner, message);
|
||||
}
|
||||
@@ -280,7 +281,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetComponent<T>(out T component)
|
||||
public bool TryGetComponent<T>([NotNullWhen(true)] out T component)
|
||||
{
|
||||
DebugTools.Assert(!Deleted, "Tried to get component on a deleted entity.");
|
||||
|
||||
@@ -288,7 +289,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetComponent(Type type, out IComponent component)
|
||||
public bool TryGetComponent(Type type, [NotNullWhen(true)] out IComponent? component)
|
||||
{
|
||||
DebugTools.Assert(!Deleted, "Tried to get component on a deleted entity.");
|
||||
|
||||
@@ -296,7 +297,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetComponent(uint netId, out IComponent component)
|
||||
public bool TryGetComponent(uint netId, [NotNullWhen(true)] out IComponent? component)
|
||||
{
|
||||
DebugTools.Assert(!Deleted, "Tried to get component on a deleted entity.");
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="subscriber">Subscriber that owns the handler.</param>
|
||||
/// <param name="eventHandler">Delegate that handles the event.</param>
|
||||
void SubscribeEvent<T>(EventSource source, IEntityEventSubscriber subscriber,
|
||||
EntityEventHandler<T> eventHandler);
|
||||
EntityEventHandler<T> eventHandler) where T : notnull;
|
||||
|
||||
/// <summary>
|
||||
/// Unsubscribes all event handlers of a given type.
|
||||
@@ -31,7 +31,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <typeparam name="T">Event type being unsubscribed from.</typeparam>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="subscriber">Subscriber that owns the handlers.</param>
|
||||
void UnsubscribeEvent<T>(EventSource source, IEntityEventSubscriber subscriber);
|
||||
void UnsubscribeEvent<T>(EventSource source, IEntityEventSubscriber subscriber) where T : notnull;
|
||||
|
||||
/// <summary>
|
||||
/// Immediately raises an event onto the bus.
|
||||
@@ -40,7 +40,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="toRaise">Event being raised.</param>
|
||||
void RaiseEvent(EventSource source, object toRaise);
|
||||
|
||||
void RaiseEvent<T>(EventSource source, T toRaise);
|
||||
void RaiseEvent<T>(EventSource source, T toRaise) where T : notnull;
|
||||
|
||||
/// <summary>
|
||||
/// Queues an event to be raised at a later time.
|
||||
@@ -55,7 +55,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <typeparam name="T">Event type being waited for.</typeparam>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> AwaitEvent<T>(EventSource source);
|
||||
Task<T> AwaitEvent<T>(EventSource source) where T : notnull;
|
||||
|
||||
/// <summary>
|
||||
/// Waits for an event to be raised. You do not have to subscribe to the event.
|
||||
@@ -64,7 +64,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> AwaitEvent<T>(EventSource source, CancellationToken cancellationToken);
|
||||
Task<T> AwaitEvent<T>(EventSource source, CancellationToken cancellationToken) where T : notnull;
|
||||
|
||||
/// <summary>
|
||||
/// Unsubscribes all event handlers for a given subscriber.
|
||||
@@ -136,7 +136,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SubscribeEvent<T>(EventSource source, IEntityEventSubscriber subscriber, EntityEventHandler<T> eventHandler)
|
||||
public void SubscribeEvent<T>(EventSource source, IEntityEventSubscriber subscriber, EntityEventHandler<T> eventHandler) where T : notnull
|
||||
{
|
||||
if (source == EventSource.None)
|
||||
throw new ArgumentOutOfRangeException(nameof(source));
|
||||
@@ -174,7 +174,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void UnsubscribeEvent<T>(EventSource source, IEntityEventSubscriber subscriber)
|
||||
public void UnsubscribeEvent<T>(EventSource source, IEntityEventSubscriber subscriber) where T : notnull
|
||||
{
|
||||
if (source == EventSource.None)
|
||||
throw new ArgumentOutOfRangeException(nameof(source));
|
||||
@@ -201,7 +201,7 @@ namespace Robust.Shared.GameObjects
|
||||
ProcessSingleEvent(source, toRaise);
|
||||
}
|
||||
|
||||
public void RaiseEvent<T>(EventSource source, T toRaise)
|
||||
public void RaiseEvent<T>(EventSource source, T toRaise) where T : notnull
|
||||
{
|
||||
if (source == EventSource.None)
|
||||
throw new ArgumentOutOfRangeException(nameof(source));
|
||||
@@ -225,13 +225,13 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<T> AwaitEvent<T>(EventSource source)
|
||||
public Task<T> AwaitEvent<T>(EventSource source) where T : notnull
|
||||
{
|
||||
return AwaitEvent<T>(source, default);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<T> AwaitEvent<T>(EventSource source, CancellationToken cancellationToken)
|
||||
public Task<T> AwaitEvent<T>(EventSource source, CancellationToken cancellationToken) where T : notnull
|
||||
{
|
||||
if(source == EventSource.None)
|
||||
throw new ArgumentOutOfRangeException(nameof(source));
|
||||
@@ -298,7 +298,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessSingleEvent<T>(EventSource source, T eventArgs)
|
||||
private void ProcessSingleEvent<T>(EventSource source, T eventArgs) where T : notnull
|
||||
{
|
||||
var eventType = typeof(T);
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace Robust.Shared.GameObjects
|
||||
return Mask == other.Mask && Equals(EqualityToken, other.EqualityToken);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is Registration other && Equals(other);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
@@ -24,15 +25,13 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
#region Dependencies
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IEntityNetworkManager EntityNetworkManager;
|
||||
[Dependency] private readonly IPrototypeManager PrototypeManager;
|
||||
[Dependency] protected readonly IEntitySystemManager EntitySystemManager;
|
||||
[Dependency] private readonly IComponentFactory ComponentFactory;
|
||||
[Dependency] private readonly IComponentManager _componentManager;
|
||||
[Dependency] private readonly IGameTiming _gameTiming;
|
||||
[Dependency] private readonly IMapManager _mapManager;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IEntityNetworkManager EntityNetworkManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager PrototypeManager = default!;
|
||||
[Dependency] protected readonly IEntitySystemManager EntitySystemManager = default!;
|
||||
[Dependency] private readonly IComponentFactory ComponentFactory = default!;
|
||||
[Dependency] private readonly IComponentManager _componentManager = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
#endregion Dependencies
|
||||
|
||||
@@ -97,22 +96,22 @@ namespace Robust.Shared.GameObjects
|
||||
#region Entity Management
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity CreateEntityUninitialized(string prototypeName);
|
||||
public abstract IEntity CreateEntityUninitialized(string? prototypeName);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity CreateEntityUninitialized(string prototypeName, GridCoordinates coordinates);
|
||||
public abstract IEntity CreateEntityUninitialized(string? prototypeName, GridCoordinates coordinates);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity CreateEntityUninitialized(string prototypeName, MapCoordinates coordinates);
|
||||
public abstract IEntity CreateEntityUninitialized(string? prototypeName, MapCoordinates coordinates);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity SpawnEntity(string protoName, GridCoordinates coordinates);
|
||||
public abstract IEntity SpawnEntity(string? protoName, GridCoordinates coordinates);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity SpawnEntity(string protoName, MapCoordinates coordinates);
|
||||
public abstract IEntity SpawnEntity(string? protoName, MapCoordinates coordinates);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity SpawnEntityNoMapInit(string protoName, GridCoordinates coordinates);
|
||||
public abstract IEntity SpawnEntityNoMapInit(string? protoName, GridCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Returns an entity by id
|
||||
@@ -130,7 +129,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="entity">The requested entity or null if the entity couldn't be found.</param>
|
||||
/// <returns>True if a value was returned, false otherwise.</returns>
|
||||
public bool TryGetEntity(EntityUid uid, out IEntity entity)
|
||||
public bool TryGetEntity(EntityUid uid, [NotNullWhen(true)] out IEntity? entity)
|
||||
{
|
||||
if (Entities.TryGetValue(uid, out entity) && !entity.Deleted)
|
||||
{
|
||||
@@ -219,7 +218,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// </summary>
|
||||
private protected Entity AllocEntity(string prototypeName, EntityUid? uid = null)
|
||||
{
|
||||
EntityPrototype prototype = null;
|
||||
EntityPrototype? prototype = null;
|
||||
if (!string.IsNullOrWhiteSpace(prototypeName))
|
||||
{
|
||||
// If the prototype doesn't exist then we throw BEFORE we allocate the entity.
|
||||
|
||||
@@ -8,12 +8,10 @@ namespace Robust.Shared.GameObjects
|
||||
public sealed class EntityState
|
||||
{
|
||||
public EntityUid Uid { get; }
|
||||
[CanBeNull]
|
||||
public ComponentChanged[] ComponentChanges { get; }
|
||||
[CanBeNull]
|
||||
public ComponentState[] ComponentStates { get; }
|
||||
public ComponentChanged[]? ComponentChanges { get; }
|
||||
public ComponentState[]? ComponentStates { get; }
|
||||
|
||||
public EntityState(EntityUid uid, ComponentChanged[] changedComponents, ComponentState[] componentStates)
|
||||
public EntityState(EntityUid uid, ComponentChanged[]? changedComponents, ComponentState[]? componentStates)
|
||||
{
|
||||
Uid = uid;
|
||||
|
||||
@@ -41,9 +39,9 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// The prototype name of the component to add.
|
||||
/// </summary>
|
||||
public readonly string ComponentName;
|
||||
public readonly string? ComponentName;
|
||||
|
||||
public ComponentChanged(bool deleted, uint netId, string componentName)
|
||||
public ComponentChanged(bool deleted, uint netId, string? componentName)
|
||||
{
|
||||
Deleted = deleted;
|
||||
NetID = netId;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects.Systems;
|
||||
@@ -13,9 +14,9 @@ namespace Robust.Shared.GameObjects
|
||||
public class EntitySystemManager : IEntitySystemManager
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager;
|
||||
[Dependency] private readonly IDynamicTypeFactory _typeFactory;
|
||||
[Dependency] private readonly IEntityManager _entityManager;
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
|
||||
[Dependency] private readonly IDynamicTypeFactory _typeFactory = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
#pragma warning restore 649
|
||||
|
||||
/// <summary>
|
||||
@@ -51,7 +52,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetEntitySystem<T>(out T entitySystem)
|
||||
public bool TryGetEntitySystem<T>([MaybeNullWhen(false)] out T entitySystem)
|
||||
where T : IEntitySystem
|
||||
{
|
||||
if (_systems.TryGetValue(typeof(T), out var system))
|
||||
|
||||
@@ -3,6 +3,8 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
// TODO: This is quite bandwidth intensive.
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Robust.Shared.GameObjects.EntitySystemMessages
|
||||
/// <summary>
|
||||
/// Specifies the name of the RSI state to use if <see cref="EffectSprite"/> is an RSI.
|
||||
/// </summary>
|
||||
public string RsiState { get; set; }
|
||||
public string? RsiState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If the sprite is an RSI state, controls whether the animation loops or ends on the last frame.
|
||||
|
||||
@@ -10,19 +10,19 @@ namespace Robust.Shared.GameObjects.EntitySystemMessages
|
||||
/// <summary>
|
||||
/// Entity that was adopted. The transform component has a property with the new parent.
|
||||
/// </summary>
|
||||
public IEntity Entity { get; }
|
||||
public IEntity? Entity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Old parent that abandoned the Entity.
|
||||
/// </summary>
|
||||
public IEntity OldParent { get; }
|
||||
public IEntity? OldParent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="EntParentChangedMessage"/>.
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="oldParent"></param>
|
||||
public EntParentChangedMessage(IEntity entity, IEntity oldParent)
|
||||
public EntParentChangedMessage(IEntity? entity, IEntity? oldParent)
|
||||
{
|
||||
Entity = entity;
|
||||
OldParent = oldParent;
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
return obj is EntityUid id && Equals(id);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Robust.Shared.GameObjects
|
||||
return Handler.Equals(other.Handler);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return ReferenceEquals(this, obj) || obj is HandlerWrapper<T> other && Equals(other);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="entity">Entity sending the message (also entity to send to).</param>
|
||||
/// <param name="component">Component that sent the message.</param>
|
||||
/// <param name="message">Message to send.</param>
|
||||
void SendComponentNetworkMessage(INetChannel channel, IEntity entity, IComponent component,
|
||||
void SendComponentNetworkMessage(INetChannel? channel, IEntity entity, IComponent component,
|
||||
ComponentMessage message);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,12 +19,12 @@ namespace Robust.Shared.GameObjects.Systems
|
||||
[Reflect(false), PublicAPI]
|
||||
public abstract class EntitySystem : IEntitySystem
|
||||
{
|
||||
[Dependency] protected readonly IEntityManager EntityManager;
|
||||
[Dependency] protected readonly IEntitySystemManager EntitySystemManager;
|
||||
[Dependency] protected readonly IEntityNetworkManager EntityNetworkManager;
|
||||
[Dependency] protected readonly IEntityManager EntityManager = default!;
|
||||
[Dependency] protected readonly IEntitySystemManager EntitySystemManager = default!;
|
||||
[Dependency] protected readonly IEntityNetworkManager EntityNetworkManager = default!;
|
||||
|
||||
protected IEntityQuery EntityQuery;
|
||||
protected IEnumerable<IEntity> RelevantEntities => EntityManager.GetEntities(EntityQuery);
|
||||
protected IEntityQuery? EntityQuery;
|
||||
protected IEnumerable<IEntity> RelevantEntities => EntityQuery != null ? EntityManager.GetEntities(EntityQuery) : EntityManager.GetEntities();
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void Initialize() { }
|
||||
|
||||
@@ -9,13 +9,13 @@ namespace Robust.Shared.GameStates
|
||||
public class GameStateMapData
|
||||
{
|
||||
// Dict of the new maps along with which grids are their defaults.
|
||||
public readonly KeyValuePair<MapId, GridId>[] CreatedMaps;
|
||||
public readonly KeyValuePair<GridId, GridCreationDatum>[] CreatedGrids;
|
||||
public readonly KeyValuePair<GridId, GridDatum>[] GridData;
|
||||
public readonly GridId[] DeletedGrids;
|
||||
public readonly MapId[] DeletedMaps;
|
||||
public readonly KeyValuePair<MapId, GridId>[]? CreatedMaps;
|
||||
public readonly KeyValuePair<GridId, GridCreationDatum>[]? CreatedGrids;
|
||||
public readonly KeyValuePair<GridId, GridDatum>[]? GridData;
|
||||
public readonly GridId[]? DeletedGrids;
|
||||
public readonly MapId[]? DeletedMaps;
|
||||
|
||||
public GameStateMapData(KeyValuePair<GridId, GridDatum>[] gridData, GridId[] deletedGrids, MapId[] deletedMaps, KeyValuePair<MapId, GridId>[] createdMaps, KeyValuePair<GridId, GridCreationDatum>[] createdGrids)
|
||||
public GameStateMapData(KeyValuePair<GridId, GridDatum>[]? gridData, GridId[]? deletedGrids, MapId[]? deletedMaps, KeyValuePair<MapId, GridId>[]? createdMaps, KeyValuePair<GridId, GridCreationDatum>[]? createdGrids)
|
||||
{
|
||||
GridData = gridData;
|
||||
DeletedGrids = deletedGrids;
|
||||
|
||||
@@ -5,6 +5,8 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Robust.Shared.GameStates
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -46,8 +46,8 @@ namespace Robust.Shared.Input.Binding
|
||||
/// before them if they appear in this list.</param>
|
||||
/// <param name="after">If other types register bindings for this key function, this handler will always fire
|
||||
/// after them if they appear in this list.</param>
|
||||
public CommandBind(BoundKeyFunction boundKeyFunction, InputCmdHandler handler, IEnumerable<Type> before = null,
|
||||
IEnumerable<Type> after = null)
|
||||
public CommandBind(BoundKeyFunction boundKeyFunction, InputCmdHandler handler, IEnumerable<Type>? before = null,
|
||||
IEnumerable<Type>? after = null)
|
||||
{
|
||||
_boundKeyFunction = boundKeyFunction;
|
||||
_after = after ?? Enumerable.Empty<Type>();
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Robust.Shared.Input
|
||||
return _value == other._value;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is KeyFunctionId other && Equals(other);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace Robust.Shared.Input
|
||||
continue;
|
||||
}
|
||||
|
||||
KeyFunctionsList.Add((BoundKeyFunction)field.GetValue(null));
|
||||
KeyFunctionsList.Add((BoundKeyFunction)field.GetValue(null)!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,12 +125,6 @@ namespace Robust.Shared.Input
|
||||
return false;
|
||||
}
|
||||
|
||||
if (list[index] == null)
|
||||
{
|
||||
func = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
func = list[index];
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -39,13 +39,13 @@ namespace Robust.Shared.Input
|
||||
internal class InputCmdContext : IInputCmdContext
|
||||
{
|
||||
private readonly List<BoundKeyFunction> _commands = new List<BoundKeyFunction>();
|
||||
private readonly IInputCmdContext _parent;
|
||||
private readonly IInputCmdContext? _parent;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="InputCmdContext"/>.
|
||||
/// </summary>
|
||||
/// <param name="parent">Parent context.</param>
|
||||
internal InputCmdContext(IInputCmdContext parent)
|
||||
internal InputCmdContext(IInputCmdContext? parent)
|
||||
{
|
||||
_parent = parent;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace Robust.Shared.Input
|
||||
/// <param name="enabled">The delegate to be ran when this command is enabled.</param>
|
||||
/// <param name="disabled">The delegate to be ran when this command is disabled.</param>
|
||||
/// <returns>The new input command.</returns>
|
||||
public static InputCmdHandler FromDelegate(StateInputCmdDelegate enabled = null,
|
||||
StateInputCmdDelegate disabled = null, bool handle=true)
|
||||
public static InputCmdHandler FromDelegate(StateInputCmdDelegate? enabled = null,
|
||||
StateInputCmdDelegate? disabled = null, bool handle=true)
|
||||
{
|
||||
return new StateInputCmdHandler
|
||||
{
|
||||
@@ -37,8 +37,8 @@ namespace Robust.Shared.Input
|
||||
|
||||
private class StateInputCmdHandler : InputCmdHandler
|
||||
{
|
||||
public StateInputCmdDelegate EnabledDelegate;
|
||||
public StateInputCmdDelegate DisabledDelegate;
|
||||
public StateInputCmdDelegate? EnabledDelegate;
|
||||
public StateInputCmdDelegate? DisabledDelegate;
|
||||
public bool Handle { get; set; }
|
||||
|
||||
public override void Enabled(ICommonSession session)
|
||||
|
||||
@@ -38,8 +38,13 @@ namespace Robust.Shared.Input
|
||||
InputFunctionId = inputFunctionId;
|
||||
}
|
||||
|
||||
public int CompareTo(InputCmdMessage other)
|
||||
public int CompareTo(InputCmdMessage? other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ReferenceEquals(this, other)) return 0;
|
||||
if (ReferenceEquals(null, other)) return 1;
|
||||
return InputSequence.CompareTo(other.InputSequence);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Robust.Shared.Input
|
||||
{
|
||||
@@ -11,7 +12,7 @@ namespace Robust.Shared.Input
|
||||
/// <summary>
|
||||
/// The current "active" context that should be used for filtering key binds.
|
||||
/// </summary>
|
||||
IInputCmdContext ActiveContext { get; }
|
||||
IInputCmdContext? ActiveContext { get; }
|
||||
|
||||
/// <summary>
|
||||
/// This event is raised when ever the Active Context is changed.
|
||||
@@ -54,7 +55,7 @@ namespace Robust.Shared.Input
|
||||
/// <param name="uniqueName">Unique name of the context to search for.</param>
|
||||
/// <param name="context">The context with the given unique name (if any).</param>
|
||||
/// <returns>If a context with a given unique name exists in the set.</returns>
|
||||
bool TryGetContext(string uniqueName, out IInputCmdContext context);
|
||||
bool TryGetContext(string uniqueName, [NotNullWhen(true)] out IInputCmdContext? context);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the context with the given unique name.
|
||||
@@ -78,19 +79,19 @@ namespace Robust.Shared.Input
|
||||
public const string DefaultContextName = "common";
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<ContextChangedEventArgs> ContextChanged;
|
||||
public event EventHandler<ContextChangedEventArgs>? ContextChanged;
|
||||
|
||||
private readonly Dictionary<string, InputCmdContext> _contexts = new Dictionary<string, InputCmdContext>();
|
||||
private InputCmdContext _activeContext;
|
||||
private InputCmdContext? _activeContext;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IInputCmdContext ActiveContext
|
||||
public IInputCmdContext? ActiveContext
|
||||
{
|
||||
get => _activeContext;
|
||||
private set
|
||||
{
|
||||
var args = new ContextChangedEventArgs(_activeContext, value);
|
||||
_activeContext = (InputCmdContext) value;
|
||||
_activeContext = (InputCmdContext?) value;
|
||||
ContextChanged?.Invoke(this, args);
|
||||
}
|
||||
}
|
||||
@@ -154,7 +155,7 @@ namespace Robust.Shared.Input
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetContext(string uniqueName, out IInputCmdContext context)
|
||||
public bool TryGetContext(string uniqueName, [NotNullWhen(true)] out IInputCmdContext? context)
|
||||
{
|
||||
if (_contexts.TryGetValue(uniqueName, out var ctext))
|
||||
{
|
||||
@@ -190,19 +191,19 @@ namespace Robust.Shared.Input
|
||||
/// <summary>
|
||||
/// The new context that became active.
|
||||
/// </summary>
|
||||
public IInputCmdContext NewContext { get; }
|
||||
public IInputCmdContext? NewContext { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The old context that used to be active.
|
||||
/// </summary>
|
||||
public IInputCmdContext OldContext { get; }
|
||||
public IInputCmdContext? OldContext { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="ContextChangedEventArgs"/>/
|
||||
/// </summary>
|
||||
/// <param name="oldContext">The old context that used to be active.</param>
|
||||
/// <param name="newContext">The new context that became active.</param>
|
||||
public ContextChangedEventArgs(IInputCmdContext oldContext, IInputCmdContext newContext)
|
||||
public ContextChangedEventArgs(IInputCmdContext? oldContext, IInputCmdContext? newContext)
|
||||
{
|
||||
OldContext = oldContext;
|
||||
NewContext = newContext;
|
||||
|
||||
@@ -92,9 +92,13 @@ namespace Robust.Shared.Input
|
||||
|
||||
#region Code for easy equality and sorting.
|
||||
|
||||
public int CompareTo(object obj)
|
||||
public int CompareTo(object? obj)
|
||||
{
|
||||
return CompareTo((BoundKeyFunction) obj);
|
||||
if (!(obj is BoundKeyFunction func))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return CompareTo(func);
|
||||
}
|
||||
|
||||
public int CompareTo(BoundKeyFunction other)
|
||||
@@ -103,9 +107,9 @@ namespace Robust.Shared.Input
|
||||
}
|
||||
|
||||
// Could maybe go dirty and optimize these on the assumption that they're singletons.
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return Equals((BoundKeyFunction) obj);
|
||||
return obj is BoundKeyFunction func && Equals(func);
|
||||
}
|
||||
|
||||
public bool Equals(BoundKeyFunction other)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Robust.Shared.Interfaces.Configuration
|
||||
/// <param name="defaultValue">The default Value of the CVar.</param>
|
||||
/// <param name="flags">Optional flags to change behavior of the CVar.</param>
|
||||
/// <param name="onValueChanged">Invoked whenever the CVar value changes.</param>
|
||||
void RegisterCVar<T>(string name, T defaultValue, CVar flags = CVar.NONE, Action<T> onValueChanged=null);
|
||||
void RegisterCVar<T>(string name, T defaultValue, CVar flags = CVar.NONE, Action<T>? onValueChanged=null);
|
||||
|
||||
/// <summary>
|
||||
/// Is the named CVar already registered?
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Robust.Shared.Interfaces.GameObjects.Components
|
||||
/// <summary>
|
||||
/// Reference to the transform of the container of this object if it exists, can be nested several times.
|
||||
/// </summary>
|
||||
ITransformComponent Parent { get; }
|
||||
ITransformComponent? Parent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The UID of the parent entity that this entity is attached to.
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <param name="message">Incoming event message.</param>
|
||||
/// <param name="netChannel">The channel of the remote client that sent the message.</param>
|
||||
/// <param name="session">The session data for the player who sent this message. Null if this is a client.</param>
|
||||
void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession session = null);
|
||||
void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null);
|
||||
|
||||
/// <summary>
|
||||
/// Get the component's state for replicating on the client.
|
||||
@@ -136,6 +136,6 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// </remarks>
|
||||
/// <param name="curState">Current component state for this tick.</param>
|
||||
/// <param name="nextState">Next component state for the next tick.</param>
|
||||
void HandleComponentState([CanBeNull]ComponentState curState, [CanBeNull]ComponentState nextState);
|
||||
void HandleComponentState(ComponentState? curState, ComponentState? nextState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
@@ -15,18 +16,18 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <summary>
|
||||
/// A component was added to the manager.
|
||||
/// </summary>
|
||||
event EventHandler<ComponentEventArgs> ComponentAdded;
|
||||
event EventHandler<ComponentEventArgs>? ComponentAdded;
|
||||
|
||||
/// <summary>
|
||||
/// A component was removed from the manager.
|
||||
/// </summary>
|
||||
event EventHandler<ComponentEventArgs> ComponentRemoved;
|
||||
event EventHandler<ComponentEventArgs>? ComponentRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// A component was deleted. This is usually deferred until some time after it was removed.
|
||||
/// Usually you will want to subscribe to <see cref="ComponentRemoved"/>.
|
||||
/// </summary>
|
||||
event EventHandler<ComponentEventArgs> ComponentDeleted;
|
||||
event EventHandler<ComponentEventArgs>? ComponentDeleted;
|
||||
|
||||
/// <summary>
|
||||
/// Instantly clears all components from the manager. This will NOT shut them down gracefully.
|
||||
@@ -153,7 +154,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <param name="uid">Entity UID to check.</param>
|
||||
/// <param name="component">Component of the specified type (if exists).</param>
|
||||
/// <returns>If the component existed in the entity.</returns>
|
||||
bool TryGetComponent<T>(EntityUid uid, out T component);
|
||||
bool TryGetComponent<T>(EntityUid uid, [NotNullWhen(true)] out T component);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the component of a specific type.
|
||||
@@ -162,7 +163,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <param name="type">Component reference type to check for.</param>
|
||||
/// <param name="component">Component of the specified type (if exists).</param>
|
||||
/// <returns>If the component existed in the entity.</returns>
|
||||
bool TryGetComponent(EntityUid uid, Type type, out IComponent component);
|
||||
bool TryGetComponent(EntityUid uid, Type type, [NotNullWhen(true)] out IComponent? component);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the component with a specified network ID.
|
||||
@@ -171,7 +172,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <param name="netID">Component Network ID to check for.</param>
|
||||
/// <param name="component">Component with the specified network id.</param>
|
||||
/// <returns>If the component existed in the entity.</returns>
|
||||
bool TryGetComponent(EntityUid uid, uint netID, out IComponent component);
|
||||
bool TryGetComponent(EntityUid uid, uint netID, [NotNullWhen(true)] out IComponent? component);
|
||||
|
||||
/// <summary>
|
||||
/// Returns ALL component type instances on an entity. A single component instance
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
@@ -44,7 +45,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <summary>
|
||||
/// The prototype that was used to create this entity.
|
||||
/// </summary>
|
||||
EntityPrototype Prototype { get; }
|
||||
EntityPrototype? Prototype { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The string that describes this entity via examine
|
||||
@@ -135,7 +136,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <typeparam name="T">The component reference type to attempt to fetch.</typeparam>
|
||||
/// <param name="component">The component, if it was found. Null otherwise.</param>
|
||||
/// <returns>True if a component with specified type was found.</returns>
|
||||
bool TryGetComponent<T>(out T component);
|
||||
bool TryGetComponent<T>([NotNullWhen(true)] out T component);
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to retrieve the component with specified type,
|
||||
@@ -144,7 +145,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <param name="type">The component reference type to attempt to fetch.</param>
|
||||
/// <param name="component">The component, if it was found. Null otherwise.</param>
|
||||
/// <returns>True if a component with specified type was found.</returns>
|
||||
bool TryGetComponent(Type type, out IComponent component);
|
||||
bool TryGetComponent(Type type, [NotNullWhen(true)] out IComponent? component);
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to retrieve the component with specified network ID,
|
||||
@@ -153,7 +154,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <param name="type">The component net ID to attempt to fetch.</param>
|
||||
/// <param name="component">The component, if it was found. Null otherwise.</param>
|
||||
/// <returns>True if a component with specified net ID was found.</returns>
|
||||
bool TryGetComponent(uint netID, out IComponent component);
|
||||
bool TryGetComponent(uint netID, [NotNullWhen(true)] out IComponent? component);
|
||||
|
||||
/// <summary>
|
||||
/// Used by the entity manager to delete the entity.
|
||||
@@ -193,7 +194,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// </summary>
|
||||
/// <param name="owner"></param>
|
||||
/// <param name="message">Message to send.</param>
|
||||
void SendNetworkMessage(IComponent owner, ComponentMessage message, INetChannel channel = null);
|
||||
void SendNetworkMessage(IComponent owner, ComponentMessage message, INetChannel? channel = null);
|
||||
|
||||
void Dirty();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <summary>
|
||||
/// Gets the serializer used to ExposeData a specific component.
|
||||
/// </summary>
|
||||
ObjectSerializer GetComponentSerializer(string componentName, YamlMappingNode protoData);
|
||||
ObjectSerializer GetComponentSerializer(string componentName, YamlMappingNode? protoData);
|
||||
|
||||
/// <summary>
|
||||
/// Gets extra component names that must also be instantiated on top of the ones defined in the prototype,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -29,11 +30,11 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
|
||||
#region Entity Management
|
||||
|
||||
IEntity CreateEntityUninitialized(string prototypeName);
|
||||
IEntity CreateEntityUninitialized(string? prototypeName);
|
||||
|
||||
IEntity CreateEntityUninitialized(string prototypeName, GridCoordinates coordinates);
|
||||
IEntity CreateEntityUninitialized(string? prototypeName, GridCoordinates coordinates);
|
||||
|
||||
IEntity CreateEntityUninitialized(string prototypeName, MapCoordinates coordinates);
|
||||
IEntity CreateEntityUninitialized(string? prototypeName, MapCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Spawns an initialized entity at the default location, using the given prototype.
|
||||
@@ -41,7 +42,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <param name="protoName">The prototype to clone. If this is null, the entity won't have a prototype.</param>
|
||||
/// <param name="coordinates"></param>
|
||||
/// <returns>Newly created entity.</returns>
|
||||
IEntity SpawnEntity(string protoName, GridCoordinates coordinates);
|
||||
IEntity SpawnEntity(string? protoName, GridCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Spawns an entity at a specific position
|
||||
@@ -49,7 +50,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <param name="protoName"></param>
|
||||
/// <param name="coordinates"></param>
|
||||
/// <returns></returns>
|
||||
IEntity SpawnEntity(string protoName, MapCoordinates coordinates);
|
||||
IEntity SpawnEntity(string? protoName, MapCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Spawns an initialized entity at the default location, using the given prototype.
|
||||
@@ -60,7 +61,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <param name="protoName">The prototype to clone. If this is null, the entity won't have a prototype.</param>
|
||||
/// <param name="coordinates"></param>
|
||||
/// <returns>Newly created entity.</returns>
|
||||
IEntity SpawnEntityNoMapInit(string protoName, GridCoordinates coordinates);
|
||||
IEntity SpawnEntityNoMapInit(string? protoName, GridCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Returns an entity by id
|
||||
@@ -75,7 +76,7 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="entity">The requested entity or null if the entity couldn't be found.</param>
|
||||
/// <returns>True if a value was returned, false otherwise.</returns>
|
||||
bool TryGetEntity(EntityUid uid, out IEntity entity);
|
||||
bool TryGetEntity(EntityUid uid, [NotNullWhen(true)] out IEntity? entity);
|
||||
|
||||
/// <summary>
|
||||
/// Returns all entities that match with the provided query.
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Robust.Shared.Interfaces.Log
|
||||
/// Log a message, taking in a format string and format list using the regular <see cref="Format" /> syntax.
|
||||
/// </summary>
|
||||
[StringFormatMethod("message")]
|
||||
void Log(LogLevel level, string message, params object[] args);
|
||||
void Log(LogLevel level, string message, params object?[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message.
|
||||
@@ -48,7 +48,7 @@ namespace Robust.Shared.Interfaces.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
void Debug(string message, params object[] args);
|
||||
void Debug(string message, params object?[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as debug.
|
||||
@@ -61,7 +61,7 @@ namespace Robust.Shared.Interfaces.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
void Info(string message, params object[] args);
|
||||
void Info(string message, params object?[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as info.
|
||||
@@ -74,7 +74,7 @@ namespace Robust.Shared.Interfaces.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
void Warning(string message, params object[] args);
|
||||
void Warning(string message, params object?[] args);
|
||||
/// <summary>
|
||||
/// Log a message as warning, taking in a format string and format list using the regular <see cref="Format" /> syntax.
|
||||
/// </summary>
|
||||
@@ -86,7 +86,7 @@ namespace Robust.Shared.Interfaces.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
void Error(string message, params object[] args);
|
||||
void Error(string message, params object?[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as error.
|
||||
@@ -99,7 +99,7 @@ namespace Robust.Shared.Interfaces.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
void Fatal(string message, params object[] args);
|
||||
void Fatal(string message, params object?[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as fatal.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
@@ -100,7 +101,7 @@ namespace Robust.Shared.Interfaces.Map
|
||||
|
||||
IMapGrid CreateGrid(MapId currentMapID, GridId? gridID = null, ushort chunkSize = 16, float snapSize = 1);
|
||||
IMapGrid GetGrid(GridId gridID);
|
||||
bool TryGetGrid(GridId gridId, out IMapGrid grid);
|
||||
bool TryGetGrid(GridId gridId, [NotNullWhen(true)] out IMapGrid? grid);
|
||||
bool GridExists(GridId gridID);
|
||||
IEnumerable<IMapGrid> GetAllMapGrids(MapId mapId);
|
||||
|
||||
@@ -114,7 +115,7 @@ namespace Robust.Shared.Interfaces.Map
|
||||
/// <param name="worldPos">Location on the map to check for a grid.</param>
|
||||
/// <param name="grid">Grid that was found, if any.</param>
|
||||
/// <returns>Returns true when a grid was found under the location.</returns>
|
||||
bool TryFindGridAt(MapId mapId, Vector2 worldPos, out IMapGrid grid);
|
||||
bool TryFindGridAt(MapId mapId, Vector2 worldPos, [NotNullWhen(true)] out IMapGrid? grid);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to find the map grid under the map location.
|
||||
@@ -125,7 +126,7 @@ namespace Robust.Shared.Interfaces.Map
|
||||
/// <param name="mapCoordinates">Location on the map to check for a grid.</param>
|
||||
/// <param name="grid">Grid that was found, if any.</param>
|
||||
/// <returns>Returns true when a grid was found under the location.</returns>
|
||||
bool TryFindGridAt(MapCoordinates mapCoordinates, out IMapGrid grid);
|
||||
bool TryFindGridAt(MapCoordinates mapCoordinates, [NotNullWhen(true)] out IMapGrid? grid);
|
||||
|
||||
IEnumerable<IMapGrid> FindGridsIntersecting(MapId mapId, Box2 worldArea);
|
||||
void DeleteGrid(GridId gridID);
|
||||
@@ -154,7 +155,7 @@ namespace Robust.Shared.Interfaces.Map
|
||||
/// </summary>
|
||||
event EventHandler<MapEventArgs> MapDestroyed;
|
||||
|
||||
GameStateMapData GetStateData(GameTick fromTick);
|
||||
GameStateMapData? GetStateData(GameTick fromTick);
|
||||
void CullDeletionHistory(GameTick uptoTick);
|
||||
|
||||
// Two methods here, so that new grids etc can be made BEFORE entities get states applied,
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Robust.Shared.Interfaces.Network
|
||||
/// <summary>
|
||||
/// The NetChannel of the server.
|
||||
/// </summary>
|
||||
INetChannel ServerChannel { get; }
|
||||
INetChannel? ServerChannel { get; }
|
||||
|
||||
ClientConnectionState ClientConnectState { get; }
|
||||
event Action<ClientConnectionState> ClientConnectStateChanged;
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Robust.Shared.Interfaces.Network
|
||||
/// <typeparam name="T">Type to register.</typeparam>
|
||||
/// <param name="name">String ID of the message.</param>
|
||||
/// <param name="rxCallback">Callback function to process the received message.</param>
|
||||
void RegisterNetMessage<T>(string name, ProcessMessage<T> rxCallback = null)
|
||||
void RegisterNetMessage<T>(string name, ProcessMessage<T>? rxCallback = null)
|
||||
where T : NetMessage;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Robust.Shared.Interfaces.Physics
|
||||
/// <param name="ignoredEnt">A single entity that can be ignored by the RayCast. Useful if the ray starts inside the body of an entity.</param>
|
||||
/// <param name="returnOnFirstHit">If false, will return a list of everything it hits, otherwise will just return a list of the first entity hit</param>
|
||||
/// <returns>An enumerable of either the first entity hit or everything hit</returns>
|
||||
IEnumerable<RayCastResults> IntersectRay(MapId mapId, CollisionRay ray, float maxLength = 50, IEntity ignoredEnt = null, bool returnOnFirstHit = true);
|
||||
IEnumerable<RayCastResults> IntersectRay(MapId mapId, CollisionRay ray, float maxLength = 50, IEntity? ignoredEnt = null, bool returnOnFirstHit = true);
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -70,7 +70,7 @@ namespace Robust.Shared.Interfaces.Physics
|
||||
/// <param name="maxLength">Maximum length of the ray in meters.</param>
|
||||
/// <param name="ignoredEnt">A single entity that can be ignored by the RayCast. Useful if the ray starts inside the body of an entity.</param>
|
||||
/// <returns>The distance the ray traveled while colliding with entities</returns>
|
||||
public float IntersectRayPenetration(MapId mapId, CollisionRay ray, float maxLength, IEntity ignoredEnt = null);
|
||||
public float IntersectRayPenetration(MapId mapId, CollisionRay ray, float maxLength, IEntity? ignoredEnt = null);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the normal vector for two colliding bodies
|
||||
@@ -99,7 +99,7 @@ namespace Robust.Shared.Interfaces.Physics
|
||||
/// <param name="predicate">A predicate to check whether to ignore an entity or not. If it returns true, it will be ignored.</param>
|
||||
/// <param name="returnOnFirstHit">If true, will only include the first hit entity in results. Otherwise, returns all of them.</param>
|
||||
/// <returns>A result object describing the hit, if any.</returns>
|
||||
IEnumerable<RayCastResults> IntersectRayWithPredicate(MapId mapId, CollisionRay ray, float maxLength = 50, Func<IEntity, bool> predicate = null, bool returnOnFirstHit = true);
|
||||
IEnumerable<RayCastResults> IntersectRayWithPredicate(MapId mapId, CollisionRay ray, float maxLength = 50, Func<IEntity, bool>? predicate = null, bool returnOnFirstHit = true);
|
||||
|
||||
event Action<DebugRayData> DebugDrawRay;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Robust.Shared.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Robust.Shared.Interfaces.Reflection
|
||||
{
|
||||
@@ -59,11 +60,11 @@ namespace Robust.Shared.Interfaces.Reflection
|
||||
/// it will add <code>Robust.Client</code>, <code>Robust.Shared</code>, etc... in front of it.
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
Type GetType(string name);
|
||||
Type? GetType(string name);
|
||||
|
||||
Type LooseGetType(string name);
|
||||
|
||||
bool TryLooseGetType(string name, out Type type);
|
||||
bool TryLooseGetType(string name, [NotNullWhen(true)] out Type? type);
|
||||
|
||||
/// <summary>
|
||||
/// Finds all Types in all Assemblies that have a specific Attribute.
|
||||
@@ -86,7 +87,7 @@ namespace Robust.Shared.Interfaces.Reflection
|
||||
/// Fired whenever an assembly is added through <see cref="LoadAssemblies"/>,
|
||||
/// this means more types might be available from <see cref="GetType(string)"/> and <see cref="GetAllChildren{T}(bool)"/>
|
||||
/// </summary>
|
||||
event EventHandler<ReflectionUpdateEventArgs> OnAssemblyAdded;
|
||||
event EventHandler<ReflectionUpdateEventArgs>? OnAssemblyAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Tries to parse an enum in the form "enum.PowerStorageAppearance.Charge", for use in prototyping.
|
||||
@@ -102,7 +103,7 @@ namespace Robust.Shared.Interfaces.Reflection
|
||||
/// <exception cref="ArgumentException">
|
||||
/// Thrown if this string is an enum reference, but the enum could not be resolved.
|
||||
/// </exception>
|
||||
bool TryParseEnumReference(string reference, out Enum @enum);
|
||||
bool TryParseEnumReference(string reference, [NotNullWhen(true)] out Enum? @enum);
|
||||
}
|
||||
|
||||
public class ReflectionUpdateEventArgs : EventArgs
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -30,7 +31,7 @@ namespace Robust.Shared.Interfaces.Resources
|
||||
/// <exception cref="FileNotFoundException">Thrown if <paramref name="pack"/> does not exist on disk.</exception>
|
||||
/// <exception cref="ArgumentException">Thrown if <paramref name="prefix"/> is not rooted.</exception>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="pack"/> is null.</exception>
|
||||
void MountContentPack(string pack, ResourcePath prefix = null);
|
||||
void MountContentPack(string pack, ResourcePath? prefix = null);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a directory to search inside of to the VFS. The directory is relative to
|
||||
@@ -41,7 +42,7 @@ namespace Robust.Shared.Interfaces.Resources
|
||||
/// <exception cref="DirectoryNotFoundException">Thrown if <paramref name="path"/> does not exist on disk.</exception>
|
||||
/// <exception cref="ArgumentException">Thrown if <paramref name="prefix"/> passed is not rooted.</exception>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="path"/> is null.</exception>
|
||||
void MountContentDirectory(string path, ResourcePath prefix = null);
|
||||
void MountContentDirectory(string path, ResourcePath? prefix = null);
|
||||
|
||||
/// <summary>
|
||||
/// Read a file from the mounted content roots.
|
||||
@@ -89,7 +90,7 @@ namespace Robust.Shared.Interfaces.Resources
|
||||
/// <returns>True if the file could be loaded, false otherwise.</returns>
|
||||
/// <exception cref="ArgumentException">Thrown if <paramref name="path"/> is not rooted.</exception>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="path"/> is null.</exception>
|
||||
bool TryContentFileRead(ResourcePath path, out Stream fileStream);
|
||||
bool TryContentFileRead(ResourcePath path, [NotNullWhen(true)] out Stream? fileStream);
|
||||
|
||||
/// <summary>
|
||||
/// Try to read a file from the mounted content roots.
|
||||
@@ -99,7 +100,7 @@ namespace Robust.Shared.Interfaces.Resources
|
||||
/// <returns>True if the file could be loaded, false otherwise.</returns>
|
||||
/// <exception cref="ArgumentException">Thrown if <paramref name="path"/> is not rooted.</exception>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="path"/> is null.</exception>
|
||||
bool TryContentFileRead(string path, out Stream fileStream);
|
||||
bool TryContentFileRead(string path, [NotNullWhen(true)] out Stream? fileStream);
|
||||
|
||||
/// <summary>
|
||||
/// Recursively finds all files in a directory and all sub directories.
|
||||
@@ -130,7 +131,7 @@ namespace Robust.Shared.Interfaces.Resources
|
||||
/// Actually, seems like JetBrains Rider has trouble loading PBD files passed into AppDomain.Load too.
|
||||
/// Hrm.
|
||||
/// </summary>
|
||||
bool TryGetDiskFilePath(ResourcePath path, out string diskPath);
|
||||
bool TryGetDiskFilePath(ResourcePath path, [NotNullWhen(true)] out string? diskPath);
|
||||
}
|
||||
|
||||
internal interface IResourceManagerInternal : IResourceManager
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Robust.Shared.Interfaces.Resources
|
||||
/// The root path of this provider.
|
||||
/// Can be null if it's a virtual provider.
|
||||
/// </summary>
|
||||
string RootDir { get; }
|
||||
string? RootDir { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a directory. If the directory exists, does nothing.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
namespace Robust.Shared.Interfaces.Serialization
|
||||
@@ -46,8 +47,9 @@ namespace Robust.Shared.Interfaces.Serialization
|
||||
/// </summary>
|
||||
public abstract Type Format { get; }
|
||||
|
||||
[return: NotNull]
|
||||
public abstract T FromCustomFormat(object obj);
|
||||
public abstract object ToCustomFormat(T t);
|
||||
public abstract object ToCustomFormat(T t); // t is never null here. Promise.
|
||||
|
||||
/// <summary>
|
||||
/// Get the corresponding YAML serializer for the custom representation.
|
||||
@@ -60,15 +62,15 @@ namespace Robust.Shared.Interfaces.Serialization
|
||||
private class DoNothing : WithFormat<T>
|
||||
{
|
||||
public override Type Format => typeof(T);
|
||||
[return: NotNull]
|
||||
public override T FromCustomFormat(object obj) { return (T)obj; }
|
||||
public override object ToCustomFormat(T t) { return t; }
|
||||
public override object ToCustomFormat(T t) { return t!; }
|
||||
|
||||
private static YamlCustomFormatSerializer<T> _serializer;
|
||||
private readonly YamlCustomFormatSerializer<T> _serializer;
|
||||
|
||||
internal DoNothing()
|
||||
{
|
||||
if (_serializer == null)
|
||||
_serializer = new YamlCustomFormatSerializer<T>(this);
|
||||
_serializer = new YamlCustomFormatSerializer<T>(this);
|
||||
}
|
||||
|
||||
public override YamlObjectSerializer.TypeSerializer GetYamlSerializer()
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace Robust.Shared.IoC
|
||||
|
||||
// To do injection of common types like components, we make DynamicMethods to do the actual injecting.
|
||||
// This is way faster than reflection and should be allocation free outside setup.
|
||||
private readonly Dictionary<Type, (InjectorDelegate @delegate, object[] services)> _injectorCache =
|
||||
new Dictionary<Type, (InjectorDelegate @delegate, object[] services)>();
|
||||
private readonly Dictionary<Type, (InjectorDelegate? @delegate, object[]? services)> _injectorCache =
|
||||
new Dictionary<Type, (InjectorDelegate? @delegate, object[]? services)>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Register<TInterface, TImplementation>(bool overwrite = false)
|
||||
@@ -151,7 +151,7 @@ namespace Robust.Shared.IoC
|
||||
|
||||
try
|
||||
{
|
||||
var instance = Activator.CreateInstance(value);
|
||||
var instance = Activator.CreateInstance(value)!;
|
||||
_services[key] = instance;
|
||||
injectList.Add(instance);
|
||||
}
|
||||
@@ -196,7 +196,7 @@ namespace Robust.Shared.IoC
|
||||
|
||||
// If @delegate is null then the type has no dependencies.
|
||||
// So running an initializer would be quite wasteful.
|
||||
@delegate?.Invoke(obj, services);
|
||||
@delegate?.Invoke(obj, services!);
|
||||
}
|
||||
|
||||
private void InjectDependenciesReflection(object obj)
|
||||
|
||||
@@ -76,10 +76,7 @@ namespace Robust.Shared.IoC
|
||||
{
|
||||
// https://blog.ploeh.dk/2012/03/15/ImplementinganAbstractFactory/
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency]
|
||||
private readonly IDependencyCollection _dependencies;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IDependencyCollection _dependencies = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public object CreateInstance(Type type)
|
||||
@@ -87,7 +84,7 @@ namespace Robust.Shared.IoC
|
||||
if (type == null)
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
|
||||
var instance = Activator.CreateInstance(type);
|
||||
var instance = Activator.CreateInstance(type)!;
|
||||
_dependencies.InjectDependencies(instance);
|
||||
return instance;
|
||||
}
|
||||
@@ -97,7 +94,7 @@ namespace Robust.Shared.IoC
|
||||
if (type == null)
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
|
||||
var instance = Activator.CreateInstance(type, args);
|
||||
var instance = Activator.CreateInstance(type, args)!;
|
||||
_dependencies.InjectDependencies(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace Robust.Shared.IoC.Exceptions
|
||||
/// <summary>
|
||||
/// The <see cref="Type.AssemblyQualifiedName" /> of the type that threw the exception inside its constructor.
|
||||
/// </summary>
|
||||
public readonly string typeName;
|
||||
public readonly string? typeName;
|
||||
|
||||
public ImplementationConstructorException(Type type, Exception inner)
|
||||
public ImplementationConstructorException(Type type, Exception? inner)
|
||||
: base($"{type} threw an exception inside its constructor.", inner)
|
||||
{
|
||||
typeName = type.AssemblyQualifiedName;
|
||||
|
||||
@@ -13,17 +13,17 @@ namespace Robust.Shared.IoC.Exceptions
|
||||
/// <summary>
|
||||
/// The type name of the type requesting the unregistered dependency.
|
||||
/// </summary>
|
||||
public readonly string OwnerType;
|
||||
public readonly string? OwnerType;
|
||||
|
||||
/// <summary>
|
||||
/// The type name of the type that was requested and unregistered.
|
||||
/// </summary>
|
||||
public readonly string TargetType;
|
||||
public readonly string? TargetType;
|
||||
|
||||
/// <summary>
|
||||
/// The name of the field that was marked as dependency.
|
||||
/// </summary>
|
||||
public readonly string FieldName;
|
||||
public readonly string? FieldName;
|
||||
|
||||
public UnregisteredDependencyException(Type owner, Type target, string fieldName)
|
||||
: base(string.Format("{0} requested unregistered type with its field {1}: {2}",
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Robust.Shared.IoC.Exceptions
|
||||
/// <summary>
|
||||
/// The actual type that was attempted to be resolved, but wasn't registered. This is the <see cref="Type.AssemblyQualifiedName"/>.
|
||||
/// </summary>
|
||||
public readonly string TypeName;
|
||||
public readonly string? TypeName;
|
||||
|
||||
public UnregisteredTypeException(Type type) : base($"Attempted to resolve unregistered type: {type}")
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Robust.Shared.IoC
|
||||
{
|
||||
DebugTools.Assert(_container.IsValueCreated, NoContextAssert);
|
||||
|
||||
_container.Value.Register<TInterface, TImplementation>(overwrite);
|
||||
_container.Value!.Register<TInterface, TImplementation>(overwrite);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -97,7 +97,7 @@ namespace Robust.Shared.IoC
|
||||
{
|
||||
DebugTools.Assert(_container.IsValueCreated, NoContextAssert);
|
||||
|
||||
_container.Value.RegisterInstance<TInterface>(implementation, overwrite);
|
||||
_container.Value!.RegisterInstance<TInterface>(implementation, overwrite);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,7 +108,7 @@ namespace Robust.Shared.IoC
|
||||
public static void Clear()
|
||||
{
|
||||
if (_container.IsValueCreated)
|
||||
_container.Value.Clear();
|
||||
_container.Value!.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,7 +124,7 @@ namespace Robust.Shared.IoC
|
||||
{
|
||||
DebugTools.Assert(_container.IsValueCreated, NoContextAssert);
|
||||
|
||||
return _container.Value.Resolve<T>();
|
||||
return _container.Value!.Resolve<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -140,7 +140,7 @@ namespace Robust.Shared.IoC
|
||||
{
|
||||
DebugTools.Assert(_container.IsValueCreated, NoContextAssert);
|
||||
|
||||
return _container.Value.ResolveType(type);
|
||||
return _container.Value!.ResolveType(type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -151,7 +151,7 @@ namespace Robust.Shared.IoC
|
||||
{
|
||||
DebugTools.Assert(_container.IsValueCreated, NoContextAssert);
|
||||
|
||||
_container.Value.BuildGraph();
|
||||
_container.Value!.BuildGraph();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -166,10 +166,10 @@ namespace Robust.Shared.IoC
|
||||
/// Thrown if a dependency field on the object is not registered.
|
||||
/// </exception>
|
||||
/// <seealso cref="BuildGraph"/>
|
||||
public static T InjectDependencies<T>(T obj)
|
||||
public static T InjectDependencies<T>(T obj) where T : notnull
|
||||
{
|
||||
DebugTools.Assert(_container.IsValueCreated, NoContextAssert);
|
||||
_container.Value.InjectDependencies(obj);
|
||||
_container.Value!.InjectDependencies(obj);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Robust.Shared.Localization
|
||||
/// </summary>
|
||||
public class CustomFormatCatalog : Catalog
|
||||
{
|
||||
public IFormatProvider CustomFormatProvider;
|
||||
public IFormatProvider? CustomFormatProvider;
|
||||
|
||||
public CustomFormatCatalog()
|
||||
: base()
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Robust.Shared.Localization
|
||||
/// Default culture used by other methods when no culture is explicitly specified.
|
||||
/// Changing this also changes the current thread's culture.
|
||||
/// </summary>
|
||||
CultureInfo DefaultCulture { get; set; }
|
||||
CultureInfo? DefaultCulture { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Load data for a culture.
|
||||
|
||||
@@ -14,13 +14,11 @@ namespace Robust.Shared.Localization
|
||||
{
|
||||
internal sealed class LocalizationManager : ILocalizationManager
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IResourceManager _resourceManager;
|
||||
[Dependency] private readonly ITextMacroFactory _textMacroFactory;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IResourceManager _resourceManager = default!;
|
||||
[Dependency] private readonly ITextMacroFactory _textMacroFactory = default!;
|
||||
|
||||
private readonly Dictionary<CultureInfo, Catalog> _catalogs = new Dictionary<CultureInfo, Catalog>();
|
||||
private CultureInfo _defaultCulture;
|
||||
private CultureInfo? _defaultCulture;
|
||||
|
||||
public string GetString(string text)
|
||||
{
|
||||
@@ -102,11 +100,16 @@ namespace Robust.Shared.Localization
|
||||
return catalog.GetParticularPluralString(context, text, pluralText, n, args);
|
||||
}
|
||||
|
||||
public CultureInfo DefaultCulture
|
||||
public CultureInfo? DefaultCulture
|
||||
{
|
||||
get => _defaultCulture;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
if (!_catalogs.ContainsKey(value))
|
||||
{
|
||||
throw new ArgumentException("That culture is not yet loaded and cannot be used.", nameof(value));
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Robust.Shared.Localization.Macros
|
||||
/// <summary>
|
||||
/// Helper function to get the gender of an object, or Epicene if the object is not IGenderable
|
||||
/// </summary>
|
||||
public static Gender GetGenderOrEpicene(object argument)
|
||||
public static Gender GetGenderOrEpicene(object? argument)
|
||||
{
|
||||
// FIXME The Entity special case is not really good
|
||||
if (argument is IEntity entity)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[RegisterTextMacro("they", "en")]
|
||||
public class They : ITextMacro
|
||||
{
|
||||
public string Format(object argument)
|
||||
public string Format(object? argument)
|
||||
{
|
||||
return IGenderable.GetGenderOrEpicene(argument) switch
|
||||
{
|
||||
@@ -18,7 +18,7 @@
|
||||
[RegisterTextMacro("their", "en")]
|
||||
public class Their : ITextMacro
|
||||
{
|
||||
public string Format(object argument)
|
||||
public string Format(object? argument)
|
||||
{
|
||||
return IGenderable.GetGenderOrEpicene(argument) switch
|
||||
{
|
||||
@@ -33,7 +33,7 @@
|
||||
[RegisterTextMacro("theirs", "en")]
|
||||
public class Theirs : ITextMacro
|
||||
{
|
||||
public string Format(object argument)
|
||||
public string Format(object? argument)
|
||||
{
|
||||
return IGenderable.GetGenderOrEpicene(argument) switch
|
||||
{
|
||||
@@ -48,7 +48,7 @@
|
||||
[RegisterTextMacro("them", "en")]
|
||||
public class Them : ITextMacro
|
||||
{
|
||||
public string Format(object argument)
|
||||
public string Format(object? argument)
|
||||
{
|
||||
return IGenderable.GetGenderOrEpicene(argument) switch
|
||||
{
|
||||
@@ -63,7 +63,7 @@
|
||||
[RegisterTextMacro("themself", "en")]
|
||||
public class Themself : ITextMacro
|
||||
{
|
||||
public string Format(object argument)
|
||||
public string Format(object? argument)
|
||||
{
|
||||
return IGenderable.GetGenderOrEpicene(argument) switch
|
||||
{
|
||||
@@ -78,7 +78,7 @@
|
||||
[RegisterTextMacro("theyre", "en")]
|
||||
public class Theyre : ITextMacro
|
||||
{
|
||||
public string Format(object argument)
|
||||
public string Format(object? argument)
|
||||
{
|
||||
return IGenderable.GetGenderOrEpicene(argument) switch
|
||||
{
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace Robust.Shared.Localization.Macros
|
||||
{
|
||||
public interface ITextMacro
|
||||
{
|
||||
public string Format(object argument);
|
||||
public string Format(object? argument);
|
||||
|
||||
public string CapitalizedFormat(object arg)
|
||||
public string CapitalizedFormat(object? arg)
|
||||
{
|
||||
string result = Format(arg);
|
||||
return char.ToUpper(result[0]) + result.Substring(1);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Robust.Shared.Localization.Macros
|
||||
CultureInfo = cultureInfo;
|
||||
}
|
||||
|
||||
public object GetFormat(Type formatType)
|
||||
public object? GetFormat(Type? formatType)
|
||||
{
|
||||
if (formatType == typeof(ICustomFormatter))
|
||||
return Formatter;
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace Robust.Shared.Localization.Macros
|
||||
Macros = macros;
|
||||
}
|
||||
|
||||
public string Format(string format, object arg, IFormatProvider formatProvider)
|
||||
public string Format(string? format, object? arg, IFormatProvider? formatProvider)
|
||||
{
|
||||
IFormatProvider fallbackProvider = GetFallbackFormatProvider(formatProvider);
|
||||
IFormatProvider? fallbackProvider = GetFallbackFormatProvider(formatProvider);
|
||||
|
||||
if (format == null || format == "")
|
||||
return string.Format(fallbackProvider, "{0}", arg);
|
||||
@@ -30,7 +30,7 @@ namespace Robust.Shared.Localization.Macros
|
||||
: grammarFunction.Format(arg);
|
||||
}
|
||||
|
||||
private static IFormatProvider GetFallbackFormatProvider(IFormatProvider formatProvider)
|
||||
private static IFormatProvider? GetFallbackFormatProvider(IFormatProvider? formatProvider)
|
||||
{
|
||||
if (formatProvider is MacroFormatProvider macroFormatProvider)
|
||||
return macroFormatProvider.CultureInfo;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Robust.Shared.Localization.Macros
|
||||
{
|
||||
public readonly string MacroName;
|
||||
|
||||
public readonly string LanguageTag;
|
||||
public readonly string? LanguageTag;
|
||||
|
||||
public RegisterTextMacroAttribute(string name)
|
||||
{
|
||||
|
||||
@@ -8,16 +8,14 @@ namespace Robust.Shared.Localization.Macros
|
||||
{
|
||||
public class TextMacroFactory : ITextMacroFactory
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IDynamicTypeFactory _typeFactory;
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IDynamicTypeFactory _typeFactory = default!;
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
|
||||
|
||||
private struct TextMacroRegistration
|
||||
{
|
||||
public Type MacroType;
|
||||
public string MacroName;
|
||||
public string LanguageTag;
|
||||
public string? LanguageTag;
|
||||
}
|
||||
|
||||
private IList<TextMacroRegistration> Macros = new List<TextMacroRegistration>();
|
||||
@@ -51,7 +49,7 @@ namespace Robust.Shared.Localization.Macros
|
||||
Register(name, null, macroType);
|
||||
}
|
||||
|
||||
public void Register(string name, string languageTag, Type macroType)
|
||||
public void Register(string name, string? languageTag, Type macroType)
|
||||
{
|
||||
Macros.Add(new TextMacroRegistration
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Robust.Shared.Log
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public Sawmill Parent { get; }
|
||||
public Sawmill? Parent { get; }
|
||||
|
||||
public LogLevel? Level
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace Robust.Shared.Log
|
||||
private readonly List<ILogHandler> _handlers = new List<ILogHandler>();
|
||||
private readonly ReaderWriterLockSlim _handlerLock = new ReaderWriterLockSlim();
|
||||
|
||||
public Sawmill(Sawmill parent, string name)
|
||||
public Sawmill(Sawmill? parent, string name)
|
||||
{
|
||||
Parent = parent;
|
||||
Name = name;
|
||||
@@ -62,7 +62,7 @@ namespace Robust.Shared.Log
|
||||
}
|
||||
}
|
||||
|
||||
public void Log(LogLevel level, string message, params object[] args)
|
||||
public void Log(LogLevel level, string message, params object?[] args)
|
||||
{
|
||||
Log(level, string.Format(message, args));
|
||||
}
|
||||
@@ -102,10 +102,10 @@ namespace Robust.Shared.Log
|
||||
{
|
||||
return Level.Value;
|
||||
}
|
||||
return Parent.GetPracticalLevel();
|
||||
return Parent?.GetPracticalLevel() ?? default;
|
||||
}
|
||||
|
||||
public void Debug(string message, params object[] args)
|
||||
public void Debug(string message, params object?[] args)
|
||||
{
|
||||
Log(LogLevel.Debug, message, args);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ namespace Robust.Shared.Log
|
||||
Log(LogLevel.Debug, message);
|
||||
}
|
||||
|
||||
public void Info(string message, params object[] args)
|
||||
public void Info(string message, params object?[] args)
|
||||
{
|
||||
Log(LogLevel.Info, message, args);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ namespace Robust.Shared.Log
|
||||
Log(LogLevel.Info, message);
|
||||
}
|
||||
|
||||
public void Warning(string message, params object[] args)
|
||||
public void Warning(string message, params object?[] args)
|
||||
{
|
||||
Log(LogLevel.Warning, message, args);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ namespace Robust.Shared.Log
|
||||
Log(LogLevel.Warning, message);
|
||||
}
|
||||
|
||||
public void Error(string message, params object[] args)
|
||||
public void Error(string message, params object?[] args)
|
||||
{
|
||||
Log(LogLevel.Error, message, args);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ namespace Robust.Shared.Log
|
||||
Log(LogLevel.Error, message);
|
||||
}
|
||||
|
||||
public void Fatal(string message, params object[] args)
|
||||
public void Fatal(string message, params object?[] args)
|
||||
{
|
||||
Log(LogLevel.Fatal, message, args);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Robust.Shared.Log
|
||||
/// Log a message, taking in a format string and format list using the regular <see cref="Format" /> syntax.
|
||||
/// </summary>
|
||||
[StringFormatMethod("message")]
|
||||
public static void LogS(LogLevel logLevel, string sawmillname, string message, params object[] args)
|
||||
public static void LogS(LogLevel logLevel, string sawmillname, string message, params object?[] args)
|
||||
{
|
||||
var sawmill = LogManagerSingleton.GetSawmill(sawmillname);
|
||||
sawmill.Log(logLevel, message, args);
|
||||
@@ -56,7 +56,7 @@ namespace Robust.Shared.Log
|
||||
/// Log a message, taking in a format string and format list using the regular <see cref="Format" /> syntax.
|
||||
/// </summary>
|
||||
[StringFormatMethod("message")]
|
||||
public static void Log(LogLevel logLevel, string message, params object[] args)
|
||||
public static void Log(LogLevel logLevel, string message, params object?[] args)
|
||||
{
|
||||
LogManagerSingleton.RootSawmill.Log(logLevel, message, args);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ namespace Robust.Shared.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
public static void DebugS(string sawmill, string message, params object[] args) => LogS(LogLevel.Debug, sawmill, message, args);
|
||||
public static void DebugS(string sawmill, string message, params object?[] args) => LogS(LogLevel.Debug, sawmill, message, args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as debug.
|
||||
@@ -87,7 +87,7 @@ namespace Robust.Shared.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
public static void Debug(string message, params object[] args) => Log(LogLevel.Debug, message, args);
|
||||
public static void Debug(string message, params object?[] args) => Log(LogLevel.Debug, message, args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as debug.
|
||||
@@ -100,7 +100,7 @@ namespace Robust.Shared.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
public static void InfoS(string sawmill, string message, params object[] args) => LogS(LogLevel.Info, sawmill, message, args);
|
||||
public static void InfoS(string sawmill, string message, params object?[] args) => LogS(LogLevel.Info, sawmill, message, args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as info.
|
||||
@@ -113,7 +113,7 @@ namespace Robust.Shared.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
public static void Info(string message, params object[] args) => Log(LogLevel.Info, message, args);
|
||||
public static void Info(string message, params object?[] args) => Log(LogLevel.Info, message, args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as info.
|
||||
@@ -126,7 +126,7 @@ namespace Robust.Shared.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
public static void WarningS(string sawmill, string message, params object[] args) => LogS(LogLevel.Warning, sawmill, message, args);
|
||||
public static void WarningS(string sawmill, string message, params object?[] args) => LogS(LogLevel.Warning, sawmill, message, args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as warning.
|
||||
@@ -139,7 +139,7 @@ namespace Robust.Shared.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
public static void Warning(string message, params object[] args) => Log(LogLevel.Warning, message, args);
|
||||
public static void Warning(string message, params object?[] args) => Log(LogLevel.Warning, message, args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as warning.
|
||||
@@ -152,7 +152,7 @@ namespace Robust.Shared.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
public static void ErrorS(string sawmill, string message, params object[] args) => LogS(LogLevel.Error, sawmill, message, args);
|
||||
public static void ErrorS(string sawmill, string message, params object?[] args) => LogS(LogLevel.Error, sawmill, message, args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as error.
|
||||
@@ -165,7 +165,7 @@ namespace Robust.Shared.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
public static void Error(string message, params object[] args) => Log(LogLevel.Error, message, args);
|
||||
public static void Error(string message, params object?[] args) => Log(LogLevel.Error, message, args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as error.
|
||||
@@ -178,7 +178,7 @@ namespace Robust.Shared.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
public static void FatalS(string sawmill, string message, params object[] args) => LogS(LogLevel.Fatal, sawmill, message, args);
|
||||
public static void FatalS(string sawmill, string message, params object?[] args) => LogS(LogLevel.Fatal, sawmill, message, args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as fatal.
|
||||
@@ -191,7 +191,7 @@ namespace Robust.Shared.Log
|
||||
/// </summary>
|
||||
/// <seealso cref="Log" />
|
||||
[StringFormatMethod("message")]
|
||||
public static void Fatal(string message, params object[] args) => Log(LogLevel.Fatal, message, args);
|
||||
public static void Fatal(string message, params object?[] args) => Log(LogLevel.Fatal, message, args);
|
||||
|
||||
/// <summary>
|
||||
/// Log a message as fatal.
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
return obj is GridCoordinates coords && Equals(coords);
|
||||
@@ -256,7 +256,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
return false;
|
||||
@@ -364,7 +364,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
return false;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
return obj is GridId id && Equals(id);
|
||||
|
||||
@@ -113,9 +113,9 @@ namespace Robust.Shared.Map
|
||||
/// <param name="ignoreEmpty">Will empty tiles be returned?</param>
|
||||
/// <param name="predicate">Optional predicate to filter the files.</param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<TileRef> GetTilesIntersecting(Box2 worldArea, bool ignoreEmpty = true, Predicate<TileRef> predicate = null);
|
||||
IEnumerable<TileRef> GetTilesIntersecting(Box2 worldArea, bool ignoreEmpty = true, Predicate<TileRef>? predicate = null);
|
||||
|
||||
IEnumerable<TileRef> GetTilesIntersecting(Circle worldArea, bool ignoreEmpty = true, Predicate<TileRef> predicate = null);
|
||||
IEnumerable<TileRef> GetTilesIntersecting(Circle worldArea, bool ignoreEmpty = true, Predicate<TileRef>? predicate = null);
|
||||
|
||||
#endregion TileAccess
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<TileRef> GetTilesIntersecting(Box2 worldArea, bool ignoreEmpty = true, Predicate<TileRef> predicate = null)
|
||||
public IEnumerable<TileRef> GetTilesIntersecting(Box2 worldArea, bool ignoreEmpty = true, Predicate<TileRef>? predicate = null)
|
||||
{
|
||||
//TODO: needs world -> local -> tile translations.
|
||||
var gridTileLb = new MapIndices((int)Math.Floor(worldArea.Left), (int)Math.Floor(worldArea.Bottom));
|
||||
@@ -254,7 +254,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<TileRef> GetTilesIntersecting(Circle worldArea, bool ignoreEmpty = true, Predicate<TileRef> predicate = null)
|
||||
public IEnumerable<TileRef> GetTilesIntersecting(Circle worldArea, bool ignoreEmpty = true, Predicate<TileRef>? predicate = null)
|
||||
{
|
||||
var aabb = new Box2(worldArea.Position.X - worldArea.Radius, worldArea.Position.Y - worldArea.Radius, worldArea.Position.X + worldArea.Radius, worldArea.Position.Y + worldArea.Radius);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
return obj is MapId id && Equals(id);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is MapIndices idx && Equals(idx);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,9 @@ namespace Robust.Shared.Map
|
||||
{
|
||||
internal partial class MapManager
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly INetManager _netManager;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly INetManager _netManager = default!;
|
||||
|
||||
public GameStateMapData GetStateData(GameTick fromTick)
|
||||
public GameStateMapData? GetStateData(GameTick fromTick)
|
||||
{
|
||||
var gridDatums = new Dictionary<GridId, GameStateMapData.GridDatum>();
|
||||
foreach (var grid in _grids.Values)
|
||||
@@ -111,7 +109,7 @@ namespace Robust.Shared.Map
|
||||
continue;
|
||||
}
|
||||
|
||||
var gridCreation = createdGrids[gridId];
|
||||
var gridCreation = createdGrids![gridId];
|
||||
DebugTools.Assert(gridCreation.IsTheDefault);
|
||||
|
||||
CreateMap(mapId, gridId);
|
||||
@@ -134,7 +132,7 @@ namespace Robust.Shared.Map
|
||||
continue;
|
||||
}
|
||||
|
||||
CreateGrid(gridData[gridId].Coordinates.MapId, gridId, creationDatum.ChunkSize,
|
||||
CreateGrid(gridData![gridId].Coordinates.MapId, gridId, creationDatum.ChunkSize,
|
||||
creationDatum.SnapSize);
|
||||
}
|
||||
}
|
||||
@@ -210,7 +208,7 @@ namespace Robust.Shared.Map
|
||||
var cEntity = _entityManager.GetEntity(_mapEntities[mapId]);
|
||||
|
||||
// locate the entity that represents this map that was just sent to us
|
||||
IEntity sharedMapEntity = null;
|
||||
IEntity? sharedMapEntity = null;
|
||||
var mapComps = _entityManager.ComponentManager.GetAllComponents<IMapComponent>();
|
||||
foreach (var mapComp in mapComps)
|
||||
{
|
||||
@@ -231,7 +229,7 @@ namespace Robust.Shared.Map
|
||||
// so they are not deleted
|
||||
foreach (var childGridTrans in cEntity.Transform.Children.ToList())
|
||||
{
|
||||
childGridTrans.AttachParent(sharedMapEntity);
|
||||
childGridTrans.AttachParent(sharedMapEntity!);
|
||||
}
|
||||
|
||||
// remove client entity
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
@@ -18,10 +19,8 @@ namespace Robust.Shared.Map
|
||||
/// <inheritdoc cref="IMapManager"/>
|
||||
internal partial class MapManager : IMapManagerInternal
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IGameTiming _gameTiming;
|
||||
[Dependency] private readonly IEntityManager _entityManager;
|
||||
#pragma warning restore 649
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public IGameTiming GameTiming => _gameTiming;
|
||||
|
||||
@@ -31,24 +30,24 @@ namespace Robust.Shared.Map
|
||||
public MapId DefaultMap => MapId.Nullspace;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<TileChangedEventArgs> TileChanged;
|
||||
public event EventHandler<TileChangedEventArgs>? TileChanged;
|
||||
|
||||
public event GridEventHandler OnGridCreated;
|
||||
public event GridEventHandler? OnGridCreated;
|
||||
|
||||
public event GridEventHandler OnGridRemoved;
|
||||
public event GridEventHandler? OnGridRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Should the OnTileChanged event be suppressed? This is useful for initially loading the map
|
||||
/// so that you don't spam an event for each of the million station tiles.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<GridChangedEventArgs> GridChanged;
|
||||
public event EventHandler<GridChangedEventArgs>? GridChanged;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<MapEventArgs> MapCreated;
|
||||
public event EventHandler<MapEventArgs>? MapCreated;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<MapEventArgs> MapDestroyed;
|
||||
public event EventHandler<MapEventArgs>? MapDestroyed;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SuppressOnTileChanged { get; set; }
|
||||
@@ -248,7 +247,7 @@ namespace Robust.Shared.Map
|
||||
{
|
||||
var mapComps = _entityManager.ComponentManager.GetAllComponents<IMapComponent>();
|
||||
|
||||
IMapComponent result = null;
|
||||
IMapComponent? result = null;
|
||||
foreach (var mapComp in mapComps)
|
||||
{
|
||||
if (mapComp.WorldMap != actualID)
|
||||
@@ -444,7 +443,7 @@ namespace Robust.Shared.Map
|
||||
if (actualID != GridId.Invalid && createEntity) // nullspace default grid is not bound to an entity
|
||||
{
|
||||
// the entity may already exist from map deserialization
|
||||
IMapGridComponent result = null;
|
||||
IMapGridComponent? result = null;
|
||||
foreach (var comp in _entityManager.ComponentManager.GetAllComponents<IMapGridComponent>())
|
||||
{
|
||||
if (comp.GridIndex != actualID)
|
||||
@@ -497,7 +496,7 @@ namespace Robust.Shared.Map
|
||||
return _grids[gridID];
|
||||
}
|
||||
|
||||
public bool TryGetGrid(GridId gridId, out IMapGrid grid)
|
||||
public bool TryGetGrid(GridId gridId, [NotNullWhen(true)] out IMapGrid? grid)
|
||||
{
|
||||
if (_grids.TryGetValue(gridId, out var gridinterface))
|
||||
{
|
||||
@@ -520,7 +519,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryFindGridAt(MapId mapId, Vector2 worldPos, out IMapGrid grid)
|
||||
public bool TryFindGridAt(MapId mapId, Vector2 worldPos, [NotNullWhen(true)] out IMapGrid? grid)
|
||||
{
|
||||
foreach (var mapGrid in _grids.Values)
|
||||
{
|
||||
@@ -539,7 +538,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryFindGridAt(MapCoordinates mapCoordinates, out IMapGrid grid)
|
||||
public bool TryFindGridAt(MapCoordinates mapCoordinates, [NotNullWhen(true)] out IMapGrid? grid)
|
||||
{
|
||||
return TryFindGridAt(mapCoordinates.MapId, mapCoordinates.Position, out grid);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Robust.Shared.Map
|
||||
private GridId _gridId;
|
||||
|
||||
[NonSerialized]
|
||||
private IMapGridInternal _mapGrid;
|
||||
private IMapGridInternal _mapGrid = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
return false;
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Robust.Shared.Network.Messages
|
||||
{
|
||||
public class MsgConCmd : NetMessage
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user