Skip to content

Commit

Permalink
v8.4.3 (#2305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misaka-ZeroTwo authored Dec 1, 2023
1 parent 297a0f4 commit 84e496f
Show file tree
Hide file tree
Showing 16 changed files with 173 additions and 40 deletions.
2 changes: 1 addition & 1 deletion EXILED.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PropertyGroup>
<!-- This is the global version and is used for all projects that don't have a version -->
<Version Condition="$(Version) == ''">8.4.2</Version>
<Version Condition="$(Version) == ''">8.4.3</Version>
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
<PublicBeta>false</PublicBeta>

Expand Down
6 changes: 3 additions & 3 deletions Exiled.API/Features/Items/Firearm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ public byte MaxAmmo
switch (Base.AmmoManagerModule)
{
case TubularMagazineAmmoManager tubularMagazineAmmoManager:
tubularMagazineAmmoManager.MaxAmmo = value;
tubularMagazineAmmoManager.MaxAmmo = (byte)(value - Base.AttachmentsValue(AttachmentParam.MagazineCapacityModifier) - (Base.Status.Flags.HasFlagFast(FirearmStatusFlags.Cocked) ? tubularMagazineAmmoManager.ChamberedRounds : 0));
break;
case ClipLoadedInternalMagAmmoManager clipLoadedInternalMagAmmoManager:
clipLoadedInternalMagAmmoManager.MaxAmmo = value;
clipLoadedInternalMagAmmoManager.MaxAmmo = (byte)(value - Base.AttachmentsValue(AttachmentParam.MagazineCapacityModifier));
break;
case AutomaticAmmoManager automaticAmmoManager:
automaticAmmoManager.MaxAmmo = value;
automaticAmmoManager.MaxAmmo = (byte)(value - Base.AttachmentsValue(AttachmentParam.MagazineCapacityModifier) - automaticAmmoManager.ChamberedAmount);
break;
default:
Log.Warn($"MaxAmmo can't be used for this Item: {Type} ({Base.AmmoManagerModule})");
Expand Down
24 changes: 21 additions & 3 deletions Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ public float HumeShield
/// <summary>
/// Gets or sets the item in the player's hand. Value will be <see langword="null"/> if the player is not holding anything.
/// </summary>
/// <seealso cref="DropHeldItem"/>
/// <seealso cref="DropHeldItem()"/>
public Item CurrentItem
{
get => Item.Get(Inventory.CurInstance);
Expand Down Expand Up @@ -1834,9 +1834,27 @@ public void Broadcast(Broadcast broadcast, bool shouldClearPrevious = false)
/// <summary>
/// Drops an item from the player's inventory.
/// </summary>
/// <param name="item">The item to be dropped.</param>
/// <param name="item">The <see cref="Item"/> to be dropped.</param>
/// <param name="isThrown">Is the item Thrown?.</param>
public void DropItem(Item item, bool isThrown = false)
{
if (item is null)
return;
Inventory.UserCode_CmdDropItem__UInt16__Boolean(item.Serial, isThrown);
}

/// <summary>
/// Drops an item from the player's inventory.
/// </summary>
/// <param name="item">The <see cref="Item"/> to be dropped.</param>
/// <returns>dropped <see cref="Pickup"/>.</returns>
public Pickup DropItem(Item item) => Pickup.Get(Inventory.ServerDropItem(item.Serial));
public Pickup DropItem(Item item) => item is not null ? Pickup.Get(Inventory.ServerDropItem(item.Serial)) : null;

/// <summary>
/// Drops the held item. Will not do anything if the player is not holding an item.
/// </summary>
/// <param name="isThrown">Is the item Thrown?.</param>
public void DropHeldItem(bool isThrown = false) => DropItem(CurrentItem, isThrown);

/// <summary>
/// Drops the held item. Will not do anything if the player is not holding an item.
Expand Down
7 changes: 5 additions & 2 deletions Exiled.CustomItems/API/Features/CustomWeapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Exiled.CustomItems.API.Features
{
using System;

using Exiled.API.Enums;
using Exiled.API.Extensions;
using Exiled.API.Features;
using Exiled.API.Features.DamageHandlers;
Expand All @@ -19,7 +18,6 @@ namespace Exiled.CustomItems.API.Features

using InventorySystem.Items.Firearms.Attachments;
using InventorySystem.Items.Firearms.Attachments.Components;
using InventorySystem.Items.Firearms.BasicMessages;

using UnityEngine;

Expand Down Expand Up @@ -77,6 +75,7 @@ public override ItemType Type
firearm.AddAttachment(Attachments);

firearm.Ammo = ClipSize;
firearm.MaxAmmo = ClipSize;

Pickup? pickup = firearm.CreatePickup(position);

Expand All @@ -102,7 +101,9 @@ public override ItemType Type
{
if (!Attachments.IsEmpty())
firearm.AddAttachment(Attachments);

byte ammo = firearm.Ammo;
firearm.MaxAmmo = ClipSize;
Log.Debug($"{nameof(Name)}.{nameof(Spawn)}: Spawning weapon with {ammo} ammo.");
Pickup? pickup = firearm.CreatePickup(position);
pickup.Scale = Scale;
Expand All @@ -126,7 +127,9 @@ public override void Give(Player player, bool displayMessage = true)
{
if (!Attachments.IsEmpty())
firearm.AddAttachment(Attachments);

firearm.Ammo = ClipSize;
firearm.MaxAmmo = ClipSize;
}

Log.Debug($"{nameof(Give)}: Adding {item.Serial} to tracker.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public SpawningTeamVehicleEventArgs(SpawnableTeamType team, bool isAllowed = tru
/// <summary>
/// Gets or sets a value indicating whether or not the vehicle can be spawned.
/// </summary>
public bool IsAllowed { get; set; } = true;
public bool IsAllowed { get; set; }
}
}
8 changes: 4 additions & 4 deletions Exiled.Events/EventArgs/Player/ClosingGeneratorEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ public ClosingGeneratorEventArgs(Player player, Scp079Generator generator, bool
}

/// <summary>
/// Gets or sets a value indicating whether or not the generator door can be opened.
/// Gets or sets a value indicating whether or not the generator door can be closed.
/// </summary>
public bool IsAllowed { get; set; }

/// <summary>
/// Gets the generator that is opening.
/// Gets the generator that is being closed.
/// </summary>
public Generator Generator { get; }

/// <summary>
/// Gets the player who's opening the generator door.
/// Gets the player who's closing the generator door.
/// </summary>
public Player Player { get; }
}
}
}
50 changes: 50 additions & 0 deletions Exiled.Events/EventArgs/Player/ItemRemovedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// -----------------------------------------------------------------------
// <copyright file="ItemRemovedEventArgs.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Player
{
using Exiled.API.Features.Items;
using Exiled.API.Features.Pickups;
using Exiled.Events.EventArgs.Interfaces;

using InventorySystem.Items;
using InventorySystem.Items.Pickups;

/// <summary>
/// Contains all information after removing an item from a player's inventory.
/// </summary>
public class ItemRemovedEventArgs : IPlayerEvent, IItemEvent, IPickupEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ItemRemovedEventArgs"/> class.
/// </summary>
/// <param name="referenceHub">The <see cref="ReferenceHub"/> the item was removed to.</param>
/// <param name="itemBase">The removed <see cref="ItemBase"/>.</param>
/// <param name="pickupBase">The <see cref="ItemPickupBase"/> the <see cref="ItemBase"/> originated from, or <see langword="null"/> if the item was not picked up.</param>
public ItemRemovedEventArgs(ReferenceHub referenceHub, ItemBase itemBase, ItemPickupBase pickupBase)
{
Player = API.Features.Player.Get(referenceHub);
Item = Item.Get(itemBase);
Pickup = Pickup.Get(pickupBase);
}

/// <summary>
/// Gets the player that had the item removed.
/// </summary>
public API.Features.Player Player { get; }

/// <summary>
/// Gets the item that was removed.
/// </summary>
public Item Item { get; }

/// <summary>
/// Gets the pickup that the item originated from or <see langword="null"/> if the item was not picked up.
/// </summary>
public Pickup Pickup { get; }
}
}
6 changes: 3 additions & 3 deletions Exiled.Events/EventArgs/Player/PickingUpItemEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public PickingUpItemEventArgs(Player player, ItemPickupBase pickup, bool isAllow
public bool IsAllowed { get; set; }

/// <summary>
/// Gets the dropped pickup.
/// Gets the pickup that's being picked up.
/// </summary>
public Pickup Pickup { get; }

/// <summary>
/// Gets the player who dropped the item.
/// Gets the player who's picking up an item.
/// </summary>
public Player Player { get; }
}
}
}
5 changes: 2 additions & 3 deletions Exiled.Events/EventArgs/Player/TogglingFlashlightEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace Exiled.Events.EventArgs.Player
using API.Features.Items;

using Interfaces;

using InventorySystem.Items.ToggleableLights.Flashlight;
using InventorySystem.Items.ToggleableLights;

/// <summary>
/// Contains all information before a player toggles a flashlight.
Expand All @@ -33,7 +32,7 @@ public class TogglingFlashlightEventArgs : IPlayerEvent, IDeniableEvent, IItemEv
/// <param name="newState">
/// <inheritdoc cref="NewState" />
/// </param>
public TogglingFlashlightEventArgs(ReferenceHub hub, FlashlightItem flashlight, bool newState)
public TogglingFlashlightEventArgs(ReferenceHub hub, ToggleableLightItemBase flashlight, bool newState)
{
Player = Player.Get(hub);
Flashlight = (Flashlight)Item.Get(flashlight);
Expand Down
8 changes: 4 additions & 4 deletions Exiled.Events/EventArgs/Scp244/OpeningScp244EventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Exiled.Events.EventArgs.Scp244
using InventorySystem.Items.Usables.Scp244;

/// <summary>
/// Contains all information before a player picks up an SCP-244.
/// Contains all information before a player opens SCP-244.
/// </summary>
public class OpeningScp244EventArgs : IDeniableEvent
{
Expand All @@ -29,13 +29,13 @@ public OpeningScp244EventArgs(Scp244DeployablePickup pickup)
}

/// <summary>
/// Gets a value representing the <see cref="Scp244Pickup"/> being picked up.
/// Gets a value representing the <see cref="Scp244Pickup"/> being opened.
/// </summary>
public Scp244Pickup Pickup { get; }

/// <summary>
/// Gets or sets a value indicating whether or not the player can interact with SCP-330.
/// Gets or sets a value indicating whether or not the player can open SCP-244.
/// </summary>
public bool IsAllowed { get; set; } = true;
}
}
}
8 changes: 4 additions & 4 deletions Exiled.Events/EventArgs/Scp244/UsingScp244EventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Exiled.Events.EventArgs.Scp244
using InventorySystem.Items.Usables.Scp244;

/// <summary>
/// Contains all information before radio battery charge is changed.
/// Contains all information before SCP-244 is used.
/// </summary>
public class UsingScp244EventArgs : IPlayerEvent, IDeniableEvent
{
Expand Down Expand Up @@ -44,13 +44,13 @@ public UsingScp244EventArgs(Scp244Item scp244, Player player, bool isAllowed = t
public Scp244 Scp244 { get; }

/// <summary>
/// Gets or sets a value indicating whether the radio battery charge can be changed or not.
/// Gets or sets a value indicating whether the SCP-244 can be used.
/// </summary>
public bool IsAllowed { get; set; }

/// <summary>
/// Gets the player who's using the radio.
/// Gets the player who's using the SCP-244.
/// </summary>
public Player Player { get; }
}
}
}
1 change: 1 addition & 0 deletions Exiled.Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public override void OnEnabled()
CharacterClassManager.OnRoundStarted += Handlers.Server.OnRoundStarted;

InventorySystem.InventoryExtensions.OnItemAdded += Handlers.Player.OnItemAdded;
InventorySystem.InventoryExtensions.OnItemRemoved += Handlers.Player.OnItemRemoved;

RagdollManager.OnRagdollSpawned += Handlers.Internal.RagdollList.OnSpawnedRagdoll;
RagdollManager.OnRagdollRemoved += Handlers.Internal.RagdollList.OnRemovedRagdoll;
Expand Down
14 changes: 14 additions & 0 deletions Exiled.Events/Handlers/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@ public class Player
/// </summary>
public static Event<ItemAddedEventArgs> ItemAdded { get; set; } = new();

/// <summary>
/// Invoked after a <see cref="T:Exiled.API.Features.Player" /> has an item removed from their inventory.
/// </summary>
public static Event<ItemRemovedEventArgs> ItemRemoved { get; set; } = new();

/// <summary>
/// Invoked before KillPlayer is called.
/// </summary>
Expand Down Expand Up @@ -927,6 +932,15 @@ public class Player
public static void OnItemAdded(ReferenceHub referenceHub, InventorySystem.Items.ItemBase itemBase, InventorySystem.Items.Pickups.ItemPickupBase pickupBase)
=> ItemAdded.InvokeSafely(new ItemAddedEventArgs(referenceHub, itemBase, pickupBase));

/// <summary>
/// Called after a <see cref="T:Exiled.API.Features.Player" /> has an item removed from their inventory.
/// </summary>
/// <param name="referenceHub">The <see cref="ReferenceHub"/> the item was removed from.</param>
/// <param name="itemBase">The removed <see cref="InventorySystem.Items.ItemBase"/>.</param>
/// <param name="pickupBase">The <see cref="InventorySystem.Items.Pickups.ItemPickupBase"/> the <see cref="InventorySystem.Items.ItemBase"/> originated from, or <see langword="null"/> if the item was not picked up.</param>
public static void OnItemRemoved(ReferenceHub referenceHub, InventorySystem.Items.ItemBase itemBase, InventorySystem.Items.Pickups.ItemPickupBase pickupBase)
=> ItemRemoved.InvokeSafely(new ItemRemovedEventArgs(referenceHub, itemBase, pickupBase));

/// <summary>
/// Called before a <see cref="API.Features.Player"/> enters in an environmental hazard.
/// </summary>
Expand Down
Loading

0 comments on commit 84e496f

Please sign in to comment.