[Fix] move ninja objectives into NinjaRole (#15490)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using Content.Server.Ninja.Systems;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Shared.Ninja.Components;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -30,16 +30,14 @@ public sealed class DoorjackCondition : IObjectiveCondition
|
||||
{
|
||||
get
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (_mind?.OwnedEntity == null
|
||||
|| !entMan.TryGetComponent<NinjaComponent>(_mind.OwnedEntity, out var ninja))
|
||||
return 0f;
|
||||
|
||||
// prevent divide-by-zero
|
||||
if (_target == 0)
|
||||
return 1f;
|
||||
|
||||
return (float) ninja.DoorsJacked / (float) _target;
|
||||
if (!NinjaSystem.GetNinjaRole(_mind, out var role))
|
||||
return 0f;
|
||||
|
||||
return (float) role.DoorsJacked / (float) _target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Content.Server.Ninja.Systems;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Shared.Ninja.Components;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -34,12 +34,10 @@ public sealed class DownloadCondition : IObjectiveCondition
|
||||
if (_target == 0)
|
||||
return 1f;
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (_mind?.OwnedEntity == null
|
||||
|| !entMan.TryGetComponent<NinjaComponent>(_mind.OwnedEntity, out var ninja))
|
||||
if (!NinjaSystem.GetNinjaRole(_mind, out var role))
|
||||
return 0f;
|
||||
|
||||
return (float) ninja.DownloadedNodes.Count / (float) _target;
|
||||
return (float) role.DownloadedNodes.Count / (float) _target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Content.Server.Ninja.Systems;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Server.Warps;
|
||||
using Content.Shared.Ninja.Components;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -23,12 +23,11 @@ public sealed class SpiderChargeCondition : IObjectiveCondition
|
||||
get
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (_mind?.OwnedEntity == null
|
||||
|| !entMan.TryGetComponent<NinjaComponent>(_mind.OwnedEntity, out var ninja)
|
||||
|| ninja.SpiderChargeTarget == null
|
||||
|| !entMan.TryGetComponent<WarpPointComponent>(ninja.SpiderChargeTarget, out var warp)
|
||||
if (!NinjaSystem.GetNinjaRole(_mind, out var role)
|
||||
|| role.SpiderChargeTarget == null
|
||||
|| !entMan.TryGetComponent<WarpPointComponent>(role.SpiderChargeTarget, out var warp)
|
||||
|| warp.Location == null)
|
||||
// if you are funny and microbomb then press c, you get this
|
||||
// this should never really happen but eh
|
||||
return Loc.GetString("objective-condition-spider-charge-no-target");
|
||||
|
||||
return Loc.GetString("objective-condition-spider-charge-title", ("location", warp.Location));
|
||||
@@ -43,12 +42,10 @@ public sealed class SpiderChargeCondition : IObjectiveCondition
|
||||
{
|
||||
get
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (_mind?.OwnedEntity == null
|
||||
|| !entMan.TryGetComponent<NinjaComponent>(_mind.OwnedEntity, out var ninja))
|
||||
if (!NinjaSystem.GetNinjaRole(_mind, out var role))
|
||||
return 0f;
|
||||
|
||||
return ninja.SpiderChargeDetonated ? 1f : 0f;
|
||||
return role.SpiderChargeDetonated ? 1f : 0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,46 +1,43 @@
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Objectives.Conditions
|
||||
namespace Content.Server.Objectives.Conditions;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class SurviveCondition : IObjectiveCondition
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed class SurviveCondition : IObjectiveCondition
|
||||
private Mind.Mind? _mind;
|
||||
|
||||
public IObjectiveCondition GetAssigned(Mind.Mind mind)
|
||||
{
|
||||
private Mind.Mind? _mind;
|
||||
return new SurviveCondition {_mind = mind};
|
||||
}
|
||||
|
||||
public IObjectiveCondition GetAssigned(Mind.Mind mind)
|
||||
{
|
||||
return new SurviveCondition {_mind = mind};
|
||||
}
|
||||
public string Title => Loc.GetString("objective-condition-survive-title");
|
||||
|
||||
public string Title => Loc.GetString("objective-condition-survive-title");
|
||||
public string Description => Loc.GetString("objective-condition-survive-description");
|
||||
|
||||
public string Description => Loc.GetString("objective-condition-survive-description");
|
||||
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Clothing/Head/Helmets/spaceninja.rsi"), "icon");
|
||||
|
||||
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Clothing/Head/Helmets/spaceninja.rsi"), "icon");
|
||||
public float Difficulty => 0.5f;
|
||||
|
||||
public float Difficulty => 0.5f;
|
||||
public float Progress => (_mind?.CharacterDeadIC ?? true) ? 0f : 1f;
|
||||
|
||||
public float Progress => (_mind?.CharacterDeadIC ?? true) ? 0f : 1f;
|
||||
public bool Equals(IObjectiveCondition? other)
|
||||
{
|
||||
return other is SurviveCondition condition && Equals(_mind, condition._mind);
|
||||
}
|
||||
|
||||
public bool Equals(IObjectiveCondition? other)
|
||||
{
|
||||
return other is SurviveCondition condition && Equals(_mind, condition._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((SurviveCondition) obj);
|
||||
}
|
||||
|
||||
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((SurviveCondition) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (_mind != null ? _mind.GetHashCode() : 0);
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (_mind != null ? _mind.GetHashCode() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Content.Server.Ninja.Systems;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Shared.Ninja.Components;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Objectives.Conditions;
|
||||
@@ -24,12 +24,10 @@ public sealed class TerrorCondition : IObjectiveCondition
|
||||
{
|
||||
get
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (_mind?.OwnedEntity == null
|
||||
|| !entMan.TryGetComponent<NinjaComponent>(_mind.OwnedEntity, out var ninja))
|
||||
if (!NinjaSystem.GetNinjaRole(_mind, out var role))
|
||||
return 0f;
|
||||
|
||||
return ninja.CalledInThreat ? 1f : 0f;
|
||||
return role.CalledInThreat ? 1f : 0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
13
Content.Server/Objectives/Requirements/NinjaRequirement.cs
Normal file
13
Content.Server/Objectives/Requirements/NinjaRequirement.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Server.Ninja;
|
||||
|
||||
namespace Content.Server.Objectives.Requirements;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class NinjaRequirement : IObjectiveRequirement
|
||||
{
|
||||
public bool CanBeAssigned(Mind.Mind mind)
|
||||
{
|
||||
return mind.HasRole<NinjaRole>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user