Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion LabApi/Features/Wrappers/Players/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using InventorySystem.Items.Usables.Scp330;
using UnityEngine;
using Utils.Networking;
using Utils.NonAllocLINQ;
Expand Down Expand Up @@ -1334,6 +1335,41 @@ public void ClearInventory(bool clearAmmo = true, bool clearItems = true)
if (clearItems)
ClearItems();
}

/// <summary>
/// Gives a candy to the player.
/// </summary>
/// <param name="candy">The candy to give the player.</param>
/// <param name="reason">The reason to grant the candy bag.</param>
public void GiveCandy(CandyKindID candy, ItemAddReason reason)
=> ReferenceHub.GrantCandy(candy, reason);

/// <summary>
/// Gives a random candy to the player.
/// </summary>
/// <param name="reason">The reason to grant the candy bag.</param>
/// <remarks>This will use <see cref="Scp330Candies.GetRandom"/>, meaning it will use <see cref="ICandy.SpawnChanceWeight"/> to choose the candy.</remarks>
public void GiveRandomCandy(ItemAddReason reason = ItemAddReason.AdminCommand)
=> GiveCandy(Scp330Candies.GetRandom(), reason);

/// <summary>
/// Checks if a player has the specified <see cref="PlayerPermissions"/>.
/// </summary>
/// <param name="permission">The permission to check the player for.</param>
/// <returns>Whether the permission check was successful.</returns>
public bool HasPermission(PlayerPermissions permission)
{
PlayerPermissions currentPerms = (PlayerPermissions)ReferenceHub.serverRoles.Permissions;
return currentPerms.HasFlag(permission);
}

/// <summary>
/// Adds regeneration to the player.
/// </summary>
/// <param name="rate">The rate to heal per second.</param>
/// <param name="duration">How long the regeneration should last.</param>
public void AddRegeneration(float rate, float duration)
=> Scp330Bag.AddSimpleRegeneration(ReferenceHub, rate, duration);

/// <summary>
/// Heals the player by the specified amount.
Expand All @@ -1342,7 +1378,7 @@ public void ClearInventory(bool clearAmmo = true, bool clearItems = true)
public void Heal(float amount) => ReferenceHub.playerStats.GetModule<HealthStat>().ServerHeal(amount);

/// <summary>
/// Creates and run a new AHP proccess.
/// Creates and run a new AHP process.
/// </summary>
/// <param name="amount">Amount of AHP to be added.</param>
/// <param name="limit">Adds limit to the AHP.</param>
Expand Down