2020-12-01 17:05:19 +01:00
#nullable enable
using Content.Server.Mobs ;
using Content.Server.Objectives.Interfaces ;
2020-12-07 14:52:55 +01:00
using Content.Shared.GameObjects.Components.Mobs.State ;
2020-12-01 17:05:19 +01:00
using JetBrains.Annotations ;
using Robust.Shared.Localization ;
2021-03-05 01:08:38 +01:00
using Robust.Shared.Serialization.Manager.Attributes ;
2020-12-01 17:05:19 +01:00
using Robust.Shared.Utility ;
namespace Content.Server.Objectives.Conditions
{
[UsedImplicitly]
2021-03-05 01:08:38 +01:00
[DataDefinition]
2020-12-01 17:05:19 +01:00
public class StayAliveCondition : IObjectiveCondition
{
private Mind ? _mind ;
public IObjectiveCondition GetAssigned ( Mind mind )
{
return new StayAliveCondition { _mind = mind } ;
}
public string Title = > Loc . GetString ( "Stay alive." ) ;
public string Description = > Loc . GetString ( "Survive this shift, we need you for another assignment." ) ;
public SpriteSpecifier Icon = > new SpriteSpecifier . Rsi ( new ResourcePath ( "Objects/Misc/skub.rsi" ) , "icon" ) ; //didn't know what else would have been a good icon for staying alive
2020-12-07 14:52:55 +01:00
public float Progress = > _mind ?
. OwnedEntity ?
. GetComponentOrNull < IMobStateComponent > ( ) ?
. IsDead ( ) ? ? false
? 0f
: 1f ;
2020-12-01 17:05:19 +01:00
public float Difficulty = > 1f ;
public bool Equals ( IObjectiveCondition ? other )
{
return other is StayAliveCondition sac & & Equals ( _mind , sac . _mind ) ;
}
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 ( ( StayAliveCondition ) obj ) ;
}
public override int GetHashCode ( )
{
return ( _mind ! = null ? _mind . GetHashCode ( ) : 0 ) ;
}
}
}