public async Task NoSuffocationTest() { var server = StartServerDummyTicker(); await server.WaitIdleAsync(); var mapLoader = server.ResolveDependency <IMapLoader>(); var mapManager = server.ResolveDependency <IMapManager>(); var entityManager = server.ResolveDependency <IEntityManager>(); MapId mapId; IMapGrid grid = null; LungComponent lung = null; MetabolismComponent metabolism = null; IEntity human = null; var testMapName = "Maps/Test/Breathing/3by3-20oxy-80nit.yml"; await server.WaitPost(() => { mapId = mapManager.CreateMap(); grid = mapLoader.LoadBlueprint(mapId, testMapName); }); Assert.NotNull(grid, $"Test blueprint {testMapName} not found."); await server.WaitAssertion(() => { var center = new Vector2(0.5f, -1.5f); var coordinates = new EntityCoordinates(grid.GridEntityId, center); human = entityManager.SpawnEntity("HumanMob_Content", coordinates); Assert.True(human.TryGetComponent(out lung)); Assert.True(human.TryGetComponent(out metabolism)); Assert.False(metabolism.Suffocating); }); for (var tick = 0; tick < 600; tick++) { await server.WaitRunTicks(tick); Assert.False(metabolism.Suffocating, $"Entity {human.Name} is suffocating on tick {tick}"); } await server.WaitIdleAsync(); }
public void GasToReagent(EntityUid uid, LungComponent lung) { foreach (var gas in Enum.GetValues <Gas>()) { var i = (int)gas; var moles = lung.Air.Moles[i]; if (moles <= 0) { continue; } var reagent = _atmosphereSystem.GasReagents[i]; if (reagent == null) { continue; } var amount = moles * Atmospherics.BreathMolesToReagentMultiplier; _solutionContainerSystem.TryAddReagent(uid, lung.LungSolution, reagent, amount, out _); // We don't remove the gas from the lung mix, // that's the responsibility of whatever gas is being metabolized. // Most things will just want to exhale again. } }
private void OnAddedToBody(EntityUid uid, LungComponent component, AddedToBodyEvent args) { Inhale(uid, component.CycleDelay); }
private void OnComponentInit(EntityUid uid, LungComponent component, ComponentInit args) { component.LungSolution = _solutionContainerSystem.EnsureSolution(uid, LungSolutionName); component.LungSolution.MaxVolume = 100.0f; component.LungSolution.CanReact = false; // No dexalin lungs }