2023-06-18 11:33:19 -07:00
|
|
|
using Content.Server.Mind;
|
2020-12-01 17:05:19 +01:00
|
|
|
using Content.Server.Objectives.Interfaces;
|
2023-07-09 22:00:08 +00:00
|
|
|
using Content.Server.Shuttles.Systems;
|
|
|
|
|
using Content.Shared.CCVar;
|
2023-01-13 16:57:10 -08:00
|
|
|
using Content.Shared.Mobs.Systems;
|
2023-07-09 22:00:08 +00:00
|
|
|
using Robust.Shared.Configuration;
|
2020-12-01 17:05:19 +01:00
|
|
|
using Robust.Shared.Utility;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Objectives.Conditions
|
|
|
|
|
{
|
|
|
|
|
public abstract class KillPersonCondition : IObjectiveCondition
|
|
|
|
|
{
|
2022-12-19 19:25:35 -08:00
|
|
|
protected IEntityManager EntityManager => IoCManager.Resolve<IEntityManager>();
|
2022-12-20 18:06:01 -06:00
|
|
|
protected MobStateSystem MobStateSystem => EntityManager.EntitySysManager.GetEntitySystem<MobStateSystem>();
|
2021-06-09 22:19:39 +02:00
|
|
|
protected Mind.Mind? Target;
|
|
|
|
|
public abstract IObjectiveCondition GetAssigned(Mind.Mind mind);
|
2020-12-01 17:05:19 +01:00
|
|
|
|
2023-07-09 22:00:08 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Whether the target must be truly dead, ignores missing evac.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected bool RequireDead = false;
|
|
|
|
|
|
2021-12-03 15:25:51 +01:00
|
|
|
public string Title
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var targetName = string.Empty;
|
2022-02-06 21:25:04 -05:00
|
|
|
var jobName = Target?.CurrentJob?.Name ?? "Unknown";
|
2021-12-03 15:25:51 +01:00
|
|
|
|
|
|
|
|
if (Target == null)
|
2022-02-06 21:25:04 -05:00
|
|
|
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
|
2021-12-03 15:25:51 +01:00
|
|
|
|
2022-11-03 22:58:19 -04:00
|
|
|
if (Target.OwnedEntity is {Valid: true} owned)
|
2022-12-19 19:25:35 -08:00
|
|
|
targetName = EntityManager.GetComponent<MetaDataComponent>(owned).EntityName;
|
2021-12-03 15:25:51 +01:00
|
|
|
|
2022-02-06 21:25:04 -05:00
|
|
|
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
|
2021-12-03 15:25:51 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-12-01 17:05:19 +01:00
|
|
|
|
2021-06-21 02:13:54 +02:00
|
|
|
public string Description => Loc.GetString("objective-condition-kill-person-description");
|
2020-12-01 17:05:19 +01:00
|
|
|
|
2023-04-20 20:16:01 +10:00
|
|
|
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ("Objects/Weapons/Guns/Pistols/viper.rsi"), "icon");
|
2020-12-01 17:05:19 +01:00
|
|
|
|
2023-06-18 11:33:19 -07:00
|
|
|
public float Progress
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2023-07-09 22:00:08 +00:00
|
|
|
if (Target == null || Target.OwnedEntity == null)
|
|
|
|
|
return 1f;
|
|
|
|
|
|
|
|
|
|
var entMan = IoCManager.Resolve<EntityManager>();
|
|
|
|
|
var mindSystem = entMan.System<MindSystem>();
|
|
|
|
|
if (mindSystem.IsCharacterDeadIc(Target))
|
|
|
|
|
return 1f;
|
|
|
|
|
|
|
|
|
|
if (RequireDead)
|
|
|
|
|
return 0f;
|
|
|
|
|
|
|
|
|
|
// if evac is disabled then they really do have to be dead
|
|
|
|
|
var configMan = IoCManager.Resolve<IConfigurationManager>();
|
|
|
|
|
if (!configMan.GetCVar(CCVars.EmergencyShuttleEnabled))
|
|
|
|
|
return 0f;
|
|
|
|
|
|
|
|
|
|
// target is escaping so you fail
|
|
|
|
|
var emergencyShuttle = entMan.System<EmergencyShuttleSystem>();
|
|
|
|
|
if (emergencyShuttle.IsTargetEscaping(Target.OwnedEntity.Value))
|
|
|
|
|
return 0f;
|
|
|
|
|
|
|
|
|
|
// evac has left without the target, greentext since the target is afk in space with a full oxygen tank and coordinates off.
|
|
|
|
|
if (emergencyShuttle.ShuttlesLeft)
|
|
|
|
|
return 1f;
|
|
|
|
|
|
|
|
|
|
// if evac is still here and target hasn't boarded, show 50% to give you an indicator that you are doing good
|
2023-07-10 23:22:54 +00:00
|
|
|
return emergencyShuttle.EmergencyShuttleArrived ? 0.5f : 0f;
|
2023-06-18 11:33:19 -07:00
|
|
|
}
|
|
|
|
|
}
|
2020-12-01 17:05:19 +01:00
|
|
|
|
2023-07-09 22:00:08 +00:00
|
|
|
public float Difficulty => 1.75f;
|
2020-12-01 17:05:19 +01:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|