Skip to content

Commit

Permalink
Merge branch 'xmas-2024' into xmas-2024-from-xmas-2023
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Dec 26, 2024
2 parents 9c92b7f + 4abfe37 commit edc7f3e
Show file tree
Hide file tree
Showing 36 changed files with 549 additions and 121 deletions.
2 changes: 1 addition & 1 deletion EXILED/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) == ''">9.0.1</Version>
<Version Condition="$(Version) == ''">9.1.1</Version>
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
<PublicBeta>false</PublicBeta>

Expand Down
6 changes: 2 additions & 4 deletions EXILED/Exiled.API/Features/Items/Armor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public IEnumerable<BodyArmor.ArmorCategoryLimitModifier> CategoryLimits
{
Weight = Weight,
StaminaUseMultiplier = StaminaUseMultiplier,
RemoveExcessOnDrop = RemoveExcessOnDrop,
CategoryLimits = CategoryLimits,
StaminaRegenMultiplier = StaminaRegenMultiplier,
AmmoLimits = AmmoLimits,
Expand All @@ -159,14 +158,13 @@ public IEnumerable<BodyArmor.ArmorCategoryLimitModifier> CategoryLimits
};

/// <inheritdoc/>
internal override void ReadPickupInfo(Pickup pickup)
internal override void ReadPickupInfoBefore(Pickup pickup)
{
base.ReadPickupInfo(pickup);
base.ReadPickupInfoBefore(pickup);
if (pickup is Pickups.BodyArmorPickup armorPickup)
{
HelmetEfficacy = armorPickup.HelmetEfficacy;
VestEfficacy = armorPickup.VestEfficacy;
RemoveExcessOnDrop = armorPickup.RemoveExcessOnDrop;
StaminaUseMultiplier = armorPickup.StaminaUseMultiplier;
StaminaRegenMultiplier = armorPickup.StaminaRegenMultiplier;
AmmoLimits = armorPickup.AmmoLimits;
Expand Down
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Items/ExplosiveGrenade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ public ExplosionGrenadeProjectile SpawnActive(Vector3 position, Player owner = n
};

/// <inheritdoc/>
internal override void ReadPickupInfo(Pickup pickup)
internal override void ReadPickupInfoBefore(Pickup pickup)
{
base.ReadPickupInfo(pickup);
base.ReadPickupInfoBefore(pickup);
if (pickup is ExplosiveGrenadePickup explosiveGrenadePickup)
{
MaxRadius = explosiveGrenadePickup.MaxRadius;
Expand Down
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Items/Firearm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,9 @@ internal override void ChangeOwner(Player oldOwner, Player newOwner)
}

/// <inheritdoc/>
internal override void ReadPickupInfo(Pickup pickup)
internal override void ReadPickupInfoBefore(Pickup pickup)
{
base.ReadPickupInfo(pickup);
base.ReadPickupInfoBefore(pickup);

if (pickup is FirearmPickup firearmPickup)
{
Expand Down
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Items/FlashGrenade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ public FlashbangProjectile SpawnActive(Vector3 position, Player owner = null)
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{FuseTime}|";

/// <inheritdoc/>
internal override void ReadPickupInfo(Pickup pickup)
internal override void ReadPickupInfoBefore(Pickup pickup)
{
base.ReadPickupInfo(pickup);
base.ReadPickupInfoBefore(pickup);
if (pickup is FlashGrenadePickup flashGrenadePickup)
{
MinimalDurationEffect = flashGrenadePickup.MinimalDurationEffect;
Expand Down
20 changes: 19 additions & 1 deletion EXILED/Exiled.API/Features/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,30 @@ internal virtual void ChangeOwner(Player oldOwner, Player newOwner)
/// Helper method for saving data between items and pickups.
/// </summary>
/// <param name="pickup"><see cref="Pickup"/>-related data to give to the <see cref="Item"/>.</param>
internal virtual void ReadPickupInfo(Pickup pickup)
/// <remarks>
/// Analog to <see cref="ReadPickupInfoAfter(Pickup)"/>, but it is called before item initialization.
/// <see cref="ItemBase.OnAdded(ItemPickupBase)"/>.
/// </remarks>
/// <see cref="ReadPickupInfoAfter"/>
internal virtual void ReadPickupInfoBefore(Pickup pickup)
{
if (pickup is not null)
{
Scale = pickup.Scale;
}
}

/// <summary>
/// Helper method for saving data between items and pickups.
/// </summary>
/// <param name="pickup"><see cref="Pickup"/>-related data to give to the <see cref="Item"/>.</param>
/// <remarks>
/// Analog to <see cref="ReadPickupInfoAfter(Pickup)"/>, but it is called after item initialization.
/// <see cref="ItemBase.OnAdded(ItemPickupBase)"/>.
/// </remarks>
/// <see cref="ReadPickupInfoBefore"/>
internal virtual void ReadPickupInfoAfter(Pickup pickup)
{
}
}
}
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Items/Jailbird.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ public void Break()
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}*";

/// <inheritdoc/>
internal override void ReadPickupInfo(Pickup pickup)
internal override void ReadPickupInfoBefore(Pickup pickup)
{
base.ReadPickupInfo(pickup);
base.ReadPickupInfoBefore(pickup);
if (pickup is JailbirdPickup jailbirdPickup)
{
MeleeDamage = jailbirdPickup.MeleeDamage;
Expand Down
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Items/Keycard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public KeycardPermissions Permissions
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{Permissions}|";

/// <inheritdoc/>
internal override void ReadPickupInfo(Pickup pickup)
internal override void ReadPickupInfoBefore(Pickup pickup)
{
base.ReadPickupInfo(pickup);
base.ReadPickupInfoBefore(pickup);
if (pickup is KeycardPickup keycardPickup)
{
Permissions = keycardPickup.Permissions;
Expand Down
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Items/Scp244.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public override Pickup CreatePickup(Vector3 position, Quaternion? rotation = nul
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* -{Primed}-";

/// <inheritdoc/>
internal override void ReadPickupInfo(Pickup pickup)
internal override void ReadPickupInfoBefore(Pickup pickup)
{
base.ReadPickupInfo(pickup);
base.ReadPickupInfoBefore(pickup);
if (pickup is Scp244Pickup scp244)
{
Health = scp244.Health;
Expand Down
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Items/Usable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ public virtual void Use()
}

/// <inheritdoc/>
internal override void ReadPickupInfo(Pickup pickup)
internal override void ReadPickupInfoBefore(Pickup pickup)
{
base.ReadPickupInfo(pickup);
base.ReadPickupInfoBefore(pickup);
if (pickup is UsablePickup usablePickup)
{
UseTime = usablePickup.UseTime;
Expand Down
8 changes: 8 additions & 0 deletions EXILED/Exiled.API/Features/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public static class Map
DecontaminationController.Singleton.NetworkDecontaminationOverride is DecontaminationController.DecontaminationStatus.Disabled ?
DecontaminationState.Disabled : (DecontaminationState)DecontaminationController.Singleton._nextPhase;

/// <summary>
/// Gets the remaining time for the decontamination process.
/// </summary>
/// <returns>
/// The remaining time in seconds for the decontamination process.
/// </returns>
public static float RemainingDecontaminationTime => Mathf.Min(0, (float)(DecontaminationController.Singleton.DecontaminationPhases[DecontaminationController.Singleton.DecontaminationPhases.Length - 1].TimeTrigger - DecontaminationController.GetServerTime));

/// <summary>
/// Gets all <see cref="PocketDimensionTeleport"/> objects.
/// </summary>
Expand Down
3 changes: 1 addition & 2 deletions EXILED/Exiled.API/Features/Pickups/BodyArmorPickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ internal BodyArmorPickup(ItemType type)
/// <summary>
/// Gets or sets a value indicating whether excess ammo should be removed when the armor is dropped.
/// </summary>
[Obsolete("Propetry is internal, and controls armor remove logic for clearing inventory")]
public bool RemoveExcessOnDrop { get; set; }

/// <summary>
Expand Down Expand Up @@ -132,7 +133,6 @@ internal override void ReadItemInfo(Item item)
{
helmetEfficacy = armoritem.HelmetEfficacy;
vestEfficacy = armoritem.VestEfficacy;
RemoveExcessOnDrop = armoritem.RemoveExcessOnDrop;
StaminaUseMultiplier = armoritem.StaminaUseMultiplier;
StaminaRegenMultiplier = armoritem.StaminaRegenMultiplier;
AmmoLimits = armoritem.AmmoLimits;
Expand All @@ -148,7 +148,6 @@ protected override void InitializeProperties(ItemBase itemBase)
{
helmetEfficacy = armoritem.HelmetEfficacy;
vestEfficacy = armoritem.VestEfficacy;
RemoveExcessOnDrop = !armoritem.DontRemoveExcessOnDrop;
StaminaUseMultiplier = armoritem._staminaUseMultiplier;
StaminaRegenMultiplier = armoritem.StaminaRegenMultiplier;
AmmoLimits = armoritem.AmmoLimits.Select(limit => (ArmorAmmoLimit)limit);
Expand Down
9 changes: 6 additions & 3 deletions EXILED/Exiled.API/Features/Pickups/FirearmPickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ public override void Spawn()
/// <inheritdoc/>
internal override void ReadItemInfo(Items.Item item)
{
Items.Firearm firearm = (Items.Firearm)item;
MaxAmmo = firearm.PrimaryMagazine.ConstantMaxAmmo;
AmmoDrain = firearm.AmmoDrain;
if (item is Items.Firearm firearm)
{
MaxAmmo = firearm.PrimaryMagazine.ConstantMaxAmmo;
AmmoDrain = firearm.AmmoDrain;
}

base.ReadItemInfo(item);
}

Expand Down
6 changes: 3 additions & 3 deletions EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ public bool IsIntercomMuted
/// <summary>
/// Gets a value indicating whether the player is speaking.
/// </summary>
public bool IsSpeaking => Role is Roles.IVoiceRole voiceRole && voiceRole.VoiceModule.IsSpeaking;
public bool IsSpeaking => Role is Roles.IVoiceRole voiceRole && voiceRole.VoiceModule.ServerIsSending;

/// <summary>
/// Gets the player's voice color.
Expand Down Expand Up @@ -2781,7 +2781,7 @@ public void AddItem(Firearm item, IEnumerable<AttachmentIdentifier> identifiers)
/// <param name="pickup">The <see cref="Pickup"/> of the item to be added.</param>
/// <param name="addReason">The reason the item was added.</param>
/// <returns>The <see cref="Item"/> that was added.</returns>
public Item AddItem(Pickup pickup, ItemAddReason addReason = ItemAddReason.Undefined) => Item.Get(Inventory.ServerAddItem(pickup.Type, addReason, pickup.Serial, pickup.Base));
public Item AddItem(Pickup pickup, ItemAddReason addReason = ItemAddReason.AdminCommand) => Item.Get(Inventory.ServerAddItem(pickup.Type, addReason, pickup.Serial, pickup.Base));

/// <summary>
/// Adds an item to the player's inventory.
Expand All @@ -2791,7 +2791,7 @@ public void AddItem(Firearm item, IEnumerable<AttachmentIdentifier> identifiers)
/// <returns>The <see cref="Item"/> that was added.</returns>
public Item AddItem(FirearmPickup pickup, IEnumerable<AttachmentIdentifier> identifiers)
{
Firearm firearm = Item.Get<Firearm>(Inventory.ServerAddItem(pickup.Type, ItemAddReason.Undefined, pickup.Serial, pickup.Base));
Firearm firearm = Item.Get<Firearm>(Inventory.ServerAddItem(pickup.Type, ItemAddReason.AdminCommand, pickup.Serial, pickup.Base));

if (identifiers is not null)
firearm.AddAttachment(identifiers);
Expand Down
2 changes: 0 additions & 2 deletions EXILED/Exiled.API/Features/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,6 @@ private void InternalCreate()
Log.Error($"[ROOMTYPE UNKNOWN] {this} Name : {gameObject?.name} Shape : {Identifier?.Shape}");
#endif

RoomLightControllersValue.AddRange(gameObject.GetComponentsInChildren<RoomLightController>());

RoomLightControllers = RoomLightControllersValue.AsReadOnly();

GetComponentsInChildren<BreakableWindow>().ForEach(component =>
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/TeslaGate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public void ForceTrigger()
/// </summary>
/// <param name="player">The <see cref="Player"/> to check.</param>
/// <returns><see langword="true"/> if the given <see cref="Player"/> is in the hurt range of the tesla gate; otherwise, <see langword="false"/>.</returns>
public bool IsPlayerInHurtRange(Player player) => player is not null && Vector3.Distance(Position, player.Position) <= Base.sizeOfTrigger * 2.2f;
public bool IsPlayerInHurtRange(Player player) => player is not null && Base.killers.Any(x => new Bounds(x.transform.position, Base.sizeOfKiller).Contains(player.Position));

/// <summary>
/// Gets a value indicating whether the <see cref="Player"/> is in the idle range of a specific tesla gate.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// -----------------------------------------------------------------------
// <copyright file="ChangingMicroHIDPickupStateEventArgs.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Item
{
using Exiled.API.Features.Pickups;

using Interfaces;
using InventorySystem.Items.MicroHID.Modules;
using InventorySystem.Items.Pickups;

/// <summary>
/// Contains all information before MicroHID pickup state is changed.
/// </summary>
public class ChangingMicroHIDPickupStateEventArgs : IDeniableEvent, IPickupEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ChangingMicroHIDPickupStateEventArgs" /> class.
/// </summary>
/// <param name="microHID">
/// <inheritdoc cref="MicroHID" />
/// </param>
/// <param name="newPhase">
/// <inheritdoc cref="NewPhase" />
/// </param>
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public ChangingMicroHIDPickupStateEventArgs(ItemPickupBase microHID, MicroHidPhase newPhase, bool isAllowed = true)
{
MicroHID = Pickup.Get<MicroHIDPickup>(microHID);
NewPhase = newPhase;
IsAllowed = isAllowed;
}

/// <summary>
/// Gets the MicroHID instance.
/// </summary>
public MicroHIDPickup MicroHID { get; }

/// <summary>
/// Gets or sets the new MicroHID state.
/// </summary>
public MicroHidPhase NewPhase { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the MicroHID state can be changed.
/// </summary>
public bool IsAllowed { get; set; }

/// <inheritdoc/>
public Pickup Pickup => MicroHID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace Exiled.Events.EventArgs.Player
using API.Features;
using API.Features.Items;
using Interfaces;

using InventorySystem.Items;
using InventorySystem.Items.MicroHID;
using InventorySystem.Items.MicroHID.Modules;

Expand All @@ -32,9 +34,9 @@ public class ChangingMicroHIDStateEventArgs : IDeniableEvent, IItemEvent
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public ChangingMicroHIDStateEventArgs(Item microHID, MicroHidPhase newPhase, bool isAllowed = true)
public ChangingMicroHIDStateEventArgs(ItemBase microHID, MicroHidPhase newPhase, bool isAllowed = true)
{
MicroHID = microHID.As<MicroHid>();
MicroHID = Item.Get<MicroHid>(microHID);
NewPhase = newPhase;
IsAllowed = isAllowed;
}
Expand Down
15 changes: 4 additions & 11 deletions EXILED/Exiled.Events/EventArgs/Player/ReloadingWeaponEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,19 @@ public class ReloadingWeaponEventArgs : IPlayerEvent, IFirearmEvent, IDeniableEv
/// <summary>
/// Initializes a new instance of the <see cref="ReloadingWeaponEventArgs" /> class.
/// </summary>
/// <param name="player">
/// <inheritdoc cref="Player" />
/// </param>
/// <param name="firearm">
/// <inheritdoc cref="Firearm" />
/// </param>
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public ReloadingWeaponEventArgs(Player player, Firearm firearm, bool isAllowed = true)
public ReloadingWeaponEventArgs(InventorySystem.Items.Firearms.Firearm firearm)
{
Firearm = firearm;
Player = player;
IsAllowed = isAllowed;
Firearm = Item.Get<Firearm>(firearm);
Player = Firearm.Owner;
}

/// <summary>
/// Gets or sets a value indicating whether the weapon can be reloaded.
/// </summary>
public bool IsAllowed { get; set; }
public bool IsAllowed { get; set; } = true;

/// <summary>
/// Gets the <see cref="API.Features.Items.Firearm" /> being reloaded.
Expand Down
13 changes: 3 additions & 10 deletions EXILED/Exiled.Events/EventArgs/Player/UnloadingWeaponEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,19 @@ public class UnloadingWeaponEventArgs : IPlayerEvent, IFirearmEvent, IDeniableEv
/// <summary>
/// Initializes a new instance of the <see cref="UnloadingWeaponEventArgs" /> class.
/// </summary>
/// <param name="player">
/// <inheritdoc cref="Player" />
/// </param>
/// <param name="firearm">
/// <inheritdoc cref="Firearm" />
/// </param>
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public UnloadingWeaponEventArgs(Player player, Firearm firearm, bool isAllowed = true)
public UnloadingWeaponEventArgs(Firearm firearm)
{
Firearm = firearm;
Player = player;
IsAllowed = isAllowed;
Player = firearm.Owner;
}

/// <summary>
/// Gets or sets a value indicating whether the weapon can be unloaded.
/// </summary>
public bool IsAllowed { get; set; }
public bool IsAllowed { get; set; } = true;

/// <summary>
/// Gets the <see cref="API.Features.Items.Firearm" /> being unloaded.
Expand Down
Loading

0 comments on commit edc7f3e

Please sign in to comment.