Skip to content

Commit

Permalink
Merge branch 'dev' into InteractingScp330CompileFix
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 authored Aug 10, 2024
2 parents 96c9b12 + a1ae554 commit a2ffbd7
Show file tree
Hide file tree
Showing 7 changed files with 336 additions and 6 deletions.
30 changes: 30 additions & 0 deletions EXILED/Exiled.API/Enums/UncuffReason.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// -----------------------------------------------------------------------
// <copyright file="UncuffReason.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Enums
{
/// <summary>
/// Reasons that player gets uncuffed.
/// </summary>
public enum UncuffReason
{
/// <summary>
/// Uncuffed by a player.
/// </summary>
Player,

/// <summary>
/// Uncuffed due to the distance between cuffer and target.
/// </summary>
OutOfRange,

/// <summary>
/// Uncuffed due to the cuffer no longer alive.
/// </summary>
CufferDied,
}
}
15 changes: 14 additions & 1 deletion EXILED/Exiled.API/Features/Npc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Exiled.API.Features
using Exiled.API.Enums;
using Exiled.API.Extensions;
using Exiled.API.Features.Components;

using Footprinting;

using MEC;
Expand Down Expand Up @@ -52,6 +51,20 @@ public Npc(GameObject gameObject)
/// </summary>
public static new List<Npc> List => Player.List.OfType<Npc>().ToList();

/// <summary>
/// Gets or sets the player's position.
/// </summary>
public override Vector3 Position
{
get => base.Position;
set
{
base.Position = value;
if (Role is Roles.FpcRole fpcRole)
fpcRole.RelativePosition = new(value);
}
}

/// <summary>
/// Retrieves the NPC associated with the specified ReferenceHub.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ public Player Cuffer
/// </summary>
/// <seealso cref="Teleport(Vector3)"/>
/// <seealso cref="Teleport(object)"/>
public Vector3 Position
public virtual Vector3 Position
{
get => Transform.position;
set => ReferenceHub.TryOverridePosition(value, Vector3.zero);
Expand Down
47 changes: 47 additions & 0 deletions EXILED/Exiled.Events/EventArgs/Player/RemovedHandcuffsEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// -----------------------------------------------------------------------
// <copyright file="RemovedHandcuffsEventArgs.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 API.Enums;
using API.Features;
using Exiled.Events.EventArgs.Interfaces;

/// <summary>
/// Contains all information after freeing a handcuffed player.
/// </summary>
public class RemovedHandcuffsEventArgs : IPlayerEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="RemovedHandcuffsEventArgs" /> class.
/// </summary>
/// <param name="cuffer">The cuffer player.</param>
/// <param name="target">The target player was uncuffed.</param>
/// <param name="uncuffReason">The reason for removing the handcuffs.</param>
public RemovedHandcuffsEventArgs(Player cuffer, Player target, UncuffReason uncuffReason)
{
Player = cuffer;
Target = target;
UncuffReason = uncuffReason;
}

/// <summary>
/// Gets the target player to be cuffed.
/// </summary>
public Player Target { get; }

/// <summary>
/// Gets the cuffer player.
/// </summary>
public Player Player { get; }

/// <summary>
/// Gets the reason for removing handcuffs.
/// </summary>
public UncuffReason UncuffReason { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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

Expand All @@ -20,11 +21,13 @@ public class RemovingHandcuffsEventArgs : IPlayerEvent, IDeniableEvent
/// </summary>
/// <param name="cuffer">The cuffer player.</param>
/// <param name="target">The target player to be uncuffed.</param>
/// <param name="uncuffReason">The reason of removing handcuffs.</param>
/// <param name="isAllowed">Indicates whether the event can be executed or not.</param>
public RemovingHandcuffsEventArgs(Player cuffer, Player target, bool isAllowed = true)
public RemovingHandcuffsEventArgs(Player cuffer, Player target, UncuffReason uncuffReason, bool isAllowed = true)
{
Player = cuffer;
Target = target;
UncuffReason = uncuffReason;
IsAllowed = isAllowed;
}

Expand All @@ -34,13 +37,19 @@ public RemovingHandcuffsEventArgs(Player cuffer, Player target, bool isAllowed =
public Player Target { get; }

/// <summary>
/// Gets or sets a value indicating whether or not the player can be handcuffed.
/// Gets or sets a value indicating whether or not the player can be handcuffed. Denying the event will only have an effect when <see cref="UncuffReason" /> is <see cref="UncuffReason.Player" /> until next major update.
/// </summary>
/// TODO: Update docs and patches
public bool IsAllowed { get; set; }

/// <summary>
/// Gets the cuffer player.
/// </summary>
public Player Player { get; }

/// <summary>
/// Gets the reason of removing handcuffs.
/// </summary>
public UncuffReason UncuffReason { get; }
}
}
11 changes: 11 additions & 0 deletions EXILED/Exiled.Events/Handlers/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ public class Player
/// </summary>
public static Event<RemovingHandcuffsEventArgs> RemovingHandcuffs { get; set; } = new();

/// <summary>
/// Invoked after freeing a handcuffed <see cref="API.Features.Player"/>.
/// </summary>
public static Event<RemovedHandcuffsEventArgs> RemovedHandcuffs { get; set; } = new();

/// <summary>
/// Invoked before a <see cref="API.Features.Player"/> escapes.
/// </summary>
Expand Down Expand Up @@ -704,6 +709,12 @@ public class Player
/// <param name="ev">The <see cref="RemovingHandcuffsEventArgs"/> instance.</param>
public static void OnRemovingHandcuffs(RemovingHandcuffsEventArgs ev) => RemovingHandcuffs.InvokeSafely(ev);

/// <summary>
/// Called after freeing a handcuffed <see cref="API.Features.Player"/>.
/// </summary>
/// <param name="ev">The <see cref="RemovedHandcuffsEventArgs"/> instance.</param>
public static void OnRemovedHandcuffs(RemovedHandcuffsEventArgs ev) => RemovedHandcuffs.InvokeSafely(ev);

/// <summary>
/// Called before a <see cref="API.Features.Player"/> escapes.
/// </summary>
Expand Down
Loading

0 comments on commit a2ffbd7

Please sign in to comment.