Skip to content

Commit

Permalink
Merge branch 'dev' into xmas-2024
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Dec 25, 2024
2 parents 638b466 + e3c7be2 commit 7c73439
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 94 deletions.
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Components/CollisionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void OnCollisionEnter(Collision collision)
Log.Error("Grenade is null!");
if (collision is null)
Log.Error("wat");
if (collision.collider)
if (!collision.collider)
Log.Error("water");
if (collision.collider.gameObject == null)
Log.Error("pepehm");
Expand Down
12 changes: 9 additions & 3 deletions EXILED/Exiled.API/Features/Core/UserSettings/SettingBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="SettingBase.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
Expand Down Expand Up @@ -131,7 +131,7 @@ public string HintDescription
public Action<Player, SettingBase> OnChanged { get; set; }

/// <summary>
/// Tries ti get the setting with the specified id.
/// Tries to get the setting with the specified id.
/// </summary>
/// <param name="player">Player who has received the setting.</param>
/// <param name="id">Id of the setting.</param>
Expand Down Expand Up @@ -328,7 +328,13 @@ internal static void OnSettingUpdated(ReferenceHub hub, ServerSpecificSettingBas
}

setting = list.Find(x => x.Id == settingBase.SettingId);
setting.OriginalDefinition.OnChanged?.Invoke(player, setting);

if (setting.OriginalDefinition == null)
{
Settings.Add(Create(settingBase.OriginalDefinition));
}

setting.OriginalDefinition?.OnChanged?.Invoke(player, setting);
}
}
}
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3714,7 +3714,7 @@ public override bool Equals(object obj)
/// <inheritdoc />
public override int GetHashCode()
{
return ReferenceHub.GetHashCode();
return base.GetHashCode();
}

/// <summary>
Expand Down
34 changes: 33 additions & 1 deletion EXILED/Exiled.API/Features/Toys/Speaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@

namespace Exiled.API.Features.Toys
{
using System.Collections.Generic;

using AdminToys;
using Enums;
using Exiled.API.Interfaces;
using UnityEngine;
using VoiceChat.Networking;
using VoiceChat.Playbacks;

/// <summary>
/// A wrapper class for <see cref="SpeakerToy"/>.
Expand Down Expand Up @@ -44,7 +48,7 @@ internal Speaker(SpeakerToy speakerToy)
public float Volume
{
get => Base.NetworkVolume;
set => Base.NetworkVolume = value;
set => Base.NetworkVolume = Mathf.Clamp01(value);
}

/// <summary>
Expand Down Expand Up @@ -86,6 +90,15 @@ public float MinDistance
set => Base.NetworkMinDistance = value;
}

/// <summary>
/// Gets or sets the controller ID of speaker.
/// </summary>
public byte ControllerId
{
get => Base.NetworkControllerId;
set => Base.NetworkControllerId = value;
}

/// <summary>
/// Creates a new <see cref="Speaker"/>.
/// </summary>
Expand All @@ -108,5 +121,24 @@ public static Speaker Create(Vector3? position, Vector3? rotation, Vector3? scal

return speaker;
}

/// <summary>
/// Plays audio through this speaker.
/// </summary>
/// <param name="message">An <see cref="AudioMessage"/> instance.</param>
/// <param name="targets">Targets who will hear the audio. If <c>null</c>, audio will be sent to all players.</param>
public static void Play(AudioMessage message, IEnumerable<Player> targets = null)
{
foreach (Player target in targets ?? Player.List)
target.Connection.Send(message);
}

/// <summary>
/// Plays audio through this speaker.
/// </summary>
/// <param name="samples">Audio samples.</param>
/// <param name="length">The length of the samples array.</param>
/// <param name="targets">Targets who will hear the audio. If <c>null</c>, audio will be sent to all players.</param>
public void Play(byte[] samples, int? length = null, IEnumerable<Player> targets = null) => Play(new AudioMessage(ControllerId, samples, length ?? samples.Length), targets);
}
}
2 changes: 1 addition & 1 deletion EXILED/Exiled.Events/EventArgs/Interfaces/IItemEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Exiled.Events.EventArgs.Interfaces
/// <summary>
/// Event args used for all <see cref="API.Features.Items.Item" /> related events.
/// </summary>
public interface IItemEvent : IExiledEvent
public interface IItemEvent : IPlayerEvent
{
/// <summary>
/// Gets the <see cref="API.Features.Items.Item" /> triggering the event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Exiled.Events.EventArgs.Item
/// <summary>
/// Contains all information before a player charges a <see cref="Jailbird"/>.
/// </summary>
public class ChargingJailbirdEventArgs : IPlayerEvent, IItemEvent
public class ChargingJailbirdEventArgs : IItemEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ChargingJailbirdEventArgs"/> class.
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.Events/EventArgs/Item/SwingingEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Exiled.Events.EventArgs.Item
/// <summary>
/// Contains all information before a player swings a <see cref="Jailbird"/>.
/// </summary>
public class SwingingEventArgs : IPlayerEvent, IItemEvent, IDeniableEvent
public class SwingingEventArgs : IItemEvent, IDeniableEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="SwingingEventArgs"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Exiled.Events.EventArgs.Player
/// <summary>
/// Contains all information after a player's held item changes.
/// </summary>
public class ChangedItemEventArgs : IPlayerEvent, IItemEvent
public class ChangedItemEventArgs : IItemEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ChangedItemEventArgs" /> class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="ChangingDisruptorModeEventArgs.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
Expand All @@ -8,6 +8,7 @@
namespace Exiled.Events.EventArgs.Player
{
using Exiled.API.Enums;
using Exiled.API.Features;
using Exiled.API.Features.Items;
using Exiled.Events.EventArgs.Interfaces;

Expand Down Expand Up @@ -37,5 +38,8 @@ public ChangingDisruptorModeEventArgs(Item firearm, bool mode)
/// Gets a new disruptor's fire mode.
/// </summary>
public DisruptorMode NewMode { get; }

/// <inheritdoc />
public Player Player => Item.Owner;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ public ChangingMicroHIDStateEventArgs(Item microHID, MicroHidPhase newPhase, boo

/// <inheritdoc/>
public Item Item => MicroHID;

/// <inheritdoc/>
public Player Player => MicroHID.Owner;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Exiled.Events.EventArgs.Player
/// <summary>
/// Contains all information before radio preset is changed.
/// </summary>
public class ChangingRadioPresetEventArgs : IPlayerEvent, IItemEvent, IDeniableEvent
public class ChangingRadioPresetEventArgs : IItemEvent, IDeniableEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ChangingRadioPresetEventArgs" /> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Exiled.Events.EventArgs.Player
/// <summary>
/// Contains all information before a player drops an item.
/// </summary>
public class DroppingItemEventArgs : IPlayerEvent, IItemEvent, IDeniableEvent
public class DroppingItemEventArgs : IItemEvent, IDeniableEvent
{
private bool isAllowed = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ public class InteractingElevatorEventArgs : IPlayerEvent, IDeniableEvent
/// <param name="elevator">
/// <inheritdoc cref="Elevator" />
/// </param>
/// <param name="isCalledFromInside">
/// <inheritdoc cref="IsCalledFromInside" />
/// </param>
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public InteractingElevatorEventArgs(Player player, ElevatorChamber elevator, bool isAllowed = true)
public InteractingElevatorEventArgs(Player player, ElevatorChamber elevator, bool isCalledFromInside, bool isAllowed = true)
{
Player = player;
Lift = Lift.Get(elevator);
Elevator = elevator;
IsCalledFromInside = isCalledFromInside;
IsAllowed = isAllowed;
}

Expand All @@ -54,6 +58,11 @@ public InteractingElevatorEventArgs(Player player, ElevatorChamber elevator, boo
/// </summary>
public bool IsAllowed { get; set; }

/// <summary>
/// Gets a value indicating whether the player as interact with the elevator from the inside.
/// </summary>
public bool IsCalledFromInside { get; }

/// <summary>
/// Gets the player who's interacting with the elevator.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Exiled.Events.EventArgs.Player
/// <summary>
/// Contains all information after adding an item to a player's inventory.
/// </summary>
public class ItemAddedEventArgs : IPlayerEvent, IItemEvent, IPickupEvent
public class ItemAddedEventArgs : IItemEvent, IPickupEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ItemAddedEventArgs"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Exiled.Events.EventArgs.Player
/// <summary>
/// Contains all information after removing an item from a player's inventory.
/// </summary>
public class ItemRemovedEventArgs : IPlayerEvent, IItemEvent, IPickupEvent
public class ItemRemovedEventArgs : IItemEvent, IPickupEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ItemRemovedEventArgs"/> class.
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.Events/EventArgs/Player/SpawningEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public SpawningEventArgs(Player player, Vector3 position, float rotation, Player
/// Gets the player's old <see cref="PlayerRoleBase">role</see>.
/// </summary>
[Obsolete("Removed because the method is no longer provide OldRole since version 14.0. Use Player.Role instead")]
public Role OldRole { get; }
public Role OldRole => Player.Role;

/// <summary>
/// Gets the player's new <see cref="PlayerRoleBase">role</see>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Exiled.Events.EventArgs.Player
/// <summary>
/// Contains all information before receving a throwing request.
/// </summary>
public class ThrowingRequestEventArgs : IPlayerEvent, IItemEvent
public class ThrowingRequestEventArgs : IItemEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ThrowingRequestEventArgs"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Exiled.Events.EventArgs.Player
/// <summary>
/// Contains all information after a player throws a grenade.
/// </summary>
public class ThrownProjectileEventArgs : IPlayerEvent, IItemEvent, IPickupEvent
public class ThrownProjectileEventArgs : IItemEvent, IPickupEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ThrownProjectileEventArgs"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@ public UsingMicroHIDEnergyEventArgs(MicroHIDItem microHIDitem, float newEnergy,
/// Gets or sets a value indicating whether the MicroHID energy can be changed.
/// </summary>
public bool IsAllowed { get; set; }

/// <inheritdoc/>
public Player Player => MicroHID.Owner;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Exiled.Events.EventArgs.Scp914
/// <summary>
/// Contains all information before SCP-914 upgrades an item.
/// </summary>
public class UpgradingInventoryItemEventArgs : IPlayerEvent, IItemEvent, IDeniableEvent
public class UpgradingInventoryItemEventArgs : IItemEvent, IDeniableEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="UpgradingInventoryItemEventArgs" /> class.
Expand Down
Loading

0 comments on commit 7c73439

Please sign in to comment.