ninja 2 electric boogaloo (#15534)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
57
Content.Server/Objectives/Conditions/TerrorCondition.cs
Normal file
57
Content.Server/Objectives/Conditions/TerrorCondition.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Content.Server.Roles;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Objectives.Interfaces;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Objectives.Conditions;
|
||||
|
||||
/// <summary>
|
||||
/// Objective condition that requires the player to be a ninja and have called in a threat.
|
||||
/// </summary>
|
||||
[DataDefinition]
|
||||
public sealed partial class TerrorCondition : IObjectiveCondition
|
||||
{
|
||||
private EntityUid? _mind;
|
||||
|
||||
public IObjectiveCondition GetAssigned(EntityUid uid, MindComponent mind)
|
||||
{
|
||||
return new TerrorCondition {_mind = uid};
|
||||
}
|
||||
|
||||
public string Title => Loc.GetString("objective-condition-terror-title");
|
||||
|
||||
public string Description => Loc.GetString("objective-condition-terror-description");
|
||||
|
||||
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResPath("Objects/Fun/Instruments/otherinstruments.rsi"), "red_phone");
|
||||
|
||||
public float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
var entMan = IoCManager.Resolve<EntityManager>();
|
||||
if (!entMan.TryGetComponent<NinjaRoleComponent>(_mind, out var role))
|
||||
return 0f;
|
||||
|
||||
return role.CalledInThreat ? 1f : 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float Difficulty => 2.75f;
|
||||
|
||||
public bool Equals(IObjectiveCondition? other)
|
||||
{
|
||||
return other is TerrorCondition cond && Equals(_mind, cond._mind);
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
return obj is TerrorCondition cond && cond.Equals(this);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _mind?.GetHashCode() ?? 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user