Add interaction tests (#15251)

This commit is contained in:
Leon Friedrich
2023-04-15 07:41:25 +12:00
committed by GitHub
parent ffe946729f
commit 489660a6bb
36 changed files with 2354 additions and 32 deletions

View File

@@ -0,0 +1,34 @@
using System.Collections.Generic;
using Content.Server.Construction;
using Content.Shared.Construction;
using Robust.Shared.GameObjects;
namespace Content.IntegrationTests.Tests.Interaction;
/// <summary>
/// System for listening to events that get raised when construction entities change.
/// In particular, when construction ghosts become real entities, and when existing entities get replaced with
/// new ones.
/// </summary>
public sealed class InteractionTestSystem : EntitySystem
{
public Dictionary<int, EntityUid> Ghosts = new();
public Dictionary<EntityUid, EntityUid> EntChanges = new();
public override void Initialize()
{
SubscribeNetworkEvent<AckStructureConstructionMessage>(OnAck);
SubscribeLocalEvent<ConstructionChangeEntityEvent>(OnEntChange);
}
private void OnEntChange(ConstructionChangeEntityEvent ev)
{
EntChanges[ev.Old] = ev.New;
}
private void OnAck(AckStructureConstructionMessage ev)
{
if (ev.Uid != null)
Ghosts[ev.GhostId] = ev.Uid.Value;
}
}