Exemple #1
0
        private void OnUIMessage(PDAComponent pda, ServerBoundUserInterfaceMessage msg)
        {
            // cast EntityUid? to EntityUid
            if (msg.Session.AttachedEntity is not {
                Valid: true
            } playerUid)
            {
                return;
            }

            switch (msg.Message)
            {
            case PDARequestUpdateInterfaceMessage _:
                UpdatePDAUserInterface(pda);
                break;

            case PDAToggleFlashlightMessage _:
            {
                if (EntityManager.TryGetComponent(pda.Owner, out UnpoweredFlashlightComponent? flashlight))
                {
                    _unpoweredFlashlight.ToggleLight(flashlight);
                }
                break;
            }

            case PDAEjectIDMessage _:
            {
                _itemSlotsSystem.TryEjectToHands(pda.Owner, pda.IdSlot, playerUid);
                break;
            }

            case PDAEjectPenMessage _:
            {
                _itemSlotsSystem.TryEjectToHands(pda.Owner, pda.PenSlot, playerUid);
                break;
            }

            case PDAShowUplinkMessage _:
            {
                if (EntityManager.TryGetComponent(pda.Owner, out UplinkComponent? uplink))
                {
                    _uplinkSystem.ToggleUplinkUI(uplink, msg.Session);
                }
                break;
            }
            }
        }
        private void OnEjectButtonPressed(EntityUid uid, NukeComponent component, NukeEjectMessage args)
        {
            if (!component.DiskSlot.HasItem)
            {
                return;
            }

            _itemSlots.TryEjectToHands(uid, component.DiskSlot, args.Session.AttachedEntity);
        }
        private void OnUIMessage(PDAComponent pda, ServerBoundUserInterfaceMessage msg)
        {
            // cast EntityUid? to EntityUid
            if (msg.Session.AttachedEntity is not {
                Valid: true
            } playerUid)
            {
                return;
            }

            // todo: move this to entity events
            switch (msg.Message)
            {
            case PDARequestUpdateInterfaceMessage _:
                UpdatePDAUserInterface(pda, playerUid);
                break;

            case PDAToggleFlashlightMessage _:
            {
                if (EntityManager.TryGetComponent(pda.Owner, out UnpoweredFlashlightComponent? flashlight))
                {
                    _unpoweredFlashlight.ToggleLight(flashlight);
                }
                break;
            }

            case PDAEjectIDMessage _:
            {
                ItemSlotsSystem.TryEjectToHands(pda.Owner, pda.IdSlot, playerUid);
                break;
            }

            case PDAEjectPenMessage _:
            {
                ItemSlotsSystem.TryEjectToHands(pda.Owner, pda.PenSlot, playerUid);
                break;
            }

            case PDAShowUplinkMessage _:
            {
                if (EntityManager.TryGetComponent(pda.Owner, out UplinkComponent? uplink))
                {
                    _uplinkSystem.ToggleUplinkUI(uplink, msg.Session);
                }
                break;
            }

            case PDAShowRingtoneMessage _:
            {
                if (EntityManager.TryGetComponent(pda.Owner, out RingerComponent? ringer))
                {
                    _ringerSystem.ToggleRingerUI(ringer, msg.Session);
                }
                break;
            }

            case PDAShowMusicMessage _:
            {
                if (TryComp(pda.Owner, out InstrumentComponent? instrument))
                {
                    _instrumentSystem.ToggleInstrumentUi(pda.Owner, msg.Session, instrument);
                }
                break;
            }
            }
        }