machine deconstruct test (#11779)
This commit is contained in:
59
Content.IntegrationTests/Tests/MachineBoardTest.cs
Normal file
59
Content.IntegrationTests/Tests/MachineBoardTest.cs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Content.Server.Construction.Components;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.IntegrationTests.Tests;
|
||||||
|
|
||||||
|
public sealed class MachineBoardTest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A list of machine boards that can be ignored by this test.
|
||||||
|
/// </summary>
|
||||||
|
private readonly HashSet<string> _ignoredPrototypes = new()
|
||||||
|
{
|
||||||
|
//These have their own construction thing going on here
|
||||||
|
"MachineParticleAcceleratorEndCapCircuitboard",
|
||||||
|
"MachineParticleAcceleratorFuelChamberCircuitboard",
|
||||||
|
"MachineParticleAcceleratorFuelChamberCircuitboard",
|
||||||
|
"MachineParticleAcceleratorPowerBoxCircuitboard",
|
||||||
|
"MachineParticleAcceleratorEmitterLeftCircuitboard",
|
||||||
|
"MachineParticleAcceleratorEmitterCenterCircuitboard",
|
||||||
|
"MachineParticleAcceleratorEmitterRightCircuitboard"
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ensures that every single machine board's corresponding entity
|
||||||
|
/// is a machine and can be properly deconstructed.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public async Task TestMachineBoardHasValidMachine()
|
||||||
|
{
|
||||||
|
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
|
||||||
|
var server = pairTracker.Pair.Server;
|
||||||
|
|
||||||
|
var protoMan = server.ResolveDependency<IPrototypeManager>();
|
||||||
|
|
||||||
|
await server.WaitAssertion(() =>
|
||||||
|
{
|
||||||
|
foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>().Where(p => !p.Abstract && !_ignoredPrototypes.Contains(p.ID)))
|
||||||
|
{
|
||||||
|
if (!p.TryGetComponent<MachineBoardComponent>(out var mbc))
|
||||||
|
continue;
|
||||||
|
var mId = mbc.Prototype;
|
||||||
|
|
||||||
|
Assert.That(mId, Is.Not.Null, $"Machine board {p.ID} does not have a corresponding machine.");
|
||||||
|
Assert.That(protoMan.TryIndex<EntityPrototype>(mId, out var mProto),
|
||||||
|
$"Machine board {p.ID}'s corresponding machine has an invalid prototype.");
|
||||||
|
Assert.That(mProto.TryGetComponent<MachineComponent>(out var mComp),
|
||||||
|
$"Machine board {p.ID}'s corresponding machine {mId} does not have MachineComponent");
|
||||||
|
Assert.That(mComp.BoardPrototype, Is.EqualTo(p.ID),
|
||||||
|
$"Machine {mId}'s BoardPrototype is not equal to it's corresponding machine board, {p.ID}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await pairTracker.CleanReturnAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
id: DiseaseDiagnoser
|
id: DiseaseDiagnoser
|
||||||
parent: BaseMachinePowered
|
parent: [ BaseMachinePowered, ConstructibleMachine ]
|
||||||
name: Disease Diagnoser Delta Extreme
|
name: Disease Diagnoser Delta Extreme
|
||||||
description: A machine that analyzes disease samples.
|
description: A machine that analyzes disease samples.
|
||||||
placement:
|
placement:
|
||||||
@@ -22,3 +22,5 @@
|
|||||||
- type: DiseaseMachineVisuals
|
- type: DiseaseMachineVisuals
|
||||||
idleState: icon
|
idleState: icon
|
||||||
runningState: running
|
runningState: running
|
||||||
|
- type: Machine
|
||||||
|
board: DiagnoserMachineCircuitboard
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
id: KitchenMicrowave
|
id: KitchenMicrowave
|
||||||
parent: BaseMachinePowered
|
parent: [ BaseMachinePowered, ConstructibleMachine ]
|
||||||
name: microwave
|
name: microwave
|
||||||
description: It's magic.
|
description: It's magic.
|
||||||
components:
|
components:
|
||||||
@@ -59,6 +59,10 @@
|
|||||||
acts: ["Breakage"]
|
acts: ["Breakage"]
|
||||||
- type: ApcPowerReceiver
|
- type: ApcPowerReceiver
|
||||||
powerLoad: 400
|
powerLoad: 400
|
||||||
|
- type: Machine
|
||||||
|
board: MicrowaveMachineCircuitboard
|
||||||
- type: ContainerContainer
|
- type: ContainerContainer
|
||||||
containers:
|
containers:
|
||||||
microwave_entity_container: !type:Container
|
microwave_entity_container: !type:Container
|
||||||
|
machine_board: !type:Container
|
||||||
|
machine_parts: !type:Container
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
id: KitchenReagentGrinder
|
id: KitchenReagentGrinder
|
||||||
parent: BaseMachinePowered
|
parent: [ BaseMachinePowered, ConstructibleMachine ]
|
||||||
name: reagent grinder
|
name: reagent grinder
|
||||||
description: From BlenderTech. Will It Blend? Let's find out!
|
description: From BlenderTech. Will It Blend? Let's find out!
|
||||||
suffix: grinder/juicer
|
suffix: grinder/juicer
|
||||||
@@ -44,7 +44,11 @@
|
|||||||
- type: ApcPowerReceiver
|
- type: ApcPowerReceiver
|
||||||
powerLoad: 300
|
powerLoad: 300
|
||||||
- type: ItemSlots
|
- type: ItemSlots
|
||||||
|
- type: Machine
|
||||||
|
board: ReagentGrinderMachineCircuitboard
|
||||||
- type: ContainerContainer
|
- type: ContainerContainer
|
||||||
containers:
|
containers:
|
||||||
ReagentGrinder-reagentContainerContainer: !type:ContainerSlot
|
ReagentGrinder-reagentContainerContainer: !type:ContainerSlot
|
||||||
ReagentGrinder-entityContainerContainer: !type:Container
|
ReagentGrinder-entityContainerContainer: !type:Container
|
||||||
|
machine_board: !type:Container
|
||||||
|
machine_parts: !type:Container
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
id: StasisBed
|
id: StasisBed
|
||||||
name: stasis bed
|
name: stasis bed
|
||||||
parent: BaseMachinePowered
|
parent: [ BaseMachinePowered, ConstructibleMachine ]
|
||||||
description: A bed that massively slows down the patient's metabolism, allowing more time to administer a proper treatment for stabilization.
|
description: A bed that massively slows down the patient's metabolism, allowing more time to administer a proper treatment for stabilization.
|
||||||
components:
|
components:
|
||||||
- type: StasisBed
|
- type: StasisBed
|
||||||
@@ -39,6 +39,8 @@
|
|||||||
- type: Strap
|
- type: Strap
|
||||||
position: Down
|
position: Down
|
||||||
rotation: -90
|
rotation: -90
|
||||||
|
- type: Machine
|
||||||
|
board: StasisBedMachineCircuitboard
|
||||||
- type: Physics
|
- type: Physics
|
||||||
bodyType: Static
|
bodyType: Static
|
||||||
- type: Fixtures
|
- type: Fixtures
|
||||||
|
|||||||
Reference in New Issue
Block a user