Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UwU #79

Merged
merged 2 commits into from
Aug 30, 2024
Merged

UwU #79

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
35 changes: 35 additions & 0 deletions EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,16 @@ public void Broadcast(ushort duration, string message, global::Broadcast.Broadca
public void AddAmmo(AmmoType ammoType, ushort amount) =>
Inventory.ServerAddAmmo(ammoType.GetItemType(), amount);

/// <summary>
/// Adds the amount of a specified ammo to player's inventory.
/// </summary>
/// <param name="ammo">A dictionary of ItemType and ushort of ammo and amount.</param>
public void AddAmmo(Dictionary<ItemType, ushort> ammo)
{
foreach (KeyValuePair<ItemType, ushort> kvp in ammo)
AddAmmo(kvp.Key.GetAmmoType(), kvp.Value);
}

/// <summary>
/// Adds the amount of a specified <see cref="AmmoType">ammo type</see> to player's inventory.
/// </summary>
Expand Down Expand Up @@ -2578,6 +2588,23 @@ public void ResetCategoryLimit(ItemCategory category)
/// <returns>If the player has a custom limit for the specific <see cref="ItemCategory"/>.</returns>
public bool HasCustomCategoryLimit(ItemCategory category) => CustomCategoryLimits.ContainsKey(category);

/// <summary>
/// Grants the player their current role's loadout.
/// </summary>
public void GrantLoadout() => GrantLoadout(Role.Type);

/// <summary>
/// Grants a player a role's loadout.
/// </summary>
/// <param name="roleType">The role loadout to give.</param>
public void GrantLoadout(RoleTypeId roleType)
{
InventoryRoleInfo info = roleType.GetInventory();

AddItem(info.Items);
AddAmmo(info.Ammo);
}

/// <summary>
/// Adds an item of the specified type with default durability(ammo/charge) and no mods to the player's inventory.
/// </summary>
Expand Down Expand Up @@ -3305,6 +3332,14 @@ public void SyncEffects(IEnumerable<Effect> effects)
SyncEffect(effect);
}

/// <summary>
/// Gets an effect of a player.
/// </summary>
/// <typeparam name="T">The <see cref="StatusEffectBase"/> to get.</typeparam>
/// <returns>The <see cref="StatusEffectBase"/> found.</returns>
public T GetEffect<T>()
where T : StatusEffectBase => ReferenceHub.playerEffectsController.GetEffect<T>();

/// <summary>
/// Gets an instance of <see cref="StatusEffectBase"/> by <see cref="EffectType"/>.
/// </summary>
Expand Down
21 changes: 15 additions & 6 deletions EXILED/Exiled.API/Features/Roles/Scp3114Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public RoleTypeId StolenRole
return;

Ragdoll.Role = value;
Identity.ServerResendIdentity();
UpdateIdentity();
}
}

Expand All @@ -166,7 +166,7 @@ public Ragdoll Ragdoll
set
{
Identity.CurIdentity.Ragdoll = value?.Base;
Identity.ServerResendIdentity();
UpdateIdentity();
}
}

Expand All @@ -179,7 +179,7 @@ public byte UnitId
set
{
Identity.CurIdentity.UnitNameId = value;
Identity.ServerResendIdentity();
UpdateIdentity();
}
}

Expand All @@ -192,7 +192,7 @@ public DisguiseStatus DisguiseStatus
set
{
Identity.CurIdentity.Status = value;
Identity.ServerResendIdentity();
UpdateIdentity();
}
}

Expand All @@ -202,7 +202,11 @@ public DisguiseStatus DisguiseStatus
public float DisguiseDuration
{
get => Identity._disguiseDurationSeconds;
set => Identity._disguiseDurationSeconds = value;
set
{
Identity._disguiseDurationSeconds = value;
UpdateIdentity();
}
}

/// <summary>
Expand All @@ -219,13 +223,18 @@ public float WarningTime
/// </summary>
internal DanceType DanceType { get; set; }

/// <summary>
/// Updates the identity of SCP-3114.
/// </summary>
public void UpdateIdentity() => Identity.ServerResendIdentity();

/// <summary>
/// Reset Scp3114 FakeIdentity.
/// </summary>
public void ResetIdentity()
{
Identity.CurIdentity.Reset();
Identity.ServerResendIdentity();
UpdateIdentity();
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions EXILED/Exiled.CustomItems/CustomItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Exiled.CustomItems
/// </summary>
public class CustomItems : Plugin<Config>
{
private RoundHandler? roundHandler;
private MapHandler? mapHandler;
private PlayerHandler? playerHandler;
private Harmony? harmony;

Expand All @@ -32,10 +32,10 @@ public class CustomItems : Plugin<Config>
public override void OnEnabled()
{
Instance = this;
roundHandler = new RoundHandler();
mapHandler = new MapHandler();
playerHandler = new PlayerHandler();

Exiled.Events.Handlers.Server.RoundStarted += roundHandler.OnRoundStarted;
Exiled.Events.Handlers.Map.Generated += mapHandler.OnMapGenerated;

Exiled.Events.Handlers.Player.ChangingItem += playerHandler.OnChangingItem;

Expand All @@ -50,7 +50,7 @@ public override void OnEnabled()
/// <inheritdoc />
public override void OnDisabled()
{
Exiled.Events.Handlers.Server.RoundStarted -= roundHandler!.OnRoundStarted;
Exiled.Events.Handlers.Map.Generated -= mapHandler!.OnMapGenerated;

Exiled.Events.Handlers.Player.ChangingItem -= playerHandler!.OnChangingItem;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
// <copyright file="RoundHandler.cs" company="Exiled Team">
// <copyright file="MapHandler.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
Expand All @@ -12,10 +12,12 @@ namespace Exiled.CustomItems.Events
/// <summary>
/// Event Handlers for the CustomItem API.
/// </summary>
internal sealed class RoundHandler
internal sealed class MapHandler
{
/// <inheritdoc cref="Exiled.Events.Handlers.Server.OnRoundStarted"/>
public void OnRoundStarted()
/// <summary>
/// Handle spawning Custom Items.
/// </summary>
public void OnMapGenerated()
{
foreach (CustomItem customItem in CustomItem.Registered)
customItem?.SpawnAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

namespace Exiled.Events.EventArgs.Player
{
using Interfaces;
using System;

using Interfaces;
using PlayerStatsSystem;

/// <summary>
/// Contains all information before player data to kill player is sent.
/// </summary>
[Obsolete]
public class KillingPlayerEventArgs : IPlayerEvent
{
/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion EXILED/Exiled.Events/Handlers/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

namespace Exiled.Events.Handlers
{
using Exiled.API.Features.Pickups;
using System;

#pragma warning disable IDE0079
#pragma warning disable IDE0060
#pragma warning disable SA1623 // Property summary documentation should match accessors
Expand Down Expand Up @@ -516,6 +517,7 @@ public class Player
/// <summary>
/// Invoked before KillPlayer is called.
/// </summary>
[Obsolete("Use DyingEventArgs")]
public static Event<KillingPlayerEventArgs> KillingPlayer { get; set; } = new();

/// <summary>
Expand Down Expand Up @@ -976,6 +978,7 @@ public class Player
/// Called before KillPlayer is called.
/// </summary>
/// <param name="ev">The <see cref="KillingPlayerEventArgs"/> event handler. </param>
[Obsolete("Use DyingEventArgs")]
public static void OnKillPlayer(KillingPlayerEventArgs ev) => KillingPlayer.InvokeSafely(ev);

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions EXILED/Exiled.Events/Patches/Fixes/KillPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace Exiled.Events.Patches.Fixes
{
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
#pragma warning disable CS0612 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete

using API.Features;
using API.Features.DamageHandlers;
Expand Down
Loading