mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* insanity * changeling real pliz * the wizard * no conflict plz :3 * Update Content.Server/Objectives/Systems/ChangelingEscapeDepartmentConditionSystem.cs Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> * linq is hell * Update Content.Server/Objectives/Systems/ChangelingEscapeDepartmentConditionSystem.cs Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com> * comment & API * wokism is real and is coming for you in this pride month * i am stoopid and dont know how to code :3 * cleanup, self review, usual stuff * oops * comments and difficulty * fuck everything * add to rolls * FFS * self ontag * filters? you should kill your mom, here's why women never fuck you here's how you could build a bomb. * ncat * Update Content.Shared/Roles/Jobs/SharedJobSystem.cs eqweqwewqe Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> * address slam,s reviews idfk this will be squashed anyway * from captain sprite (apparently removed on master) to atmosian sprite * Minor cleanup changes --------- Co-authored-by: nomdéraisonnablementlong <you@example.com> Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com> Co-authored-by: ScarKy0 <scarky0@onet.eu> Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
77 lines
2.4 KiB
C#
77 lines
2.4 KiB
C#
using Content.Server.Objectives.Components;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Objectives.Components;
|
|
using Content.Shared.Roles.Jobs;
|
|
using Robust.Shared.GameObjects;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace Content.Server.Objectives.Systems;
|
|
|
|
/// <summary>
|
|
/// Provides API for other components and handles setting the title.
|
|
/// </summary>
|
|
public sealed partial class TargetObjectiveSystem : EntitySystem
|
|
{
|
|
[Dependency] private MetaDataSystem _metaData = default!;
|
|
[Dependency] private SharedJobSystem _job = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<TargetObjectiveComponent, ObjectiveAfterAssignEvent>(OnAfterAssign);
|
|
}
|
|
|
|
private void OnAfterAssign(EntityUid uid, TargetObjectiveComponent comp, ref ObjectiveAfterAssignEvent args)
|
|
{
|
|
if (!GetTarget(uid, out var target, comp))
|
|
return;
|
|
|
|
_metaData.SetEntityName(uid, GetTitle(target.Value, comp.Title), args.Meta);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the Target field for the title and other components to use.
|
|
/// </summary>
|
|
public void SetTarget(EntityUid uid, EntityUid target, TargetObjectiveComponent? comp = null)
|
|
{
|
|
if (!Resolve(uid, ref comp))
|
|
return;
|
|
|
|
comp.Target = target;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the target from the component.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// If it is null then the prototype is invalid, just return.
|
|
/// </remarks>
|
|
public bool GetTarget(EntityUid uid, [NotNullWhen(true)] out EntityUid? target, TargetObjectiveComponent? comp = null)
|
|
{
|
|
target = Resolve(uid, ref comp) ? comp.Target : null;
|
|
return target != null;
|
|
}
|
|
|
|
private string GetTitle(EntityUid target, string title)
|
|
{
|
|
var targetName = "Unknown";
|
|
if (TryComp<MindComponent>(target, out var mind) && mind.CharacterName != null)
|
|
{
|
|
targetName = mind.CharacterName;
|
|
}
|
|
|
|
var jobName = _job.MindTryGetJobName(target);
|
|
|
|
var deptName = Loc.GetString("department-Unknown");
|
|
if (_job.MindTryGetJobId(target, out var jobId))
|
|
{
|
|
if (jobId.HasValue && _job.TryGetDepartment(jobId.Value, out var deptProto))
|
|
{
|
|
deptName = Loc.GetString(deptProto.Name);
|
|
}
|
|
}
|
|
return Loc.GetString(title, ("targetName", targetName), ("job", jobName), ("department", deptName));
|
|
}
|
|
|
|
}
|