* basic implementation * minor fixes * objectives temp commit * proper onstart bind * changes all conditions to be bound to a mind-instance * oops * oops v2 * adds possiblity to enable duplicate assignment of objective equal objectives are unable to be added * minor fixes, adds greentext * refactors incompatability to be defined by requirements * fixes a wrong whitespace * minor fix * addressed reviews v1 * address reviews v2 Co-authored-by: Exp <theexp111@gmail.com> * final sweep * adds/refactors traitor&sss cvars * Update Content.Server/Mobs/Mind.cs * never trust github web * adds datasets & makes codewords use them * addresses exp's reviews * addressed zumos reviews Co-authored-by: Paul <ritter.paul1+git@googlemail.com> Co-authored-by: Exp <theexp111@gmail.com>
61 lines
2.4 KiB
C#
61 lines
2.4 KiB
C#
#nullable enable
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Content.Server.GameObjects.Components.Mobs;
|
|
using Content.Server.Mobs.Roles;
|
|
using Content.Shared.GameObjects.Components.Actor;
|
|
using Content.Shared.Objectives;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Interfaces.Network;
|
|
using Robust.Shared.Players;
|
|
|
|
namespace Content.Server.GameObjects.Components.Actor
|
|
{
|
|
[RegisterComponent]
|
|
public class CharacterInfoComponent : SharedCharacterInfoComponent
|
|
{
|
|
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null)
|
|
{
|
|
if(session?.AttachedEntity != Owner) return;
|
|
|
|
switch (message)
|
|
{
|
|
case RequestCharacterInfoMessage _:
|
|
var conditions = new Dictionary<string, List<ConditionInfo>>();
|
|
var jobTitle = "No Profession";
|
|
if (Owner.TryGetComponent(out MindComponent? mindComponent))
|
|
{
|
|
var mind = mindComponent.Mind;
|
|
|
|
if (mind != null)
|
|
{
|
|
// getting conditions
|
|
foreach (var objective in mind.AllObjectives)
|
|
{
|
|
if (!conditions.ContainsKey(objective.Prototype.Issuer))
|
|
conditions[objective.Prototype.Issuer] = new List<ConditionInfo>();
|
|
foreach (var condition in objective.Conditions)
|
|
{
|
|
conditions[objective.Prototype.Issuer].Add(new ConditionInfo(condition.Title,
|
|
condition.Description, condition.Icon, condition.Progress));
|
|
}
|
|
}
|
|
|
|
// getting jobtitle
|
|
foreach (var role in mind.AllRoles)
|
|
{
|
|
if (role.GetType() == typeof(Job))
|
|
{
|
|
jobTitle = role.Name;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
SendNetworkMessage(new CharacterInfoMessage(jobTitle, conditions));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|