private void OnInhaleLocation(EntityUid uid, BeingDisposedComponent component, InhaleLocationEvent args)
 {
     if (TryComp <DisposalHolderComponent>(component.Holder, out var holder))
     {
         args.Gas = holder.Air;
     }
 }
 private void OnInhaleLocation(EntityUid uid, InternalsComponent component, InhaleLocationEvent args)
 {
     if (component.AreInternalsWorking())
     {
         var gasTank = Comp <GasTankComponent>(component.GasTankEntity !.Value);
         args.Gas = gasTank.RemoveAirVolume(Atmospherics.BreathVolume);
     }
 }
示例#3
0
 private void OnInhaleLocation(EntityUid uid, InternalsComponent component, InhaleLocationEvent args)
 {
     if (AreInternalsWorking(component))
     {
         var gasTank = Comp <GasTankComponent>(component.GasTankEntity !.Value);
         args.Gas = _gasTank.RemoveAirVolume(gasTank, Atmospherics.BreathVolume);
         // TODO: Should listen to gas tank updates instead I guess?
         _alerts.ShowAlert(component.Owner, AlertType.Internals, GetSeverity(component));
     }
 }
示例#4
0
        public void Inhale(EntityUid uid, SharedBodyComponent?body = null)
        {
            if (!Resolve(uid, ref body, false))
            {
                return;
            }

            var organs = _bodySystem.GetComponentsOnMechanisms <LungComponent>(uid, body);

            // Inhale gas
            var ev = new InhaleLocationEvent();

            RaiseLocalEvent(uid, ev, false);

            if (ev.Gas == null)
            {
                ev.Gas = _atmosSys.GetContainingMixture(uid, false, true);
                if (ev.Gas == null)
                {
                    return;
                }
            }

            var ratio     = (Atmospherics.BreathVolume / ev.Gas.Volume);
            var actualGas = ev.Gas.RemoveRatio(ratio);

            var lungRatio = 1.0f / organs.Count;
            var gas       = organs.Count == 1 ? actualGas : actualGas.RemoveRatio(lungRatio);

            foreach (var(lung, _) in organs)
            {
                // Merge doesn't remove gas from the giver.
                _atmosSys.Merge(lung.Air, gas);
                _lungSystem.GasToReagent(lung.Owner, lung);
            }
        }