예제 #1
0
        private void UpdatePDAUserInterface(PDAComponent pda)
        {
            var ownerInfo = new PDAIdInfoText
            {
                ActualOwnerName = pda.OwnerName,
                IdOwner         = pda.ContainedID?.FullName,
                JobTitle        = pda.ContainedID?.JobTitle
            };

            if (!_uiSystem.TryGetUi(pda.Owner, PDAUiKey.Key, out var ui))
            {
                return;
            }

            var hasInstrument = HasComp <InstrumentComponent>(pda.Owner);
            var state         = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, false, hasInstrument);

            ui.SetState(state);

            // TODO UPLINK RINGTONES/SECRETS This is just a janky placeholder way of hiding uplinks from non syndicate
            // players. This should really use a sort of key-code entry system that selects an account which is not directly tied to
            // a player entity.

            if (!HasComp <UplinkComponent>(pda.Owner))
            {
                return;
            }

            var uplinkState = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, true, hasInstrument);

            foreach (var session in ui.SubscribedSessions)
            {
                if (session.AttachedEntity is not EntityUid {
                    Valid: true
                } user)
                {
                    continue;
                }

                if (_uplinkAccounts.HasAccount(user))
                {
                    ui.SetState(uplinkState, session);
                }
            }
        }
예제 #2
0
        private void AfterUIOpen(EntityUid uid, PDAComponent pda, AfterActivatableUIOpenEvent args)
        {
            // A new user opened the UI --> Check if they are a traitor and should get a user specific UI state override.
            if (!HasComp <UplinkComponent>(pda.Owner) || !_uplinkAccounts.HasAccount(args.User))
            {
                return;
            }

            if (!_uiSystem.TryGetUi(pda.Owner, PDAUiKey.Key, out var ui))
            {
                return;
            }

            var ownerInfo = new PDAIdInfoText
            {
                ActualOwnerName = pda.OwnerName,
                IdOwner         = pda.ContainedID?.FullName,
                JobTitle        = pda.ContainedID?.JobTitle
            };

            var state = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, true, HasComp <InstrumentComponent>(pda.Owner));

            ui.SetState(state, args.Session);
        }