示例#1
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);
            }
        }
示例#2
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));
            }
        }