Remove LungBehavior and replace with LungComponent/System (#5630)
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Body.Behavior;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Body.Components;
|
||||
using NUnit.Framework;
|
||||
@@ -17,7 +16,7 @@ using Robust.Shared.Maths;
|
||||
namespace Content.IntegrationTests.Tests.Body
|
||||
{
|
||||
[TestFixture]
|
||||
[TestOf(typeof(LungBehavior))]
|
||||
[TestOf(typeof(LungSystem))]
|
||||
public class LungTest : ContentIntegrationTest
|
||||
{
|
||||
private const string Prototypes = @"
|
||||
@@ -64,8 +63,12 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
|
||||
var human = entityManager.SpawnEntity("HumanBodyAndBloodstreamDummy", new MapCoordinates(Vector2.Zero, mapId));
|
||||
|
||||
var bodySys = EntitySystem.Get<BodySystem>();
|
||||
var lungSys = EntitySystem.Get<LungSystem>();
|
||||
|
||||
Assert.That(human.TryGetComponent(out SharedBodyComponent body));
|
||||
Assert.That(body.TryGetMechanismBehaviors(out List<LungBehavior> lungs));
|
||||
|
||||
var lungs = bodySys.GetComponentsOnMechanisms<LungComponent>(human.Uid, body).ToArray();
|
||||
Assert.That(lungs.Count, Is.EqualTo(1));
|
||||
Assert.That(human.TryGetComponent(out BloodstreamComponent bloodstream));
|
||||
|
||||
@@ -78,8 +81,8 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
gas.AdjustMoles(Gas.Oxygen, originalOxygen);
|
||||
gas.AdjustMoles(Gas.Nitrogen, originalNitrogen);
|
||||
|
||||
var lung = lungs[0];
|
||||
lung.Inhale(1, gas);
|
||||
var (lung, _) = lungs[0];
|
||||
lungSys.TakeGasFrom(lung.OwnerUid, 1, gas, lung);
|
||||
|
||||
var lungOxygen = originalOxygen * breathedPercentage;
|
||||
var lungNitrogen = originalNitrogen * breathedPercentage;
|
||||
@@ -100,7 +103,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
Assert.Zero(lungOxygenBeforeExhale);
|
||||
Assert.Zero(lungNitrogenBeforeExhale);
|
||||
|
||||
lung.Exhale(1, gas);
|
||||
lungSys.PushGasTo(lung.OwnerUid, gas, lung);
|
||||
|
||||
var lungOxygenAfterExhale = lung.Air.GetMoles(Gas.Oxygen);
|
||||
var exhaledOxygen = Math.Abs(lungOxygenBeforeExhale - lungOxygenAfterExhale);
|
||||
@@ -168,8 +171,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
var coordinates = new EntityCoordinates(grid.GridEntityId, center);
|
||||
human = entityManager.SpawnEntity("HumanBodyAndBloodstreamDummy", coordinates);
|
||||
|
||||
Assert.True(human.TryGetComponent(out SharedBodyComponent body));
|
||||
Assert.True(body.HasMechanismBehavior<LungBehavior>());
|
||||
Assert.True(human.HasComponent<SharedBodyComponent>());
|
||||
Assert.True(human.TryGetComponent(out respirator));
|
||||
Assert.False(respirator.Suffocating);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user