Roundstart antag role restrictions revival (#20108)

Co-authored-by: Ray <vigersray@gmail.com>
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-09-20 08:54:53 +01:00
committed by GitHub
parent 35246963c7
commit 4fbebb6917
14 changed files with 229 additions and 150 deletions

View File

@@ -1,45 +1,46 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Roles
namespace Content.Shared.Roles;
/// <summary>
/// Describes information for a single antag.
/// </summary>
[Prototype("antag")]
[Serializable, NetSerializable]
public sealed class AntagPrototype : IPrototype
{
[ViewVariables]
[IdDataField]
public string ID { get; private set; } = default!;
/// <summary>
/// Describes information for a single antag.
/// The name of this antag as displayed to players.
/// </summary>
[Prototype("antag")]
public sealed class AntagPrototype : IPrototype
{
[ViewVariables]
[IdDataField]
public string ID { get; private set; } = default!;
[DataField("name")]
public string Name { get; private set; } = "";
/// <summary>
/// The name of this antag as displayed to players.
/// </summary>
[DataField("name")]
public string Name { get; private set; } = "";
/// <summary>
/// The antag's objective, shown in a tooltip in the antag preference menu or as a ghost role description.
/// </summary>
[DataField("objective", required: true)]
public string Objective { get; private set; } = "";
/// <summary>
/// The description of this antag shown in a tooltip.
/// </summary>
[DataField("description")]
public string? Description { get; private set; }
/// <summary>
/// Whether or not the antag role is one of the bad guys.
/// </summary>
[DataField("antagonist")]
public bool Antagonist { get; private set; }
/// <summary>
/// The antag's objective, displayed at round-start to the player.
/// </summary>
[DataField("objective")]
public string Objective { get; private set; } = "";
/// <summary>
/// Whether or not the player can set the antag role in antag preferences.
/// </summary>
[DataField("setPreference")]
public bool SetPreference { get; private set; }
/// <summary>
/// Whether or not the antag role is one of the bad guys.
/// </summary>
[DataField("antagonist")]
public bool Antagonist { get; private set; }
/// <summary>
/// Whether or not the player can set the antag role in antag preferences.
/// </summary>
[DataField("setPreference")]
public bool SetPreference { get; private set; }
}
/// <summary>
/// Requirements that must be met to opt in to this antag role.
/// </summary>
[DataField("requirements")]
public HashSet<JobRequirement>? Requirements;
}

View File

@@ -3,6 +3,7 @@ using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.Roles.Jobs;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
@@ -12,9 +13,11 @@ namespace Content.Shared.Roles
/// Abstract class for playtime and other requirements for role gates.
/// </summary>
[ImplicitDataDefinitionForInheritors]
[Serializable, NetSerializable]
public abstract partial class JobRequirement{}
[UsedImplicitly]
[Serializable, NetSerializable]
public sealed partial class DepartmentTimeRequirement : JobRequirement
{
/// <summary>
@@ -39,6 +42,7 @@ namespace Content.Shared.Roles
}
[UsedImplicitly]
[Serializable, NetSerializable]
public sealed partial class RoleTimeRequirement : JobRequirement
{
/// <summary>
@@ -55,6 +59,7 @@ namespace Content.Shared.Roles
}
[UsedImplicitly]
[Serializable, NetSerializable]
public sealed partial class OverallPlaytimeRequirement : JobRequirement
{
/// <inheritdoc cref="DepartmentTimeRequirement.Time"/>
@@ -209,7 +214,6 @@ namespace Content.Shared.Roles
return false;
}
return true;
}
default: