Пример #1
0
        private void OnInit(EntityUid uid, NukeComponent component, ComponentInit args)
        {
            component.RemainingTime = component.Timer;
            _itemSlots.AddItemSlot(uid, component.Name, component.DiskSlot);

            UpdateStatus(uid, component);
            UpdateUserInterface(uid, component);
        }
Пример #2
0
        private void OnEjectButtonPressed(EntityUid uid, NukeComponent component, NukeEjectMessage args)
        {
            if (!component.DiskSlot.HasItem)
            {
                return;
            }

            _itemSlots.TryEjectToHands(uid, component.DiskSlot, args.Session.AttachedEntity);
        }
Пример #3
0
        private void OnEnterButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadEnterMessage args)
        {
            if (component.Status != NukeStatus.AWAIT_CODE)
            {
                return;
            }

            UpdateStatus(uid, component);
            UpdateUserInterface(uid, component);
        }
Пример #4
0
        private void CheckAnchorAttempt(EntityUid uid, NukeComponent component, BaseAnchoredAttemptEvent args)
        {
            // cancel any anchor attempt if armed
            if (component.Status == NukeStatus.ARMED)
            {
                var msg = Loc.GetString("nuke-component-cant-anchor");
                _popups.PopupEntity(msg, uid, Filter.Entities(args.User));

                args.Cancel();
            }
        }
Пример #5
0
        private void CheckAnchorAttempt(EntityUid uid, NukeComponent component, BaseAnchoredAttemptEvent args)
        {
            // cancel any anchor attempt without nuke disk
            if (!component.DiskSlot.HasItem)
            {
                var msg = Loc.GetString("nuke-component-cant-anchor");
                _popups.PopupEntity(msg, uid, Filter.Entities(args.User));

                args.Cancel();
            }
        }
Пример #6
0
        private void OnClearButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadClearMessage args)
        {
            PlaySound(uid, component.KeypadPressSound, 0f, component);

            if (component.Status != NukeStatus.AWAIT_CODE)
            {
                return;
            }

            component.EnteredCode = "";
            UpdateUserInterface(uid, component);
        }
Пример #7
0
        private void OnItemSlotChanged(EntityUid uid, NukeComponent component, ContainerModifiedMessage args)
        {
            if (!component.Initialized)
            {
                return;
            }

            if (args.Container.ID != component.DiskSlot.ID)
            {
                return;
            }

            UpdateStatus(uid, component);
            UpdateUserInterface(uid, component);
        }
Пример #8
0
        private void OnArmButtonPressed(EntityUid uid, NukeComponent component, NukeArmedMessage args)
        {
            if (!component.DiskSlot.HasItem)
            {
                return;
            }

            if (component.Status == NukeStatus.AWAIT_ARM)
            {
                ArmBomb(uid, component);
            }
            else
            {
                DisarmBomb(uid, component);
            }
        }
Пример #9
0
        private void OnKeypadButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadMessage args)
        {
            PlaySound(uid, component.KeypadPressSound, 0.125f, component);

            if (component.Status != NukeStatus.AWAIT_CODE)
            {
                return;
            }

            if (component.EnteredCode.Length >= _codes.Code.Length)
            {
                return;
            }

            component.EnteredCode += args.Value.ToString();
            UpdateUserInterface(uid, component);
        }
Пример #10
0
        private void DisarmBombDoafter(EntityUid uid, EntityUid user, NukeComponent nuke)
        {
            nuke.DisarmCancelToken = new();
            var doafter = new DoAfterEventArgs(user, nuke.DisarmDoafterLength, nuke.DisarmCancelToken.Value, uid)
            {
                TargetCancelledEvent = new NukeDisarmCancelledEvent(),
                TargetFinishedEvent  = new NukeDisarmSuccessEvent(),
                BreakOnDamage        = true,
                BreakOnStun          = true,
                BreakOnTargetMove    = true,
                BreakOnUserMove      = true,
                NeedHand             = true,
            };

            _doAfterSystem.DoAfter(doafter);
            _popups.PopupEntity(Loc.GetString("nuke-component-doafter-warning"), user,
                                Filter.Entities(user), PopupType.LargeCaution);
        }
Пример #11
0
        private async void OnAnchorButtonPressed(EntityUid uid, NukeComponent component, NukeAnchorMessage args)
        {
            if (!component.DiskSlot.HasItem)
            {
                return;
            }

            if (!EntityManager.TryGetComponent(uid, out TransformComponent? transform))
            {
                return;
            }

            // manually set transform anchor (bypassing anchorable)
            // todo: it will break pullable system
            transform.Coordinates = transform.Coordinates.SnapToGrid();
            transform.Anchored    = !transform.Anchored;

            UpdateUserInterface(uid, component);
        }
Пример #12
0
        private void OnArmButtonPressed(EntityUid uid, NukeComponent component, NukeArmedMessage args)
        {
            if (!component.DiskSlot.HasItem)
            {
                return;
            }

            if (component.Status == NukeStatus.AWAIT_ARM && Transform(uid).Anchored)
            {
                ArmBomb(uid, component);
            }
            else
            {
                if (args.Session.AttachedEntity is not {
                } user)
                {
                    return;
                }

                DisarmBombDoafter(uid, user, component);
            }
        }
Пример #13
0
 private void OnAnchorAttempt(EntityUid uid, NukeComponent component, AnchorAttemptEvent args)
 {
     CheckAnchorAttempt(uid, component, args);
 }
Пример #14
0
 private void OnRemove(EntityUid uid, NukeComponent component, ComponentRemove args)
 {
     _itemSlots.RemoveItemSlot(uid, component.DiskSlot);
 }
Пример #15
0
 private void OnDisarmSuccess(EntityUid uid, NukeComponent component, NukeDisarmSuccessEvent args)
 {
     component.DisarmCancelToken = null;
     DisarmBomb(uid, component);
 }
Пример #16
0
 private void OnDisarmCancelled(EntityUid uid, NukeComponent component, NukeDisarmCancelledEvent args)
 {
     component.DisarmCancelToken = null;
 }
Пример #17
0
 private void OnAnchorChanged(EntityUid uid, NukeComponent component, ref AnchorStateChangedEvent args)
 {
     UpdateUserInterface(uid, component);
 }
Пример #18
0
 private void NukeDisarmedAudio(NukeComponent component)
 {
     _soundSystem.PlayGlobalOnStation(component.Owner, component.DisarmSound.GetSound());
     _soundSystem.StopStationEventMusic(component.Owner, StationEventMusicType.Nuke);
 }
Пример #19
0
 private void NukeArmedAudio(NukeComponent component)
 {
     _soundSystem.PlayGlobalOnStation(component.Owner, component.ArmSound.GetSound());
 }