private void OnMapInit(EntityUid uid, PresetIdCardComponent id, MapInitEvent args)
        {
            // If a preset ID card is spawned on a station at setup time,
            // the station may not exist,
            // or may not yet know whether it is on extended access (players not spawned yet).
            // PlayerJobsAssigned makes sure extended access is configured correctly in that case.

            var station = _stationSystem.GetOwningStation(id.Owner);
            var extended = false;
            if (station != null)
                extended = Comp<StationJobsComponent>(station.Value).ExtendedAccess;

            SetupIdAccess(uid, id, extended);
        }
        private void SetupIdAccess(EntityUid uid, PresetIdCardComponent id, bool extended)
        {
            if (id.JobName == null)
                return;

            if (!_prototypeManager.TryIndex(id.JobName, out JobPrototype? job))
            {
                Logger.ErrorS("access", $"Invalid job id ({id.JobName}) for preset card");
                return;
            }

            _accessSystem.SetAccessToJob(uid, job, extended);

            // and also change job title on a card id
            _cardSystem.TryChangeJobTitle(uid, job.LocalizedName);
        }
Ejemplo n.º 3
0
        private void OnMapInit(EntityUid uid, PresetIdCardComponent id, MapInitEvent args)
        {
            if (id.JobName == null)
            {
                return;
            }

            if (!_prototypeManager.TryIndex(id.JobName, out JobPrototype? job))
            {
                Logger.ErrorS("access", $"Invalid job id ({id.JobName}) for preset card");
                return;
            }

            // set access for access component
            _accessSystem.TrySetTags(uid, job.Access);

            // and also change job title on a card id
            _cardSystem.TryChangeJobTitle(uid, job.Name);
        }