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

Dev to master #3

Merged
merged 26 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7262f06
Merge pull request #23 from ExMod-Team/master
Jesus-QC Aug 1, 2024
c9654ee
uwu (#5)
VALERA771 Aug 1, 2024
6ebeac5
Merge pull request #26 from ExMod-Team/master
louis1706 Aug 2, 2024
5653733
AdminToy.List (#18)
louis1706 Aug 2, 2024
5a519a4
Fix `Jailbird::WearState` (#12)
louis1706 Aug 2, 2024
81c3652
Porting EXILED9 RespawnedTeam event. by.VALERA771 (#27)
YongAn404 Aug 2, 2024
1f2d209
Fix not returning null (#22)
louis1706 Aug 4, 2024
4e50826
RecontainedEventArgs more feature (#20)
louis1706 Aug 6, 2024
3ffe156
InteractingScp330.cs: Reduction of bloat code from original design. (…
Undid-Iridium Aug 6, 2024
e39238e
IScp330Event (#11)
louis1706 Aug 6, 2024
f1cc6f4
PR than i made (#9)
louis1706 Aug 6, 2024
eb046ac
[Events] Fix null reference (#15)
louis1706 Aug 6, 2024
a7354b7
Offline mode support (#19)
x3rt Aug 6, 2024
259cabb
Fix NW bugs (#32)
skyfr0676 Aug 6, 2024
26d1fcc
Useless Event (939 Placed Amnestic Cloud) (#40)
x3rt Aug 7, 2024
03d6bd7
Fix custom role classes giving custom ammo when they are not suppose …
TtroubleTT Aug 7, 2024
06cf2d7
`Item::<T>Get()` and `Pickup::<T>Get()` (#17)
louis1706 Aug 9, 2024
09de18b
FixNpcNoclip (#34)
louis1706 Aug 9, 2024
a1ae554
Implements more patches for RemovingHandcuffs event and adding Remove…
Misaka-ZeroTwo Aug 9, 2024
2c41d7d
Interacting scp330 compile fix (#43)
Undid-Iridium Aug 10, 2024
08a5deb
Trello is no more & more NW Fix & Fix IL Code on dev (#28)
louis1706 Aug 10, 2024
a3595e1
Additions (#29)
Misfiy Aug 11, 2024
fada367
`[EXILED::API]` Pickup::Category (#46)
NotZer0Two Aug 11, 2024
2ee9f46
Fix (#50)
NotZer0Two Aug 11, 2024
0e2bea5
Merge branch 'master' into dev
Misaka-ZeroTwo Aug 11, 2024
ee317e7
`[Exiled::API]` Removing breaking changes (#54)
VALERA771 Aug 12, 2024
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
5 changes: 5 additions & 0 deletions EXILED/Exiled.API/Enums/AuthenticationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@ public enum AuthenticationType
/// Indicates that the player has been authenticated as DedicatedServer.
/// </summary>
DedicatedServer,

/// <summary>
/// Indicates that the player has been authenticated during Offline mode.
/// </summary>
Offline,
}
}
37 changes: 37 additions & 0 deletions EXILED/Exiled.API/Enums/HazardType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// -----------------------------------------------------------------------
// <copyright file="HazardType.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
{
using Exiled.API.Features.Hazards;

/// <summary>
/// Unique identifier for a <see cref="Hazard"/>.
/// </summary>
public enum HazardType
{
/// <summary>
/// SCP-939 amnestic cloud.
/// </summary>
AmnesticCloud,

/// <summary>
/// Sinkhole spawned at start of round.
/// </summary>
Sinkhole,

/// <summary>
/// SCP-173 tantrum.
/// </summary>
Tantrum,

/// <summary>
/// Should never happen
/// </summary>
Unknown,
}
}
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,
}
}
63 changes: 63 additions & 0 deletions EXILED/Exiled.API/Extensions/BitwiseExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// -----------------------------------------------------------------------
// <copyright file="BitwiseExtensions.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Extensions
{
using System;

/// <summary>
/// Extensions for bitwise operations.
/// </summary>
public static class BitwiseExtensions
{
/// <summary>
/// Adds the specified flags to the given enum value.
/// </summary>
/// <typeparam name="T">The type of the enum.</typeparam>
/// <param name="flags">The enum value to add flags to.</param>
/// <param name="newFlags">The flags to add.</param>
/// <returns>The enum value with the specified flags added.</returns>
public static T AddFlags<T>(this T flags, params T[] newFlags)
where T : Enum => flags.ModifyFlags(true, newFlags);

/// <summary>
/// Removes the specified flags from the given enum value.
/// </summary>
/// <typeparam name="T">The type of the enum.</typeparam>
/// <param name="flags">The enum value to remove flags from.</param>
/// <param name="oldFlags">The flags to remove.</param>
/// <returns>The enum value with the specified flags removed.</returns>
public static T RemoveFlags<T>(this T flags, params T[] oldFlags)
where T : Enum => flags.ModifyFlags(false, oldFlags);

/// <summary>
/// Sets the specified flag to the given value, default is true.
/// </summary>
/// <param name="flags">The flags enum to modify.</param>
/// <param name="value">The value to set the flag to.</param>
/// <param name="changeFlags">The flags to modify.</param>
/// <typeparam name="T">The type of the enum.</typeparam>
/// <returns>The flags enum with the flag set to the given value.</returns>
public static T ModifyFlags<T>(this T flags, bool value, params T[] changeFlags)
where T : Enum
{
long currentValue = Convert.ToInt64(flags);

foreach (T flag in changeFlags)
{
long flagValue = Convert.ToInt64(flag);

if (value)
currentValue |= flagValue;
else
currentValue &= ~flagValue;
}

return (T)Enum.ToObject(typeof(T), currentValue);
}
}
}
9 changes: 4 additions & 5 deletions EXILED/Exiled.API/Extensions/MirrorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,11 @@ public static void SendFakeTargetRpc(Player target, NetworkIdentity behaviorOwne
/// <example>
/// EffectOnlySCP207.
/// <code>
/// MirrorExtensions.SendCustomSync(player, player.ReferenceHub.networkIdentity, typeof(PlayerEffectsController), (writer) => {
/// writer.WriteUInt64(1ul); // DirtyObjectsBit
/// writer.WriteUInt32(1); // DirtyIndexCount
/// MirrorExtensions.SendFakeSyncObject(player, player.NetworkIdentity, typeof(PlayerEffectsController), (writer) => {
/// writer.WriteULong(1ul); // DirtyObjectsBit
/// writer.WriteUInt(1); // DirtyIndexCount
/// writer.WriteByte((byte)SyncList&lt;byte&gt;.Operation.OP_SET); // Operations
/// writer.WriteUInt32(17); // EditIndex
/// writer.WriteByte(1); // Value
/// writer.WriteUInt(17); // EditIndex
/// });
/// </code>
/// </example>
Expand Down
23 changes: 13 additions & 10 deletions EXILED/Exiled.API/Extensions/RoleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,22 @@ public static SpawnLocation GetRandomSpawnLocation(this RoleTypeId roleType)
return null;
}

/// <summary>
/// Gets the starting <see cref="InventoryRoleInfo"/> of a <see cref="RoleTypeId"/>.
/// </summary>
/// <param name="role">The <see cref="RoleTypeId"/>.</param>
/// <returns>The <see cref="InventoryRoleInfo"/> that the role receives on spawn. </returns>
public static InventoryRoleInfo GetInventory(this RoleTypeId role)
=> StartingInventories.DefinedInventories.TryGetValue(role, out InventoryRoleInfo info)
? info
: new(Array.Empty<ItemType>(), new());

/// <summary>
/// Gets the starting items of a <see cref="RoleTypeId"/>.
/// </summary>
/// <param name="roleType">The <see cref="RoleTypeId"/>.</param>
/// <returns>An <see cref="Array"/> of <see cref="ItemType"/> that the role receives on spawn. Will be empty for classes that do not spawn with items.</returns>
public static ItemType[] GetStartingInventory(this RoleTypeId roleType)
{
if (StartingInventories.DefinedInventories.TryGetValue(roleType, out InventoryRoleInfo info))
return info.Items;

return Array.Empty<ItemType>();
}
public static ItemType[] GetStartingInventory(this RoleTypeId roleType) => GetInventory(roleType).Items;

/// <summary>
/// Gets the starting ammo of a <see cref="RoleTypeId"/>.
Expand All @@ -160,10 +164,9 @@ public static ItemType[] GetStartingInventory(this RoleTypeId roleType)
/// <returns>An <see cref="Array"/> of <see cref="ItemType"/> that the role receives on spawn. Will be empty for classes that do not spawn with ammo.</returns>
public static Dictionary<AmmoType, ushort> GetStartingAmmo(this RoleTypeId roleType)
{
if (StartingInventories.DefinedInventories.TryGetValue(roleType, out InventoryRoleInfo info))
return info.Ammo.ToDictionary(kvp => kvp.Key.GetAmmoType(), kvp => kvp.Value);
InventoryRoleInfo info = roleType.GetInventory();

return new();
return info.Ammo.ToDictionary(kvp => kvp.Key.GetAmmoType(), kvp => kvp.Value);
}
}
}
6 changes: 5 additions & 1 deletion EXILED/Exiled.API/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ public static string GetBefore(this string input, char symbol)
/// </summary>
/// <param name="userId">The user id.</param>
/// <returns>Returns the raw user id.</returns>
public static string GetRawUserId(this string userId) => userId.Substring(0, userId.LastIndexOf('@'));
public static string GetRawUserId(this string userId)
{
int index = userId.IndexOf('@');
return index == -1 ? userId : userId.Substring(0, index);
}

/// <summary>
/// Gets a SHA256 hash of a player's user id without the authentication.
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Camera : IWrapper<Scp079Camera>, IWorldSpace
/// <summary>
/// A <see cref="Dictionary{TKey,TValue}"/> containing all known <see cref="Scp079Camera"/>s and their corresponding <see cref="Camera"/>.
/// </summary>
internal static readonly Dictionary<Scp079Camera, Camera> Camera079ToCamera = new(250);
internal static readonly Dictionary<Scp079Camera, Camera> Camera079ToCamera = new(250, new ComponentsEqualityComparer());

private static readonly Dictionary<string, CameraType> NameToCameraType = new()
{
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Doors/AirlockController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AirlockController
/// <summary>
/// A <see cref="Dictionary{TKey,TValue}"/> containing all known <see cref="BaseController"/>'s and their corresponding <see cref="AirlockController"/>.
/// </summary>
internal static readonly Dictionary<BaseController, AirlockController> BaseToExiledControllers = new();
internal static readonly Dictionary<BaseController, AirlockController> BaseToExiledControllers = new(new ComponentsEqualityComparer());

/// <summary>
/// Initializes a new instance of the <see cref="AirlockController"/> class.
Expand Down
59 changes: 44 additions & 15 deletions EXILED/Exiled.API/Features/Doors/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace Exiled.API.Features.Doors
using Exiled.API.Enums;
using Exiled.API.Extensions;
using Exiled.API.Features.Core;
using Exiled.API.Features.Hazards;
using Exiled.API.Interfaces;
using global::Hazards;
using Interactables.Interobjects;
using Interactables.Interobjects.DoorUtils;
using MEC;
Expand All @@ -38,7 +40,7 @@ public class Door : TypeCastObject<Door>, IWrapper<DoorVariant>, IWorldSpace
/// <summary>
/// A <see cref="Dictionary{TKey,TValue}"/> containing all known <see cref="DoorVariant"/>'s and their corresponding <see cref="Door"/>.
/// </summary>
internal static readonly Dictionary<DoorVariant, Door> DoorVariantToDoor = new();
internal static readonly Dictionary<DoorVariant, Door> DoorVariantToDoor = new(new ComponentsEqualityComparer());

/// <summary>
/// Initializes a new instance of the <see cref="Door"/> class.
Expand Down Expand Up @@ -309,6 +311,31 @@ public static Door Get(DoorVariant doorVariant)
return DoorVariantToDoor[doorVariant];
}

/// <summary>
/// Gets the <see cref="Door"/> by <see cref="DoorVariant"/>.
/// </summary>
/// <param name="doorVariant">The <see cref="DoorVariant"/> to convert into an door.</param>
/// <typeparam name="T">The specified <see cref="Door"/> type.</typeparam>
/// <returns>The door wrapper for the given <see cref="DoorVariant"/>.</returns>
public static T Get<T>(DoorVariant doorVariant)
where T : Door => Get(doorVariant) as T;

/// <summary>
/// Gets a <see cref="Door"/> given the specified <see cref="DoorType"/>.
/// </summary>
/// <param name="doorType">The <see cref="DoorType"/> to search for.</param>
/// <returns>The <see cref="Door"/> with the given <see cref="DoorType"/> or <see langword="null"/> if not found.</returns>
public static Door Get(DoorType doorType) => List.FirstOrDefault(x => x.Type == doorType);

/// <summary>
/// Gets the <see cref="Door"/> by <see cref="DoorVariant"/>.
/// </summary>
/// <param name="doorType">The <see cref="DoorVariant"/> to convert into an door.</param>
/// <typeparam name="T">The specified <see cref="Door"/> type.</typeparam>
/// <returns>The door wrapper for the given <see cref="DoorVariant"/>.</returns>
public static T Get<T>(DoorType doorType)
where T : Door => Get(doorType) as T;

/// <summary>
/// Gets a <see cref="Door"/> given the specified name.
/// </summary>
Expand All @@ -320,27 +347,22 @@ public static Door Get(string name)
return nameExtension is null ? null : Get(nameExtension.TargetDoor);
}

/// <summary>
/// Gets the <see cref="Door"/> by <see cref="DoorVariant"/>.
/// </summary>
/// <param name="name">The name to search for.</param>
/// <typeparam name="T">The specified <see cref="Door"/> type.</typeparam>
/// <returns>The door wrapper for the given <see cref="DoorVariant"/>.</returns>
public static T Get<T>(string name)
where T : Door => Get(name) as T;

/// <summary>
/// Gets the door object associated with a specific <see cref="UnityEngine.GameObject"/>, or creates a new one if there isn't one.
/// </summary>
/// <param name="gameObject">The base-game <see cref="UnityEngine.GameObject"/>.</param>
/// <returns>The <see cref="Door"/> with the given name or <see langword="null"/> if not found.</returns>
public static Door Get(GameObject gameObject) => gameObject is null ? null : Get(gameObject.GetComponentInChildren<DoorVariant>());

/// <summary>
/// Gets a <see cref="IEnumerable{T}"/> of <see cref="Door"/> filtered based on a predicate.
/// </summary>
/// <param name="predicate">The condition to satify.</param>
/// <returns>A <see cref="IEnumerable{T}"/> of <see cref="Door"/> which contains elements that satify the condition.</returns>
public static IEnumerable<Door> Get(Func<Door, bool> predicate) => List.Where(predicate);

/// <summary>
/// Gets a <see cref="Door"/> given the specified <see cref="DoorType"/>.
/// </summary>
/// <param name="doorType">The <see cref="DoorType"/> to search for.</param>
/// <returns>The <see cref="Door"/> with the given <see cref="DoorType"/> or <see langword="null"/> if not found.</returns>
public static Door Get(DoorType doorType) => List.FirstOrDefault(x => x.Type == doorType);

/// <summary>
/// Returns the closest <see cref="Door"/> to the given <paramref name="position"/>.
/// </summary>
Expand All @@ -367,6 +389,13 @@ public static Door Random(ZoneType type = ZoneType.Unspecified, bool onlyUnbroke
return doors[UnityEngine.Random.Range(0, doors.Count)];
}

/// <summary>
/// Gets a <see cref="IEnumerable{T}"/> of <see cref="Door"/> filtered based on a predicate.
/// </summary>
/// <param name="predicate">The condition to satify.</param>
/// <returns>A <see cref="IEnumerable{T}"/> of <see cref="Door"/> which contains elements that satify the condition.</returns>
public static IEnumerable<Door> Get(Func<Door, bool> predicate) => List.Where(predicate);

/// <summary>
/// Locks all <see cref="Door">doors</see> given the specified <see cref="ZoneType"/>.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Generator : IWrapper<Scp079Generator>, IWorldSpace
/// <summary>
/// A <see cref="List{T}"/> of <see cref="Generator"/> on the map.
/// </summary>
internal static readonly Dictionary<Scp079Generator, Generator> Scp079GeneratorToGenerator = new();
internal static readonly Dictionary<Scp079Generator, Generator> Scp079GeneratorToGenerator = new(new ComponentsEqualityComparer());
private Room room;

/// <summary>
Expand Down
22 changes: 21 additions & 1 deletion EXILED/Exiled.API/Features/Hazards/AmnesticCloudHazard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------
// ------------------------------------------------------------------------

namespace Exiled.API.Features.Hazards
{
using Exiled.API.Enums;
using PlayerRoles.PlayableScps.Scp939;

/// <summary>
/// A wrapper for SCP-939's amnestic cloud.
/// </summary>
public class AmnesticCloudHazard : TemporaryHazard
{
private static Scp939AmnesticCloudInstance amnesticCloudPrefab;

/// <summary>
/// Initializes a new instance of the <see cref="AmnesticCloudHazard"/> class.
/// </summary>
Expand All @@ -26,9 +29,26 @@ public AmnesticCloudHazard(Scp939AmnesticCloudInstance hazard)
Owner = Player.Get(Ability.Owner);
}

/// <summary>
/// Gets the amnestic cloud prefab.
/// </summary>
public static Scp939AmnesticCloudInstance AmnesticCloudPrefab
{
get
{
if (amnesticCloudPrefab == null)
amnesticCloudPrefab = PrefabHelper.GetPrefab<Scp939AmnesticCloudInstance>(PrefabType.AmnesticCloudHazard);

return amnesticCloudPrefab;
}
}

/// <inheritdoc cref="Hazard.Base"/>
public new Scp939AmnesticCloudInstance Base { get; }

/// <inheritdoc />
public override HazardType Type => HazardType.AmnesticCloud;

/// <summary>
/// Gets the <see cref="Scp939AmnesticCloudAbility"/> for this instance.
/// </summary>
Expand Down
Loading
Loading