mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-04 05:17:28 +00:00
* Pass 1. * i'm FREE * Prevent hangups. * okay fine here's an attribute for settings, will polish later and prolly remove the overridable thing. * sigh. * fix singular trigger bug so LatheTest doesn't flake. * Remove SystemAttribute usage. * Poke * I used the shotgun. You know why? Cause the shot gun doesn’t miss, and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang, bang, and they’re fucking done. I use four shots just to make damn sure. Because, once again, I’m not there to coddle a buncha criminal scum sucking f------, I’m there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned, which I won’t, you can guarantee I will continue to use the shotgun to apprehend criminals. Because it’s quick, clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots, which take half a clip just to bring someone down, or with the tazer bolts which are slow as balls, impossible to aim and do about next to jack shit, fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls. * Change the faulty store test into two tests, one of which is ignored for failing.
135 lines
6.1 KiB
C#
135 lines
6.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Content.IntegrationTests.Fixtures;
|
|
using Content.Shared.Lathe;
|
|
using Content.Shared.Materials;
|
|
using Content.Shared.Prototypes;
|
|
using Content.Shared.Research.Prototypes;
|
|
using Content.Shared.Whitelist;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.IntegrationTests.Tests.Lathe;
|
|
|
|
[TestFixture]
|
|
public sealed class LatheTest : GameTest
|
|
{
|
|
[Test]
|
|
public async Task TestLatheRecipeIngredientsFitLathe()
|
|
{
|
|
var pair = Pair;
|
|
var server = pair.Server;
|
|
|
|
var mapData = await pair.CreateTestMap();
|
|
|
|
var entMan = server.EntMan;
|
|
var protoMan = server.ProtoMan;
|
|
var compFactory = server.ResolveDependency<IComponentFactory>();
|
|
var materialStorageSystem = server.System<SharedMaterialStorageSystem>();
|
|
var whitelistSystem = server.System<EntityWhitelistSystem>();
|
|
var latheSystem = server.System<SharedLatheSystem>();
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
// Find all the lathes
|
|
var latheProtos = protoMan.EnumeratePrototypes<EntityPrototype>()
|
|
.Where(p => !p.Abstract)
|
|
.Where(p => !pair.IsTestPrototype(p))
|
|
.Where(p => p.HasComponent<LatheComponent>());
|
|
|
|
// Find every EntityPrototype that can be inserted into a MaterialStorage
|
|
var materialEntityProtos = protoMan.EnumeratePrototypes<EntityPrototype>()
|
|
.Where(p => !p.Abstract)
|
|
.Where(p => !pair.IsTestPrototype(p))
|
|
.Where(p => p.HasComponent<PhysicalCompositionComponent>());
|
|
|
|
// Spawn all of the above material EntityPrototypes - we need actual entities to do whitelist checks
|
|
var materialEntities = new List<EntityUid>(materialEntityProtos.Count());
|
|
foreach (var materialEntityProto in materialEntityProtos)
|
|
{
|
|
materialEntities.Add(entMan.SpawnEntity(materialEntityProto.ID, mapData.GridCoords));
|
|
}
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
// Check each lathe individually
|
|
foreach (var latheProto in latheProtos)
|
|
{
|
|
if (!latheProto.TryGetComponent<LatheComponent>(out var latheComp, compFactory))
|
|
continue;
|
|
|
|
if (!latheProto.TryGetComponent<MaterialStorageComponent>(out var storageComp, compFactory))
|
|
continue;
|
|
|
|
// Test which material-containing entities are accepted by this lathe
|
|
var acceptedMaterials = new HashSet<ProtoId<MaterialPrototype>>();
|
|
foreach (var materialEntity in materialEntities)
|
|
{
|
|
Assert.That(entMan.TryGetComponent<PhysicalCompositionComponent>(materialEntity, out var compositionComponent));
|
|
if (whitelistSystem.IsWhitelistFail(storageComp.Whitelist, materialEntity))
|
|
continue;
|
|
|
|
// Mark the lathe as accepting each material in the entity
|
|
foreach (var (material, _) in compositionComponent.MaterialComposition)
|
|
{
|
|
acceptedMaterials.Add(material);
|
|
}
|
|
}
|
|
|
|
// Collect all possible recipes assigned to this lathe
|
|
var recipes = new HashSet<ProtoId<LatheRecipePrototype>>();
|
|
latheSystem.AddRecipesFromPacks(recipes, latheComp.StaticPacks);
|
|
latheSystem.AddRecipesFromPacks(recipes, latheComp.DynamicPacks);
|
|
if (latheProto.TryGetComponent<EmagLatheRecipesComponent>(out var emagRecipesComp, compFactory))
|
|
{
|
|
latheSystem.AddRecipesFromPacks(recipes, emagRecipesComp.EmagStaticPacks);
|
|
latheSystem.AddRecipesFromPacks(recipes, emagRecipesComp.EmagDynamicPacks);
|
|
}
|
|
|
|
// Check each recipe assigned to this lathe
|
|
foreach (var recipeId in recipes)
|
|
{
|
|
if (!protoMan.TryIndex(recipeId, out var recipeProto))
|
|
{
|
|
Assert.Fail($"Lathe recipe '{recipeId}' does not exist");
|
|
continue;
|
|
}
|
|
|
|
// Track the total material volume of the recipe
|
|
var totalQuantity = 0;
|
|
// Check each material called for by the recipe
|
|
foreach (var (materialId, quantity) in recipeProto.Materials)
|
|
{
|
|
Assert.That(protoMan.HasIndex(materialId), $"Material '{materialId}' does not exist");
|
|
// Make sure the material is accepted by the lathe
|
|
Assert.That(acceptedMaterials, Does.Contain(materialId), $"Lathe {latheProto.ID} has recipe {recipeId} but does not accept any materials containing {materialId}");
|
|
totalQuantity += quantity;
|
|
}
|
|
// Make sure the recipe doesn't call for more material than the lathe can hold
|
|
if (storageComp.StorageLimit != null)
|
|
Assert.That(totalQuantity, Is.LessThanOrEqualTo(storageComp.StorageLimit), $"Lathe {latheProto.ID} has recipe {recipeId} which calls for {totalQuantity} units of materials but can only hold {storageComp.StorageLimit}");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public async Task AllLatheRecipesValidTest()
|
|
{
|
|
var pair = Pair;
|
|
|
|
var server = pair.Server;
|
|
var proto = server.ProtoMan;
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
foreach (var recipe in proto.EnumeratePrototypes<LatheRecipePrototype>())
|
|
{
|
|
if (recipe.Result == null)
|
|
Assert.That(recipe.ResultReagents, Is.Not.Null, $"Recipe '{recipe.ID}' has no result or result reagents.");
|
|
}
|
|
});
|
|
}
|
|
}
|