Example #1
0
    /// <summary>
    /// Equips an ID card and PDA onto the given entity.
    /// </summary>
    /// <param name="entity">Entity to load out.</param>
    /// <param name="characterName">Character name to use for the ID.</param>
    /// <param name="jobPrototype">Job prototype to use for the PDA and ID.</param>
    /// <param name="station">The station this player is being spawned on.</param>
    public void EquipIdCard(EntityUid entity, string characterName, JobPrototype jobPrototype, EntityUid?station)
    {
        if (!_inventorySystem.TryGetSlotEntity(entity, "id", out var idUid))
        {
            return;
        }

        if (!EntityManager.TryGetComponent(idUid, out PDAComponent? pdaComponent) || pdaComponent.ContainedID == null)
        {
            return;
        }

        var card   = pdaComponent.ContainedID;
        var cardId = card.Owner;

        _cardSystem.TryChangeFullName(cardId, characterName, card);
        _cardSystem.TryChangeJobTitle(cardId, jobPrototype.LocalizedName, card);

        var extendedAccess = false;

        if (station != null)
        {
            var data = Comp <StationJobsComponent>(station.Value);
            extendedAccess = data.ExtendedAccess;
        }

        _accessSystem.SetAccessToJob(cardId, jobPrototype, extendedAccess);

        _pdaSystem.SetOwner(pdaComponent, characterName);
    }
Example #2
0
        /// <summary>
        /// Set the access on an <see cref="AccessComponent"/> to the access for a specific job.
        /// </summary>
        /// <param name="uid">The ID of the entity with the access component.</param>
        /// <param name="prototype">The job prototype to use access from.</param>
        /// <param name="extended">Whether to apply extended job access.</param>
        /// <param name="access">The access component.</param>
        public void SetAccessToJob(
            EntityUid uid,
            JobPrototype prototype,
            bool extended,
            AccessComponent?access = null)
        {
            if (!Resolve(uid, ref access))
            {
                return;
            }

            access.Tags.Clear();
            access.Tags.UnionWith(prototype.Access);

            TryAddGroups(uid, prototype.AccessGroups, access);

            if (extended)
            {
                access.Tags.UnionWith(prototype.ExtendedAccess);
                TryAddGroups(uid, prototype.ExtendedAccessGroups, access);
            }
        }
Example #3
0
 public Job(Mind.Mind mind, JobPrototype jobPrototype) : base(mind)
 {
     Prototype  = jobPrototype;
     Name       = jobPrototype.LocalizedName;
     CanBeAntag = jobPrototype.CanBeAntag;
 }
 /// <inheritdoc cref="TryAssignJob(Robust.Shared.GameObjects.EntityUid,string,Content.Server.Station.Components.StationJobsComponent?)"/>
 /// <param name="station">Station to assign a job on.</param>
 /// <param name="job">Job to assign.</param>
 /// <param name="stationJobs">Resolve pattern, station jobs component of the station.</param>
 public bool TryAssignJob(EntityUid station, JobPrototype job, StationJobsComponent?stationJobs = null)
 {
     return(TryAssignJob(station, job.ID, stationJobs));
 }
 /// <inheritdoc cref="TryAdjustJobSlot(Robust.Shared.GameObjects.EntityUid,string,int,bool,bool,Content.Server.Station.Components.StationJobsComponent?)"/>
 /// <param name="station">Station to adjust the job slot on.</param>
 /// <param name="job">Job to adjust.</param>
 /// <param name="amount">Amount to adjust by.</param>
 /// <param name="createSlot">Whether or not it should create the slot if it doesn't exist.</param>
 /// <param name="clamp">Whether or not to clamp to zero if you'd remove more jobs than are available.</param>
 /// <param name="stationJobs">Resolve pattern, station jobs component of the station.</param>
 public bool TryAdjustJobSlot(EntityUid station, JobPrototype job, int amount, bool createSlot = false, bool clamp = false,
                              StationJobsComponent?stationJobs = null)
 {
     return(TryAdjustJobSlot(station, job.ID, amount, createSlot, clamp, stationJobs));
 }
Example #6
0
 public Job(Mind mind, JobPrototype jobPrototype) : base(mind)
 {
     Prototype = jobPrototype;
     Name      = jobPrototype.Name;
 }