Skip to content

Commit 074153a

Browse files
authored
Merge pull request #35 from Misfiy/dev
0.5.0 Release
2 parents 0c48cea + 4477374 commit 074153a

File tree

6 files changed

+104
-2
lines changed

6 files changed

+104
-2
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
namespace SecretAPI.Extensions
2+
{
3+
using Interactables.Interobjects.DoorUtils;
4+
using LabApi.Features.Wrappers;
5+
6+
/// <summary>
7+
/// Extensions related to the player.
8+
/// </summary>
9+
public static class PlayerExtensions
10+
{
11+
/// <summary>
12+
/// Checks if a player has the permission.
13+
/// </summary>
14+
/// <param name="player">The player to check.</param>
15+
/// <param name="permission">The permission to check.</param>
16+
/// <returns>If player has permission.</returns>
17+
public static bool HasGamePermission(this Player player, PlayerPermissions permission)
18+
{
19+
if (player.UserGroup == null)
20+
return false;
21+
22+
PlayerPermissions currentPerms = (PlayerPermissions)player.UserGroup.Permissions;
23+
return currentPerms.HasFlag(permission);
24+
}
25+
26+
/// <summary>
27+
/// Checks whether a player has permission to access a <see cref="IDoorPermissionRequester"/>.
28+
/// </summary>
29+
/// <param name="player">The player to check.</param>
30+
/// <param name="requester">The requester to check the player for permissions on.</param>
31+
/// <returns>Whether a valid permission was found.</returns>
32+
public static bool HasDoorPermission(this Player player, IDoorPermissionRequester requester)
33+
{
34+
if (player.IsBypassEnabled)
35+
return true;
36+
37+
if (player.RoleBase is IDoorPermissionProvider roleProvider && requester.PermissionsPolicy.CheckPermissions(roleProvider.GetPermissions(requester)))
38+
return true;
39+
40+
foreach (Item? item in player.Items)
41+
{
42+
if (item?.Base is IDoorPermissionProvider itemProvider && requester.PermissionsPolicy.CheckPermissions(itemProvider.GetPermissions(requester)))
43+
return true;
44+
}
45+
46+
return false;
47+
}
48+
}
49+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
namespace SecretAPI.Extensions
2+
{
3+
using System.Linq;
4+
using LabApi.Features.Interfaces;
5+
using LabApi.Features.Wrappers;
6+
using Scp914;
7+
8+
/// <summary>
9+
/// Extensions related to SCP-914.
10+
/// </summary>
11+
public static class Scp914Extensions
12+
{
13+
/// <summary>
14+
/// Process Player like 914 Without Being in 914.
15+
/// </summary>
16+
/// <param name="player">The player.</param>
17+
/// <param name="heldOnly">If it should upgrade only the held item.</param>
18+
/// <param name="setting">The knob setting.</param>
19+
public static void Process914Player(this Player player, bool heldOnly, Scp914KnobSetting setting)
20+
{
21+
if (heldOnly)
22+
{
23+
Process914Item(player.CurrentItem, setting);
24+
return;
25+
}
26+
27+
foreach (Item? item in player.Items.ToList())
28+
Process914Item(item, setting);
29+
}
30+
31+
/// <summary>
32+
/// Processes an item in 914.
33+
/// </summary>
34+
/// <param name="item">The item to process.</param>
35+
/// <param name="setting">The setting to process the item on.</param>
36+
public static void Process914Item(this Item? item, Scp914KnobSetting setting)
37+
{
38+
if (item == null)
39+
return;
40+
41+
IScp914ItemProcessor? processor = Scp914.GetItemProcessor(item.Type);
42+
processor?.UpgradeItem(setting, item);
43+
}
44+
}
45+
}

SecretAPI/Features/Effects/CustomPlayerEffect.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public override void Start()
4545
internal static void Initialize()
4646
{
4747
SecretApi.Harmony?.PatchCategory(nameof(CustomPlayerEffect), SecretApi.Assembly);
48+
#pragma warning disable CS0618 // Type or member is obsolete
4849
IGravityEffect.Initialize();
50+
#pragma warning restore CS0618 // Type or member is obsolete
4951
EffectsToRegister.Add(typeof(TemporaryDamageImmunity));
5052
EffectsToRegister.Add(typeof(StaminaUsageDisablerEffect));
5153
EffectsToRegister.Add(typeof(SprintDisablerEffect));

SecretAPI/Features/Effects/GravityIncreaseEffect.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
namespace SecretAPI.Features.Effects
22
{
3+
using System;
34
using UnityEngine;
45

56
/// <summary>
67
/// Increases the gravity of the player.
78
/// </summary>
9+
[Obsolete("This will be removed")]
810
public class GravityIncreaseEffect : CustomPlayerEffect, IGravityEffect
911
{
1012
/// <inheritdoc />

SecretAPI/Features/Effects/IGravityEffect.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
namespace SecretAPI.Features.Effects
22
{
3+
using System;
34
using CustomPlayerEffects;
45
using LabApi.Events.Handlers;
6+
using PlayerRoles.FirstPersonControl;
57
using UnityEngine;
68

79
/// <summary>
810
/// Handles an effect that affects gravity.
911
/// </summary>
12+
[Obsolete("This will be removed in the future.")]
1013
public interface IGravityEffect
1114
{
1215
/// <summary>
@@ -21,7 +24,7 @@ internal static void Initialize()
2124
{
2225
PlayerEvents.UpdatedEffect += ev =>
2326
{
24-
Vector3 multi = new(0f, -19.6f, 0f);
27+
Vector3 multi = FpcGravityController.DefaultGravity;
2528
bool isAffected = false;
2629
foreach (StatusEffectBase effectBase in ev.Player.ActiveEffects)
2730
{

SecretAPI/Features/UserSettings/CustomSetting.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ private static void SendSettingsToPlayer(Player player, int version = 1)
123123
ordered.AddRange(grouping.Select(setting => setting.Base));
124124
}
125125

126-
ordered.AddRange(ServerSpecificSettingsSync.DefinedSettings);
126+
if (ServerSpecificSettingsSync.DefinedSettings != null)
127+
ordered.AddRange(ServerSpecificSettingsSync.DefinedSettings);
127128

128129
ServerSpecificSettingsSync.SendToPlayer(player.ReferenceHub, [.. ordered], version);
129130
}

0 commit comments

Comments
 (0)