Example #1
0
 private void OnEmagged(EntityUid uid, ApcComponent comp, GotEmaggedEvent args)
 {
     if (!comp.Emagged)
     {
         comp.Emagged = true;
         args.Handled = true;
     }
 }
        public void AddApc(ApcComponent apc)
        {
            if (!apc.Owner.TryGetComponent(out BatteryComponent battery))
            {
                return;
            }

            _apcBatteries.Add(apc, battery);
        }
 public void RemoveApc(ApcComponent apc)
 {
     _apcBatteries.Remove(apc);
     if (!_apcBatteries.Any())
     {
         foreach (var receiver in _providerReceivers.SelectMany(kvp => kvp.Value))
         {
             receiver.HasApcPower = false;
         }
     }
 }
Example #4
0
        private void OnToggleMainBreaker(EntityUid uid, ApcComponent component, ApcToggleMainBreakerMessage args)
        {
            TryComp <AccessReaderComponent>(uid, out var access);
            if (args.Session.AttachedEntity == null)
            {
                return;
            }

            if (access == null || _accessReader.IsAllowed(args.Session.AttachedEntity.Value, access))
            {
                ApcToggleBreaker(uid, component);
            }
            else
            {
                _popupSystem.PopupCursor(Loc.GetString("apc-component-insufficient-access"),
                                         Filter.Entities(args.Session.AttachedEntity.Value), PopupType.Medium);
            }
        }
Example #5
0
        private void OnToggleMainBreaker(EntityUid uid, ApcComponent component, ApcToggleMainBreakerMessage args)
        {
            TryComp <AccessReaderComponent>(uid, out var access);
            if (args.Session.AttachedEntity == null)
            {
                return;
            }

            if (access == null || _accessReader.IsAllowed(access, args.Session.AttachedEntity.Value))
            {
                component.MainBreakerEnabled = !component.MainBreakerEnabled;
                Comp <PowerNetworkBatteryComponent>(uid).CanDischarge = component.MainBreakerEnabled;

                UpdateUIState(uid, component);
                SoundSystem.Play(Filter.Pvs(uid), component.OnReceiveMessageSound.GetSound(), uid, AudioParams.Default.WithVolume(-2f));
            }
            else
            {
                _popupSystem.PopupCursor(Loc.GetString("apc-component-insufficient-access"),
                                         Filter.Entities(args.Session.AttachedEntity.Value));
            }
        }
 public void RemoveApc(ApcComponent apc)
 {
 }
 public void AddApc(ApcComponent apc)
 {
 }
Example #8
0
 private void OnApcInit(EntityUid uid, ApcComponent component, MapInitEvent args)
 {
     UpdateApcState(uid, component);
 }
Example #9
0
 // Change the APC's state only when the battery state changes, or when it's first created.
 private void OnBatteryChargeChanged(EntityUid uid, ApcComponent component, ChargeChangedEvent args)
 {
     UpdateApcState(uid, component);
 }
 public void AddApc(ApcComponent apc)
 {
     _apcBatteries.Add(apc, apc.Battery);
 }