Enable nullability in Content.Server (#3685)
This commit is contained in:
@@ -8,8 +8,8 @@ namespace Content.Server.GameObjects.EntitySystems.AI.LoadBalancer
|
||||
public class AiActionRequest
|
||||
{
|
||||
public EntityUid EntityUid { get; }
|
||||
public Blackboard Context { get; }
|
||||
public IEnumerable<IAiUtility> Actions { get; }
|
||||
public Blackboard? Context { get; }
|
||||
public IEnumerable<IAiUtility>? Actions { get; }
|
||||
|
||||
public AiActionRequest(EntityUid uid, Blackboard context, IEnumerable<IAiUtility> actions)
|
||||
{
|
||||
|
||||
@@ -9,13 +9,14 @@ using Content.Server.AI.WorldState.States.Utility;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Content.Server.GameObjects.EntitySystems.JobQueues;
|
||||
using Content.Shared.AI;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.AI.LoadBalancer
|
||||
{
|
||||
public class AiActionRequestJob : Job<UtilityAction>
|
||||
{
|
||||
#if DEBUG
|
||||
public static event Action<SharedAiDebug.UtilityAiDebugMessage> FoundAction;
|
||||
public static event Action<SharedAiDebug.UtilityAiDebugMessage>? FoundAction;
|
||||
#endif
|
||||
private readonly AiActionRequest _request;
|
||||
|
||||
@@ -27,7 +28,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.LoadBalancer
|
||||
_request = request;
|
||||
}
|
||||
|
||||
protected override async Task<UtilityAction> Process()
|
||||
protected override async Task<UtilityAction?> Process()
|
||||
{
|
||||
if (_request.Context == null)
|
||||
{
|
||||
@@ -55,7 +56,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.LoadBalancer
|
||||
|
||||
// Use last action as the basis for the cutoff
|
||||
var cutoff = _request.Context.GetState<LastUtilityScoreState>().GetValue();
|
||||
UtilityAction foundAction = null;
|
||||
UtilityAction? foundAction = null;
|
||||
|
||||
// To see what I was trying to do watch these 2 videos about Infinite Axis Utility System (IAUS):
|
||||
// Architecture Tricks: Managing Behaviors in Time, Space, and Depth
|
||||
@@ -83,7 +84,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.LoadBalancer
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
foreach (var expanded in expandableUtilityAction.GetActions(_request.Context))
|
||||
{
|
||||
actions.Push(expanded);
|
||||
@@ -116,8 +117,12 @@ namespace Content.Server.GameObjects.EntitySystems.AI.LoadBalancer
|
||||
#if DEBUG
|
||||
if (foundAction != null)
|
||||
{
|
||||
var selfState = _request.Context.GetState<SelfState>().GetValue();
|
||||
|
||||
DebugTools.AssertNotNull(selfState);
|
||||
|
||||
FoundAction?.Invoke(new SharedAiDebug.UtilityAiDebugMessage(
|
||||
_request.Context.GetState<SelfState>().GetValue().Uid,
|
||||
selfState!.Uid,
|
||||
DebugTime,
|
||||
cutoff,
|
||||
foundAction.GetType().Name,
|
||||
|
||||
@@ -12,7 +12,6 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -40,7 +39,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
private PathfindingSystem _pathfindingSystem;
|
||||
private PathfindingSystem _pathfindingSystem = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Queued region updates
|
||||
@@ -180,7 +179,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
var targetNode = _pathfindingSystem.GetNode(targetTile);
|
||||
|
||||
var collisionMask = 0;
|
||||
if (entity.TryGetComponent(out IPhysBody physics))
|
||||
if (entity.TryGetComponent(out IPhysBody? physics))
|
||||
{
|
||||
collisionMask = physics.CollisionMask;
|
||||
}
|
||||
@@ -229,7 +228,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
var reachableArgs = ReachableArgs.GetArgs(entity);
|
||||
var reachableRegions = GetReachableRegions(reachableArgs, targetRegion);
|
||||
|
||||
return reachableRegions.Contains(entityRegion);
|
||||
return entityRegion != null && reachableRegions.Contains(entityRegion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -238,7 +237,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
/// <param name="reachableArgs"></param>
|
||||
/// <param name="region"></param>
|
||||
/// <returns></returns>
|
||||
public HashSet<PathfindingRegion> GetReachableRegions(ReachableArgs reachableArgs, PathfindingRegion region)
|
||||
public HashSet<PathfindingRegion> GetReachableRegions(ReachableArgs reachableArgs, PathfindingRegion? region)
|
||||
{
|
||||
// if we're on a node that's not tracked at all atm then region will be null
|
||||
if (region == null)
|
||||
@@ -276,7 +275,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
/// <returns></returns>
|
||||
private ReachableArgs GetCachedArgs(ReachableArgs accessibleArgs)
|
||||
{
|
||||
ReachableArgs foundArgs = null;
|
||||
ReachableArgs? foundArgs = null;
|
||||
|
||||
foreach (var (cachedAccessible, _) in _cachedAccessible)
|
||||
{
|
||||
@@ -422,7 +421,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public PathfindingRegion GetRegion(IEntity entity)
|
||||
public PathfindingRegion? GetRegion(IEntity entity)
|
||||
{
|
||||
var entityTile = _mapManager.GetGrid(entity.Transform.GridID).GetTileRef(entity.Transform.Coordinates);
|
||||
var entityNode = _pathfindingSystem.GetNode(entityTile);
|
||||
@@ -434,7 +433,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <returns></returns>
|
||||
public PathfindingRegion GetRegion(PathfindingNode node)
|
||||
public PathfindingRegion? GetRegion(PathfindingNode node)
|
||||
{
|
||||
// Not sure on the best way to optimise this
|
||||
// On the one hand, just storing each node's region is faster buuutttt muh memory
|
||||
@@ -469,7 +468,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
/// <param name="x">This is already calculated in advance so may as well re-use it</param>
|
||||
/// <param name="y">This is already calculated in advance so may as well re-use it</param>
|
||||
/// <returns></returns>
|
||||
private PathfindingRegion CalculateNode(
|
||||
private PathfindingRegion? CalculateNode(
|
||||
PathfindingNode node,
|
||||
Dictionary<PathfindingNode, PathfindingRegion> existingRegions,
|
||||
HashSet<PathfindingRegion> chunkRegions,
|
||||
@@ -499,8 +498,8 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
// Otherwise, make our own region.
|
||||
var leftNeighbor = x > 0 ? parentChunk.Nodes[x - 1, y] : null;
|
||||
var bottomNeighbor = y > 0 ? parentChunk.Nodes[x, y - 1] : null;
|
||||
PathfindingRegion leftRegion;
|
||||
PathfindingRegion bottomRegion;
|
||||
PathfindingRegion? leftRegion;
|
||||
PathfindingRegion? bottomRegion;
|
||||
|
||||
// We'll check if our left or down neighbors are already in a region and join them
|
||||
|
||||
@@ -562,7 +561,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="target"></param>
|
||||
private void MergeInto(PathfindingRegion source, PathfindingRegion target, Dictionary<PathfindingNode, PathfindingRegion> existingRegions = null)
|
||||
private void MergeInto(PathfindingRegion source, PathfindingRegion target, Dictionary<PathfindingNode, PathfindingRegion>? existingRegions = null)
|
||||
{
|
||||
DebugTools.AssertNotNull(source);
|
||||
DebugTools.AssertNotNull(target);
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
}
|
||||
|
||||
// HashSet wasn't working correctly so uhh we got this.
|
||||
public bool Equals(PathfindingRegion other)
|
||||
public bool Equals(PathfindingRegion? other)
|
||||
{
|
||||
if (other == null) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
@@ -12,11 +12,11 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
public class AStarPathfindingJob : Job<Queue<TileRef>>
|
||||
{
|
||||
#if DEBUG
|
||||
public static event Action<SharedAiDebug.AStarRouteDebug> DebugRoute;
|
||||
public static event Action<SharedAiDebug.AStarRouteDebug>? DebugRoute;
|
||||
#endif
|
||||
|
||||
private readonly PathfindingNode _startNode;
|
||||
private PathfindingNode _endNode;
|
||||
private readonly PathfindingNode? _startNode;
|
||||
private PathfindingNode? _endNode;
|
||||
private readonly PathfindingArgs _pathfindingArgs;
|
||||
|
||||
public AStarPathfindingJob(
|
||||
@@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
_pathfindingArgs = pathfindingArgs;
|
||||
}
|
||||
|
||||
protected override async Task<Queue<TileRef>> Process()
|
||||
protected override async Task<Queue<TileRef>?> Process()
|
||||
{
|
||||
if (_startNode == null ||
|
||||
_endNode == null ||
|
||||
@@ -50,7 +50,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
var costSoFar = new Dictionary<PathfindingNode, float>();
|
||||
var cameFrom = new Dictionary<PathfindingNode, PathfindingNode>();
|
||||
|
||||
PathfindingNode currentNode = null;
|
||||
PathfindingNode? currentNode = null;
|
||||
frontier.Add((0.0f, _startNode));
|
||||
costSoFar[_startNode] = 0.0f;
|
||||
var routeFound = false;
|
||||
@@ -121,7 +121,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
return null;
|
||||
}
|
||||
|
||||
var route = PathfindingHelpers.ReconstructPath(cameFrom, currentNode);
|
||||
DebugTools.AssertNotNull(currentNode);
|
||||
|
||||
var route = PathfindingHelpers.ReconstructPath(cameFrom, currentNode!);
|
||||
|
||||
if (route.Count == 1)
|
||||
{
|
||||
|
||||
@@ -16,11 +16,11 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
// Some of this is probably fugly due to other structural changes in pathfinding so it could do with optimisation
|
||||
// Realistically it's probably not getting used given it doesn't support tile costs which can be very useful
|
||||
#if DEBUG
|
||||
public static event Action<SharedAiDebug.JpsRouteDebug> DebugRoute;
|
||||
public static event Action<SharedAiDebug.JpsRouteDebug>? DebugRoute;
|
||||
#endif
|
||||
|
||||
private readonly PathfindingNode _startNode;
|
||||
private PathfindingNode _endNode;
|
||||
private readonly PathfindingNode? _startNode;
|
||||
private PathfindingNode? _endNode;
|
||||
private readonly PathfindingArgs _pathfindingArgs;
|
||||
|
||||
public JpsPathfindingJob(double maxTime,
|
||||
@@ -34,7 +34,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
_pathfindingArgs = pathfindingArgs;
|
||||
}
|
||||
|
||||
protected override async Task<Queue<TileRef>> Process()
|
||||
protected override async Task<Queue<TileRef>?> Process()
|
||||
{
|
||||
// VERY similar to A*; main difference is with the neighbor tiles you look for jump nodes instead
|
||||
if (_startNode == null ||
|
||||
@@ -58,7 +58,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
var jumpNodes = new HashSet<PathfindingNode>();
|
||||
#endif
|
||||
|
||||
PathfindingNode currentNode = null;
|
||||
PathfindingNode? currentNode = null;
|
||||
openTiles.Add((0, _startNode));
|
||||
gScores[_startNode] = 0.0f;
|
||||
var routeFound = false;
|
||||
@@ -123,7 +123,10 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
return null;
|
||||
}
|
||||
|
||||
var route = PathfindingHelpers.ReconstructJumpPath(cameFrom, currentNode);
|
||||
DebugTools.AssertNotNull(currentNode);
|
||||
|
||||
var route = PathfindingHelpers.ReconstructJumpPath(cameFrom, currentNode!);
|
||||
|
||||
if (route.Count == 1)
|
||||
{
|
||||
return null;
|
||||
@@ -153,14 +156,14 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
return route;
|
||||
}
|
||||
|
||||
private PathfindingNode GetJumpPoint(PathfindingNode currentNode, Direction direction, PathfindingNode endNode)
|
||||
private PathfindingNode? GetJumpPoint(PathfindingNode currentNode, Direction direction, PathfindingNode endNode)
|
||||
{
|
||||
var count = 0;
|
||||
|
||||
while (count < 1000)
|
||||
{
|
||||
count++;
|
||||
PathfindingNode nextNode = null;
|
||||
PathfindingNode? nextNode = null;
|
||||
foreach (var node in currentNode.GetNeighbors())
|
||||
{
|
||||
if (PathfindingHelpers.RelativeDirection(node, currentNode) == direction)
|
||||
@@ -285,10 +288,10 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
// I tried just casting direction ints and offsets to make it smaller but brain no worky.
|
||||
// From NorthEast we check (Closed / Open) S - SE, W - NW
|
||||
|
||||
PathfindingNode openNeighborOne = null;
|
||||
PathfindingNode closedNeighborOne = null;
|
||||
PathfindingNode openNeighborTwo = null;
|
||||
PathfindingNode closedNeighborTwo = null;
|
||||
PathfindingNode? openNeighborOne = null;
|
||||
PathfindingNode? closedNeighborOne = null;
|
||||
PathfindingNode? openNeighborTwo = null;
|
||||
PathfindingNode? closedNeighborTwo = null;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
@@ -400,10 +403,10 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
/// </summary>
|
||||
private bool IsCardinalJumpPoint(Direction direction, PathfindingNode currentNode)
|
||||
{
|
||||
PathfindingNode openNeighborOne = null;
|
||||
PathfindingNode closedNeighborOne = null;
|
||||
PathfindingNode openNeighborTwo = null;
|
||||
PathfindingNode closedNeighborTwo = null;
|
||||
PathfindingNode? openNeighborOne = null;
|
||||
PathfindingNode? closedNeighborOne = null;
|
||||
PathfindingNode? openNeighborTwo = null;
|
||||
PathfindingNode? closedNeighborTwo = null;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
|
||||
@@ -177,12 +177,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
return _nodes[chunkX, chunkY];
|
||||
}
|
||||
|
||||
private void CreateNode(TileRef tile, PathfindingChunk parent = null)
|
||||
private void CreateNode(TileRef tile, PathfindingChunk? parent = null)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
parent = this;
|
||||
}
|
||||
parent ??= this;
|
||||
|
||||
var node = new PathfindingNode(parent, tile);
|
||||
var offsetX = tile.X - Indices.X;
|
||||
|
||||
@@ -36,10 +36,10 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
// Given there's different collision layers stored for each node in the graph it's probably not worth it to cache this
|
||||
// Also this will help with corner-cutting
|
||||
|
||||
PathfindingNode northNeighbor = null;
|
||||
PathfindingNode southNeighbor = null;
|
||||
PathfindingNode eastNeighbor = null;
|
||||
PathfindingNode westNeighbor = null;
|
||||
PathfindingNode? northNeighbor = null;
|
||||
PathfindingNode? southNeighbor = null;
|
||||
PathfindingNode? eastNeighbor = null;
|
||||
PathfindingNode? westNeighbor = null;
|
||||
foreach (var neighbor in currentNode.GetNeighbors())
|
||||
{
|
||||
if (neighbor.TileRef.X == currentNode.TileRef.X &&
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
/// <returns></returns>
|
||||
public IEnumerable<PathfindingNode> GetNeighbors()
|
||||
{
|
||||
List<PathfindingChunk> neighborChunks = null;
|
||||
List<PathfindingChunk>? neighborChunks = null;
|
||||
if (ParentChunk.OnEdge(this))
|
||||
{
|
||||
neighborChunks = ParentChunk.RelevantChunks(this).ToList();
|
||||
@@ -80,7 +80,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
{
|
||||
DebugTools.AssertNotNull(neighborChunks);
|
||||
// Get the relevant chunk and then get the node on it
|
||||
foreach (var neighbor in neighborChunks)
|
||||
foreach (var neighbor in neighborChunks!)
|
||||
{
|
||||
// A lot of edge transitions are going to have a single neighboring chunk
|
||||
// (given > 1 only affects corners)
|
||||
@@ -96,7 +96,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
}
|
||||
}
|
||||
|
||||
public PathfindingNode GetNeighbor(Direction direction)
|
||||
public PathfindingNode? GetNeighbor(Direction direction)
|
||||
{
|
||||
var chunkXOffset = TileRef.X - ParentChunk.Indices.X;
|
||||
var chunkYOffset = TileRef.Y - ParentChunk.Indices.Y;
|
||||
@@ -266,7 +266,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
// TODO: Check for powered I think (also need an event for when it's depowered
|
||||
// AccessReader calls this whenever opening / closing but it can seem to get called multiple times
|
||||
// Which may or may not be intended?
|
||||
if (entity.TryGetComponent(out AccessReader accessReader) && !_accessReaders.ContainsKey(entity))
|
||||
if (entity.TryGetComponent(out AccessReader? accessReader) && !_accessReaders.ContainsKey(entity))
|
||||
{
|
||||
_accessReaders.Add(entity, accessReader);
|
||||
ParentChunk.Dirty();
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
}
|
||||
}
|
||||
|
||||
private void QueueGridChange(object sender, GridChangedEventArgs eventArgs)
|
||||
private void QueueGridChange(object? sender, GridChangedEventArgs eventArgs)
|
||||
{
|
||||
foreach (var (position, _) in eventArgs.Modified)
|
||||
{
|
||||
@@ -245,7 +245,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
}
|
||||
}
|
||||
|
||||
private void QueueTileChange(object sender, TileChangedEventArgs eventArgs)
|
||||
private void QueueTileChange(object? sender, TileChangedEventArgs eventArgs)
|
||||
{
|
||||
_tileUpdateQueue.Enqueue(eventArgs.NewTile);
|
||||
}
|
||||
@@ -264,7 +264,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
{
|
||||
if (entity.Deleted ||
|
||||
_lastKnownPositions.ContainsKey(entity) ||
|
||||
!entity.TryGetComponent(out IPhysBody physics) ||
|
||||
!entity.TryGetComponent(out IPhysBody? physics) ||
|
||||
!PathfindingNode.IsRelevant(entity, physics))
|
||||
{
|
||||
return;
|
||||
@@ -303,7 +303,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
{
|
||||
// If we've moved to space or the likes then remove us.
|
||||
if (moveEvent.Sender.Deleted ||
|
||||
!moveEvent.Sender.TryGetComponent(out IPhysBody physics) ||
|
||||
!moveEvent.Sender.TryGetComponent(out IPhysBody? physics) ||
|
||||
!PathfindingNode.IsRelevant(moveEvent.Sender, physics) ||
|
||||
moveEvent.NewPosition.GetGridId(EntityManager) == GridId.Invalid)
|
||||
{
|
||||
@@ -368,7 +368,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
|
||||
public bool CanTraverse(IEntity entity, PathfindingNode node)
|
||||
{
|
||||
if (entity.TryGetComponent(out IPhysBody physics) &&
|
||||
if (entity.TryGetComponent(out IPhysBody? physics) &&
|
||||
(physics.CollisionMask & node.BlockedCollisionMask) != 0)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
||||
|
||||
private PathfindingSystem _pathfindingSystem;
|
||||
private PathfindingSystem _pathfindingSystem = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Whether we try to avoid non-blocking physics objects
|
||||
@@ -127,7 +127,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
public void Unregister(IEntity entity)
|
||||
{
|
||||
if (entity.TryGetComponent(out AiControllerComponent controller))
|
||||
if (entity.TryGetComponent(out AiControllerComponent? controller))
|
||||
{
|
||||
controller.VelocityDir = Vector2.Zero;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
private SteeringStatus Steer(IEntity entity, IAiSteeringRequest steeringRequest, float frameTime)
|
||||
{
|
||||
// Main optimisation to be done below is the redundant calls and adding more variables
|
||||
if (entity.Deleted || !entity.TryGetComponent(out AiControllerComponent controller) || !ActionBlockerSystem.CanMove(entity))
|
||||
if (entity.Deleted || !entity.TryGetComponent(out AiControllerComponent? controller) || !ActionBlockerSystem.CanMove(entity))
|
||||
{
|
||||
return SteeringStatus.NoPath;
|
||||
}
|
||||
@@ -414,7 +414,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
var startTile = gridManager.GetTileRef(entity.Transform.Coordinates);
|
||||
var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid);
|
||||
var collisionMask = 0;
|
||||
if (entity.TryGetComponent(out IPhysBody physics))
|
||||
if (entity.TryGetComponent(out IPhysBody? physics))
|
||||
{
|
||||
collisionMask = physics.CollisionMask;
|
||||
}
|
||||
@@ -600,7 +600,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
return Vector2.Zero;
|
||||
}
|
||||
|
||||
if (target.TryGetComponent(out IPhysBody physics))
|
||||
if (target.TryGetComponent(out IPhysBody? physics))
|
||||
{
|
||||
var targetDistance = (targetPos.Position - entityPos.Position);
|
||||
targetPos = targetPos.Offset(physics.LinearVelocity * targetDistance);
|
||||
@@ -618,7 +618,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
/// <returns></returns>
|
||||
private Vector2 CollisionAvoidance(IEntity entity, Vector2 direction, ICollection<IEntity> ignoredTargets)
|
||||
{
|
||||
if (direction == Vector2.Zero || !entity.TryGetComponent(out IPhysBody physics))
|
||||
if (direction == Vector2.Zero || !entity.TryGetComponent(out IPhysBody? physics))
|
||||
{
|
||||
return Vector2.Zero;
|
||||
}
|
||||
@@ -659,7 +659,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
// if we're moving in the same direction then ignore
|
||||
// So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction
|
||||
// i.e. towards the right
|
||||
if (physicsEntity.TryGetComponent(out IPhysBody otherPhysics) &&
|
||||
if (physicsEntity.TryGetComponent(out IPhysBody? otherPhysics) &&
|
||||
Vector2.Dot(otherPhysics.LinearVelocity, direction) > 0)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -41,6 +41,9 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
if (highScoreEntries.Min(e => e.Score) >= entry.Score) return null;
|
||||
|
||||
var lowestHighscore = highScoreEntries.Min();
|
||||
|
||||
if (lowestHighscore == null) return null;
|
||||
|
||||
highScoreEntries.Remove(lowestHighscore);
|
||||
highScoreEntries.Add(entry);
|
||||
return GetPlacement(highScoreEntries, entry);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Prototypes.Cargo;
|
||||
using Content.Shared.GameTicking;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Cargo;
|
||||
using Content.Server.GameObjects.Components.Cargo;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Prototypes.Cargo;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
@@ -104,12 +105,12 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
/// <summary>
|
||||
/// Returns whether the account exists, eventually passing the account in the out parameter.
|
||||
/// </summary>
|
||||
public bool TryGetBankAccount(int id, out CargoBankAccount account)
|
||||
public bool TryGetBankAccount(int id, [NotNullWhen(true)] out CargoBankAccount? account)
|
||||
{
|
||||
return _accountsDict.TryGetValue(id, out account);
|
||||
}
|
||||
|
||||
public bool TryGetOrderDatabase(int id, out CargoOrderDatabase database)
|
||||
public bool TryGetOrderDatabase(int id, [NotNullWhen(true)] out CargoOrderDatabase? database)
|
||||
{
|
||||
return _databasesDict.TryGetValue(id, out database);
|
||||
}
|
||||
@@ -182,7 +183,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
foreach (var comp in ComponentManager.EntityQuery<CargoOrderDatabaseComponent>(true))
|
||||
{
|
||||
if (!comp.ConnectedToDatabase || comp.Database.Id != id)
|
||||
if (comp.Database == null || comp.Database.Id != id)
|
||||
continue;
|
||||
comp.Dirty();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
private void HandleDragDropMessage(DragDropMessage msg, EntitySessionEventArgs args)
|
||||
{
|
||||
var performer = args.SenderSession.AttachedEntity;
|
||||
|
||||
if (performer == null) return;
|
||||
if (!EntityManager.TryGetEntity(msg.Dropped, out var dropped)) return;
|
||||
if (!EntityManager.TryGetEntity(msg.Target, out var target)) return;
|
||||
|
||||
@@ -93,12 +95,12 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
}
|
||||
}
|
||||
|
||||
private bool HandleActivateItemInWorld(ICommonSession session, EntityCoordinates coords, EntityUid uid)
|
||||
private bool HandleActivateItemInWorld(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||
{
|
||||
if (!EntityManager.TryGetEntity(uid, out var used))
|
||||
return false;
|
||||
|
||||
var playerEnt = ((IPlayerSession) session).AttachedEntity;
|
||||
var playerEnt = ((IPlayerSession?) session)?.AttachedEntity;
|
||||
|
||||
if (playerEnt == null || !playerEnt.IsValid())
|
||||
{
|
||||
@@ -118,7 +120,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
/// Activates the IActivate behavior of an object
|
||||
/// Verifies that the user is capable of doing the use interaction first
|
||||
/// </summary>
|
||||
public void TryInteractionActivate(IEntity user, IEntity used)
|
||||
public void TryInteractionActivate(IEntity? user, IEntity? used)
|
||||
{
|
||||
if (user != null && used != null && ActionBlockerSystem.CanUse(user))
|
||||
{
|
||||
@@ -135,7 +137,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
return;
|
||||
}
|
||||
|
||||
if (!used.TryGetComponent(out IActivate activateComp))
|
||||
if (!used.TryGetComponent(out IActivate? activateComp))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -148,7 +150,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
}
|
||||
}
|
||||
|
||||
private bool HandleWideAttack(ICommonSession session, EntityCoordinates coords, EntityUid uid)
|
||||
private bool HandleWideAttack(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||
{
|
||||
// client sanitization
|
||||
if (!coords.IsValid(_entityManager))
|
||||
@@ -164,14 +166,14 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
return true;
|
||||
}
|
||||
|
||||
var userEntity = ((IPlayerSession) session).AttachedEntity;
|
||||
var userEntity = ((IPlayerSession?) session)?.AttachedEntity;
|
||||
|
||||
if (userEntity == null || !userEntity.IsValid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (userEntity.TryGetComponent(out CombatModeComponent combatMode) && combatMode.IsInCombatMode)
|
||||
if (userEntity.TryGetComponent(out CombatModeComponent? combatMode) && combatMode.IsInCombatMode)
|
||||
{
|
||||
DoAttack(userEntity, coords, true);
|
||||
}
|
||||
@@ -193,7 +195,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out CombatModeComponent combatMode) && combatMode.IsInCombatMode)
|
||||
if (entity.TryGetComponent(out CombatModeComponent? combatMode) && combatMode.IsInCombatMode)
|
||||
{
|
||||
DoAttack(entity, coords, false, uid);
|
||||
}
|
||||
@@ -203,7 +205,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
}
|
||||
}
|
||||
|
||||
public bool HandleClientUseItemInHand(ICommonSession session, EntityCoordinates coords, EntityUid uid)
|
||||
public bool HandleClientUseItemInHand(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||
{
|
||||
// client sanitization
|
||||
if (!coords.IsValid(_entityManager))
|
||||
@@ -219,14 +221,14 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
return true;
|
||||
}
|
||||
|
||||
var userEntity = ((IPlayerSession) session).AttachedEntity;
|
||||
var userEntity = ((IPlayerSession?) session)?.AttachedEntity;
|
||||
|
||||
if (userEntity == null || !userEntity.IsValid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (userEntity.TryGetComponent(out CombatModeComponent combat) && combat.IsInCombatMode)
|
||||
if (userEntity.TryGetComponent(out CombatModeComponent? combat) && combat.IsInCombatMode)
|
||||
DoAttack(userEntity, coords, false, uid);
|
||||
else
|
||||
UserInteraction(userEntity, coords, uid);
|
||||
@@ -234,7 +236,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool HandleTryPullObject(ICommonSession session, EntityCoordinates coords, EntityUid uid)
|
||||
private bool HandleTryPullObject(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||
{
|
||||
// client sanitization
|
||||
if (!coords.IsValid(_entityManager))
|
||||
@@ -250,7 +252,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
return false;
|
||||
}
|
||||
|
||||
var player = session.AttachedEntity;
|
||||
var player = session?.AttachedEntity;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
@@ -269,7 +271,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pulledObject.TryGetComponent(out PullableComponent pull))
|
||||
if (!pulledObject.TryGetComponent(out PullableComponent? pull))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
return Minds.ContainsValue(mind);
|
||||
}
|
||||
|
||||
public Dictionary<int, string> GetIdToUser()
|
||||
public Dictionary<int, string?> GetIdToUser()
|
||||
{
|
||||
return Minds.ToDictionary(m => m.Key, m => m.Value.CharacterName);
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
[Dependency] public readonly IRobustRandom Random = default!;
|
||||
|
||||
public AudioSystem AudioSystem { get; private set; }
|
||||
public AudioSystem AudioSystem { get; private set; } = default!;
|
||||
|
||||
public ActSystem ActSystem { get; private set; }
|
||||
public ActSystem ActSystem { get; private set; } = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
if (player.AttachedEntity == null
|
||||
|| player.AttachedEntity.Transform.GridID != gridId
|
||||
|| !player.AttachedEntity.TryGetComponent(out CameraRecoilComponent recoil))
|
||||
|| !player.AttachedEntity.TryGetComponent(out CameraRecoilComponent? recoil))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Items;
|
||||
@@ -11,7 +12,6 @@ using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Interfaces;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -57,20 +57,20 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
private static void HandleContainerModified(ContainerModifiedMessage args)
|
||||
{
|
||||
if (args.Container.Owner.TryGetComponent(out IHandsComponent handsComponent))
|
||||
if (args.Container.Owner.TryGetComponent(out IHandsComponent? handsComponent))
|
||||
{
|
||||
handsComponent.HandleSlotModifiedMaybe(args);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryGetAttachedComponent<T>(IPlayerSession session, out T component)
|
||||
private static bool TryGetAttachedComponent<T>(IPlayerSession? session, [NotNullWhen(true)] out T? component)
|
||||
where T : Component
|
||||
{
|
||||
component = default;
|
||||
|
||||
var ent = session.AttachedEntity;
|
||||
var ent = session?.AttachedEntity;
|
||||
|
||||
if (ent == null || !ent.IsValid() || !ent.TryGetComponent(out T comp))
|
||||
if (ent == null || !ent.IsValid() || !ent.TryGetComponent(out T? comp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -79,9 +79,9 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void HandleSwapHands(ICommonSession session)
|
||||
private static void HandleSwapHands(ICommonSession? session)
|
||||
{
|
||||
if (!TryGetAttachedComponent(session as IPlayerSession, out HandsComponent handsComp))
|
||||
if (!TryGetAttachedComponent(session as IPlayerSession, out HandsComponent? handsComp))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -105,14 +105,14 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private bool HandleDrop(ICommonSession session, EntityCoordinates coords, EntityUid uid)
|
||||
private bool HandleDrop(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||
{
|
||||
var ent = ((IPlayerSession) session).AttachedEntity;
|
||||
var ent = ((IPlayerSession?) session)?.AttachedEntity;
|
||||
|
||||
if (ent == null || !ent.IsValid())
|
||||
return false;
|
||||
|
||||
if (!ent.TryGetComponent(out HandsComponent handsComp))
|
||||
if (!ent.TryGetComponent(out HandsComponent? handsComp))
|
||||
return false;
|
||||
|
||||
if (handsComp.ActiveHand == null || handsComp.GetActiveHand == null)
|
||||
@@ -136,41 +136,44 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void HandleActivateItem(ICommonSession session)
|
||||
private static void HandleActivateItem(ICommonSession? session)
|
||||
{
|
||||
if (!TryGetAttachedComponent(session as IPlayerSession, out HandsComponent handsComp))
|
||||
if (!TryGetAttachedComponent(session as IPlayerSession, out HandsComponent? handsComp))
|
||||
return;
|
||||
|
||||
handsComp.ActivateItem();
|
||||
}
|
||||
|
||||
private bool HandleThrowItem(ICommonSession session, EntityCoordinates coords, EntityUid uid)
|
||||
private bool HandleThrowItem(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||
{
|
||||
var playerEnt = ((IPlayerSession)session).AttachedEntity;
|
||||
var playerEnt = ((IPlayerSession?)session)?.AttachedEntity;
|
||||
|
||||
if (playerEnt == null || !playerEnt.IsValid())
|
||||
return false;
|
||||
|
||||
if (!playerEnt.TryGetComponent(out HandsComponent handsComp))
|
||||
if (!playerEnt.TryGetComponent(out HandsComponent? handsComp))
|
||||
return false;
|
||||
|
||||
if (!handsComp.CanDrop(handsComp.ActiveHand))
|
||||
if (handsComp.ActiveHand == null || !handsComp.CanDrop(handsComp.ActiveHand))
|
||||
return false;
|
||||
|
||||
var throwEnt = handsComp.GetItem(handsComp.ActiveHand).Owner;
|
||||
var throwEnt = handsComp.GetItem(handsComp.ActiveHand)?.Owner;
|
||||
|
||||
if (throwEnt == null)
|
||||
return false;
|
||||
|
||||
if (!handsComp.ThrowItem())
|
||||
return false;
|
||||
|
||||
// throw the item, split off from a stack if it's meant to be thrown individually
|
||||
if (!throwEnt.TryGetComponent(out StackComponent stackComp) || stackComp.Count < 2 || !stackComp.ThrowIndividually)
|
||||
if (!throwEnt.TryGetComponent(out StackComponent? stackComp) || stackComp.Count < 2 || !stackComp.ThrowIndividually)
|
||||
{
|
||||
handsComp.Drop(handsComp.ActiveHand);
|
||||
}
|
||||
else
|
||||
{
|
||||
stackComp.Use(1);
|
||||
throwEnt = throwEnt.EntityManager.SpawnEntity(throwEnt.Prototype.ID, playerEnt.Transform.Coordinates);
|
||||
throwEnt = throwEnt.EntityManager.SpawnEntity(throwEnt.Prototype?.ID, playerEnt.Transform.Coordinates);
|
||||
|
||||
// can only throw one item at a time, regardless of what the prototype stack size is.
|
||||
if (throwEnt.TryGetComponent<StackComponent>(out var newStackComp))
|
||||
@@ -196,28 +199,28 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
return true;
|
||||
}
|
||||
|
||||
private void HandleSmartEquipBackpack(ICommonSession session)
|
||||
private void HandleSmartEquipBackpack(ICommonSession? session)
|
||||
{
|
||||
HandleSmartEquip(session, Slots.BACKPACK);
|
||||
}
|
||||
|
||||
private void HandleSmartEquipBelt(ICommonSession session)
|
||||
private void HandleSmartEquipBelt(ICommonSession? session)
|
||||
{
|
||||
HandleSmartEquip(session, Slots.BELT);
|
||||
}
|
||||
|
||||
private void HandleSmartEquip(ICommonSession session, Slots equipmentSlot)
|
||||
private void HandleSmartEquip(ICommonSession? session, Slots equipmentSlot)
|
||||
{
|
||||
var plyEnt = ((IPlayerSession) session).AttachedEntity;
|
||||
var plyEnt = ((IPlayerSession?) session)?.AttachedEntity;
|
||||
|
||||
if (plyEnt == null || !plyEnt.IsValid())
|
||||
return;
|
||||
|
||||
if (!plyEnt.TryGetComponent(out HandsComponent handsComp) ||
|
||||
!plyEnt.TryGetComponent(out InventoryComponent inventoryComp))
|
||||
if (!plyEnt.TryGetComponent(out HandsComponent? handsComp) ||
|
||||
!plyEnt.TryGetComponent(out InventoryComponent? inventoryComp))
|
||||
return;
|
||||
|
||||
if (!inventoryComp.TryGetSlotItem(equipmentSlot, out ItemComponent equipmentItem)
|
||||
if (!inventoryComp.TryGetSlotItem(equipmentSlot, out ItemComponent? equipmentItem)
|
||||
|| !equipmentItem.Owner.TryGetComponent<ServerStorageComponent>(out var storageComponent))
|
||||
{
|
||||
plyEnt.PopupMessage(Loc.GetString("You have no {0} to take something out of!",
|
||||
@@ -231,7 +234,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
storageComponent.PlayerInsertHeldEntity(plyEnt);
|
||||
}
|
||||
else
|
||||
else if (storageComponent.StoredEntities != null)
|
||||
{
|
||||
if (storageComponent.StoredEntities.Count == 0)
|
||||
{
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace Content.Server.GameObjects.EntitySystems.JobQueues
|
||||
/// <summary>
|
||||
/// Represents the status of this job as a regular task.
|
||||
/// </summary>
|
||||
public Task<T> AsTask { get; }
|
||||
public Task<T?> AsTask { get; }
|
||||
|
||||
public T Result { get; private set; }
|
||||
public Exception Exception { get; private set; }
|
||||
public T? Result { get; private set; }
|
||||
public Exception? Exception { get; private set; }
|
||||
protected CancellationToken Cancellation { get; }
|
||||
|
||||
public double DebugTime { get; private set; }
|
||||
@@ -34,11 +34,11 @@ namespace Content.Server.GameObjects.EntitySystems.JobQueues
|
||||
protected readonly IStopwatch StopWatch;
|
||||
|
||||
// TCS for the Task property.
|
||||
private readonly TaskCompletionSource<T> _taskTcs;
|
||||
private readonly TaskCompletionSource<T?> _taskTcs;
|
||||
|
||||
// TCS to call to resume the suspended job.
|
||||
private TaskCompletionSource<object> _resume;
|
||||
private Task _workInProgress;
|
||||
private TaskCompletionSource<object?>? _resume;
|
||||
private Task? _workInProgress;
|
||||
|
||||
protected Job(double maxTime, CancellationToken cancellation = default)
|
||||
: this(maxTime, new Stopwatch(), cancellation)
|
||||
@@ -51,7 +51,7 @@ namespace Content.Server.GameObjects.EntitySystems.JobQueues
|
||||
StopWatch = stopwatch;
|
||||
Cancellation = cancellation;
|
||||
|
||||
_taskTcs = new TaskCompletionSource<T>();
|
||||
_taskTcs = new TaskCompletionSource<T?>();
|
||||
AsTask = _taskTcs.Task;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Content.Server.GameObjects.EntitySystems.JobQueues
|
||||
{
|
||||
DebugTools.AssertNull(_resume);
|
||||
|
||||
_resume = new TaskCompletionSource<object>();
|
||||
_resume = new TaskCompletionSource<object?>();
|
||||
Status = JobStatus.Paused;
|
||||
DebugTime += StopWatch.Elapsed.TotalSeconds;
|
||||
return _resume.Task;
|
||||
@@ -99,7 +99,7 @@ namespace Content.Server.GameObjects.EntitySystems.JobQueues
|
||||
|
||||
// Immediately block on resume so that everything stays correct.
|
||||
Status = JobStatus.Paused;
|
||||
_resume = new TaskCompletionSource<object>();
|
||||
_resume = new TaskCompletionSource<object?>();
|
||||
|
||||
await _resume.Task;
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Content.Server.GameObjects.EntitySystems.JobQueues
|
||||
await task;
|
||||
|
||||
// Immediately block on resume so that everything stays correct.
|
||||
_resume = new TaskCompletionSource<object>();
|
||||
_resume = new TaskCompletionSource<object?>();
|
||||
Status = JobStatus.Paused;
|
||||
|
||||
await _resume.Task;
|
||||
@@ -144,11 +144,11 @@ namespace Content.Server.GameObjects.EntitySystems.JobQueues
|
||||
|
||||
if (Cancellation.IsCancellationRequested)
|
||||
{
|
||||
resume.TrySetCanceled();
|
||||
resume?.TrySetCanceled();
|
||||
}
|
||||
else
|
||||
{
|
||||
resume.SetResult(null);
|
||||
resume?.SetResult(null);
|
||||
}
|
||||
|
||||
if (Status != JobStatus.Finished && Status != JobStatus.Waiting)
|
||||
@@ -158,7 +158,7 @@ namespace Content.Server.GameObjects.EntitySystems.JobQueues
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Task<T> Process();
|
||||
protected abstract Task<T?> Process();
|
||||
|
||||
private async Task ProcessWrap()
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
private void RotateEvent(RotateEvent ev)
|
||||
{
|
||||
if (!ev.Sender.TryGetComponent(out NodeContainerComponent container))
|
||||
if (!ev.Sender.TryGetComponent(out NodeContainerComponent? container))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
mapManager.TileChanged -= HandleTileChanged;
|
||||
}
|
||||
|
||||
private void HandleTileChanged(object sender, TileChangedEventArgs eventArgs)
|
||||
private void HandleTileChanged(object? sender, TileChangedEventArgs eventArgs)
|
||||
{
|
||||
// If this gets hammered you could probably queue up all the tile changes every tick but I doubt that would ever happen.
|
||||
foreach (var (puddle, snapGrid) in ComponentManager.EntityQuery<PuddleComponent, SnapGridComponent>(true))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Content.Server.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Interfaces;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -9,14 +9,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
[UsedImplicitly]
|
||||
public class RadioSystem : EntitySystem
|
||||
{
|
||||
private List<string> _messages;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_messages = new List<string>();
|
||||
}
|
||||
private readonly List<string> _messages = new();
|
||||
|
||||
public void SpreadMessage(IRadio source, IEntity speaker, string message, int channel)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
_servers.Remove(server);
|
||||
}
|
||||
|
||||
public ResearchServerComponent GetServerById(int id)
|
||||
public ResearchServerComponent? GetServerById(int id)
|
||||
{
|
||||
foreach (var server in Servers)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Threading;
|
||||
using Content.Server.Interfaces.Chat;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Shared.GameTicking;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -33,16 +32,16 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
public TimeSpan CallCooldown { get; } = TimeSpan.FromSeconds(30);
|
||||
|
||||
public delegate void RoundEndCountdownStarted();
|
||||
public event RoundEndCountdownStarted OnRoundEndCountdownStarted;
|
||||
public event RoundEndCountdownStarted? OnRoundEndCountdownStarted;
|
||||
|
||||
public delegate void RoundEndCountdownCancelled();
|
||||
public event RoundEndCountdownCancelled OnRoundEndCountdownCancelled;
|
||||
public event RoundEndCountdownCancelled? OnRoundEndCountdownCancelled;
|
||||
|
||||
public delegate void RoundEndCountdownFinished();
|
||||
public event RoundEndCountdownFinished OnRoundEndCountdownFinished;
|
||||
public event RoundEndCountdownFinished? OnRoundEndCountdownFinished;
|
||||
|
||||
public delegate void CallCooldownEnded();
|
||||
public event CallCooldownEnded OnCallCooldownEnded;
|
||||
public event CallCooldownEnded? OnCallCooldownEnded;
|
||||
|
||||
void IResettingEntitySystem.Reset()
|
||||
{
|
||||
|
||||
@@ -12,14 +12,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
public class SignalLinkerSystem : EntitySystem
|
||||
{
|
||||
private Dictionary<NetUserId, SignalTransmitterComponent> _transmitters;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_transmitters = new Dictionary<NetUserId, SignalTransmitterComponent>();
|
||||
}
|
||||
private readonly Dictionary<NetUserId, SignalTransmitterComponent?> _transmitters = new();
|
||||
|
||||
public bool SignalLinkerKeybind(NetUserId id, bool? enable)
|
||||
{
|
||||
@@ -35,7 +28,9 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
if (_transmitters.Count == 0)
|
||||
{
|
||||
CommandBinds.Builder
|
||||
.BindBefore(EngineKeyFunctions.Use, new PointerInputCmdHandler(HandleUse), typeof(InteractionSystem))
|
||||
.BindBefore(EngineKeyFunctions.Use,
|
||||
new PointerInputCmdHandler(HandleUse),
|
||||
typeof(InteractionSystem))
|
||||
.Register<SignalLinkerSystem>();
|
||||
}
|
||||
|
||||
@@ -59,8 +54,13 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
return enable.Value;
|
||||
}
|
||||
|
||||
private bool HandleUse(ICommonSession session, EntityCoordinates coords, EntityUid uid)
|
||||
private bool HandleUse(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||
{
|
||||
if (session?.AttachedEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_transmitters.TryGetValue(session.UserId, out var signalTransmitter))
|
||||
{
|
||||
return false;
|
||||
@@ -88,6 +88,5 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,14 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
|
||||
{
|
||||
private const string RadiationPrototype = "RadiationPulse";
|
||||
|
||||
public IEntity RadiationPulse(EntityCoordinates coordinates, float range, int dps, bool decay = true, float minPulseLifespan = 0.8f, float maxPulseLifespan = 2.5f, string sound = null)
|
||||
public IEntity RadiationPulse(
|
||||
EntityCoordinates coordinates,
|
||||
float range,
|
||||
int dps,
|
||||
bool decay = true,
|
||||
float minPulseLifespan = 0.8f,
|
||||
float maxPulseLifespan = 2.5f,
|
||||
string? sound = null)
|
||||
{
|
||||
var radiationEntity = EntityManager.SpawnEntity(RadiationPrototype, coordinates);
|
||||
var radiation = radiationEntity.GetComponent<RadiationPulseComponent>();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.EntitySystems.Click;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -34,7 +33,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
var oldParentEntity = message.Container.Owner;
|
||||
|
||||
if (oldParentEntity.TryGetComponent(out ServerStorageComponent storageComp))
|
||||
if (oldParentEntity.TryGetComponent(out ServerStorageComponent? storageComp))
|
||||
{
|
||||
storageComp.HandleEntityMaybeRemoved(message);
|
||||
}
|
||||
@@ -44,7 +43,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
var oldParentEntity = message.Container.Owner;
|
||||
|
||||
if (oldParentEntity.TryGetComponent(out ServerStorageComponent storageComp))
|
||||
if (oldParentEntity.TryGetComponent(out ServerStorageComponent? storageComp))
|
||||
{
|
||||
storageComp.HandleEntityMaybeInserted(message);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
public class TimerTriggerEventArgs : EventArgs
|
||||
{
|
||||
public TimerTriggerEventArgs(IEntity user, IEntity source)
|
||||
{
|
||||
User = user;
|
||||
Source = source;
|
||||
}
|
||||
|
||||
public IEntity User { get; set; }
|
||||
public IEntity Source { get; set; }
|
||||
}
|
||||
@@ -31,11 +37,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
Timer.Spawn(delay, () =>
|
||||
{
|
||||
var timerTriggerEventArgs = new TimerTriggerEventArgs
|
||||
{
|
||||
User = user,
|
||||
Source = trigger
|
||||
};
|
||||
var timerTriggerEventArgs = new TimerTriggerEventArgs(user, trigger);
|
||||
var timerTriggers = trigger.GetAllComponents<ITimerTrigger>().ToList();
|
||||
|
||||
foreach (var timerTrigger in timerTriggers)
|
||||
|
||||
@@ -97,13 +97,13 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
private void EntParentChanged(EntParentChangedMessage ev)
|
||||
{
|
||||
if (!ev.Entity.TryGetComponent(out ServerAlertsComponent status))
|
||||
if (!ev.Entity.TryGetComponent(out ServerAlertsComponent? status))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev.OldParent != null &&
|
||||
ev.OldParent.TryGetComponent(out IMapGridComponent mapGrid))
|
||||
ev.OldParent.TryGetComponent(out IMapGridComponent? mapGrid))
|
||||
{
|
||||
var oldGrid = mapGrid.GridIndex;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared.GameTicking;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -11,7 +12,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
[ViewVariables] private readonly Dictionary<string, WireLayout> _layouts =
|
||||
new();
|
||||
|
||||
public bool TryGetLayout(string id, out WireLayout layout)
|
||||
public bool TryGetLayout(string id, [NotNullWhen(true)] out WireLayout? layout)
|
||||
{
|
||||
return _layouts.TryGetValue(id, out layout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user