Files
tbd-station-14/Content.IntegrationTests/Tests/NPC/NPCTest.cs
metalgearsloth c31c848afd Shooting NPCs and more (#18042)
* Add pirate shooting

* Shooting working

* Basics working

* Refactor time

* More conversion

* Update primitives

* Update yml

* weh

* Building again

* Draft

* weh

* b

* Start shutdown

* Starting to take form

* Code side done

* is it worky

* Fix prototypes

* stuff

* Shitty working

* Juke events working

* Even more cleanup

* RTX

* Fix interaction combat mode and compquery

* GetAmmoCount relays

* Fix rotation speed

* Juke fixes

* fixes

* weh

* The collision avoidance never ends

* Fixes

* Pause support

* framework

* lazy

* Fix idling

* Fix drip

* goobed

* Fix takeover shutdown bug

* Merge fixes

* shitter

* Fix carpos
2023-08-01 19:48:56 -05:00

56 lines
1.7 KiB
C#

using System.Collections.Generic;
using Content.Server.NPC.HTN;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.IntegrationTests.Tests.NPC;
[TestFixture]
public sealed class NPCTest
{
[Test]
public async Task CompoundRecursion()
{
var pool = await PoolManager.GetServerClient(new PoolSettings() { NoClient = true });
var server = pool.Pair.Server;
await server.WaitIdleAsync();
var htnSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<HTNSystem>();
var protoManager = server.ResolveDependency<IPrototypeManager>();
await server.WaitAssertion(() =>
{
var counts = new Dictionary<string, int>();
foreach (var compound in protoManager.EnumeratePrototypes<HTNCompoundPrototype>())
{
Count(compound, counts, htnSystem, protoManager);
counts.Clear();
}
});
await pool.CleanReturnAsync();
}
private static void Count(HTNCompoundPrototype compound, Dictionary<string, int> counts, HTNSystem htnSystem, IPrototypeManager protoManager)
{
foreach (var branch in compound.Branches)
{
foreach (var task in branch.Tasks)
{
if (task is HTNCompoundTask compoundTask)
{
var count = counts.GetOrNew(compound.ID);
count++;
Assert.That(count, Is.LessThan(50));
counts[compound.ID] = count;
Count(protoManager.Index<HTNCompoundPrototype>(compoundTask.Task), counts, htnSystem, protoManager);
}
}
}
}
}