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

            _apcBatteries.Add(apc, battery);
        }
예제 #3
0
 public void RemoveApc(ApcComponent apc)
 {
     _apcBatteries.Remove(apc);
     if (!_apcBatteries.Any())
     {
         foreach (var receiver in _providerReceivers.SelectMany(kvp => kvp.Value))
         {
             receiver.HasApcPower = false;
         }
     }
 }
예제 #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);
            }
        }
예제 #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));
            }
        }
예제 #6
0
 public void RemoveApc(ApcComponent apc)
 {
 }
예제 #7
0
 public void AddApc(ApcComponent apc)
 {
 }
예제 #8
0
 private void OnApcInit(EntityUid uid, ApcComponent component, MapInitEvent args)
 {
     UpdateApcState(uid, component);
 }
예제 #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);
 }
예제 #10
0
 public void AddApc(ApcComponent apc)
 {
     _apcBatteries.Add(apc, apc.Battery);
 }