Fix namespaces and optimize imports (#1651)
* Fix namespaces and optimize imports * Cleanup fixes * Merge conflict fixes * Merge conflict fixes * Merge conflict fixes
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Access;
|
||||
using Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders;
|
||||
using Content.Server.GameObjects.EntitySystems.Pathfinding;
|
||||
using Content.Shared.AI;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -75,7 +73,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
// Plus this way we can check if everything is equal except for vision so an entity with a lower vision radius can use an entity with a higher vision radius' cached result
|
||||
private Dictionary<ReachableArgs, Dictionary<PathfindingRegion, (TimeSpan CacheTime, HashSet<PathfindingRegion> Regions)>> _cachedAccessible =
|
||||
new Dictionary<ReachableArgs, Dictionary<PathfindingRegion, (TimeSpan, HashSet<PathfindingRegion>)>>();
|
||||
|
||||
|
||||
private readonly List<PathfindingRegion> _queuedCacheDeletions = new List<PathfindingRegion>();
|
||||
|
||||
#if DEBUG
|
||||
@@ -91,7 +89,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
#endif
|
||||
_mapmanager.OnGridRemoved += GridRemoved;
|
||||
}
|
||||
|
||||
|
||||
private void GridRemoved(GridId gridId)
|
||||
{
|
||||
_regions.Remove(gridId);
|
||||
@@ -457,7 +455,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
/// <param name="y">This is already calculated in advance so may as well re-use it</param>
|
||||
/// <returns></returns>
|
||||
private PathfindingRegion CalculateNode(
|
||||
PathfindingNode node,
|
||||
PathfindingNode node,
|
||||
Dictionary<PathfindingNode, PathfindingRegion> existingRegions,
|
||||
HashSet<PathfindingRegion> chunkRegions,
|
||||
int x, int y)
|
||||
@@ -497,15 +495,15 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
!leftRegion.IsDoor)
|
||||
{
|
||||
// We'll try and connect the left node's region to the bottom region if they're separate (yay merge)
|
||||
if (bottomNeighbor != null &&
|
||||
if (bottomNeighbor != null &&
|
||||
existingRegions.TryGetValue(bottomNeighbor, out bottomRegion) &&
|
||||
bottomRegion != leftRegion &&
|
||||
bottomRegion != leftRegion &&
|
||||
!bottomRegion.IsDoor)
|
||||
{
|
||||
bottomRegion.Add(node);
|
||||
existingRegions.Add(node, bottomRegion);
|
||||
MergeInto(leftRegion, bottomRegion, existingRegions);
|
||||
|
||||
|
||||
// Cleanup leftRegion
|
||||
// MergeInto will remove it from the overall region chunk cache while we need to remove it from
|
||||
// our short-term ones (chunkRegions and existingRegions)
|
||||
@@ -515,7 +513,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
{
|
||||
existingRegions[leftNode] = bottomRegion;
|
||||
}
|
||||
|
||||
|
||||
return bottomRegion;
|
||||
}
|
||||
|
||||
@@ -549,7 +547,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);
|
||||
@@ -586,7 +584,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
private void ClearCache(PathfindingRegion region)
|
||||
{
|
||||
DebugTools.Assert(region.Deleted);
|
||||
|
||||
|
||||
// Need to forcibly clear cache for ourself and anything that includes us
|
||||
foreach (var (_, cachedRegions) in _cachedAccessible)
|
||||
{
|
||||
@@ -599,7 +597,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
// We could just have GetVisionAccessible remove us if it can tell we're deleted but that
|
||||
// seems like it could be unreliable
|
||||
var regionsToClear = new List<PathfindingRegion>();
|
||||
|
||||
|
||||
foreach (var (otherRegion, cache) in cachedRegions)
|
||||
{
|
||||
if (cache.Regions.Contains(region))
|
||||
@@ -613,9 +611,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
cachedRegions.Remove(otherRegion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG
|
||||
if (_regions.TryGetValue(region.ParentChunk.GridId, out var chunks) &&
|
||||
if (_regions.TryGetValue(region.ParentChunk.GridId, out var chunks) &&
|
||||
chunks.TryGetValue(region.ParentChunk, out var regions))
|
||||
{
|
||||
DebugTools.Assert(!regions.Contains(region));
|
||||
@@ -642,7 +640,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
_queuedCacheDeletions.Add(region);
|
||||
region.Shutdown();
|
||||
}
|
||||
|
||||
|
||||
_regions[chunk.GridId].Remove(chunk);
|
||||
}
|
||||
|
||||
@@ -673,7 +671,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
{
|
||||
DebugTools.Assert(!region.Deleted);
|
||||
}
|
||||
|
||||
|
||||
DebugTools.Assert(chunkRegions.Count < Math.Pow(PathfindingChunk.ChunkSize, 2));
|
||||
SendRegionsDebugMessage(chunk.GridId);
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders;
|
||||
using Content.Server.GameObjects.EntitySystems.Pathfinding;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
@@ -36,7 +35,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
{
|
||||
startNode = pathfindingSystem.GetNode(pathfindingArgs.End);
|
||||
}
|
||||
|
||||
|
||||
PathfindingNode currentNode;
|
||||
openTiles.Enqueue(startNode);
|
||||
|
||||
@@ -49,13 +48,13 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
// No distances stored so can just check closed tiles here
|
||||
if (closedTiles.Contains(neighbor.TileRef)) continue;
|
||||
closedTiles.Add(currentNode.TileRef);
|
||||
|
||||
|
||||
// So currently tileCost gets the octile distance between the 2 so we'll also use that for our range check
|
||||
var tileCost = PathfindingHelpers.GetTileCost(pathfindingArgs, startNode, neighbor);
|
||||
var direction = PathfindingHelpers.RelativeDirection(neighbor, currentNode);
|
||||
|
||||
if (tileCost == null ||
|
||||
tileCost > pathfindingArgs.Proximity ||
|
||||
|
||||
if (tileCost == null ||
|
||||
tileCost > pathfindingArgs.Proximity ||
|
||||
!PathfindingHelpers.DirectionTraversable(pathfindingArgs.CollisionMask, pathfindingArgs.Access, currentNode, direction))
|
||||
{
|
||||
continue;
|
||||
@@ -67,4 +66,4 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Content.Server.GameObjects.EntitySystems.Pathfinding;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
{
|
||||
@@ -16,7 +13,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
/// Bottom-left reference node of the region
|
||||
/// </summary>
|
||||
public PathfindingNode OriginNode { get; }
|
||||
|
||||
|
||||
// The shape may be anything within the bounds of a chunk, this is just a quick way to do a bounds-check
|
||||
|
||||
/// <summary>
|
||||
@@ -49,13 +46,13 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
{
|
||||
// Tell our neighbors we no longer exist ;-/
|
||||
var neighbors = new List<PathfindingRegion>(Neighbors);
|
||||
|
||||
|
||||
for (var i = 0; i < neighbors.Count; i++)
|
||||
{
|
||||
var neighbor = neighbors[i];
|
||||
neighbor.Neighbors.Remove(this);
|
||||
}
|
||||
|
||||
|
||||
_nodes.Clear();
|
||||
Neighbors.Clear();
|
||||
|
||||
@@ -81,7 +78,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
{
|
||||
xDistance = Math.Abs(xDistance + otherRegion.Width);
|
||||
}
|
||||
|
||||
|
||||
if (yDistance > 0)
|
||||
{
|
||||
yDistance -= Height;
|
||||
@@ -90,7 +87,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
{
|
||||
yDistance = Math.Abs(yDistance + otherRegion.Height);
|
||||
}
|
||||
|
||||
|
||||
return PathfindingHelpers.OctileDistance(xDistance, yDistance);
|
||||
}
|
||||
|
||||
@@ -121,10 +118,10 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
{
|
||||
Height = yHeight;
|
||||
}
|
||||
|
||||
|
||||
_nodes.Add(node);
|
||||
}
|
||||
|
||||
|
||||
// HashSet wasn't working correctly so uhh we got this.
|
||||
public bool Equals(PathfindingRegion other)
|
||||
{
|
||||
@@ -141,4 +138,4 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
return OriginNode.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.EntitySystems.JobQueues;
|
||||
using Content.Server.GameObjects.EntitySystems.Pathfinding;
|
||||
using Content.Shared.AI;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -55,7 +53,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
costSoFar[_startNode] = 0.0f;
|
||||
var routeFound = false;
|
||||
var count = 0;
|
||||
|
||||
|
||||
while (frontier.Count > 0)
|
||||
{
|
||||
// Handle whether we need to pause if we've taken too long
|
||||
@@ -69,7 +67,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Actual pathfinding here
|
||||
(_, currentNode) = frontier.Take();
|
||||
if (currentNode.Equals(_endNode))
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.EntitySystems.JobQueues;
|
||||
using Content.Server.GameObjects.EntitySystems.Pathfinding;
|
||||
using Content.Shared.AI;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
@@ -284,7 +282,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
// If we're going diagonally need to check all cardinals.
|
||||
// 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;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.EntitySystems.Pathfinding;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders
|
||||
{
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.EntitySystems.Pathfinding;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Interfaces.Timing;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
@@ -23,7 +20,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
Chunk = chunk;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class PathfindingChunk
|
||||
{
|
||||
public TimeSpan LastUpdate { get; private set; }
|
||||
@@ -53,7 +50,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
CreateNode(tileRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Dirty();
|
||||
}
|
||||
|
||||
@@ -71,7 +68,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
{
|
||||
var pathfindingSystem = EntitySystem.Get<PathfindingSystem>();
|
||||
var chunkGrid = pathfindingSystem.Graph[GridId];
|
||||
|
||||
|
||||
for (var x = -1; x <= 1; x++)
|
||||
{
|
||||
for (var y = -1; y <= 1; y++)
|
||||
@@ -159,7 +156,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
}
|
||||
|
||||
yield break;
|
||||
|
||||
|
||||
}
|
||||
// South edge
|
||||
if (node.TileRef.Y == _indices.Y)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Access;
|
||||
using Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible;
|
||||
using Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders;
|
||||
using Content.Server.GameObjects.EntitySystems.Pathfinding;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -38,40 +36,40 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
// If it's a diagonal we need to check NSEW to see if we can get to it and stop corner cutting, NE needs N and E etc.
|
||||
// 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;
|
||||
foreach (var neighbor in currentNode.GetNeighbors())
|
||||
{
|
||||
if (neighbor.TileRef.X == currentNode.TileRef.X &&
|
||||
if (neighbor.TileRef.X == currentNode.TileRef.X &&
|
||||
neighbor.TileRef.Y == currentNode.TileRef.Y + 1)
|
||||
{
|
||||
northNeighbor = neighbor;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (neighbor.TileRef.X == currentNode.TileRef.X + 1 &&
|
||||
}
|
||||
|
||||
if (neighbor.TileRef.X == currentNode.TileRef.X + 1 &&
|
||||
neighbor.TileRef.Y == currentNode.TileRef.Y)
|
||||
{
|
||||
eastNeighbor = neighbor;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (neighbor.TileRef.X == currentNode.TileRef.X &&
|
||||
|
||||
if (neighbor.TileRef.X == currentNode.TileRef.X &&
|
||||
neighbor.TileRef.Y == currentNode.TileRef.Y - 1)
|
||||
{
|
||||
southNeighbor = neighbor;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (neighbor.TileRef.X == currentNode.TileRef.X - 1 &&
|
||||
}
|
||||
|
||||
if (neighbor.TileRef.X == currentNode.TileRef.X - 1 &&
|
||||
neighbor.TileRef.Y == currentNode.TileRef.Y)
|
||||
{
|
||||
westNeighbor = neighbor;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (direction)
|
||||
@@ -130,7 +128,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static Queue<TileRef> ReconstructPath(Dictionary<PathfindingNode, PathfindingNode> cameFrom, PathfindingNode current)
|
||||
{
|
||||
var running = new Stack<TileRef>();
|
||||
@@ -244,7 +242,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
|
||||
return 1.4f * dstX + (dstY - dstX);
|
||||
}
|
||||
|
||||
|
||||
public static float OctileDistance(TileRef endTile, TileRef startTile)
|
||||
{
|
||||
// "Fast Euclidean" / octile.
|
||||
|
||||
@@ -3,16 +3,13 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Access;
|
||||
using Content.Server.GameObjects.Components.Doors;
|
||||
using Content.Server.GameObjects.EntitySystems.AI.Pathfinding;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
{
|
||||
public class PathfindingNode
|
||||
{
|
||||
@@ -20,7 +17,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
private readonly PathfindingChunk _parentChunk;
|
||||
|
||||
public TileRef TileRef { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Whenever there's a change in the collision layers we update the mask as the graph has more reads than writes
|
||||
/// </summary>
|
||||
@@ -46,7 +43,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
|
||||
public static bool IsRelevant(IEntity entity, ICollidableComponent collidableComponent)
|
||||
{
|
||||
if (entity.Transform.GridID == GridId.Invalid ||
|
||||
if (entity.Transform.GridID == GridId.Invalid ||
|
||||
(PathfindingSystem.TrackedCollisionLayers & collidableComponent.CollisionLayer) == 0)
|
||||
{
|
||||
return false;
|
||||
@@ -66,7 +63,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
{
|
||||
neighborChunks = ParentChunk.RelevantChunks(this).ToList();
|
||||
}
|
||||
|
||||
|
||||
for (var x = -1; x <= 1; x++)
|
||||
{
|
||||
for (var y = -1; y <= 1; y++)
|
||||
@@ -112,7 +109,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
{
|
||||
return ParentChunk.Nodes[chunkXOffset + 1, chunkYOffset];
|
||||
}
|
||||
|
||||
|
||||
neighborMapIndices = new MapIndices(TileRef.X + 1, TileRef.Y);
|
||||
foreach (var neighbor in ParentChunk.GetNeighbors())
|
||||
{
|
||||
@@ -129,7 +126,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
{
|
||||
return ParentChunk.Nodes[chunkXOffset + 1, chunkYOffset + 1];
|
||||
}
|
||||
|
||||
|
||||
neighborMapIndices = new MapIndices(TileRef.X + 1, TileRef.Y + 1);
|
||||
foreach (var neighbor in ParentChunk.GetNeighbors())
|
||||
{
|
||||
@@ -146,7 +143,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
{
|
||||
return ParentChunk.Nodes[chunkXOffset, chunkYOffset + 1];
|
||||
}
|
||||
|
||||
|
||||
neighborMapIndices = new MapIndices(TileRef.X, TileRef.Y + 1);
|
||||
foreach (var neighbor in ParentChunk.GetNeighbors())
|
||||
{
|
||||
@@ -163,7 +160,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
{
|
||||
return ParentChunk.Nodes[chunkXOffset - 1, chunkYOffset + 1];
|
||||
}
|
||||
|
||||
|
||||
neighborMapIndices = new MapIndices(TileRef.X - 1, TileRef.Y + 1);
|
||||
foreach (var neighbor in ParentChunk.GetNeighbors())
|
||||
{
|
||||
@@ -180,7 +177,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
{
|
||||
return ParentChunk.Nodes[chunkXOffset - 1, chunkYOffset];
|
||||
}
|
||||
|
||||
|
||||
neighborMapIndices = new MapIndices(TileRef.X - 1, TileRef.Y);
|
||||
foreach (var neighbor in ParentChunk.GetNeighbors())
|
||||
{
|
||||
@@ -197,7 +194,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
{
|
||||
return ParentChunk.Nodes[chunkXOffset - 1, chunkYOffset - 1];
|
||||
}
|
||||
|
||||
|
||||
neighborMapIndices = new MapIndices(TileRef.X - 1, TileRef.Y - 1);
|
||||
foreach (var neighbor in ParentChunk.GetNeighbors())
|
||||
{
|
||||
@@ -214,7 +211,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
{
|
||||
return ParentChunk.Nodes[chunkXOffset, chunkYOffset - 1];
|
||||
}
|
||||
|
||||
|
||||
neighborMapIndices = new MapIndices(TileRef.X, TileRef.Y - 1);
|
||||
foreach (var neighbor in ParentChunk.GetNeighbors())
|
||||
{
|
||||
@@ -231,7 +228,7 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
{
|
||||
return ParentChunk.Nodes[chunkXOffset + 1, chunkYOffset - 1];
|
||||
}
|
||||
|
||||
|
||||
neighborMapIndices = new MapIndices(TileRef.X + 1, TileRef.Y - 1);
|
||||
foreach (var neighbor in ParentChunk.GetNeighbors())
|
||||
{
|
||||
@@ -276,9 +273,9 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
DebugTools.Assert((PathfindingSystem.TrackedCollisionLayers & collidableComponent.CollisionLayer) != 0);
|
||||
|
||||
|
||||
if (!collidableComponent.Anchored)
|
||||
{
|
||||
_physicsLayers.Add(entity, collidableComponent.CollisionLayer);
|
||||
@@ -304,12 +301,12 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
if (_physicsLayers.ContainsKey(entity))
|
||||
{
|
||||
_physicsLayers.Remove(entity);
|
||||
}
|
||||
}
|
||||
else if (_accessReaders.ContainsKey(entity))
|
||||
{
|
||||
_accessReaders.Remove(entity);
|
||||
ParentChunk.Dirty();
|
||||
}
|
||||
}
|
||||
else if (_blockedCollidables.ContainsKey(entity))
|
||||
{
|
||||
_blockedCollidables.Remove(entity);
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Content.Server.GameObjects.Components.Access;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders;
|
||||
using Content.Server.GameObjects.EntitySystems.JobQueues;
|
||||
using Content.Server.GameObjects.EntitySystems.JobQueues.Queues;
|
||||
using Content.Server.GameObjects.EntitySystems.Pathfinding;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
@@ -275,9 +271,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
/// <param name="entity"></param>
|
||||
private void HandleEntityAdd(IEntity entity)
|
||||
{
|
||||
if (entity.Deleted ||
|
||||
if (entity.Deleted ||
|
||||
_lastKnownPositions.ContainsKey(entity) ||
|
||||
!entity.TryGetComponent(out ICollidableComponent collidableComponent) ||
|
||||
!entity.TryGetComponent(out ICollidableComponent collidableComponent) ||
|
||||
!PathfindingNode.IsRelevant(entity, collidableComponent))
|
||||
{
|
||||
return;
|
||||
@@ -315,23 +311,23 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
private void HandleEntityMove(MoveEvent moveEvent)
|
||||
{
|
||||
// If we've moved to space or the likes then remove us.
|
||||
if (moveEvent.Sender.Deleted ||
|
||||
if (moveEvent.Sender.Deleted ||
|
||||
!moveEvent.Sender.TryGetComponent(out ICollidableComponent collidableComponent) ||
|
||||
!PathfindingNode.IsRelevant(moveEvent.Sender, collidableComponent))
|
||||
{
|
||||
HandleEntityRemove(moveEvent.Sender);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Memory leak protection until grid parenting confirmed fix / you REALLY need the performance
|
||||
var gridBounds = _mapManager.GetGrid(moveEvent.Sender.Transform.GridID).WorldBounds;
|
||||
|
||||
|
||||
if (!gridBounds.Contains(moveEvent.Sender.Transform.WorldPosition))
|
||||
{
|
||||
HandleEntityRemove(moveEvent.Sender);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// If we move from space to a grid we may need to start tracking it.
|
||||
if (!_lastKnownPositions.TryGetValue(moveEvent.Sender, out var oldNode))
|
||||
{
|
||||
@@ -342,7 +338,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
// The pathfinding graph is tile-based so first we'll check if they're on a different tile and if we need to update.
|
||||
// If you get entities bigger than 1 tile wide you'll need some other system so god help you.
|
||||
var newTile = _mapManager.GetGrid(moveEvent.NewPosition.GridID).GetTileRef(moveEvent.NewPosition);
|
||||
|
||||
|
||||
if (oldNode == null || oldNode.TileRef == newTile)
|
||||
{
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user