Skip to content

Commit

Permalink
Merge branch 'space-sunrise:master' into DOUBLE-LANG-FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinary1 authored Jun 7, 2024
2 parents b4cfa6b + 6b7fe51 commit c40591e
Show file tree
Hide file tree
Showing 269 changed files with 2,661 additions and 132 deletions.
3 changes: 3 additions & 0 deletions Content.Client/Clothing/ClientClothingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public sealed class ClientClothingSystem : ClothingSystem
{"belt", "BELT"},
{"gloves", "HAND"},
{"shoes", "FEET"},
{"pants", "PANTS"}, // Sunrise-edit
{"socks", "SOCKS"}, // Sunrise-edit
{"bra", "BRA"}, // Sunrise-edit
{"id", "IDCARD"},
{"pocket1", "POCKET1"},
{"pocket2", "POCKET2"},
Expand Down
8 changes: 6 additions & 2 deletions Content.Client/Guidebook/Controls/GuidebookWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:fancyTree="clr-namespace:Content.Client.UserInterface.Controls.FancyTree"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
SetSize="750 700"
SetSize="850 700"
MinSize="100 200"
Resizable="True"
Title="{Loc 'guidebook-window-title'}">
Expand All @@ -21,9 +21,13 @@
Margin="0 5 10 5">
</LineEdit>
</BoxContainer>
<BoxContainer Access="Internal" Name="ReturnContainer" Orientation="Horizontal" HorizontalAlignment="Right" Visible="False">
<Button Name="HomeButton" Text="{Loc 'ui-rules-button-home'}" Margin="0 0 10 0"/>
</BoxContainer>
<ScrollContainer Name="Scroll" HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True">
<Control>
<BoxContainer Orientation="Vertical" Name="EntryContainer" Margin="5 5 5 5" Visible="False"/>
<BoxContainer Orientation="Vertical" Name="EntryContainer" Margin="5 5 5 5" Visible="False">
</BoxContainer>
<BoxContainer Orientation="Vertical" Name="Placeholder" Margin="5 5 5 5">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'guidebook-placeholder-text'}"/>
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'guidebook-placeholder-text-2'}"/>
Expand Down
11 changes: 11 additions & 0 deletions Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Client.UserInterface.ControlExtensions;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Controls.FancyTree;
using Content.Client.UserInterface.Systems.Info;
using Content.Shared.Guidebook;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
Expand Down Expand Up @@ -36,7 +37,13 @@ public GuidebookWindow()
private void OnSelectionChanged(TreeItem? item)
{
if (item != null && item.Metadata is GuideEntry entry)
{
ShowGuide(entry);

var isRulesEntry = entry.RuleEntry;
ReturnContainer.Visible = isRulesEntry;
HomeButton.OnPressed += _ => ShowGuide(entry);
}
else
ClearSelectedGuide();
}
Expand Down Expand Up @@ -153,6 +160,10 @@ private void RepopulateTree(List<ProtoId<GuideEntryPrototype>>? roots = null, Pr
return null;
}

var rulesProto = UserInterfaceManager.GetUIController<InfoUIController>().GetCoreRuleEntry();
if (entry.RuleEntry && entry.Id != rulesProto.Id)
return null;

var item = Tree.AddItem(parent);
item.Metadata = entry;
var name = Loc.GetString(entry.Name);
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,8 @@ public void RefreshAntags()
selector.Setup(items, title, 250, description, guides: antag.Guides);
selector.Select(Profile?.AntagPreferences.Contains(antag.ID) == true ? 0 : 1);

if (!_requirements.CheckRoleTime(antag.Requirements, out var reason))
var requirements = _entManager.System<SharedRoleSystem>().GetAntagRequirement(antag);
if (!_requirements.CheckRoleTime(requirements, out var reason))
{
selector.LockRequirements(reason);
Profile = Profile?.WithAntagPreference(antag.ID, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ public bool IsAllowed(JobPrototype job, [NotNullWhen(false)] out FormattedMessag
}
// Sunrise-End

return CheckRoleTime(job.Requirements, out reason);
return CheckRoleTime(job, out reason);
}

public bool CheckRoleTime(JobPrototype job, [NotNullWhen(false)] out FormattedMessage? reason)
{
var reqs = _entManager.System<SharedRoleSystem>().GetJobRequirement(job);
return CheckRoleTime(reqs, out reason);
}

public bool CheckRoleTime(HashSet<JobRequirement>? requirements, [NotNullWhen(false)] out FormattedMessage? reason)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ private void OnWindowClosed()
{
if (GuidebookButton != null)
GuidebookButton.Pressed = false;

if (_guideWindow != null)
_guideWindow.ReturnContainer.Visible = false;
}

private void OnWindowOpen()
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Antag/AntagSelectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ public AntagSelectionPlayerPool GetPlayerPool(Entity<AntagSelectionComponent> en
/// </summary>
public bool IsSessionValid(Entity<AntagSelectionComponent> ent, ICommonSession? session, AntagSelectionDefinition def, EntityUid? mind = null)
{
// TODO ROLE TIMERS
// Check if antag role requirements are met

if (session == null)
return true;

Expand Down
4 changes: 4 additions & 0 deletions Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public sealed partial class GhostRoleComponent : Component

[DataField("rules")] private string _roleRules = "ghost-role-component-default-rules";

// TODO ROLE TIMERS
// Actually make use of / enforce this requirement?
// Why is this even here.
// Move to ghost role prototype & respect CCvars.GameRoleTimerOverride
[DataField("requirements")]
public HashSet<JobRequirement>? Requirements;

Expand Down
37 changes: 9 additions & 28 deletions Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
[Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly PlayTimeTrackingManager _tracking = default!;
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly SharedRoleSystem _role = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -197,7 +198,6 @@ private void OnGetDisallowedJobs(ref GetDisallowedJobsEvent ev)
public bool IsAllowed(ICommonSession player, string role)
{
if (!_prototypes.TryIndex<JobPrototype>(role, out var job) ||
job.Requirements == null ||
!_cfg.GetCVar(CCVars.GameRoleTimers))
return true;

Expand All @@ -224,19 +224,8 @@ public HashSet<ProtoId<JobPrototype>> GetDisallowedJobs(ICommonSession player)

foreach (var job in _prototypes.EnumeratePrototypes<JobPrototype>())
{
if (job.Requirements != null)
{
foreach (var requirement in job.Requirements)
{
if (JobRequirements.TryRequirementMet(requirement, playTimes, out _, EntityManager, _prototypes))
continue;

goto NoRole;
}
}

roles.Add(job.ID);
NoRole:;
if (JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes))
roles.Add(job.ID);
}

return roles;
Expand All @@ -257,22 +246,14 @@ public void RemoveDisallowedJobs(NetUserId userId, List<ProtoId<JobPrototype>> j

for (var i = 0; i < jobs.Count; i++)
{
var job = jobs[i];

if (!_prototypes.TryIndex(job, out var jobber) ||
jobber.Requirements == null ||
jobber.Requirements.Count == 0)
continue;

foreach (var requirement in jobber.Requirements)
if (_prototypes.TryIndex(jobs[i], out var job)
&& JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes))
{
if (JobRequirements.TryRequirementMet(requirement, playTimes, out _, EntityManager, _prototypes))
continue;

jobs.RemoveSwap(i);
i--;
break;
continue;
}

jobs.RemoveSwap(i);
i--;
}
}

Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Maps;
using Content.Shared.Roles;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Physics.Components;
Expand Down Expand Up @@ -219,6 +220,12 @@ public static readonly CVarDef<bool>
public static readonly CVarDef<bool>
GameRoleTimers = CVarDef.Create("game.role_timers", true, CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Override default role requirements using a <see cref="JobRequirementOverridePrototype"/>
/// </summary>
public static readonly CVarDef<string>
GameRoleTimerOverride = CVarDef.Create("game.role_timer_override", "", CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// If roles should be restricted based on whether or not they are whitelisted.
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions Content.Shared/Ghost/Roles/GhostRolePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ public sealed partial class GhostRolePrototype : IPrototype
/// <summary>
/// The name of the ghostrole.
/// </summary>
[DataField]
[DataField(required: true)]
public string Name { get; set; } = default!;

/// <summary>
/// The description of the ghostrole.
/// </summary>
[DataField]
[DataField(required: true)]
public string Description { get; set; } = default!;

/// <summary>
/// The entity prototype of the ghostrole
/// </summary>
[DataField]
public string EntityPrototype = default!;
[DataField(required: true)]
public EntProtoId EntityPrototype;

/// <summary>
/// Rules of the ghostrole
/// </summary>
[DataField]
[DataField(required: true)]
public string Rules = default!;
}
}
5 changes: 5 additions & 0 deletions Content.Shared/Ghost/Roles/GhostRolesEuiMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public struct GhostRoleInfo
public string Name { get; set; }
public string Description { get; set; }
public string Rules { get; set; }

// TODO ROLE TIMERS
// Actually make use of / enforce this requirement?
// Why is this even here.
// Move to ghost role prototype & respect CCvars.GameRoleTimerOverride
public HashSet<JobRequirement>? Requirements { get; set; }

/// <inheritdoc cref="GhostRoleKind"/>
Expand Down
2 changes: 2 additions & 0 deletions Content.Shared/Guidebook/GuideEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class GuideEntry
/// </summary>
[DataField] public bool FilterEnabled = default!;

[DataField] public bool RuleEntry;

/// <summary>
/// Priority for sorting top-level guides when shown in a tree / table of contents.
/// If the guide is the child of some other guide, the order simply determined by the order of children in <see cref="Children"/>.
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/Inventory/SlotFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public enum SlotFlags
LEGS = 1 << 13,
FEET = 1 << 14,
SUITSTORAGE = 1 << 15,
PANTS = 1 << 16, // Sunrise-edit
BRA = 1 << 17, // Sunrise-edit
SOCKS = 1 << 18, // Sunrise-edit
All = ~NONE,

WITHOUT_POCKET = All & ~POCKET
Expand Down
25 changes: 25 additions & 0 deletions Content.Shared/Preferences/Loadouts/Effects/SexLoadoutEffect.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Humanoid;
using Robust.Shared.Player;
using Robust.Shared.Utility;

namespace Content.Shared.Preferences.Loadouts.Effects;

public sealed partial class SexLoadoutEffect : LoadoutEffect
{
[DataField(required: true)]
public List<Sex> Sex = new();

public override bool Validate(HumanoidCharacterProfile profile, RoleLoadout loadout, LoadoutPrototype proto, ICommonSession session, IDependencyCollection collection,
[NotNullWhen(false)] out FormattedMessage? reason)
{
if (Sex.Contains(profile.Sex))
{
reason = null;
return true;
}

reason = FormattedMessage.FromUnformatted(Loc.GetString("loadout-group-sex-restriction"));
return false;
}
}
4 changes: 3 additions & 1 deletion Content.Shared/Roles/AntagPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public sealed partial class AntagPrototype : IPrototype
/// <summary>
/// Requirements that must be met to opt in to this antag role.
/// </summary>
[DataField("requirements")]
// TODO ROLE TIMERS
// Actually check if the requirements are met. Because apparently this is actually unused.
[DataField, Access(typeof(SharedRoleSystem), Other = AccessPermissions.None)]
public HashSet<JobRequirement>? Requirements;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Roles/JobPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public sealed partial class JobPrototype : IPrototype
[ViewVariables(VVAccess.ReadOnly)]
public string? LocalizedDescription => Description is null ? null : Loc.GetString(Description);

[DataField("requirements")]
[DataField, Access(typeof(SharedRoleSystem), Other = AccessPermissions.None)]
public HashSet<JobRequirement>? Requirements;

[DataField("joinNotifyCrew")]
Expand Down
20 changes: 20 additions & 0 deletions Content.Shared/Roles/JobRequirementOverridePrototype.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Robust.Shared.Prototypes;

namespace Content.Shared.Roles;

/// <summary>
/// Collection of job, antag, and ghost-role job requirements for per-server requirement overrides.
/// </summary>
[Prototype]
public sealed partial class JobRequirementOverridePrototype : IPrototype
{
[ViewVariables]
[IdDataField]
public string ID { get; private set; } = default!;

[DataField]
public Dictionary<ProtoId<JobPrototype>, HashSet<JobRequirement>> Jobs = new ();

[DataField]
public Dictionary<ProtoId<AntagPrototype>, HashSet<JobRequirement>> Antags = new ();
}
Loading

0 comments on commit c40591e

Please sign in to comment.