ninja 2 electric boogaloo (#15534)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-09-10 07:20:27 +01:00
committed by GitHub
parent 25c8a03276
commit 24810d916b
153 changed files with 3892 additions and 78 deletions

View File

@@ -0,0 +1,70 @@
using Content.Server.Roles;
using Content.Shared.Mind;
using Content.Shared.Objectives.Interfaces;
using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Server.Objectives.Conditions;
/// <summary>
/// Objective condition that requires the player to be a ninja and have doorjacked at least a random number of airlocks.
/// </summary>
[DataDefinition]
public sealed partial class DoorjackCondition : IObjectiveCondition
{
private EntityUid? _mind;
private int _target;
public IObjectiveCondition GetAssigned(EntityUid uid, MindComponent mind)
{
// TODO: clamp to number of doors on station incase its somehow a shittle or something
return new DoorjackCondition {
_mind = uid,
_target = IoCManager.Resolve<IRobustRandom>().Next(15, 40)
};
}
public string Title => Loc.GetString("objective-condition-doorjack-title", ("count", _target));
public string Description => Loc.GetString("objective-condition-doorjack-description", ("count", _target));
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResPath("Objects/Tools/emag.rsi"), "icon");
public float Progress
{
get
{
// prevent divide-by-zero
if (_target == 0)
return 1f;
var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.TryGetComponent<NinjaRoleComponent>(_mind, out var role))
return 0f;
if (role.DoorsJacked >= _target)
return 1f;
return (float) role.DoorsJacked / (float) _target;
}
}
public float Difficulty => 1.5f;
public bool Equals(IObjectiveCondition? other)
{
return other is DoorjackCondition cond && Equals(_mind, cond._mind) && _target == cond._target;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj is DoorjackCondition cond && cond.Equals(this);
}
public override int GetHashCode()
{
return HashCode.Combine(_mind?.GetHashCode() ?? 0, _target);
}
}

View File

@@ -0,0 +1,75 @@
using Content.Server.Roles;
using Content.Server.Warps;
using Content.Shared.Mind;
using Content.Shared.Objectives.Interfaces;
using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Server.Objectives.Conditions;
/// <summary>
/// Objective condition that requires the player to be a ninja and have detonated their spider charge.
/// </summary>
[DataDefinition]
public sealed partial class SpiderChargeCondition : IObjectiveCondition
{
private EntityUid? _mind;
public IObjectiveCondition GetAssigned(EntityUid uid, MindComponent mind)
{
return new SpiderChargeCondition {
_mind = uid
};
}
public string Title
{
get
{
var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.TryGetComponent<NinjaRoleComponent>(_mind, out var role)
|| role.SpiderChargeTarget == null
|| !entMan.TryGetComponent<WarpPointComponent>(role.SpiderChargeTarget, out var warp)
|| warp.Location == null)
// 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));
}
}
public string Description => Loc.GetString("objective-condition-spider-charge-description");
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResPath("Objects/Weapons/Bombs/spidercharge.rsi"), "icon");
public float Progress
{
get
{
var entMan = IoCManager.Resolve<EntityManager>();
if (!entMan.TryGetComponent<NinjaRoleComponent>(_mind, out var role))
return 0f;
return role.SpiderChargeDetonated ? 1f : 0f;
}
}
public float Difficulty => 2.5f;
public bool Equals(IObjectiveCondition? other)
{
return other is SpiderChargeCondition 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 SpiderChargeCondition cond && cond.Equals(this);
}
public override int GetHashCode()
{
return _mind?.GetHashCode() ?? 0;
}
}

View File

@@ -0,0 +1,70 @@
using Content.Server.Roles;
using Content.Shared.Mind;
using Content.Shared.Objectives.Interfaces;
using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Server.Objectives.Conditions;
/// <summary>
/// Objective condition that requires the player to be a ninja and have stolen at least a random number of technologies.
/// </summary>
[DataDefinition]
public sealed partial class StealResearchCondition : IObjectiveCondition
{
private EntityUid? _mind;
private int _target;
public IObjectiveCondition GetAssigned(EntityUid uid, MindComponent mind)
{
// TODO: clamp to number of research nodes in a single discipline maybe so easily maintainable
return new StealResearchCondition {
_mind = uid,
_target = IoCManager.Resolve<IRobustRandom>().Next(5, 10)
};
}
public string Title => Loc.GetString("objective-condition-steal-research-title", ("count", _target));
public string Description => Loc.GetString("objective-condition-steal-research-description");
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResPath("Structures/Machines/server.rsi"), "server");
public float Progress
{
get
{
// prevent divide-by-zero
if (_target == 0)
return 1f;
var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.TryGetComponent<NinjaRoleComponent>(_mind, out var role))
return 0f;
if (role.DownloadedNodes.Count >= _target)
return 1f;
return (float) role.DownloadedNodes.Count / (float) _target;
}
}
public float Difficulty => 2.5f;
public bool Equals(IObjectiveCondition? other)
{
return other is StealResearchCondition cond && Equals(_mind, cond._mind) && _target == cond._target;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj is StealResearchCondition cond && cond.Equals(this);
}
public override int GetHashCode()
{
return HashCode.Combine(_mind?.GetHashCode() ?? 0, _target);
}
}

View File

@@ -0,0 +1,58 @@
using Content.Shared.Mind;
using Content.Shared.Objectives.Interfaces;
using Robust.Shared.Utility;
namespace Content.Server.Objectives.Conditions;
/// <summary>
/// Just requires that the player is not dead, ignores evac and what not.
/// </summary>
[DataDefinition]
public sealed partial class SurviveCondition : IObjectiveCondition
{
private EntityUid? _mind;
public IObjectiveCondition GetAssigned(EntityUid uid, MindComponent mind)
{
return new SurviveCondition {_mind = uid};
}
public string Title => Loc.GetString("objective-condition-survive-title");
public string Description => Loc.GetString("objective-condition-survive-description");
public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResPath("Clothing/Mask/ninja.rsi"), "icon");
public float Difficulty => 0.5f;
public float Progress
{
get
{
var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.TryGetComponent<MindComponent>(_mind, out var mind))
return 0f;
var mindSystem = entMan.System<SharedMindSystem>();
return mindSystem.IsCharacterDeadIc(mind) ? 0f : 1f;
}
}
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 int GetHashCode()
{
return (_mind != null ? _mind.GetHashCode() : 0);
}
}

View 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;
}
}

View File

@@ -0,0 +1,18 @@
using Content.Server.Roles;
using Content.Shared.Mind;
using Content.Shared.Objectives.Interfaces;
namespace Content.Server.Objectives.Requirements;
/// <summary>
/// Requires the player's mind to have the ninja role component, aka be a ninja.
/// </summary>
[DataDefinition]
public sealed partial class NinjaRequirement : IObjectiveRequirement
{
public bool CanBeAssigned(EntityUid mindId, MindComponent mind)
{
var entMan = IoCManager.Resolve<IEntityManager>();
return entMan.HasComponent<NinjaRoleComponent>(mindId);
}
}

View File

@@ -0,0 +1,19 @@
using Content.Server.Roles;
using Content.Shared.Mind;
using Content.Shared.Objectives.Interfaces;
namespace Content.Server.Objectives.Requirements;
/// <summary>
/// Requires the player to be a ninja that has a spider charge target assigned, which is almost always the case.
/// </summary>
[DataDefinition]
public sealed partial class SpiderChargeTargetRequirement : IObjectiveRequirement
{
public bool CanBeAssigned(EntityUid mindId, MindComponent mind)
{
var entMan = IoCManager.Resolve<IEntityManager>();
entMan.TryGetComponent<NinjaRoleComponent>(mindId, out var role);
return role?.SpiderChargeTarget != null;
}
}