Simple sponsorship system (#1189)
* simple sponsorship system * priority Join * OOC Sponsor Color * Update CP14SponsorRolePrototype.cs * loadout sponsorship * bruh * refactor to interfaces * Update CP14ClientSponsorManager.cs * finish loadout option * role pass
This commit is contained in:
@@ -24,6 +24,7 @@ using Content.Client.Singularity;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Client.Viewport;
|
||||
using Content.Client.Voting;
|
||||
using Content.Shared._CP14.Sponsor;
|
||||
using Content.Shared.Ame.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Gravity;
|
||||
@@ -48,6 +49,7 @@ namespace Content.Client.Entry
|
||||
//CP14
|
||||
[Dependency] private readonly DiscordAuthManager _discordAuth = default!;
|
||||
[Dependency] private readonly JoinQueueManager _joinQueueManager = default!;
|
||||
[Dependency] private readonly ICP14SponsorManager _sponsorManager = default!;
|
||||
//CP14 end
|
||||
[Dependency] private readonly IBaseClient _baseClient = default!;
|
||||
[Dependency] private readonly IGameController _gameController = default!;
|
||||
@@ -170,6 +172,7 @@ namespace Content.Client.Entry
|
||||
_overlayManager.AddOverlay(new CP14BasePostProcessOverlay());
|
||||
_discordAuth.Initialize();
|
||||
_joinQueueManager.Initialize();
|
||||
_sponsorManager.Initialize();
|
||||
//CP14 end
|
||||
_overlayManager.AddOverlay(new SingularityOverlay());
|
||||
_overlayManager.AddOverlay(new RadiationPulseOverlay());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Client._CP14.Discord;
|
||||
using Content.Client._CP14.JoinQueue;
|
||||
using Content.Client._CP14.Sponsor;
|
||||
using Content.Client.Administration.Managers;
|
||||
using Content.Client.Changelog;
|
||||
using Content.Client.Chat.Managers;
|
||||
@@ -22,6 +23,7 @@ using Content.Client.Voting;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Client.Lobby;
|
||||
using Content.Client.Players.RateLimiting;
|
||||
using Content.Shared._CP14.Sponsor;
|
||||
using Content.Shared.Administration.Managers;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Players.PlayTimeTracking;
|
||||
@@ -38,6 +40,7 @@ namespace Content.Client.IoC
|
||||
//CP14
|
||||
collection.Register<DiscordAuthManager>();
|
||||
collection.Register<JoinQueueManager>();
|
||||
collection.Register<ICP14SponsorManager, ClientSponsorSystem>();
|
||||
//CP14 end
|
||||
collection.Register<IParallaxManager, ParallaxManager>();
|
||||
collection.Register<IChatManager, ChatManager>();
|
||||
|
||||
@@ -126,7 +126,8 @@ public sealed class JobRequirementsManager : ISharedPlaytimeManager
|
||||
var reasons = new List<string>();
|
||||
foreach (var requirement in requirements)
|
||||
{
|
||||
if (requirement.Check(_entManager, _prototypes, profile, _roles, out var jobReason))
|
||||
//CP14 Add NetUserId for sponsorship checks
|
||||
if (requirement.Check(_playerManager.LocalSession?.UserId, _entManager, _prototypes, profile, _roles, out var jobReason))
|
||||
continue;
|
||||
|
||||
reasons.Add(jobReason.ToMarkup());
|
||||
|
||||
49
Content.Client/_CP14/Sponsor/CP14ClientSponsorManager.cs
Normal file
49
Content.Client/_CP14/Sponsor/CP14ClientSponsorManager.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared._CP14.Sponsor;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client._CP14.Sponsor;
|
||||
|
||||
public sealed class ClientSponsorSystem : ICP14SponsorManager
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly IClientNetManager _net = default!;
|
||||
|
||||
private CP14SponsorRolePrototype? _sponsorRole;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_net.RegisterNetMessage<CP14SponsorRoleUpdate>(OnSponsorRoleUpdate);
|
||||
_net.Disconnect += NetOnDisconnected;
|
||||
}
|
||||
|
||||
private void NetOnDisconnected(object? sender, NetDisconnectedArgs e)
|
||||
{
|
||||
_sponsorRole = null;
|
||||
}
|
||||
|
||||
private void OnSponsorRoleUpdate(CP14SponsorRoleUpdate msg)
|
||||
{
|
||||
if (!_proto.TryIndex(msg.Role, out var indexedRole))
|
||||
return;
|
||||
|
||||
_sponsorRole = indexedRole;
|
||||
}
|
||||
|
||||
public bool TryGetSponsorOOCColor(NetUserId userId, [NotNullWhen(true)] out Color? color)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool UserHasFeature(NetUserId userId, ProtoId<CP14SponsorFeaturePrototype> feature, bool ifDisabledSponsorhip = true)
|
||||
{
|
||||
if (_sponsorRole is null)
|
||||
return false;
|
||||
|
||||
if (!_proto.TryIndex(feature, out var indexedFeature))
|
||||
return false;
|
||||
|
||||
return _sponsorRole.Priority >= indexedFeature.MinPriority;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user