From 33f4cbaf74a91a223d76591536615fd4c3356fc4 Mon Sep 17 00:00:00 2001 From: "Dr. Inzi" <158808246+DrInzi@users.noreply.github.com> Date: Fri, 9 Feb 2024 10:52:03 +0100 Subject: [PATCH 01/11] [Exiled::API] Additions to Features.Player (#2435) * [Exiled::API] Added AccountAge to Features.Player * [Exiled::API] Additions to Features.Player * Update Exiled.API.csproj * Update Player.cs * Update Exiled.API.csproj * Update Player.cs * Update Player.cs (reviews with yamato baguette) * Update Player.cs * Update Player.cs * Update Player.cs * Update Player.cs * Update Player.cs * Update Player.cs * Update Player.cs * Update Player.cs * Merge branch 'IsScp096Target-IsScp173Observer' of https://github.com/DrInzi/EXILED into IsScp096Target-IsScp173Observer --------- Co-authored-by: INZI Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com> --- Exiled.API/Features/Player.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 3c180239c5..d2dd65a465 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1109,6 +1109,24 @@ public bool BadgeHidden /// public bool IsInventoryFull => Items.Count >= Inventory.MaxSlots; + /// + /// Gets a value indicating whether the player is a target of SCP-096. + /// + /// + /// This property checks if the player is present in the list of targets maintained by SCP-096. + /// + /// True if the player is a target of SCP-096; otherwise, false. + public bool IsScp096Target => Player.List.Any(x => x.Role is Roles.Scp096Role scp096Role && scp096Role.Targets.Contains(x)); + + /// + /// Gets a value indicating whether the player is an observer of SCP-173. + /// + /// + /// This property checks if the player is present in the list of observers maintained by SCP-173. + /// + /// True if the player is an observer of SCP-173; otherwise, false. + public bool IsScp173Observer => Player.List.Any(x => x.Role is Roles.Scp173Role scp173Role && scp173Role.ObservingPlayers.Contains(x)); + /// /// Gets a value indicating whether or not the player has agreed to microphone recording. /// From a3fae80861d668213c2189d57793741c10cacbe5 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Fri, 9 Feb 2024 10:53:06 +0100 Subject: [PATCH 02/11] Boup (#2440) --- Exiled.API/Extensions/DamageTypeExtensions.cs | 6 +---- Exiled.CreditTags/CreditTags.cs | 23 ++++++++----------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Exiled.API/Extensions/DamageTypeExtensions.cs b/Exiled.API/Extensions/DamageTypeExtensions.cs index 8d9985f966..3f58d449e3 100644 --- a/Exiled.API/Extensions/DamageTypeExtensions.cs +++ b/Exiled.API/Extensions/DamageTypeExtensions.cs @@ -117,11 +117,7 @@ public static class DamageTypeExtensions /// /// The damage type to be checked. /// Returns whether or not the is caused by status effect. - public static bool IsStatusEffect(this DamageType type) => type switch - { - DamageType.Asphyxiation or DamageType.Poison or DamageType.Bleeding or DamageType.Scp207 or DamageType.Hypothermia or DamageType.Strangled => true, - _ => false, - }; + public static bool IsStatusEffect(this DamageType type) => type is DamageType.Asphyxiation or DamageType.Poison or DamageType.Bleeding or DamageType.Scp207 or DamageType.Hypothermia or DamageType.Strangled; /// /// Gets the of an s. diff --git a/Exiled.CreditTags/CreditTags.cs b/Exiled.CreditTags/CreditTags.cs index aecb1b758e..09a2a4f77e 100644 --- a/Exiled.CreditTags/CreditTags.cs +++ b/Exiled.CreditTags/CreditTags.cs @@ -134,22 +134,17 @@ void ShowRank(RankType rank) { switch (Config.Mode) { - case InfoSide.Badge: - if (canReceiveCreditBadge) - SetCreditBadge(player, value); - + case InfoSide.Badge when canReceiveCreditBadge: + SetCreditBadge(player, value); break; - case InfoSide.CustomPlayerInfo: - if (canReceiveCreditCustomInfo) - SetCreditCustomInfo(player, value); - + case InfoSide.CustomPlayerInfo when canReceiveCreditCustomInfo: + SetCreditCustomInfo(player, value); break; - case InfoSide.FirstAvailable: - if (canReceiveCreditBadge) - SetCreditBadge(player, value); - else if (canReceiveCreditCustomInfo) - SetCreditCustomInfo(player, value); - + case InfoSide.FirstAvailable when canReceiveCreditBadge: + SetCreditBadge(player, value); + break; + case InfoSide.FirstAvailable when canReceiveCreditCustomInfo: + SetCreditCustomInfo(player, value); break; } } From c27579b7b68c0674f88fd57ef3594f168c467dd8 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Fri, 9 Feb 2024 10:53:17 +0100 Subject: [PATCH 03/11] EscapeScenario (#2439) --- Exiled.API/Enums/EscapeScenario.cs | 23 +++++++++++++------ .../EventArgs/Player/EscapingEventArgs.cs | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Exiled.API/Enums/EscapeScenario.cs b/Exiled.API/Enums/EscapeScenario.cs index b02058ccdd..2c8f4f7223 100644 --- a/Exiled.API/Enums/EscapeScenario.cs +++ b/Exiled.API/Enums/EscapeScenario.cs @@ -7,39 +7,48 @@ namespace Exiled.API.Enums { + using Exiled.API.Features.Core.Generic; + + using static Escape; + /// /// A set of different Escape Scenario Type. /// - public enum EscapeScenario + public sealed class EscapeScenario : EnumClass { /// /// No Escape Scenario. /// - None, + public static readonly EscapeScenario None = new(EscapeScenarioType.None); /// /// ClassD Escape Scenario. /// - ClassD, + public static readonly EscapeScenario ClassD = new(EscapeScenarioType.ClassD); /// /// Cuffed ClassD Escape. /// - CuffedClassD, + public static readonly EscapeScenario CuffedClassD = new(EscapeScenarioType.CuffedClassD); /// /// Scientist Escape. /// - Scientist, + public static readonly EscapeScenario Scientist = new(EscapeScenarioType.Scientist); /// /// Cuffed Scientist Escape. /// - CuffedScientist, + public static readonly EscapeScenario CuffedScientist = new(EscapeScenarioType.CuffedScientist); /// /// Unspecified Escape. /// - CustomEscape, + public static readonly EscapeScenario CustomEscape = new((EscapeScenarioType)5); + + private EscapeScenario(EscapeScenarioType value) + : base(value) + { + } } } \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs b/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs index 109a744b12..f51eb1df75 100644 --- a/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs @@ -39,7 +39,7 @@ public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escap Player = player; NewRole = newRole; EscapeScenario = escapeScenario; - IsAllowed = escapeScenario is not EscapeScenario.CustomEscape; + IsAllowed = escapeScenario != EscapeScenario.CustomEscape; } /// From c0c83969f12db43984526914df7d9ff610b6b40d Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Fri, 9 Feb 2024 10:53:41 +0100 Subject: [PATCH 04/11] TODO (#2438) * TODO * bool --- Exiled.API/Enums/EffectType.cs | 2 +- Exiled.API/Features/Player.cs | 19 ------------- Exiled.API/Features/Roles/Scp106Role.cs | 8 +++--- .../Player/AimingDownSightEventArgs.cs | 9 ++----- .../Player/ChangingMoveStateEventArgs.cs | 27 +++---------------- .../Player/PreAuthenticatingEventArgs.cs | 7 ----- .../Scp0492/ConsumingCorpseEventArgs.cs | 17 +++--------- .../EventArgs/Scp173/BlinkingEventArgs.cs | 3 +-- Exiled.Events/Handlers/Player.cs | 9 +++---- .../Events/Player/ChangingMoveState.cs | 5 +--- .../Patches/Events/Player/DamagingWindow.cs | 4 +-- .../Events/Player/FirearmRequestReceived.cs | 10 ++----- .../Patches/Events/Player/ThrownProjectile.cs | 2 +- .../Patches/Events/Scp0492/Consuming.cs | 9 +++---- Exiled.Events/Patches/Generic/RoomList.cs | 1 + 15 files changed, 30 insertions(+), 102 deletions(-) diff --git a/Exiled.API/Enums/EffectType.cs b/Exiled.API/Enums/EffectType.cs index 665f481632..690856b642 100644 --- a/Exiled.API/Enums/EffectType.cs +++ b/Exiled.API/Enums/EffectType.cs @@ -21,7 +21,7 @@ public enum EffectType /// /// This EffectType do not exist it's only use when not found or error. /// - None = -1, // TODO: remove = -1 + None, /// /// The player isn't able to open their inventory or reload a weapon. diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index d2dd65a465..2ad3f57386 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1517,16 +1517,6 @@ public static Player Get(string args) /// An representing the processed players. public static IEnumerable GetProcessedData(ArraySegment args, int startIndex = 0) => GetProcessedData(args, startIndex, out string[] _); - /// - /// Adds a player's UserId to the list of reserved slots. - /// - /// This method does not permanently give a user a reserved slot. The slot will be removed if the reserved slots are reloaded. - /// The UserId of the player to add. - /// if the slot was successfully added, or if the provided UserId already has a reserved slot. - /// - // TODO: Remove this method - public static bool AddReservedSlot(string userId) => ReservedSlot.Users.Add(userId); - /// /// Adds a player's UserId to the list of reserved slots. /// @@ -1579,15 +1569,6 @@ public static bool AddToWhitelist(string userId, bool isPermanent) /// public static void ReloadWhitelist() => WhiteList.Reload(); - /// - /// Adds the player's UserId to the list of reserved slots. - /// - /// This method does not permanently give a user a reserved slot. The slot will be removed if the reserved slots are reloaded. - /// if the slot was successfully added, or if the player already has a reserved slot. - /// - // TODO: Remove this method - public bool GiveReservedSlot() => AddReservedSlot(UserId); - /// /// Adds a player's UserId to the list of reserved slots. /// diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index 79ce548735..e4ed9e4a03 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -297,15 +297,16 @@ public bool UsePortal(Vector3 position, float cost = 0f) /// Send a player to the pocket dimension. /// /// The to send. - public void CapturePlayer(Player player) // Convert to bool. + /// If the player has been capture in PocketDimension. + public bool CapturePlayer(Player player) { if (player is null) - return; + return false; Attack._targetHub = player.ReferenceHub; DamageHandlerBase handler = new ScpDamageHandler(Attack.Owner, AttackDamage, DeathTranslations.PocketDecay); if (!Attack._targetHub.playerStats.DealDamage(handler)) - return; + return false; Attack.SendCooldown(Attack._hitCooldown); Vigor += VigorCaptureReward; @@ -313,6 +314,7 @@ public void CapturePlayer(Player player) // Convert to bool. Hitmarker.SendHitmarkerDirectly(Attack.Owner, 1f); player.EnableEffect(EffectType.PocketCorroding); + return true; } /// diff --git a/Exiled.Events/EventArgs/Player/AimingDownSightEventArgs.cs b/Exiled.Events/EventArgs/Player/AimingDownSightEventArgs.cs index eebbae5a3a..9370ba42b5 100644 --- a/Exiled.Events/EventArgs/Player/AimingDownSightEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/AimingDownSightEventArgs.cs @@ -15,7 +15,6 @@ namespace Exiled.Events.EventArgs.Player /// /// Contains all information when a player aims. /// - // TODO: remove stupid AdsIn/AdsOut propetry, and let exists only one public class AimingDownSightEventArgs : IPlayerEvent, IFirearmEvent { /// @@ -30,15 +29,11 @@ public class AimingDownSightEventArgs : IPlayerEvent, IFirearmEvent /// /// /// - /// - /// - /// - public AimingDownSightEventArgs(Player player, Firearm firearm, bool adsIn, bool adsOut) + public AimingDownSightEventArgs(Player player, Firearm firearm, bool adsIn) { Firearm = firearm; Player = player; AdsIn = adsIn; - AdsOut = adsOut; } /// @@ -49,7 +44,7 @@ public AimingDownSightEventArgs(Player player, Firearm firearm, bool adsIn, bool /// /// Gets a value indicating whether or not the player is aiming down sight out. /// - public bool AdsOut { get; } + public bool AdsOut => !AdsIn; /// /// Gets the used to trigger the aim action. diff --git a/Exiled.Events/EventArgs/Player/ChangingMoveStateEventArgs.cs b/Exiled.Events/EventArgs/Player/ChangingMoveStateEventArgs.cs index 1c55aa6aaf..dc22fa26e9 100644 --- a/Exiled.Events/EventArgs/Player/ChangingMoveStateEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/ChangingMoveStateEventArgs.cs @@ -18,7 +18,7 @@ namespace Exiled.Events.EventArgs.Player /// /// Contains all information before changing movement state. /// - public class ChangingMoveStateEventArgs : IPlayerEvent, IDeniableEvent + public class ChangingMoveStateEventArgs : IPlayerEvent { /// /// Initializes a new instance of the class. @@ -32,16 +32,10 @@ public class ChangingMoveStateEventArgs : IPlayerEvent, IDeniableEvent /// /// /// - /// - /// - /// - public ChangingMoveStateEventArgs(Player player, PlayerMovementState oldState, PlayerMovementState newState, bool isAllowed = true) + public ChangingMoveStateEventArgs(Player player, PlayerMovementState oldState, PlayerMovementState newState) { Player = player; OldState = oldState; -#pragma warning disable CS0618 - NewState = newState; -#pragma warning restore CS0618 } /// @@ -55,21 +49,8 @@ public ChangingMoveStateEventArgs(Player player, PlayerMovementState oldState, P public PlayerMovementState OldState { get; } /// - /// Gets or sets the new state. - /// - // TODO: remove setter - public PlayerMovementState NewState - { - get; - [Obsolete("Setter was removed due to desync problems.")] - set; - } - - /// - /// Gets or sets a value indicating whether the player can change the movement state. + /// Gets the new state. /// - // TODO: remove - [Obsolete("Property was removed due to desync problems.")] - public bool IsAllowed { get; set; } = true; + public PlayerMovementState NewState { get; } } } \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs b/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs index 0b10296f2a..da0845899b 100644 --- a/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs @@ -15,13 +15,6 @@ namespace Exiled.Events.EventArgs.Player using PluginAPI.Events; -#pragma warning disable SA1600 //TODO: -#pragma warning disable SA1309 -#pragma warning disable SA1623 -#pragma warning disable SA1201 -#pragma warning disable SA1611 -#pragma warning disable CS1591 - /// /// Contains all information before pre-authenticating a player. /// diff --git a/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs b/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs index d398e147a5..dd136a91dd 100644 --- a/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs @@ -24,16 +24,14 @@ public class ConsumingCorpseEventArgs : IScp0492Event, IRagdollEvent, IDeniableE /// /// /// - /// /// /// See for all ragdolls consumed. - // TODO: remove isAllowed argument - public ConsumingCorpseEventArgs(ReferenceHub player, BasicRagdoll ragDoll, ZombieConsumeAbility.ConsumeError error, bool isAllowed = true) + public ConsumingCorpseEventArgs(ReferenceHub player, BasicRagdoll ragDoll, bool isAllowed = true) { Player = Player.Get(player); Scp0492 = Player.Role.As(); Ragdoll = Ragdoll.Get(ragDoll); - ErrorCode = error; + IsAllowed = isAllowed; } /// @@ -49,18 +47,9 @@ public ConsumingCorpseEventArgs(ReferenceHub player, BasicRagdoll ragDoll, Zombi /// public Ragdoll Ragdoll { get; } - /// - /// Gets or sets error code to send back to client. - /// - public ZombieConsumeAbility.ConsumeError ErrorCode { get; set; } - /// /// Gets or sets a value indicating whether 049-2 can consume a corpse. /// - public bool IsAllowed - { - get => ErrorCode == ZombieConsumeAbility.ConsumeError.None; - set => ErrorCode = value ? ZombieConsumeAbility.ConsumeError.None : ZombieConsumeAbility.ConsumeError.TargetNotValid; - } + public bool IsAllowed { get; set; } } } \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp173/BlinkingEventArgs.cs b/Exiled.Events/EventArgs/Scp173/BlinkingEventArgs.cs index 5ef166038d..f46635930b 100644 --- a/Exiled.Events/EventArgs/Scp173/BlinkingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp173/BlinkingEventArgs.cs @@ -58,8 +58,7 @@ public BlinkingEventArgs(Player player, List targets, Vector3 blinkPos) /// /// Gets a of players who have triggered SCP-173. /// - // TODO: convert to ReadOnlyCollection - public List Targets { get; } + public IReadOnlyList Targets { get; } /// /// Gets or sets a value indicating whether or not the player is allowed to blink. diff --git a/Exiled.Events/Handlers/Player.cs b/Exiled.Events/Handlers/Player.cs index bd66fa0798..c949dd92ca 100644 --- a/Exiled.Events/Handlers/Player.cs +++ b/Exiled.Events/Handlers/Player.cs @@ -469,8 +469,8 @@ public class Player /// /// Invoked before a damage a Window. - /// // TODO: DamagingWindow instead of PlayerDamageWindow - public static Event PlayerDamageWindow { get; set; } = new(); + /// + public static Event DamagingWindow { get; set; } = new(); /// /// Invoked before a damage a Door. @@ -652,8 +652,7 @@ public class Player /// Called before throwing a grenade. /// /// The instance. - // TODO: rename that to OnThrownProjectile - public static void OnThrowingProjectile(ThrownProjectileEventArgs ev) => ThrownProjectile.InvokeSafely(ev); + public static void OnThrownProjectile(ThrownProjectileEventArgs ev) => ThrownProjectile.InvokeSafely(ev); /// /// Called before receving a throwing request. @@ -1001,7 +1000,7 @@ public static void OnItemRemoved(ReferenceHub referenceHub, InventorySystem.Item /// Called before a damage a window. /// /// The instance. - public static void OnPlayerDamageWindow(DamagingWindowEventArgs ev) => PlayerDamageWindow.InvokeSafely(ev); + public static void OnPlayerDamageWindow(DamagingWindowEventArgs ev) => DamagingWindow.InvokeSafely(ev); /// /// Called before a damage a window. diff --git a/Exiled.Events/Patches/Events/Player/ChangingMoveState.cs b/Exiled.Events/Patches/Events/Player/ChangingMoveState.cs index 1c11ad5332..090db2c42a 100644 --- a/Exiled.Events/Patches/Events/Player/ChangingMoveState.cs +++ b/Exiled.Events/Patches/Events/Player/ChangingMoveState.cs @@ -58,10 +58,7 @@ private static IEnumerable Transpiler(IEnumerable /// Patch the . - /// Adds the event. + /// Adds the event. /// - [EventPatch(typeof(Player), nameof(Player.PlayerDamageWindow))] + [EventPatch(typeof(Player), nameof(Player.DamagingWindow))] [HarmonyPatch(typeof(BreakableWindow), nameof(BreakableWindow.Damage))] internal static class DamagingWindow { diff --git a/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs b/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs index 5a6b90e439..1a7a46d8b5 100644 --- a/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs +++ b/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs @@ -183,10 +183,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Fri, 9 Feb 2024 10:54:15 +0100 Subject: [PATCH 05/11] SpawnReason (#2441) * SpawnReason - SpawnReason.ForceClass => spawnReason.RemoteAdmin Add SpawnReason.ForceClass * Fix --- Exiled.API/Enums/SpawnReason.cs | 35 +++++++++++++++++++++---------- Exiled.API/Features/Roles/Role.cs | 8 +++---- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Exiled.API/Enums/SpawnReason.cs b/Exiled.API/Enums/SpawnReason.cs index d5ab04e202..c7c9b6cb0e 100644 --- a/Exiled.API/Enums/SpawnReason.cs +++ b/Exiled.API/Enums/SpawnReason.cs @@ -7,54 +7,67 @@ namespace Exiled.API.Enums { + using Exiled.API.Features.Core.Generic; + using PlayerRoles; + /// /// Possible spawn reasons. /// - public enum SpawnReason : byte // TOTO: Remove this file and use Basegame + public sealed class SpawnReason : EnumClass { /// /// No reason specified. /// - None, + public static readonly SpawnReason None = new(RoleChangeReason.None); /// /// The round has just started. /// - RoundStart, + public static readonly SpawnReason RoundStart = new(RoleChangeReason.RoundStart); /// /// The player joined and the round recently started. /// - LateJoin, + public static readonly SpawnReason LateJoin = new(RoleChangeReason.LateJoin); /// /// The player was dead and is respawning. /// - Respawn, + public static readonly SpawnReason Respawn = new(RoleChangeReason.Respawn); /// /// The player has died. /// - Died, + public static readonly SpawnReason Died = new(RoleChangeReason.Died); /// /// The player has escaped. /// - Escaped, + public static readonly SpawnReason Escaped = new(RoleChangeReason.Escaped); /// /// The player was revived by SCP-049. /// - Revived, + public static readonly SpawnReason Revived = new(RoleChangeReason.Revived); /// - /// The player's role was changed by an admin command or plugin. + /// The player's role was changed by an admin command. /// - ForceClass, + public static readonly SpawnReason RemoteAdmin = new(RoleChangeReason.RemoteAdmin); /// /// The user will be destroyed. /// - Destroyed, + public static readonly SpawnReason Destroyed = new(RoleChangeReason.Destroyed); + + /// + /// The player's role was changed by an exiled plugin. + /// + public static readonly SpawnReason ForceClass = new(RoleChangeReason.RemoteAdmin); + + private SpawnReason(RoleChangeReason value) + : base(value) + { + } } } \ No newline at end of file diff --git a/Exiled.API/Features/Roles/Role.cs b/Exiled.API/Features/Roles/Role.cs index a7d38bdabc..8900b2ad81 100644 --- a/Exiled.API/Features/Roles/Role.cs +++ b/Exiled.API/Features/Roles/Role.cs @@ -229,14 +229,14 @@ public static RoleTypeId Random(bool includeNonPlayableRoles = false, IEnumerabl /// /// The new to be set. /// The defining why the player's role was changed. - public virtual void Set(RoleTypeId newRole, SpawnReason reason = Enums.SpawnReason.ForceClass) => Set(newRole, reason, RoleSpawnFlags.All); + public virtual void Set(RoleTypeId newRole, SpawnReason reason = null) => Set(newRole, reason ?? Enums.SpawnReason.ForceClass, RoleSpawnFlags.All); - /// + /// S /// Sets the player's . /// /// The new to be set. /// The defining player spawn logic. - public virtual void Set(RoleTypeId newRole, RoleSpawnFlags spawnFlags) => Owner.RoleManager.ServerSetRole(newRole, (RoleChangeReason)Enums.SpawnReason.ForceClass, spawnFlags); + public virtual void Set(RoleTypeId newRole, RoleSpawnFlags spawnFlags) => Owner.RoleManager.ServerSetRole(newRole, Enums.SpawnReason.ForceClass, spawnFlags); /// /// Sets the player's . @@ -245,7 +245,7 @@ public static RoleTypeId Random(bool includeNonPlayableRoles = false, IEnumerabl /// The defining why the player's role was changed. /// The defining player spawn logic. public virtual void Set(RoleTypeId newRole, SpawnReason reason, RoleSpawnFlags spawnFlags) => - Owner.RoleManager.ServerSetRole(newRole, (RoleChangeReason)reason, spawnFlags); + Owner.RoleManager.ServerSetRole(newRole, reason, spawnFlags); /// /// Creates a role from and . From 73ae1f3b88fb516a77d1034683498babc2d99bc3 Mon Sep 17 00:00:00 2001 From: Yamato Date: Fri, 9 Feb 2024 12:35:56 +0100 Subject: [PATCH 06/11] Fix EscapingEvent --- Exiled.Events/EventArgs/Player/EscapingEventArgs.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs b/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs index f51eb1df75..b7ae474745 100644 --- a/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs @@ -17,6 +17,8 @@ namespace Exiled.Events.EventArgs.Player using Respawning; + using static Escape; + /// /// Contains all information before a player escapes. /// @@ -34,11 +36,11 @@ public class EscapingEventArgs : IPlayerEvent, IDeniableEvent /// /// /// - public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escapeScenario) + public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenarioType escapeScenario) { Player = player; NewRole = newRole; - EscapeScenario = escapeScenario; + EscapeScenario = (EscapeScenario)escapeScenario; IsAllowed = escapeScenario != EscapeScenario.CustomEscape; } @@ -57,7 +59,7 @@ public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escap /// /// /// - public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escapeScenario, KeyValuePair respawnTickets) + public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenarioType escapeScenario, KeyValuePair respawnTickets) : this(player, newRole, escapeScenario) { RespawnTickets = respawnTickets; @@ -81,7 +83,7 @@ public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escap /// /// A that will be initialized with. /// - public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escapeScenario, SpawnableTeamType teamToGrantTickets, float ticketsToGrant) + public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenarioType escapeScenario, SpawnableTeamType teamToGrantTickets, float ticketsToGrant) : this(player, newRole, escapeScenario) { if (teamToGrantTickets != SpawnableTeamType.None) From c2d9035baf4f5fd5134ddb248a17b71570f1a797 Mon Sep 17 00:00:00 2001 From: Yamato Date: Fri, 9 Feb 2024 13:05:00 +0100 Subject: [PATCH 07/11] Yamato Stupidity fix --- Exiled.API/Enums/SpawnReason.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Enums/SpawnReason.cs b/Exiled.API/Enums/SpawnReason.cs index c7c9b6cb0e..2ea15f84a2 100644 --- a/Exiled.API/Enums/SpawnReason.cs +++ b/Exiled.API/Enums/SpawnReason.cs @@ -63,7 +63,7 @@ public sealed class SpawnReason : EnumClass /// /// The player's role was changed by an exiled plugin. /// - public static readonly SpawnReason ForceClass = new(RoleChangeReason.RemoteAdmin); + public static readonly SpawnReason ForceClass = new((RoleChangeReason)9); private SpawnReason(RoleChangeReason value) : base(value) From c8dac35ac4c2a127429823d8eacaca54b70ea52a Mon Sep 17 00:00:00 2001 From: Yamato Date: Fri, 9 Feb 2024 13:07:44 +0100 Subject: [PATCH 08/11] i miss this --- Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs b/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs index c4e52dec3d..92ba68a943 100644 --- a/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs +++ b/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs @@ -16,6 +16,7 @@ namespace Exiled.Events.Patches.Events.Player using API.Features.Core.Generic.Pools; using API.Features.Roles; + using Exiled.API.Enums; using Exiled.Events.EventArgs.Player; using HarmonyLib; @@ -111,8 +112,9 @@ private static IEnumerable Transpiler(IEnumerable Date: Sat, 10 Feb 2024 03:06:54 +0300 Subject: [PATCH 09/11] new ext (#2446) --- Exiled.API/Extensions/MirrorExtensions.cs | 26 ++++++++++++++++++----- Exiled.API/Features/Roles/Scp3114Role.cs | 12 +++++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Exiled.API/Extensions/MirrorExtensions.cs b/Exiled.API/Extensions/MirrorExtensions.cs index 7baf72eb64..79ec9e3a4c 100644 --- a/Exiled.API/Extensions/MirrorExtensions.cs +++ b/Exiled.API/Extensions/MirrorExtensions.cs @@ -17,18 +17,14 @@ namespace Exiled.API.Extensions using Features; using Features.Core.Generic.Pools; - using InventorySystem.Items.Firearms; - using Mirror; - using PlayerRoles; using PlayerRoles.FirstPersonControl; using PlayerRoles.PlayableScps.Scp049.Zombies; + using PlayerRoles.Subroutines; using RelativePositioning; - using Respawning; - using UnityEngine; /// @@ -449,6 +445,26 @@ public static void EditNetworkObject(NetworkIdentity identity, Action + /// Sends a . + /// + /// Base instance. + /// Action that will apply needed changes to a . + /// Should message be sent to everybody or to only. + /// A type of . + public static void SendRpc(this T subroutineBase, Action applyingChanges, bool toAll = true) + where T : SubroutineBase + { + applyingChanges(subroutineBase); + + SubroutineMessage msg = new(subroutineBase, true); + + if (toAll) + NetworkServer.SendToAll(msg); + else + subroutineBase.Role._lastOwner.connectionToClient.Send(msg); + } + // Get components index in identity.(private) private static int GetComponentIndex(NetworkIdentity identity, Type type) { diff --git a/Exiled.API/Features/Roles/Scp3114Role.cs b/Exiled.API/Features/Roles/Scp3114Role.cs index 31ef601c1c..3814ad3081 100644 --- a/Exiled.API/Features/Roles/Scp3114Role.cs +++ b/Exiled.API/Features/Roles/Scp3114Role.cs @@ -9,6 +9,8 @@ namespace Exiled.API.Features.Roles { using System.Collections.Generic; + using Exiled.API.Enums; + using Exiled.API.Extensions; using PlayerRoles; using PlayerRoles.PlayableScps; using PlayerRoles.PlayableScps.HumeShield; @@ -235,5 +237,15 @@ public void PlaySound(Scp3114VoiceLines.VoiceLinesName voiceLine = Scp3114VoiceL /// The List of Roles already spawned. /// The Spawn Chance. public float GetSpawnChance(List alreadySpawned) => Base is ISpawnableScp spawnableScp ? spawnableScp.GetSpawnChance(alreadySpawned) : 0; + + /// + /// Stops dancing. + /// + public void StopDancing() => Dance.SendRpc(x => x.IsDancing = false); + + /// + /// Starts dancing. + /// + public void StartDanging() => Dance.SendRpc(x => x.IsDancing = true); } } \ No newline at end of file From 4e69cb2b76e967b4647a23382ee7a37f59e3a68b Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Sat, 10 Feb 2024 01:08:41 +0100 Subject: [PATCH 10/11] Local / world position (#2442) * Move API from Room to GameEntity * fix --- Exiled.API/Features/Core/GameEntity.cs | 14 ++++++++++++++ Exiled.API/Features/Room.cs | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Exiled.API/Features/Core/GameEntity.cs b/Exiled.API/Features/Core/GameEntity.cs index 4085c423ff..32bb44c698 100644 --- a/Exiled.API/Features/Core/GameEntity.cs +++ b/Exiled.API/Features/Core/GameEntity.cs @@ -117,6 +117,20 @@ public virtual Quaternion Rotation /// The filtered collection of objects. public static IEnumerable GetFarthestEntities(Vector3 vector, float distance) => List.Where(p => p.GameObject.transform && (vector - p.GameObject.transform.position).sqrMagnitude >= distance * distance); + /// + /// Returns the local space position, based on a world space position. + /// + /// World position. + /// Local position, based on the GameEntity. + public Vector3 LocalPosition(Vector3 position) => Transform.InverseTransformPoint(position); + + /// + /// Returns the World position, based on a local space position. + /// + /// Local position. + /// World position, based on the GameEntity. + public Vector3 WorldPosition(Vector3 offset) => Transform.TransformPoint(offset); + /// public T AddComponent(string name = "") where T : EActor diff --git a/Exiled.API/Features/Room.cs b/Exiled.API/Features/Room.cs index da1885ad8c..cb2daf3e7e 100644 --- a/Exiled.API/Features/Room.cs +++ b/Exiled.API/Features/Room.cs @@ -332,20 +332,6 @@ public static Room FindParentRoom(GameObject objectInRoom) /// object. public static Room Random(ZoneType zoneType = ZoneType.Unspecified) => (zoneType is not ZoneType.Unspecified ? Get(r => r.Zone.HasFlag(zoneType)) : List).Random(); - /// - /// Returns the local space position, based on a world space position. - /// - /// World position. - /// Local position, based on the room. - public Vector3 LocalPosition(Vector3 position) => Transform.InverseTransformPoint(position); - - /// - /// Returns the World position, based on a local space position. - /// - /// Local position. - /// World position, based on the room. - public Vector3 WorldPosition(Vector3 offset) => Transform.TransformPoint(offset); - /// /// Flickers the room's lights off for a duration. /// From 4a0ccb81bbc512509b983151a1fe6713db87e9c9 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Sat, 10 Feb 2024 01:10:12 +0100 Subject: [PATCH 11/11] bool DamageWindow (#2444) * bool DamageWindow * . --- Exiled.API/Features/Recontainer.cs | 2 +- Exiled.API/Features/Window.cs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Exiled.API/Features/Recontainer.cs b/Exiled.API/Features/Recontainer.cs index bdbbfcdf79..4f73ce1096 100644 --- a/Exiled.API/Features/Recontainer.cs +++ b/Exiled.API/Features/Recontainer.cs @@ -224,6 +224,6 @@ public static bool IsContainmentSequenceSuccessful /// /// Breaks the glass protecting the activator button. /// - public static void BreakGlass() => ActivatorWindow.BreakWindow(); + public static void Break() => ActivatorWindow.Break(); } } \ No newline at end of file diff --git a/Exiled.API/Features/Window.cs b/Exiled.API/Features/Window.cs index a1819c9f57..8a62e79b9b 100644 --- a/Exiled.API/Features/Window.cs +++ b/Exiled.API/Features/Window.cs @@ -181,23 +181,21 @@ public static bool TryGet(Func predicate, out IEnumerable /// /// Break the window. /// - public void BreakWindow() => Base.BreakWindow(); + public void Break() => Base.BreakWindow(); /// /// Damages the window. /// /// The amount of damage to deal. - public void DamageWindow(float amount) => Base.ServerDamageWindow(amount); + public void Damage(float amount) => Base.ServerDamageWindow(amount); /// /// Damages the window. /// /// The amount of damage to deal. /// The handler of damage. - public void DamageWindow(float amount, DamageHandlerBase handler) - { - Base.Damage(amount, handler, Vector3.zero); - } + /// Whether or not the Window get Damage. + public bool Damage(float amount, DamageHandlerBase handler) => Base.Damage(amount, handler, Vector3.zero); /// /// Returns the Window in a human-readable format.