Content update for NetEntities (#18935)

This commit is contained in:
metalgearsloth
2023-09-11 09:42:41 +10:00
committed by GitHub
parent 389c8d1a2c
commit 5a0fc68be2
526 changed files with 3058 additions and 2215 deletions

View File

@@ -60,8 +60,8 @@ namespace Content.Client.NPC
private PathfindingDebugMode _modes = PathfindingDebugMode.None;
// It's debug data IDC if it doesn't support snapshots I just want something fast.
public Dictionary<EntityUid, Dictionary<Vector2i, List<PathfindingBreadcrumb>>> Breadcrumbs = new();
public Dictionary<EntityUid, Dictionary<Vector2i, Dictionary<Vector2i, List<DebugPathPoly>>>> Polys = new();
public Dictionary<NetEntity, Dictionary<Vector2i, List<PathfindingBreadcrumb>>> Breadcrumbs = new();
public Dictionary<NetEntity, Dictionary<Vector2i, Dictionary<Vector2i, List<DebugPathPoly>>>> Polys = new();
public readonly List<(TimeSpan Time, PathRouteMessage Message)> Routes = new();
public override void Initialize()
@@ -184,7 +184,9 @@ namespace Content.Client.NPC
foreach (var grid in _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb))
{
if (found || !_system.Breadcrumbs.TryGetValue(grid.Owner, out var crumbs) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform))
var netGrid = _entManager.GetNetEntity(grid.Owner);
if (found || !_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform))
continue;
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
@@ -257,7 +259,7 @@ namespace Content.Client.NPC
if (!_mapManager.TryFindGridAt(mouseWorldPos, out var gridUid, out var grid) || !xformQuery.TryGetComponent(gridUid, out var gridXform))
return;
if (!_system.Polys.TryGetValue(gridUid, out var data))
if (!_system.Polys.TryGetValue(_entManager.GetNetEntity(gridUid), out var data))
return;
var tileRef = grid.GetTileRef(mouseWorldPos);
@@ -333,7 +335,9 @@ namespace Content.Client.NPC
{
foreach (var grid in _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb))
{
if (!_system.Breadcrumbs.TryGetValue(grid.Owner, out var crumbs) ||
var netGrid = _entManager.GetNetEntity(grid.Owner);
if (!_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) ||
!xformQuery.TryGetComponent(grid.Owner, out var gridXform))
{
continue;
@@ -390,7 +394,9 @@ namespace Content.Client.NPC
{
foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, aabb))
{
if (!_system.Polys.TryGetValue(grid.Owner, out var data) ||
var netGrid = _entManager.GetNetEntity(grid.Owner);
if (!_system.Polys.TryGetValue(netGrid, out var data) ||
!xformQuery.TryGetComponent(grid.Owner, out var gridXform))
continue;
@@ -424,7 +430,9 @@ namespace Content.Client.NPC
{
foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, aabb))
{
if (!_system.Polys.TryGetValue(grid.Owner, out var data) ||
var netGrid = _entManager.GetNetEntity(grid.Owner);
if (!_system.Polys.TryGetValue(netGrid, out var data) ||
!xformQuery.TryGetComponent(grid.Owner, out var gridXform))
continue;
@@ -450,10 +458,10 @@ namespace Content.Client.NPC
Color color;
Vector2 neighborPos;
if (neighborPoly.EntityId != poly.GraphUid)
if (neighborPoly.NetEntity != poly.GraphUid)
{
color = Color.Green;
var neighborMap = neighborPoly.ToMap(_entManager);
var neighborMap = _entManager.GetCoordinates(neighborPoly).ToMap(_entManager);
if (neighborMap.MapId != args.MapId)
continue;
@@ -478,7 +486,9 @@ namespace Content.Client.NPC
{
foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds))
{
if (!_system.Breadcrumbs.TryGetValue(grid.Owner, out var crumbs) ||
var netGrid = _entManager.GetNetEntity(grid.Owner);
if (!_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) ||
!xformQuery.TryGetComponent(grid.Owner, out var gridXform))
continue;
@@ -506,7 +516,7 @@ namespace Content.Client.NPC
{
foreach (var node in route.Message.Path)
{
if (!_entManager.TryGetComponent<TransformComponent>(node.GraphUid, out var graphXform))
if (!_entManager.TryGetComponent<TransformComponent>(_entManager.GetEntity(node.GraphUid), out var graphXform))
continue;
worldHandle.SetTransform(graphXform.WorldMatrix);
@@ -525,12 +535,14 @@ namespace Content.Client.NPC
foreach (var (node, cost) in route.Message.Costs)
{
if (matrix != node.GraphUid)
var graph = _entManager.GetEntity(node.GraphUid);
if (matrix != graph)
{
if (!_entManager.TryGetComponent<TransformComponent>(node.GraphUid, out var graphXform))
if (!_entManager.TryGetComponent<TransformComponent>(graph, out var graphXform))
continue;
matrix = node.GraphUid;
matrix = graph;
worldHandle.SetTransform(graphXform.WorldMatrix);
}