Files
crystall-punk-14/Content.Server/Objectives/Conditions/KillPersonCondition.cs

61 lines
2.1 KiB
C#
Raw Normal View History

using Content.Server.Objectives.Interfaces;
using Content.Server.Roles;
2021-12-03 15:25:51 +01:00
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Utility;
namespace Content.Server.Objectives.Conditions
{
public abstract class KillPersonCondition : IObjectiveCondition
{
2021-06-09 22:19:39 +02:00
protected Mind.Mind? Target;
public abstract IObjectiveCondition GetAssigned(Mind.Mind mind);
2021-12-03 15:25:51 +01:00
public string Title
{
get
{
var targetName = string.Empty;
var jobName = Target?.CurrentJob?.Name ?? "Unknown";
2021-12-03 15:25:51 +01:00
if (Target == null)
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
2021-12-03 15:25:51 +01:00
2021-12-05 21:02:04 +01:00
if (Target.CharacterName != null)
2021-12-03 15:25:51 +01:00
targetName = Target.CharacterName;
2021-12-05 21:02:04 +01:00
else if (Target.OwnedEntity is {Valid: true} owned)
targetName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(owned).EntityName;
2021-12-03 15:25:51 +01:00
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
2021-12-03 15:25:51 +01:00
}
}
public string Description => Loc.GetString("objective-condition-kill-person-description");
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Objects/Weapons/Guns/Pistols/mk58_wood.rsi"), "icon");
public float Progress => (Target?.CharacterDeadIC ?? true) ? 1f : 0f;
public float Difficulty => 2f;
public bool Equals(IObjectiveCondition? other)
{
return other is KillPersonCondition kpc && Equals(Target, kpc.Target);
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((KillPersonCondition) obj);
}
public override int GetHashCode()
{
return Target?.GetHashCode() ?? 0;
}
}
}