From 99c295cdb9c3d38aadd0120db706032ea2d88fcb Mon Sep 17 00:00:00 2001 From: Miki_hero <100715076+Mikihero@users.noreply.github.com> Date: Sun, 24 Nov 2024 22:06:29 +0100 Subject: [PATCH 001/102] Added a BanManager (#192) * added a banmanager * added optional ban issuer * Update EXILED/Exiled.API/Features/BanManager.cs * Update EXILED/Exiled.API/Features/BanManager.cs * reorder methods + public --------- Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com> --- EXILED/Exiled.API/Features/BanManager.cs | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 EXILED/Exiled.API/Features/BanManager.cs diff --git a/EXILED/Exiled.API/Features/BanManager.cs b/EXILED/Exiled.API/Features/BanManager.cs new file mode 100644 index 000000000..219c272eb --- /dev/null +++ b/EXILED/Exiled.API/Features/BanManager.cs @@ -0,0 +1,58 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features +{ + using System; + + /// + /// Useful class to manage player bans. + /// + public static class BanManager + { + /// + /// Bans an offline player. + /// + /// Type of the ban (UserID/IP). + /// The UserID or IP address to ban. + /// The ban reason. + /// A representing the duration. + /// The Nickname of the ban issuer. + /// Whether the ban was successful. + public static bool OfflineBanPlayer(BanHandler.BanType banType, string id, string reason, TimeSpan duration, string issuer = "SERVER CONSOLE") => OfflineBanPlayer(banType, id, reason, duration.TotalSeconds, issuer); + + /// + /// Bans an offline player. + /// + /// Type of the ban (UserID/IP). + /// The UserID or IP address to ban. + /// The ban reason. + /// Duration in seconds. + /// The Nickname of the ban issuer. + /// Whether the ban was successful. + public static bool OfflineBanPlayer(BanHandler.BanType banType, string id, string reason, double duration, string issuer = "SERVER CONSOLE") + { + BanDetails details = new() + { + OriginalName = "Unknown - offline ban", + Id = id, + IssuanceTime = DateTime.UtcNow.Ticks, + Expires = DateTime.UtcNow.AddSeconds(duration).Ticks, + Reason = reason, + Issuer = issuer, + }; + return BanHandler.IssueBan(details, banType); + } + + /// + /// Unbans a player. + /// + /// Type of the ban (UserID/IP). + /// The UserID or IP address to ban.\ + public static void UnbanPlayer(BanHandler.BanType banType, string id) => BanHandler.RemoveBan(id, banType); + } +} \ No newline at end of file From 9ab44bdb3ae47567dac0b386bf9a6f5ac41db4ac Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 25 Nov 2024 06:09:03 +0000 Subject: [PATCH 002/102] docs: clearer documentation on item events (#191) * docs: clearer documentation on item events * docs: grammatical mistake Because you pronounce usable as you-sable, it should be a not an * docs: more clarification * docs: usable cref > item * docs: clarification on UsingItem * docs: add remark to say that user may be in cooldown * docs: item > user * docs: remove useless remarks * docs: edit remark to say only the important parts * docs: UsingItem doesn't invoke on Items.Item --- EXILED/Exiled.Events/Handlers/Player.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.Events/Handlers/Player.cs b/EXILED/Exiled.Events/Handlers/Player.cs index ddf76f1a4..581b10014 100644 --- a/EXILED/Exiled.Events/Handlers/Player.cs +++ b/EXILED/Exiled.Events/Handlers/Player.cs @@ -70,12 +70,16 @@ public class Player public static Event EarningAchievement { get; set; } = new(); /// - /// Invoked before using an . + /// Invoked before the player starts to use an . In other words, it is invoked just before the animation starts. /// + /// + /// Will be invoked even if the is on cooldown. + /// Candies are the only that do not invoke this event. + /// public static Event UsingItem { get; set; } = new(); /// - /// Invoked after a uses an . + /// Invoked before a finishes using a . In other words, it is invoked after the animation finishes but before the is actually used. /// public static Event UsingItemCompleted { get; set; } = new (); From e5c54b74dad40a006abe786c646df3337dedb02d Mon Sep 17 00:00:00 2001 From: X <24619207+Undid-Iridium@users.noreply.github.com> Date: Mon, 25 Nov 2024 01:11:36 -0500 Subject: [PATCH 003/102] Scp330 interacting fix (#184) --- EXILED/Exiled.API/Features/Items/Scp330.cs | 5 -- .../Scp330/InteractingScp330EventArgs.cs | 16 ++--- .../Events/Scp330/InteractingScp330.cs | 60 +++++++++++++------ 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/EXILED/Exiled.API/Features/Items/Scp330.cs b/EXILED/Exiled.API/Features/Items/Scp330.cs index 159e6ccac..f31bfcf25 100644 --- a/EXILED/Exiled.API/Features/Items/Scp330.cs +++ b/EXILED/Exiled.API/Features/Items/Scp330.cs @@ -87,11 +87,6 @@ internal Scp330() /// public CandyKindID ExposedType { get; set; } = CandyKindID.None; - /// - /// Gets or sets the candy that will be added to the bag. Used for events. - /// - internal CandyKindID CandyToAdd { get; set; } = CandyKindID.None; - /// /// Adds a specific candy to the bag. /// diff --git a/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs index 526042dd9..84f53ffce 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs @@ -46,8 +46,6 @@ public InteractingScp330EventArgs(Player player, int usage) Scp330.RemoveAllCandy(); player.AddItem(Scp330); } - - Scp330.CandyToAdd = Scp330Candies.GetRandom(); } /// @@ -55,15 +53,6 @@ public InteractingScp330EventArgs(Player player, int usage) /// public int UsageCount { get; } - /// - /// Gets or sets a value indicating the type of candy that will be received from this interaction. - /// - public CandyKindID Candy - { - get => Scp330.CandyToAdd; - set => Scp330.CandyToAdd = value; - } - /// /// Gets or sets a value indicating whether the player's hands should get severed. /// @@ -75,6 +64,11 @@ public CandyKindID Candy /// It won't work if = . public bool ShouldPlaySound { get; set; } + /// + /// Gets or sets a value indicating the type of candy that will be received from this interaction. + /// + public CandyKindID Candy { get; set; } + /// /// Gets or sets a value indicating whether the player is allowed to interact with SCP-330. /// diff --git a/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs b/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs index 71c5bf3cf..28b657a45 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs @@ -9,6 +9,7 @@ namespace Exiled.Events.Patches.Events.Scp330 { #pragma warning disable SA1402 #pragma warning disable SA1313 + using System.Collections.Generic; using System.Reflection.Emit; @@ -18,6 +19,7 @@ namespace Exiled.Events.Patches.Events.Scp330 using Exiled.Events.EventArgs.Scp330; using HarmonyLib; using Interactables.Interobjects; + using InventorySystem; using InventorySystem.Items.Usables.Scp330; using PluginAPI.Events; @@ -73,19 +75,37 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(Scp330Bag), nameof(Scp330Bag.ServerProcessPickup)))) + remove_offset; + + // Remove original add candy logic + newInstructions.RemoveRange(remove_index, 4); + /* next code will used to override sound rpc check by EXILED * old: * if (args.PlaySound) * new: - * if (args.PlaySound && ev.PlaySound) + * if (args.PlaySound | ev.PlaySound) */ - offset = 1; index = newInstructions.FindLastIndex( instruction => instruction.Calls(PropertyGetter(typeof(PlayerInteractScp330Event), nameof(PlayerInteractScp330Event.PlaySound)))) + offset; - newInstructions.InsertRange( index, new[] @@ -93,9 +113,8 @@ private static IEnumerable Transpiler(IEnumerable= 2) @@ -135,21 +154,28 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } - } - /// - /// Replaces with . - /// - [EventPatch(typeof(Handlers.Scp330), nameof(Handlers.Scp330.InteractingScp330))] - [HarmonyPatch(typeof(Scp330Bag), nameof(Scp330Bag.TryAddSpecific))] - internal static class ReplaceCandy - { - private static void Prefix(Scp330Bag __instance, ref CandyKindID kind) + private static bool ServerProcessPickup(ReferenceHub player, CandyKindID candy, out Scp330Bag bag) { - Scp330 scp330 = Item.Get(__instance); + if (!Scp330Bag.TryGetBag(player, out bag)) + { + player.inventory.ServerAddItem(ItemType.SCP330); + + if (!Scp330Bag.TryGetBag(player, out bag)) + return false; + + bag.Candies = new List { candy }; + bag.ServerRefreshBag(); + + return true; + } + + bool result = bag.TryAddSpecific(candy); + + if (bag.AcquisitionAlreadyReceived) + bag.ServerRefreshBag(); - if (scp330.CandyToAdd != CandyKindID.None) - kind = scp330.CandyToAdd; + return result; } } } \ No newline at end of file From e63a7ca5477fd94e2b0f5b285485011214e114d7 Mon Sep 17 00:00:00 2001 From: icedchai <70030002+icedchai@users.noreply.github.com> Date: Mon, 25 Nov 2024 00:19:20 -0600 Subject: [PATCH 004/102] Updated CustomItems & CustomRoles give commands to use default RAUtils.ProcessPlayerIdOrNamesList (#179) * Update Give.cs * Update Give.cs * fixed style violation * Fixed issue * Player.GetProcessedData * Update EXILED.props * list.isempty * Revert "Update EXILED.props" This reverts commit 410fb613ad4e1e08d86c534f53e3250d6e83f122. --------- Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com> --- EXILED/Exiled.CustomItems/Commands/Give.cs | 33 +++++++++++++--------- EXILED/Exiled.CustomRoles/Commands/Give.cs | 27 ++++++++++++------ 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/EXILED/Exiled.CustomItems/Commands/Give.cs b/EXILED/Exiled.CustomItems/Commands/Give.cs index 31151934a..cc63ed222 100644 --- a/EXILED/Exiled.CustomItems/Commands/Give.cs +++ b/EXILED/Exiled.CustomItems/Commands/Give.cs @@ -18,6 +18,8 @@ namespace Exiled.CustomItems.Commands using Exiled.Permissions.Extensions; using RemoteAdmin; + using UnityStandardAssets.Effects; + using Utils; /// /// The command to give a player an item. @@ -97,22 +99,27 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s response = $"Custom item {item?.Name} given to all players who can receive them ({eligiblePlayers.Count} players)"; return true; default: - if (Player.Get(identifier) is not { } player) - { - response = $"Unable to find player: {identifier}."; - return false; - } + break; + } - if (!CheckEligible(player)) - { - response = "Player cannot receive custom items!"; - return false; - } + IEnumerable list = Player.GetProcessedData(arguments, 1); + + if (list.IsEmpty()) + { + response = "Cannot find player! Try using the player ID!"; + return false; + } + foreach (Player player in list) + { + if (CheckEligible(player)) + { item?.Give(player); - response = $"{item?.Name} given to {player.Nickname} ({player.UserId})"; - return true; + } } + + response = $"{item?.Name} given to {list.Count()} players!"; + return true; } /// @@ -120,4 +127,4 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s /// private bool CheckEligible(Player player) => player.IsAlive && !player.IsCuffed && (player.Items.Count < 8); } -} \ No newline at end of file +} diff --git a/EXILED/Exiled.CustomRoles/Commands/Give.cs b/EXILED/Exiled.CustomRoles/Commands/Give.cs index ed52669f8..4eb357feb 100644 --- a/EXILED/Exiled.CustomRoles/Commands/Give.cs +++ b/EXILED/Exiled.CustomRoles/Commands/Give.cs @@ -19,6 +19,7 @@ namespace Exiled.CustomRoles.Commands using Exiled.Permissions.Extensions; using RemoteAdmin; + using Utils; /// /// The command to give a role to player(s). @@ -96,16 +97,24 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s ListPool.Pool.Return(players); return true; default: - if (Player.Get(identifier) is not Player ply) - { - response = $"Unable to find a player: {identifier}"; - return false; - } - - role.AddRole(ply); - response = $"{role.Name} given to {ply.Nickname}."; - return true; + break; + } + + IEnumerable list = Player.GetProcessedData(arguments, 1); + if (list.IsEmpty()) + { + response = "Cannot find player! Try using the player ID!"; + return false; } + + foreach (Player player in list) + { + role.AddRole(player); + } + + response = $"Customrole {role.Name} given to {list.Count()} players!"; + + return true; } catch (Exception e) { From aa61c0ecf5cf9c6186afe806c43471b304ce2f5c Mon Sep 17 00:00:00 2001 From: Mikhail Reznichenko Date: Mon, 25 Nov 2024 11:22:34 +0500 Subject: [PATCH 005/102] Improved Door.Lock method (#173) * fix door unlocking after calling Door.Lock multiple times with the same DoorLockType Signed-off-by: Mikhail Reznichenko * revert ChangeLock changes & replace ChangeLock call inside Lock with new code Signed-off-by: Mikhail Reznichenko * add new Door.Lock method Signed-off-by: Mikhail Reznichenko --------- Signed-off-by: Mikhail Reznichenko Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com> --- EXILED/Exiled.API/Features/Doors/Door.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index 4f949748e..310285642 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -518,10 +518,22 @@ public void ChangeLock(DoorLockType lockType) /// The of the lockdown. public void Lock(float time, DoorLockType lockType) { - ChangeLock(lockType); + Lock(lockType); Unlock(time, lockType); } + /// + /// Locks all active locks on the door for infinite time. + /// + /// The of the lockdown. + public void Lock(DoorLockType lockType) + { + DoorLockType locks = DoorLockType; + locks |= lockType; + Base.NetworkActiveLocks = (ushort)locks; + DoorEvents.TriggerAction(Base, IsLocked ? DoorAction.Locked : DoorAction.Unlocked, null); + } + /// /// Unlocks and clears all active locks on the door. /// From 07113063bfa0ea99f2a2bbb909c3a5e39cdb8115 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Tue, 26 Nov 2024 19:40:02 +0100 Subject: [PATCH 006/102] SCP:SL 14 all done from client (so not finish) (#194) * secret update * i can't do more * more * temporary * Speaker * More propperty * Panel Change * i don't find more to do * PitKiller * . * ExtraTargetCount * Nuke * fix error * remove uneeded code * Fix * Fix * PocketTeleportList * . * TryGetFirst * Update doc * PitDeath * effect uppdate * that? * respawn + npc + remove obsolete * fix signature * API fixed Tbh i don't really believe that anything from this will work as expcted but... something deeply inside tells that it will * oh fuck is it real?! * useless fix * something new here --------- Co-authored-by: VALERA771 <72030575+VALERA771@users.noreply.github.com> Co-authored-by: Nameless <85962933+Misfiy@users.noreply.github.com> Co-authored-by: VALERA771 --- EXILED/Exiled.API/Enums/AdminToyType.cs | 5 + EXILED/Exiled.API/Enums/EffectType.cs | 22 +- EXILED/Exiled.API/Enums/RespawnEffectType.cs | 11 +- EXILED/Exiled.API/Enums/SpawnLocationType.cs | 6 - EXILED/Exiled.API/Enums/SpawnableFaction.cs | 35 + .../Extensions/EffectTypeExtension.cs | 8 +- .../Exiled.API/Extensions/ItemExtensions.cs | 13 +- .../Exiled.API/Extensions/MirrorExtensions.cs | 17 +- .../Exiled.API/Extensions/RoleExtensions.cs | 15 +- .../Features/Components/CollisionHandler.cs | 6 +- .../DamageHandlers/CustomDamageHandler.cs | 2 +- .../DamageHandlers/GenericDamageHandler.cs | 8 +- EXILED/Exiled.API/Features/Doors/Door.cs | 2 +- .../Exiled.API/Features/Doors/ElevatorDoor.cs | 30 +- EXILED/Exiled.API/Features/Items/Armor.cs | 9 +- EXILED/Exiled.API/Features/Items/Firearm.cs | 123 +- .../Exiled.API/Features/Items/Flashlight.cs | 7 - EXILED/Exiled.API/Features/Items/Item.cs | 18 + EXILED/Exiled.API/Features/Lift.cs | 22 +- EXILED/Exiled.API/Features/Map.cs | 41 +- EXILED/Exiled.API/Features/Npc.cs | 18 +- .../Features/Pickups/FirearmPickup.cs | 31 +- EXILED/Exiled.API/Features/Pickups/Pickup.cs | 24 +- .../Pickups/Projectiles/Projectile.cs | 13 - .../Pickups/Projectiles/Scp018Projectile.cs | 11 +- EXILED/Exiled.API/Features/Player.cs | 121 +- EXILED/Exiled.API/Features/Ragdoll.cs | 2 +- EXILED/Exiled.API/Features/Respawn.cs | 179 ++- .../Exiled.API/Features/Roles/Scp079Role.cs | 2 +- .../Exiled.API/Features/Roles/Scp106Role.cs | 89 +- .../Exiled.API/Features/Roles/Scp3114Role.cs | 13 +- EXILED/Exiled.API/Features/Round.cs | 21 +- EXILED/Exiled.API/Features/Server.cs | 8 - EXILED/Exiled.API/Features/Toys/AdminToy.cs | 3 +- EXILED/Exiled.API/Features/Toys/Light.cs | 53 +- EXILED/Exiled.API/Features/Toys/Speaker.cs | 84 ++ EXILED/Exiled.API/Features/Warhead.cs | 2 +- EXILED/Exiled.API/Features/Window.cs | 6 +- .../Exiled.CreditTags.csproj | 2 - .../API/EventArgs/OwnerEscapingEventArgs.cs | 15 +- .../API/Features/CustomItem.cs | 23 +- .../API/Features/CustomWeapon.cs | 6 +- .../EventArgs/Map/PlacingBloodEventArgs.cs | 64 - .../Map/PlacingBulletHoleEventArgs.cs | 19 +- .../Map/SpawningTeamVehicleEventArgs.cs | 6 +- .../EventArgs/Player/EscapingEventArgs.cs | 52 - .../EventArgs/Player/ShootingEventArgs.cs | 2 +- .../Scp079/ElevatorTeleportingEventArgs.cs | 2 +- .../Scp330/InteractingScp330EventArgs.cs | 1 - .../Server/RespawnedTeamEventArgs.cs | 9 +- .../Server/RespawningTeamEventArgs.cs | 39 +- EXILED/Exiled.Events/Events.cs | 8 +- .../Handlers/Internal/MapGenerated.cs | 4 +- EXILED/Exiled.Events/Handlers/Map.cs | 11 - EXILED/Exiled.Events/Handlers/Server.cs | 4 +- .../Events/Map/ExplodingFlashGrenade.cs | 5 +- .../Patches/Events/Map/PlacingBlood.cs | 110 -- .../Patches/Events/Map/PlacingBulletHole.cs | 18 +- .../Patches/Events/Map/SpawningTeamVehicle.cs | 9 +- .../Patches/Events/Player/ChangingItem.cs | 5 +- .../Events/Player/ChangingRoleAndSpawned.cs | 7 +- .../Events/Player/EnteringKillerCollision.cs | 4 +- .../Events/Player/EscapingAndEscaped.cs | 32 +- .../Events/Player/FirearmRequestReceived.cs | 9 +- .../Events/Player/InteractingElevator.cs | 17 +- .../Patches/Events/Player/Shot.cs | 118 +- .../Patches/Events/Scp106/ExitStalking.cs | 2 +- .../Patches/Events/Scp106/Stalking.cs | 4 +- .../Events/Scp330/InteractingScp330.cs | 7 +- .../Patches/Events/Server/RespawningTeam.cs | 44 +- .../Patches/Events/Server/RoundEnd.cs | 4 +- .../Fixes/Fix106RegenerationWithScp244.cs | 8 +- .../Patches/Fixes/NWFixScp096BreakingDoor.cs | 4 +- .../Patches/Fixes/Scp3114FriendlyFireFix.cs | 1 + .../Fixes/WeaponAttachmentDesyncFix.cs | 6 +- .../AddRespawnTargetMultiplierConfig.cs | 54 - .../Patches/Generic/FirearmDistribution.cs | 27 + .../Patches/Generic/IndividualFriendlyFire.cs | 2 +- .../Exiled.Events/Patches/Generic/LiftList.cs | 10 +- .../Generic/PocketDimensionTeleportList.cs | 29 + .../Patches/Generic/TeleportList.cs | 26 - EXILED/Exiled.Loader/AutoUpdateFiles.cs | 2 +- EXILED/Exiled.Loader/AutoUpdateFiles.tt | 4 +- .../Extensions/Permissions.cs | 4 +- .../SCPSLRessources/NW_Documentation.md | 1119 ++++++++++++++--- 85 files changed, 1787 insertions(+), 1251 deletions(-) create mode 100644 EXILED/Exiled.API/Enums/SpawnableFaction.cs create mode 100644 EXILED/Exiled.API/Features/Toys/Speaker.cs delete mode 100644 EXILED/Exiled.Events/EventArgs/Map/PlacingBloodEventArgs.cs delete mode 100644 EXILED/Exiled.Events/Patches/Events/Map/PlacingBlood.cs delete mode 100644 EXILED/Exiled.Events/Patches/Generic/AddRespawnTargetMultiplierConfig.cs create mode 100644 EXILED/Exiled.Events/Patches/Generic/FirearmDistribution.cs create mode 100644 EXILED/Exiled.Events/Patches/Generic/PocketDimensionTeleportList.cs delete mode 100644 EXILED/Exiled.Events/Patches/Generic/TeleportList.cs diff --git a/EXILED/Exiled.API/Enums/AdminToyType.cs b/EXILED/Exiled.API/Enums/AdminToyType.cs index 181c62552..c7f937721 100644 --- a/EXILED/Exiled.API/Enums/AdminToyType.cs +++ b/EXILED/Exiled.API/Enums/AdminToyType.cs @@ -27,5 +27,10 @@ public enum AdminToyType /// ShootingTarget toy. /// ShootingTarget, + + /// + /// Speaker toy. + /// + Speaker, } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Enums/EffectType.cs b/EXILED/Exiled.API/Enums/EffectType.cs index 2ba874dd8..b2894486e 100644 --- a/EXILED/Exiled.API/Enums/EffectType.cs +++ b/EXILED/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. @@ -239,5 +239,25 @@ public enum EffectType /// . /// Slowness, + + /// + /// . + /// + Scp1344, + + /// + /// . + /// + SeveredEyes, + + /// + /// . + /// + PitDeath, + + /// + /// . + /// + Blurred, } } diff --git a/EXILED/Exiled.API/Enums/RespawnEffectType.cs b/EXILED/Exiled.API/Enums/RespawnEffectType.cs index 672f26d40..d26f7be26 100644 --- a/EXILED/Exiled.API/Enums/RespawnEffectType.cs +++ b/EXILED/Exiled.API/Enums/RespawnEffectType.cs @@ -16,21 +16,16 @@ namespace Exiled.API.Enums /// /// /// - public enum RespawnEffectType : byte + public enum RespawnEffectType { - /// - /// Plays the music to alive and . - /// - PlayChaosInsurgencyMusic = 0, - /// /// Summons the van. /// - SummonChaosInsurgencyVan = 128, + SummonChaosInsurgencyVan, /// /// Summons the NTF chopper. /// - SummonNtfChopper = 129, + SummonNtfChopper, } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Enums/SpawnLocationType.cs b/EXILED/Exiled.API/Enums/SpawnLocationType.cs index 927542ffe..12d32ce2a 100644 --- a/EXILED/Exiled.API/Enums/SpawnLocationType.cs +++ b/EXILED/Exiled.API/Enums/SpawnLocationType.cs @@ -147,11 +147,5 @@ public enum SpawnLocationType /// Just inside the door at the bottom of the server's room. /// InsideServersBottom, - - /// - /// Inside a random locker on the map. - /// - [Obsolete("Use LockerSpawnPoint instead")] - InsideLocker, } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Enums/SpawnableFaction.cs b/EXILED/Exiled.API/Enums/SpawnableFaction.cs new file mode 100644 index 000000000..131a7a4ff --- /dev/null +++ b/EXILED/Exiled.API/Enums/SpawnableFaction.cs @@ -0,0 +1,35 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Enums +{ + /// + /// All spawnable factions. + /// + public enum SpawnableFaction + { + /// + /// Normal NTF wave. + /// + NtfWave, + + /// + /// Normal Chaos wave. + /// + ChaosWave, + + /// + /// Mini NTF wave. + /// + NtfMiniWave, + + /// + /// Mini Chaos wave. + /// + ChaosMiniWave, + } +} \ No newline at end of file diff --git a/EXILED/Exiled.API/Extensions/EffectTypeExtension.cs b/EXILED/Exiled.API/Extensions/EffectTypeExtension.cs index f602bcdae..0b977356e 100644 --- a/EXILED/Exiled.API/Extensions/EffectTypeExtension.cs +++ b/EXILED/Exiled.API/Extensions/EffectTypeExtension.cs @@ -33,7 +33,7 @@ public static class EffectTypeExtension { EffectType.AmnesiaVision, typeof(AmnesiaVision) }, { EffectType.Asphyxiated, typeof(Asphyxiated) }, { EffectType.Bleeding, typeof(Bleeding) }, - { EffectType.Blinded, typeof(Blinded) }, + { EffectType.Blinded, typeof(Blindness) }, { EffectType.BodyshotReduction, typeof(BodyshotReduction) }, { EffectType.Burned, typeof(Burned) }, { EffectType.CardiacArrest, typeof(CardiacArrest) }, @@ -74,6 +74,10 @@ public static class EffectTypeExtension { EffectType.Ghostly, typeof(Ghostly) }, { EffectType.FogControl, typeof(FogControl) }, { EffectType.Slowness, typeof(Slowness) }, + { EffectType.Scp1344, typeof(Scp1344) }, + { EffectType.SeveredEyes, typeof(SeveredEyes) }, + { EffectType.PitDeath, typeof(PitDeath) }, + { EffectType.Blurred, typeof(Blurred) }, }); /// @@ -146,7 +150,7 @@ or EffectType.Corroding or EffectType.Decontaminating or EffectType.Hemorrhage o /// The . /// Whether the effect heals. /// - public static bool IsHealing(this EffectType effect) => effect.TryGetType(out Type type) && typeof(IHealablePlayerEffect).IsAssignableFrom(type); + public static bool IsHealing(this EffectType effect) => effect.TryGetType(out Type type) && typeof(IHealableEffect).IsAssignableFrom(type); /// /// Returns whether the provided is a negative effect. diff --git a/EXILED/Exiled.API/Extensions/ItemExtensions.cs b/EXILED/Exiled.API/Extensions/ItemExtensions.cs index c0fda94b1..3fc97516f 100644 --- a/EXILED/Exiled.API/Extensions/ItemExtensions.cs +++ b/EXILED/Exiled.API/Extensions/ItemExtensions.cs @@ -18,6 +18,7 @@ namespace Exiled.API.Extensions using InventorySystem; using InventorySystem.Items; using InventorySystem.Items.Firearms.Attachments; + using InventorySystem.Items.Firearms.Modules; using InventorySystem.Items.Pickups; using Structs; @@ -123,12 +124,12 @@ public static T GetItemBase(this ItemType type) /// /// The weapon that you want to get maximum of. /// Returns the maximum. - public static byte GetMaxAmmo(this FirearmType item) + public static int GetMaxAmmo(this FirearmType item) { if (!InventoryItemLoader.AvailableItems.TryGetValue(item.GetItemType(), out ItemBase itemBase) || itemBase is not InventorySystem.Items.Firearms.Firearm firearm) return 0; - return firearm.AmmoManagerModule.MaxAmmo; + return (firearm.Modules.FirstOrDefault(x => x is IAmmoContainerModule) as IAmmoContainerModule).AmmoMax; } /// @@ -323,5 +324,13 @@ public static uint GetBaseCode(this FirearmType type) /// The to check. /// of the specified . public static ItemCategory GetCategory(this ItemType type) => GetItemBase(type).Category; + + /// + /// Checks if the specified has the specified . + /// + /// Weapon to check. + /// Attachment to check. + /// true if weapon has the specified attachment. Otherwise, false. + public static bool HasAttachment(this Firearm firearm, AttachmentName attachment) => firearm.Attachments.FirstOrDefault(x => x.Name == attachment)?.IsEnabled ?? false; } } diff --git a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs index f8c49599f..133904473 100644 --- a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs +++ b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs @@ -151,7 +151,7 @@ public static ReadOnlyDictionary RpcFullNames /// Plays a beep sound that only the target can hear. /// /// Target to play sound to. - public static void PlayBeepSound(this Player player) => SendFakeTargetRpc(player, ReferenceHub.HostHub.networkIdentity, typeof(AmbientSoundPlayer), nameof(AmbientSoundPlayer.RpcPlaySound), 7); + public static void PlayBeepSound(this Player player) => SendFakeTargetRpc(player, ReferenceHub._hostHub.networkIdentity, typeof(AmbientSoundPlayer), nameof(AmbientSoundPlayer.RpcPlaySound), 7); /// /// Set on the player that only the can see. @@ -171,6 +171,8 @@ public static ReadOnlyDictionary RpcFullNames /// GunAudioMessage's audioClipId to set (default = 0). public static void PlayGunSound(this Player player, Vector3 position, ItemType itemType, byte volume, byte audioClipId = 0) { + // TODO: Not finish + /* GunAudioMessage message = new() { Weapon = itemType, @@ -180,7 +182,7 @@ public static void PlayGunSound(this Player player, Vector3 position, ItemType i ShooterPosition = new RelativePosition(position), }; - player.Connection.Send(message); + player.Connection.Send(message);*/ } /// @@ -222,17 +224,6 @@ public static void SetName(this Player target, Player player, string name) target.SendFakeSyncVar(player.NetworkIdentity, typeof(NicknameSync), nameof(NicknameSync.Network_displayName), name); } - /// - /// Sets of a that only the player can see. - /// - /// Room to modify. - /// Only this player can see room color. - /// Light intensity multiplier to set. - [Obsolete("This features has been remove by NW", true)] - public static void SetRoomLightIntensityForTargetOnly(this Room room, Player target, float multiplier) - { - } - /// /// Change character model for appearance. /// It will continue until 's changes. diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index c36592500..e86805f00 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -17,7 +17,7 @@ namespace Exiled.API.Extensions using InventorySystem.Configs; using PlayerRoles; using PlayerRoles.FirstPersonControl; - + using Respawning.Waves; using UnityEngine; using Team = PlayerRoles.Team; @@ -210,5 +210,18 @@ public static Dictionary GetStartingAmmo(this RoleTypeId roleT return info.Ammo.ToDictionary(kvp => kvp.Key.GetAmmoType(), kvp => kvp.Value); } + + /// + /// Gets the of a . + /// + /// A instance. + /// associated with the wave. + public static SpawnableFaction GetFaction(this SpawnableWaveBase waveBase) => waveBase switch + { + NtfSpawnWave => SpawnableFaction.NtfWave, + NtfMiniWave => SpawnableFaction.NtfMiniWave, + ChaosSpawnWave => SpawnableFaction.ChaosWave, + _ => SpawnableFaction.ChaosMiniWave + }; } } diff --git a/EXILED/Exiled.API/Features/Components/CollisionHandler.cs b/EXILED/Exiled.API/Features/Components/CollisionHandler.cs index b98e7bb5a..2cd1cd220 100644 --- a/EXILED/Exiled.API/Features/Components/CollisionHandler.cs +++ b/EXILED/Exiled.API/Features/Components/CollisionHandler.cs @@ -56,9 +56,11 @@ private void OnCollisionEnter(Collision collision) Log.Error("Grenade is null!"); if (collision is null) Log.Error("wat"); - if (collision.gameObject == null) + if (collision.collider) + Log.Error("water"); + if (collision.collider.gameObject == null) Log.Error("pepehm"); - if (collision.gameObject == Owner || collision.gameObject.TryGetComponent(out _)) + if (collision.collider.gameObject == Owner || collision.collider.gameObject.TryGetComponent(out _)) return; Grenade.TargetTime = 0.1f; diff --git a/EXILED/Exiled.API/Features/DamageHandlers/CustomDamageHandler.cs b/EXILED/Exiled.API/Features/DamageHandlers/CustomDamageHandler.cs index 115990925..67b464474 100644 --- a/EXILED/Exiled.API/Features/DamageHandlers/CustomDamageHandler.cs +++ b/EXILED/Exiled.API/Features/DamageHandlers/CustomDamageHandler.cs @@ -71,7 +71,7 @@ public CustomDamageHandler(Player target, Player attacker, float damage, DamageT Base = { Owner = attacker.ReferenceHub }, }; - CustomBase = new FirearmDamageHandler(firearm, target, new BaseFirearmHandler(firearm.Base, damage)); + CustomBase = new FirearmDamageHandler(firearm, target, new PlayerStatsSystem.FirearmDamageHandler() { Firearm = firearm.Base, Damage = damage }); } /// diff --git a/EXILED/Exiled.API/Features/DamageHandlers/GenericDamageHandler.cs b/EXILED/Exiled.API/Features/DamageHandlers/GenericDamageHandler.cs index 152f77af2..64efd0c86 100644 --- a/EXILED/Exiled.API/Features/DamageHandlers/GenericDamageHandler.cs +++ b/EXILED/Exiled.API/Features/DamageHandlers/GenericDamageHandler.cs @@ -10,14 +10,12 @@ namespace Exiled.API.Features.DamageHandlers using Enums; using Footprinting; - using Items; using PlayerRoles.PlayableScps.Scp096; using PlayerRoles.PlayableScps.Scp939; using PlayerStatsSystem; - using UnityEngine; /// @@ -113,7 +111,7 @@ public GenericDamageHandler(Player player, Player attacker, float damage, Damage Base = new MicroHidDamageHandler(microHidOwner, damage); break; case DamageType.Explosion: - Base = new ExplosionDamageHandler(attacker.Footprint, UnityEngine.Vector3.zero, damage, 0); + Base = new ExplosionDamageHandler(attacker.Footprint, UnityEngine.Vector3.zero, damage, 0, ExplosionType.Grenade); break; case DamageType.Firearm: GenericFirearm(player, attacker, damage, damageType, ItemType.GunAK); @@ -155,7 +153,7 @@ public GenericDamageHandler(Player player, Player attacker, float damage, Damage GenericFirearm(player, attacker, damage, damageType, ItemType.GunA7); break; case DamageType.ParticleDisruptor: - Base = new DisruptorDamageHandler(Attacker, damage); + Base = new DisruptorDamageHandler(new (Item.Create(ItemType.ParticleDisruptor, attacker).Base as InventorySystem.Items.Firearms.Firearm, InventorySystem.Items.Firearms.Modules.DisruptorActionModule.FiringState.FiringSingle), Vector3.up, damage); break; case DamageType.Scp096: Scp096Role curr096 = attacker.ReferenceHub.roleManager.CurrentRole as Scp096Role ?? new Scp096Role(); @@ -259,7 +257,7 @@ private void GenericFirearm(Player player, Player attacker, float amount, Damage Owner = attacker.ReferenceHub, }, }; - Base = new PlayerStatsSystem.FirearmDamageHandler(firearm.Base, amount); + Base = new PlayerStatsSystem.FirearmDamageHandler() { Firearm = firearm.Base, Damage = amount }; } } } diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index 310285642..315142c53 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -614,7 +614,7 @@ private DoorType GetDoorType() }, "Elevator" => (Base as Interactables.Interobjects.ElevatorDoor)?.Group switch { - ElevatorGroup.Nuke => DoorType.ElevatorNuke, + ElevatorGroup.Nuke01 or ElevatorGroup.Nuke02 => DoorType.ElevatorNuke, ElevatorGroup.Scp049 => DoorType.ElevatorScp049, ElevatorGroup.GateB => DoorType.ElevatorGateB, ElevatorGroup.GateA => DoorType.ElevatorGateA, diff --git a/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs b/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs index aa011f7fe..dd597645c 100644 --- a/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs +++ b/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs @@ -12,6 +12,8 @@ namespace Exiled.API.Features.Doors using Exiled.API.Enums; using Interactables.Interobjects; + using Interactables.Interobjects.DoorUtils; + using UnityEngine; /// /// Represents an elevator door. @@ -28,6 +30,8 @@ internal ElevatorDoor(Interactables.Interobjects.ElevatorDoor door, List r { Base = door; Lift = Lift.Get(x => x.Group == Group).FirstOrDefault(); + + Panel = Object.FindObjectsOfType().FirstOrDefault(x => x._door == door); } /// @@ -36,29 +40,29 @@ internal ElevatorDoor(Interactables.Interobjects.ElevatorDoor door, List r public new Interactables.Interobjects.ElevatorDoor Base { get; } /// - /// Gets the that this door's belongs to. + /// Gets the that this door's belongs to. + /// + public ElevatorGroup Group => Base.Group; + + /// + /// Gets the associated with this lift. /// - public ElevatorManager.ElevatorGroup Group => Base.Group; + public ElevatorPanel Panel { get; } /// /// Gets the type according to . /// public ElevatorType ElevatorType => Group switch { - ElevatorManager.ElevatorGroup.Scp049 => ElevatorType.Scp049, - ElevatorManager.ElevatorGroup.GateA => ElevatorType.GateA, - ElevatorManager.ElevatorGroup.GateB => ElevatorType.GateB, - ElevatorManager.ElevatorGroup.LczA01 or ElevatorManager.ElevatorGroup.LczA02 => ElevatorType.LczA, - ElevatorManager.ElevatorGroup.LczB01 or ElevatorManager.ElevatorGroup.LczB02 => ElevatorType.LczB, - ElevatorManager.ElevatorGroup.Nuke => ElevatorType.Nuke, + ElevatorGroup.Scp049 => ElevatorType.Scp049, + ElevatorGroup.GateA => ElevatorType.GateA, + ElevatorGroup.GateB => ElevatorType.GateB, + ElevatorGroup.LczA01 or ElevatorGroup.LczA02 => ElevatorType.LczA, + ElevatorGroup.LczB01 or ElevatorGroup.LczB02 => ElevatorType.LczB, + ElevatorGroup.Nuke01 or ElevatorGroup.Nuke02 => ElevatorType.Nuke, _ => ElevatorType.Unknown, }; - /// - /// Gets the target panel for this lift. - /// - public ElevatorPanel Panel => Base.TargetPanel; - /// /// Gets the associated with this elevator door. /// diff --git a/EXILED/Exiled.API/Features/Items/Armor.cs b/EXILED/Exiled.API/Features/Items/Armor.cs index 30b99bc7c..6fe2bc097 100644 --- a/EXILED/Exiled.API/Features/Items/Armor.cs +++ b/EXILED/Exiled.API/Features/Items/Armor.cs @@ -115,14 +115,9 @@ public float StaminaUseMultiplier public float StaminaRegenMultiplier { get; set; } = 1f; /// - /// Gets or sets how much the users movement speed should be affected when wearing this armor. (higher values = slower movement). + /// Gets how much the users movement speed should be affected when wearing this armor. (higher values = slower movement). /// - public float MovementSpeedMultiplier - { - get => Base._movementSpeedMultiplier; - [Obsolete("This Setter was causing desync to client", true)] - set => _ = value; - } + public float MovementSpeedMultiplier => Base._movementSpeedMultiplier; /// /// Gets how much worse and s are affected by wearing this armor. diff --git a/EXILED/Exiled.API/Features/Items/Firearm.cs b/EXILED/Exiled.API/Features/Items/Firearm.cs index 750bd9d96..0ec5a6493 100644 --- a/EXILED/Exiled.API/Features/Items/Firearm.cs +++ b/EXILED/Exiled.API/Features/Items/Firearm.cs @@ -5,6 +5,8 @@ // // ----------------------------------------------------------------------- +using MEC; + namespace Exiled.API.Features.Items { using System; @@ -68,11 +70,10 @@ public Firearm(BaseFirearm itemBase) internal Firearm(ItemType type) : this((BaseFirearm)Server.Host.Inventory.CreateItemInstance(new(type, 0), false)) { - FirearmStatusFlags firearmStatusFlags = FirearmStatusFlags.MagazineInserted; - if (Base.HasAdvantageFlag(AttachmentDescriptiveAdvantages.Flashlight)) - firearmStatusFlags |= FirearmStatusFlags.FlashlightEnabled; + FlashlightAttachment flashlight = Attachments.OfType().FirstOrDefault(); - Base.Status = new FirearmStatus(MaxAmmo, firearmStatusFlags, Base.Status.Attachments); + if (flashlight != null && flashlight.IsEnabled) + flashlight.ServerSendStatus(true); } /// . @@ -112,37 +113,20 @@ public static IReadOnlyDictionary /// Gets or sets the amount of ammo in the firearm. /// - public byte Ammo + public int Ammo { - get => Base.Status.Ammo; - set => Base.Status = new FirearmStatus(value, Base.Status.Flags, Base.Status.Attachments); + get => (Base.Modules[Array.IndexOf(Base.Modules, typeof(MagazineModule))] as MagazineModule).AmmoStored; + set => (Base.Modules[Array.IndexOf(Base.Modules, typeof(MagazineModule))] as MagazineModule).AmmoStored = value; } /// /// Gets or sets the max ammo for this firearm. /// /// Disruptor can't be used for MaxAmmo. - public byte MaxAmmo + public int MaxAmmo { - get => Base.AmmoManagerModule.MaxAmmo; - set - { - switch (Base.AmmoManagerModule) - { - case TubularMagazineAmmoManager tubularMagazineAmmoManager: - tubularMagazineAmmoManager.MaxAmmo = (byte)(value - Base.AttachmentsValue(AttachmentParam.MagazineCapacityModifier) - (Base.Status.Flags.HasFlagFast(FirearmStatusFlags.Cocked) ? tubularMagazineAmmoManager.ChamberedRounds : 0)); - break; - case ClipLoadedInternalMagAmmoManager clipLoadedInternalMagAmmoManager: - clipLoadedInternalMagAmmoManager.MaxAmmo = (byte)(value - Base.AttachmentsValue(AttachmentParam.MagazineCapacityModifier)); - break; - case AutomaticAmmoManager automaticAmmoManager: - automaticAmmoManager.MaxAmmo = (byte)(value - Base.AttachmentsValue(AttachmentParam.MagazineCapacityModifier) - automaticAmmoManager.ChamberedAmount); - break; - default: - Log.Warn($"MaxAmmo can't be used for this Item: {Type} ({Base.AmmoManagerModule})"); - return; - } - } + get => (Base.Modules[Array.IndexOf(Base.Modules, typeof(MagazineModule))] as MagazineModule).AmmoMax; + set => (Base.Modules[Array.IndexOf(Base.Modules, typeof(MagazineModule))] as MagazineModule)._defaultCapacity = value; // Synced? } /// @@ -153,17 +137,20 @@ public byte MaxAmmo /// /// Gets the of the firearm. /// - public AmmoType AmmoType => Base.AmmoType.GetAmmoType(); + public AmmoType AmmoType => (Base.Modules.OfType().FirstOrDefault()?.AmmoType ?? ItemType.None).GetAmmoType(); + /// /// Gets a value indicating whether the firearm is being aimed. /// - public bool Aiming => Base.AdsModule.ServerAds; + public bool Aiming => Base.Modules.OfType().FirstOrDefault()?.AdsTarget ?? false; /// /// Gets a value indicating whether the firearm's flashlight module is enabled. /// - public bool FlashlightEnabled => Base.Status.Flags.HasFlagFast(FirearmStatusFlags.FlashlightEnabled); + public bool FlashlightEnabled => Base.IsEmittingLight; + + // TODO NOT FINISH /// /// Gets a value indicating whether the firearm's NightVision is being used. @@ -178,7 +165,7 @@ public byte MaxAmmo /// /// Gets a value indicating whether the firearm is automatic. /// - public bool IsAutomatic => Base is AutomaticFirearm; + public bool IsAutomatic => Array.Exists(Base.Modules, x => x is AutomaticActionModule); /// /// Gets the s of the firearm. @@ -209,11 +196,13 @@ public IEnumerable AttachmentIdentifiers /// public float FireRate { - get => Base is AutomaticFirearm auto ? auto._fireRate : 1f; + get => Base.Modules.OfType().FirstOrDefault()?.BaseFireRate ?? 0f; set { - if (Base is AutomaticFirearm auto) - auto._fireRate = value; + AutomaticActionModule module = Base.Modules.OfType().FirstOrDefault(); + + if (module != null) + module.BaseFireRate = value; } } @@ -224,18 +213,22 @@ public float FireRate /// public RecoilSettings Recoil { - get => Base is AutomaticFirearm auto ? auto._recoil : default; + get => Base.Modules.OfType().FirstOrDefault()?.BaseRecoil ?? default; set { - if (Base is AutomaticFirearm auto) - auto.ActionModule = new AutomaticAction(Base, auto._semiAutomatic, auto._boltTravelTime, 1f / auto._fireRate, auto._dryfireClipId, auto._triggerClipId, auto._gunshotPitchRandomization, value, auto._recoilPattern, false, Mathf.Max(1, auto._chamberSize)); + RecoilPatternModule module = Base.Modules.OfType().FirstOrDefault(); + + if (module != null) + module.BaseRecoil = value; } } + /* /// /// Gets the firearm's . Will be for non-automatic weapons. /// public FirearmRecoilPattern RecoilPattern => Base is AutomaticFirearm auto ? auto._recoilPattern : null; + */ /// /// Gets a of and [] which contains all available attachments for all firearms. @@ -277,7 +270,9 @@ public void AddAttachment(AttachmentIdentifier identifier) : identifier.Code; Base.ApplyAttachmentsCode((Base.GetCurrentAttachmentsCode() & ~toRemove) | newCode, true); - Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags, Base.GetCurrentAttachmentsCode()); + + // TODO Not finish + // Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags, Base.GetCurrentAttachmentsCode()); } /// @@ -319,10 +314,12 @@ public void RemoveAttachment(AttachmentIdentifier identifier) Base.ApplyAttachmentsCode(Base.GetCurrentAttachmentsCode() & ~code, true); + // TODO: Not finish + /* if (identifier.Name == AttachmentName.Flashlight) Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags & ~FirearmStatusFlags.FlashlightEnabled, Base.GetCurrentAttachmentsCode()); else - Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags, Base.GetCurrentAttachmentsCode()); + Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags, Base.GetCurrentAttachmentsCode());*/ } /// @@ -335,10 +332,12 @@ public void RemoveAttachment(AttachmentName attachmentName) Base.ApplyAttachmentsCode(Base.GetCurrentAttachmentsCode() & ~code, true); + // TODO Not finish + /* if (attachmentName == AttachmentName.Flashlight) Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags & ~FirearmStatusFlags.FlashlightEnabled, Base.GetCurrentAttachmentsCode()); else - Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags, Base.GetCurrentAttachmentsCode()); + Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags, Base.GetCurrentAttachmentsCode());*/ } /// @@ -356,10 +355,12 @@ public void RemoveAttachment(AttachmentSlot attachmentSlot) Base.ApplyAttachmentsCode(Base.GetCurrentAttachmentsCode() & ~code, true); + // TODO Not finish + /* if (firearmAttachment.Name == AttachmentName.Flashlight) Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags & ~FirearmStatusFlags.FlashlightEnabled, Base.GetCurrentAttachmentsCode()); else - Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags, Base.GetCurrentAttachmentsCode()); + Base.Status = new FirearmStatus(Math.Min(Ammo, MaxAmmo), Base.Status.Flags, Base.GetCurrentAttachmentsCode());*/ } /// @@ -602,6 +603,28 @@ public void ClearPreferences() ClearPreferences(player); } + /// + /// Reloads current . + /// + /// Whether empty magazine should be loaded. + public void Reload(bool emptyMagazine = false) + { + MagazineModule magazineModule = Base.Modules.OfType().FirstOrDefault(); + + if (magazineModule == null) + return; + + magazineModule.ServerRemoveMagazine(); + + Timing.CallDelayed(0.1f, () => + { + if (emptyMagazine) + magazineModule.ServerInsertEmptyMagazine(); + else + magazineModule.ServerInsertMagazine(); + }); + } + /// /// Clones current object. /// @@ -613,11 +636,13 @@ public override Item Clone() Ammo = Ammo, }; + // TODO Not finish + /* if (cloneableItem.Base is AutomaticFirearm) { cloneableItem.FireRate = FireRate; cloneableItem.Recoil = Recoil; - } + }*/ cloneableItem.AddAttachment(AttachmentIdentifiers); @@ -632,14 +657,18 @@ public override Item Clone() internal override void ChangeOwner(Player oldOwner, Player newOwner) { Base.Owner = newOwner.ReferenceHub; + Base._footprintCacheSet = false; + } - if (Base.HitregModule is StandardHitregBase hitReg) + internal override void ReadPickupInfo(Pickup pickup) + { + base.ReadPickupInfo(pickup); + + if (pickup is FirearmPickup firearmPickup) { - hitReg.Hub = Base.Owner; + // TODO If synced + // MaxAmmo = firearmPickup.MaxAmmo; } - - Base._sendStatusNextFrame = true; - Base._footprintValid = false; } } } diff --git a/EXILED/Exiled.API/Features/Items/Flashlight.cs b/EXILED/Exiled.API/Features/Items/Flashlight.cs index 7cdf432bf..0e9de906b 100644 --- a/EXILED/Exiled.API/Features/Items/Flashlight.cs +++ b/EXILED/Exiled.API/Features/Items/Flashlight.cs @@ -45,13 +45,6 @@ internal Flashlight(ItemType type) /// Can be or . public new ToggleableLightItemBase Base { get; } - /// - [Obsolete("Use IsEmittingLight instead.")] - public bool Active - { - get => IsEmittingLight; - set => IsEmittingLight = value; - } /// /// Gets or sets a value indicating whether the item is emitting light. diff --git a/EXILED/Exiled.API/Features/Items/Item.cs b/EXILED/Exiled.API/Features/Items/Item.cs index 7ba1afab5..308c75758 100644 --- a/EXILED/Exiled.API/Features/Items/Item.cs +++ b/EXILED/Exiled.API/Features/Items/Item.cs @@ -174,6 +174,15 @@ public ushort Serial /// public Player Owner => Player.Get(Base.Owner) ?? Server.Host; + /// + /// Gets or sets a reason for adding this item to the inventory. + /// + public ItemAddReason AddReason + { + get => Base.ServerAddReason; + set => Base.ServerAddReason = value; + } + /// /// Gets an existing or creates a new instance of one. /// @@ -233,6 +242,15 @@ public static T Get(ItemBase itemBase) /// Returns the Item found or if not found. public static Item Get(ushort serial) => List.FirstOrDefault(x => x.Serial == serial); + /// + /// Gets the Item belonging to the specified serial. + /// + /// The Item serial. + /// The specified type. + /// Returns the Item found or if not found. + public static T Get(ushort serial) + where T : Item => Get(serial) as T; + /// /// Creates a new with the proper inherited subclass. /// diff --git a/EXILED/Exiled.API/Features/Lift.cs b/EXILED/Exiled.API/Features/Lift.cs index 04b15f4c3..c74942490 100644 --- a/EXILED/Exiled.API/Features/Lift.cs +++ b/EXILED/Exiled.API/Features/Lift.cs @@ -121,8 +121,8 @@ public Quaternion Rotation /// public ElevatorSequence Status { - get => Base._curSequence; - set => Base._curSequence = value; + get => Base.CurSequence; + set => Base.CurSequence = value; } /// @@ -140,7 +140,7 @@ public ElevatorSequence Status ElevatorGroup.GateB => ElevatorType.GateB, ElevatorGroup.LczA01 or ElevatorGroup.LczA02 => ElevatorType.LczA, ElevatorGroup.LczB01 or ElevatorGroup.LczB02 => ElevatorType.LczB, - ElevatorGroup.Nuke => ElevatorType.Nuke, + ElevatorGroup.Nuke01 or ElevatorGroup.Nuke02 => ElevatorType.Nuke, _ => ElevatorType.Unknown, }; @@ -162,7 +162,7 @@ public ElevatorSequence Status /// /// Gets a value indicating whether the lift is locked. /// - public bool IsLocked => Base.ActiveLocks > 0; + public bool IsLocked => Base.ActiveLocksAnyDoors > 0 || Base.ActiveLocksAllDoors > 0; /// /// Gets or sets the . @@ -196,12 +196,12 @@ public float AnimationTime /// /// Gets the . /// - public int CurrentLevel => Base.CurrentLevel; + public int CurrentLevel => Base.DestinationLevel; /// /// Gets the . /// - public Doors.ElevatorDoor CurrentDestination => Door.Get(Base.CurrentDestination); + public Doors.ElevatorDoor CurrentDestination => Door.Get(Base.DestinationDoor); /// /// Gets a of which contains all the instances from the specified . @@ -272,9 +272,8 @@ public static bool TryMeltPlayer(Player player) /// Tries to start the lift. /// /// The destination level. - /// Indicates whether the start will be forced. - /// if the lift was started successfully; otherwise, . - public bool TryStart(int level, bool isForced = false) => TrySetDestination(Group, level, isForced); + /// Allowing queing. + public void TryStart(int level, bool allowQueueing = false) => Base.ServerSetDestination(level, allowQueueing); /// /// Changes lock of the lift. @@ -295,12 +294,7 @@ public void ChangeLock(DoorLockReason lockReason) else { door.ChangeLock((DoorLockType)lockReason); - - if (CurrentLevel != 1) - TrySetDestination(Group, 1, true); } - - Base.RefreshLocks(Group, door.Base); } } diff --git a/EXILED/Exiled.API/Features/Map.cs b/EXILED/Exiled.API/Features/Map.cs index 6f1d288db..d3950db22 100644 --- a/EXILED/Exiled.API/Features/Map.cs +++ b/EXILED/Exiled.API/Features/Map.cs @@ -43,11 +43,6 @@ namespace Exiled.API.Features /// public static class Map { - /// - /// A list of s on the map. - /// - internal static readonly List TeleportsValue = new(8); - private static AmbientSoundPlayer ambientSoundPlayer; private static SqueakSpawner squeakSpawner; @@ -79,15 +74,6 @@ DecontaminationController.Singleton.NetworkDecontaminationOverride is Decontamin /// public static ReadOnlyCollection PocketDimensionTeleports { get; } = TeleportsValue.AsReadOnly(); - /// - /// Gets all objects in the current map. - /// - /// - /// This property is obsolete. Use instead to retrieve a collection of all instances. - /// - [Obsolete("Use Locker.List instead.")] - public static ReadOnlyCollection Lockers { get; } = Features.Lockers.Locker.BaseToExiledLockers.Keys.ToList().AsReadOnly(); - /// /// Gets all objects. /// @@ -102,7 +88,7 @@ public static int Seed set { if (!SeedSynchronizer.MapGenerated) - SeedSynchronizer._singleton.Network_syncSeed = value; + SeedSynchronizer.Seed = value; } } @@ -121,13 +107,18 @@ public static bool IsDecontaminationEnabled /// /// Gets the . /// - public static AmbientSoundPlayer AmbientSoundPlayer => ambientSoundPlayer ??= ReferenceHub.HostHub.GetComponent(); + public static AmbientSoundPlayer AmbientSoundPlayer => ambientSoundPlayer ??= ReferenceHub._hostHub.GetComponent(); /// /// Gets the . /// public static SqueakSpawner SqueakSpawner => squeakSpawner ??= Object.FindObjectOfType(); + /// + /// Gets a list of s on the map. + /// + internal static List TeleportsValue { get; } = new(); + /// /// Broadcasts a message to all players. /// @@ -229,16 +220,6 @@ public static void ResetLightsColor() light.NetworkOverrideColor = Color.clear; } - /// - /// Gets a random object from the current map. - /// - /// - /// This method is obsolete. Use instead to get a random instance. - /// - /// A randomly selected object. - [Obsolete("Use Locker.Random() instead.")] - public static MapGeneration.Distributors.Locker GetRandomLocker() => Lockers.GetRandomValue(); - /// /// Gets a random . /// @@ -319,7 +300,7 @@ public static void CleanAllRagdolls(IEnumerable ragDolls) /// /// The position of the blood decal. /// The direction of the blood decal. - public static void PlaceBlood(Vector3 position, Vector3 direction) => new GunDecalMessage(position, direction, DecalPoolType.Blood).SendToAuthenticated(0); + public static void PlaceBlood(Vector3 position, Vector3 direction) => _ = 0; /* new GunDecalMessage(position, direction, DecalPoolType.Blood).SendToAuthenticated(0);*/ // TODO: Not finish /// /// Gets all the near cameras. @@ -380,15 +361,17 @@ public static void ExplodeEffect(Vector3 position, ProjectileType projectileType /// The audio clip ID to play. public static void PlayGunSound(Vector3 position, ItemType firearmType, byte maxDistance = 45, byte audioClipId = 0) { + // TODO: Not finish + /* GunAudioMessage msg = new() { Weapon = firearmType, AudioClipId = audioClipId, MaxDistance = maxDistance, - ShooterHub = ReferenceHub.HostHub, + ShooterHub = ReferenceHub._hostHub, ShooterPosition = new RelativePosition(position), }; - msg.SendToAuthenticated(); + msg.SendToAuthenticated();*/ } /// diff --git a/EXILED/Exiled.API/Features/Npc.cs b/EXILED/Exiled.API/Features/Npc.cs index 28ee0d117..d31b0b530 100644 --- a/EXILED/Exiled.API/Features/Npc.cs +++ b/EXILED/Exiled.API/Features/Npc.cs @@ -19,6 +19,7 @@ namespace Exiled.API.Features using Exiled.API.Features.Components; using Exiled.API.Features.Roles; using Footprinting; + using GameCore; using MEC; using Mirror; using PlayerRoles; @@ -132,6 +133,21 @@ public override Vector3 Position /// The NPC associated with the NetworkConnection, or null if not found. public static new Npc? Get(NetworkConnection conn) => Player.Get(conn) as Npc; + // TODO: Write docs. + public static Npc Create(string name, RoleTypeId role, Vector3 position) + { + // TODO: Test this. + Npc npc = new(DummyUtils.SpawnDummy(name)) + { + IsNPC = true, + }; + + npc.Role.Set(role); + npc.Position = position; + + return npc; + } + /// /// Spawns an NPC based on the given parameters. /// @@ -141,7 +157,7 @@ public override Vector3 Position /// The userID of the NPC. /// The position to spawn the NPC. /// The spawned. - [Obsolete("This metod is marked as obsolet due to a bug that make player have the same id. Use Npc.Spawn(string) instead")] + [Obsolete("This method is marked as obsolete due to a bug that make player have the same id. Use Npc.Spawn(string) instead", true)] public static Npc Spawn(string name, RoleTypeId role, int id = 0, string userId = PlayerAuthenticationManager.DedicatedId, Vector3? position = null) { GameObject newObject = UnityEngine.Object.Instantiate(Mirror.NetworkManager.singleton.playerPrefab); diff --git a/EXILED/Exiled.API/Features/Pickups/FirearmPickup.cs b/EXILED/Exiled.API/Features/Pickups/FirearmPickup.cs index df1fb0c6a..936ac1d2c 100644 --- a/EXILED/Exiled.API/Features/Pickups/FirearmPickup.cs +++ b/EXILED/Exiled.API/Features/Pickups/FirearmPickup.cs @@ -38,8 +38,10 @@ internal FirearmPickup(ItemType type) Base = (BaseFirearm)((Pickup)this).Base; IsDistributed = true; + // TODO not finish + /* if (type is ItemType.ParticleDisruptor && Status.Ammo == 0) - Status = new FirearmStatus(5, FirearmStatusFlags.MagazineInserted, 0); + Status = new FirearmStatus(5, FirearmStatusFlags.MagazineInserted, 0);*/ } /// @@ -50,12 +52,17 @@ internal FirearmPickup(ItemType type) /// /// Gets or sets a value indicating whether the pickup is already distributed. /// - public bool IsDistributed - { + public bool IsDistributed { get; set; } + + // TODO NOT FINISH + /*{ get => Base.Distributed; set => Base.Distributed = value; - } + }*/ + // TODO not finish + + /* /// /// Gets or sets the . /// @@ -64,16 +71,15 @@ public FirearmStatus Status get => Base.NetworkStatus; set => Base.NetworkStatus = value; } + */ /// /// Gets or sets a value indicating how many ammo have this . /// - public byte Ammo - { - get => Base.NetworkStatus.Ammo; - set => Base.NetworkStatus = new(value, Base.NetworkStatus.Flags, Base.NetworkStatus.Attachments); - } + /// This will be updated only when item will be picked up. + public int Ammo { get; set; } + /* /// /// Gets or sets the . /// @@ -82,20 +88,21 @@ public FirearmStatusFlags Flags get => Base.NetworkStatus.Flags; set => Base.NetworkStatus = new(Base.NetworkStatus.Ammo, value, Base.NetworkStatus.Attachments); } + */ /// /// Gets or sets a value indicating whether the attachment code have this . /// public uint Attachments { - get => Base.NetworkStatus.Attachments; - set => Base.NetworkStatus = new(Base.NetworkStatus.Ammo, Base.NetworkStatus.Flags, value); + get => Base.Worldmodel.AttachmentCode; + set => Base.Worldmodel.AttachmentCode = value; } /// /// Returns the FirearmPickup in a human readable format. /// /// A string containing FirearmPickup related data. - public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{IsDistributed}| -{Ammo}-"; + public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{IsDistributed}| -{/*Ammo*/0}-"; } } diff --git a/EXILED/Exiled.API/Features/Pickups/Pickup.cs b/EXILED/Exiled.API/Features/Pickups/Pickup.cs index 89e9df487..286e7cf7b 100644 --- a/EXILED/Exiled.API/Features/Pickups/Pickup.cs +++ b/EXILED/Exiled.API/Features/Pickups/Pickup.cs @@ -130,16 +130,7 @@ internal Pickup(ItemType type) /// /// Gets or sets the pickup's PhysicsModule. /// - public PickupStandardPhysics PhysicsModule - { - get => Base.PhysicsModule as PickupStandardPhysics; - [Obsolete("Unsafe.")] - set - { - Base.PhysicsModule.DestroyModule(); - Base.PhysicsModule = value; - } - } + public PickupStandardPhysics PhysicsModule => Base.PhysicsModule as PickupStandardPhysics; /// /// Gets or sets the unique serial number for the item. @@ -557,19 +548,6 @@ public static Pickup Create(ItemType type) public static Pickup CreateAndSpawn(ItemType type, Vector3 position, Quaternion rotation, Player previousOwner = null) where T : Pickup => CreateAndSpawn(type, position, rotation, previousOwner) as T; - /// - /// Spawns a . - /// - /// The too spawn. - /// The position to spawn the at. - /// The rotation to spawn the . - /// An optional previous owner of the item. - /// The Spawn. - /// - [Obsolete("Use pickup.Spawn(Vector3, Quaternion, Player) instead of this", true)] - public static Pickup Spawn(Pickup pickup, Vector3 position, Quaternion rotation, Player previousOwner = null) - => pickup.Spawn(position, rotation, previousOwner); - /// /// Returns the amount of time it will take for the provided to pick up this item, based on and active status effects. /// diff --git a/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs b/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs index e6bdb2614..7abab57d6 100644 --- a/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs +++ b/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs @@ -114,19 +114,6 @@ internal Projectile(ItemType type) public static Projectile Create(ProjectileType projectiletype) where T : Projectile => Create(projectiletype) as T; - /// - /// Spawns a . - /// - /// The too spawn. - /// The position to spawn the at. - /// The rotation to spawn the . - /// Whether the should be in active state after spawn. - /// An optional previous owner of the item. - /// The Spawn. - [Obsolete("Use pickup.Spawn(Vector3, Quaternion, Player) instead of this", true)] - public static Projectile Spawn(Projectile pickup, Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) - => pickup.Spawn(position, rotation, shouldBeActive, previousOwner); - /// /// Creates and spawns a . /// diff --git a/EXILED/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs b/EXILED/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs index 1452a921d..6bb476370 100644 --- a/EXILED/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs +++ b/EXILED/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs @@ -52,16 +52,7 @@ internal Scp018Projectile() /// /// Gets or sets the pickup's PhysicsModule. /// - public new Scp018Physics PhysicsModule - { - get => Base.PhysicsModule as Scp018Physics; - [Obsolete("Unsafe.", true)] - set - { - Base.PhysicsModule.DestroyModule(); - Base.PhysicsModule = value; - } - } + public new Scp018Physics PhysicsModule => Base.PhysicsModule as Scp018Physics; /// /// Gets or sets the pickup's max velocity. diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 751bd9f80..6a67717b1 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -36,9 +36,9 @@ namespace Exiled.API.Features using InventorySystem.Disarming; using InventorySystem.Items; using InventorySystem.Items.Armor; - using InventorySystem.Items.Firearms; using InventorySystem.Items.Firearms.Attachments; - using InventorySystem.Items.Firearms.BasicMessages; + using InventorySystem.Items.Firearms.Modules; + using InventorySystem.Items.Firearms.ShotEvents; using InventorySystem.Items.Usables; using InventorySystem.Items.Usables.Scp330; using MapGeneration.Distributors; @@ -158,7 +158,7 @@ public Player(GameObject gameObject) public Dictionary> CustomRoleFriendlyFireMultiplier { get; set; } = DictionaryPool>.Pool.Get(); /// - /// Gets or sets a unique custom role that does not adbide to base game for this player. Used in conjunction with . + /// Gets or sets a unique custom role that does not abide to base game for this player. Used in conjunction with . /// public string UniqueRole { get; set; } = string.Empty; @@ -260,12 +260,6 @@ public int Id /// public string UserId => referenceHub.authManager.UserId; - /// - /// Gets or sets the player's custom user id. - /// - [Obsolete("Remove by NW", true)] - public string CustomUserId { get; set; } - /// /// Gets the player's user id without the authentication. /// @@ -359,7 +353,7 @@ public string CustomInfo set { // NW Client check. - if (value.Contains('<')) + if (value.Contains('<')) { foreach (string token in value.Split('<')) { @@ -622,6 +616,8 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences /// Players can be cuffed without another player being the cuffer. public bool IsCuffed => Inventory.IsDisarmed(); + // TODO NOT FINISH + /* /// /// Gets a value indicating whether the player is reloading a weapon. /// @@ -631,6 +627,7 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences /// Gets a value indicating whether the player is aiming with a weapon. /// public bool IsAimingDownWeapon => CurrentItem is Firearm firearm && firearm.Aiming; + */ /// /// Gets a value indicating whether the player has enabled weapon's flashlight module. @@ -1788,9 +1785,12 @@ public bool ReloadWeapon() { if (CurrentItem is Firearm firearm) { - bool result = firearm.Base.AmmoManagerModule.ServerTryReload(); + // TODO not finish + /* + bool result = firearm.Base.Ammo.ServerTryReload(); Connection.Send(new RequestMessage(firearm.Serial, RequestType.Reload)); return result; + */ } return false; @@ -2161,7 +2161,7 @@ public void Hurt(Player attacker, float amount, DamageType damageType = DamageTy /// The throw force. /// The armor penetration amount. public void Hurt(Player attacker, float damage, Vector3 force = default, int armorPenetration = 0) => - Hurt(new ExplosionDamageHandler(attacker.Footprint, force, damage, armorPenetration)); + Hurt(new ExplosionDamageHandler(attacker.Footprint, force, damage, armorPenetration, ExplosionType.Grenade)); /// /// Hurts the player. @@ -2264,7 +2264,7 @@ public void Vaporize(Player attacker = null, string cassieAnnouncement = "") if ((Role.Side != Side.Scp) && !string.IsNullOrEmpty(cassieAnnouncement)) Cassie.Message(cassieAnnouncement); - Kill(new DisruptorDamageHandler(attacker?.Footprint ?? Footprint, -1)); + Kill(new DisruptorDamageHandler(new DisruptorShotEvent(Item.Create(ItemType.ParticleDisruptor, attacker).Base as InventorySystem.Items.Firearms.Firearm, DisruptorActionModule.FiringState.FiringSingle), Vector3.up, -1)); } /// @@ -2465,17 +2465,6 @@ public ushort GetAmmoLimit(AmmoType type, bool ignoreArmor = false) return InventorySystem.Configs.InventoryLimits.GetAmmoLimit(type.GetItemType(), referenceHub); } - /// - /// Gets the maximum amount of ammo the player can hold, given the ammo . - /// - /// The of the ammo to check. - /// The maximum amount of ammo this player can carry. - [Obsolete("Use Player::GetAmmoLimit(AmmoType, bool) instead.")] - public int GetAmmoLimit(AmmoType type) - { - return (int)InventorySystem.Configs.InventoryLimits.GetAmmoLimit(type.GetItemType(), referenceHub); - } - /// /// Gets the maximum amount of ammo the player can hold, given the ammo . /// This limit will scale with the armor the player is wearing. @@ -2532,15 +2521,6 @@ public void ResetAmmoLimit(AmmoType ammoType) /// If the player has a custom limit for the specific . public bool HasCustomAmmoLimit(AmmoType ammoType) => CustomAmmoLimits.ContainsKey(ammoType); - /// - /// Gets the maximum amount of an the player can hold, based on the armor the player is wearing, as well as server configuration. - /// - /// The to check. - /// The maximum amount of items in the category that the player can hold. - [Obsolete("Use Player::GetCategoryLimit(ItemCategory, bool) instead.")] - public int GetCategoryLimit(ItemCategory category) => - InventorySystem.Configs.InventoryLimits.GetCategoryLimit(category, referenceHub); - /// /// Gets the maximum amount of an the player can hold, based on the armor the player is wearing, as well as server configuration. /// @@ -2668,16 +2648,6 @@ public Item AddItem(ItemType itemType) return item; } - /// - /// Adds an item of the specified type with default durability(ammo/charge) and no mods to the player's inventory. - /// - /// The item to be added. - /// The attachments to be added to the item. - /// The given to the player. - [Obsolete("Use AddItem(ItemType) or AddItem(FirearmType, IEnumerable)", true)] - public Item AddItem(ItemType itemType, IEnumerable identifiers = null) - => itemType.GetFirearmType() is FirearmType.None ? AddItem(itemType) : AddItem(itemType.GetFirearmType(), identifiers); - /// /// Adds an firearm of the specified type with default durability(ammo/charge) and no mods to the player's inventory. /// @@ -2695,12 +2665,15 @@ public Item AddItem(FirearmType firearmType, IEnumerable i else if (Preferences is not null && Preferences.TryGetValue(firearmType, out AttachmentIdentifier[] attachments)) firearm.Base.ApplyAttachmentsCode(attachments.GetAttachmentsCode(), true); + // TODO Not finish + /* FirearmStatusFlags flags = FirearmStatusFlags.MagazineInserted; if (firearm.Attachments.Any(a => a.Name == AttachmentName.Flashlight)) flags |= FirearmStatusFlags.FlashlightEnabled; firearm.Base.Status = new FirearmStatus(firearm.MaxAmmo, flags, firearm.Base.GetCurrentAttachmentsCode()); + */ } AddItem(item); @@ -2726,17 +2699,6 @@ public IEnumerable AddItem(ItemType itemType, int amount) return items; } - /// - /// Adds the amount of items of the specified type with default durability(ammo/charge) and no mods to the player's inventory. - /// - /// The item to be added. - /// The amount of items to be added. - /// The attachments to be added to the item. - /// An containing the items given. - [Obsolete("Use AddItem(ItemType, int) or AddItem(FirearmType, int, IEnumerable)", true)] - public IEnumerable AddItem(ItemType itemType, int amount, IEnumerable identifiers) - => itemType.GetFirearmType() is FirearmType.None ? AddItem(itemType, amount) : AddItem(itemType.GetFirearmType(), amount, identifiers); - /// /// Adds the amount of firearms of the specified type with default durability(ammo/charge) and no mods to the player's inventory. /// @@ -2776,22 +2738,6 @@ public IEnumerable AddItem(IEnumerable items) return returnedItems; } - /// - /// Adds the list of items of the specified type with default durability(ammo/charge) and no mods to the player's inventory. - /// - /// The of and of to be added. - /// An containing the items given. - [Obsolete("Use AddItem(Dictionary>) instead of this", true)] - public IEnumerable AddItem(Dictionary> items) - { - List returnedItems = new(items.Count); - - foreach (KeyValuePair> item in items) - returnedItems.Add(AddItem(item.Key, item.Value)); - - return returnedItems; - } - /// /// Adds the list of items of the specified type with default durability(ammo/charge) and no mods to the player's inventory. /// @@ -2847,8 +2793,9 @@ public void AddItem(Firearm item, IEnumerable identifiers) /// Adds an item to the player's inventory. /// /// The of the item to be added. + /// The reason the item was added. /// The that was added. - public Item AddItem(Pickup pickup) => Item.Get(Inventory.ServerAddItem(pickup.Type, pickup.Serial, pickup.Base)); + public Item AddItem(Pickup pickup, ItemAddReason addReason = ItemAddReason.Undefined) => Item.Get(Inventory.ServerAddItem(pickup.Type, addReason, pickup.Serial, pickup.Base)); /// /// Adds an item to the player's inventory. @@ -2858,7 +2805,7 @@ public void AddItem(Firearm item, IEnumerable identifiers) /// The that was added. public Item AddItem(FirearmPickup pickup, IEnumerable identifiers) { - Firearm firearm = Item.Get(Inventory.ServerAddItem(pickup.Type, pickup.Serial, pickup.Base)); + Firearm firearm = Item.Get(Inventory.ServerAddItem(pickup.Type, ItemAddReason.Undefined, pickup.Serial, pickup.Base)); if (identifiers is not null) firearm.AddAttachment(identifiers); @@ -2871,12 +2818,14 @@ public Item AddItem(FirearmPickup pickup, IEnumerable iden /// /// The item to be added. /// The object of the item. + /// The reason the item was added. /// The that was added. - public Item AddItem(ItemBase itemBase, Item item = null) + public Item AddItem(ItemBase itemBase, Item item = null, ItemAddReason addReason = ItemAddReason.AdminCommand) { try { item ??= Item.Get(itemBase); + item.AddReason = addReason; Inventory.UserInventory.Items[item.Serial] = itemBase; @@ -2900,23 +2849,6 @@ public Item AddItem(ItemBase itemBase, Item item = null) return null; } - /// - /// Adds the of items to the player's inventory. - /// - /// The item to be added. - /// The amount of items to be added. - [Obsolete("Removed this method can't be functional")] - public void AddItem(Item item, int amount) => _ = item; - - /// - /// Adds the of items to the player's inventory. - /// - /// The firearm to be added. - /// The amount of items to be added. - /// The attachments to be added to the item. - [Obsolete("Removed this method can't be functional")] - public void AddItem(Firearm firearm, int amount, IEnumerable identifiers) => _ = firearm; - /// /// Adds the list of items to the player's inventory. /// @@ -3359,13 +3291,6 @@ public void EnableEffects(IEnumerable types, float duration = 0f, bo } } - /// - /// Enables a of on the player. - /// - /// The of to enable. - [Obsolete("Use SyncEffects(IEnumerable) instead of this")] - public void EnableEffects(IEnumerable effects) => SyncEffects(effects); - /// /// Syncs a of on the player. /// @@ -3785,7 +3710,7 @@ public void SetCooldownItem(float time, ItemType itemType) /// /// Explode the player. /// - public void Explode() => ExplosionUtils.ServerExplode(ReferenceHub); + public void Explode() => ExplosionUtils.ServerExplode(ReferenceHub, ExplosionType.Grenade); /// /// Explode the player. diff --git a/EXILED/Exiled.API/Features/Ragdoll.cs b/EXILED/Exiled.API/Features/Ragdoll.cs index d27c076da..bb0a83f6d 100644 --- a/EXILED/Exiled.API/Features/Ragdoll.cs +++ b/EXILED/Exiled.API/Features/Ragdoll.cs @@ -117,7 +117,7 @@ public DamageHandlerBase DamageHandler /// /// Gets a value indicating whether the ragdoll has been already cleaned up. /// - public bool IsFrozen => Base._frozen; + public bool IsFrozen => Base.Frozen; /// /// Gets or sets a value indicating whether the ragdoll can be cleaned up. diff --git a/EXILED/Exiled.API/Features/Respawn.cs b/EXILED/Exiled.API/Features/Respawn.cs index 9ac5d6812..1f3774f43 100644 --- a/EXILED/Exiled.API/Features/Respawn.cs +++ b/EXILED/Exiled.API/Features/Respawn.cs @@ -9,12 +9,13 @@ namespace Exiled.API.Features { using System; using System.Collections.Generic; - using System.Linq; using CustomPlayerEffects; using Enums; using PlayerRoles; using Respawning; + using Respawning.Waves; + using Respawning.Waves.Generic; using UnityEngine; /// @@ -54,20 +55,26 @@ public static GameObject ChaosVan } /// - /// Gets or sets the next known that will spawn. + /// Gets or sets the next known that will spawn. /// - public static SpawnableTeamType NextKnownTeam + public static Faction NextKnownFaction { - get => RespawnManager.Singleton.NextKnownTeam; - set => RespawnManager.Singleton.NextKnownTeam = value; + get => WaveManager._nextWave.TargetFaction; + set => WaveManager._nextWave = WaveManager.Waves.Find(x => x.TargetFaction == value); } + /// + /// Gets the next known that will spawn. + /// + public static SpawnableTeamType NextKnownTeam => NextKnownFaction.GetSpawnableTeam(); + + /* TODO: Possibly moved to TimedWave /// /// Gets or sets the amount of seconds before the next respawn phase will occur. /// public static float TimeUntilNextPhase { - get => RespawnManager.Singleton._timeForNextSequence - (float)RespawnManager.Singleton._stopwatch.Elapsed.TotalSeconds; + get => RespawnManager.Singleton._timeForNextSequence - (float)RespawnManager.Singleton._stopwatch.Elapsed.TotalSeconds set => RespawnManager.Singleton._timeForNextSequence = (float)RespawnManager.Singleton._stopwatch.Elapsed.TotalSeconds + value; } @@ -80,31 +87,17 @@ public static float TimeUntilNextPhase /// Gets a indicating the moment in UTC time the next respawn wave will occur. /// public static DateTime NextTeamTime => DateTime.UtcNow.AddSeconds(TimeUntilSpawnWave.TotalSeconds); + */ /// - /// Gets a value indicating whether a team is currently being spawned or the animations are playing for a team. - /// - public static bool IsSpawning => RespawnManager.Singleton._curSequence is RespawnManager.RespawnSequencePhase.PlayingEntryAnimations or RespawnManager.RespawnSequencePhase.SpawningSelectedTeam; - - /// - /// Gets or sets the amount of spawn tickets belonging to the Chaos Insurgency. + /// Gets the current state of the . /// - /// - public static float ChaosTickets - { - get => RespawnTokensManager.Counters[0].Amount; - set => RespawnTokensManager.ModifyTokens(SpawnableTeamType.ChaosInsurgency, value); - } + public static WaveManager.WaveQueueState CurrentState => WaveManager.State; /// - /// Gets or sets the amount of spawn tickets belonging to the NTF. + /// Gets a value indicating whether a team is currently being spawned or the animations are playing for a team. /// - /// - public static float NtfTickets - { - get => RespawnTokensManager.Counters[1].Amount; - set => RespawnTokensManager.ModifyTokens(SpawnableTeamType.NineTailedFox, value); - } + public static bool IsSpawning => WaveManager.State == WaveManager.WaveQueueState.WaveSpawning; /// /// Gets or sets a value indicating whether spawn protection is enabled. @@ -139,55 +132,94 @@ public static bool ProtectedCanShoot public static List ProtectedTeams => SpawnProtected.ProtectedTeams; /// - /// Play an effect when a certain class spawns. + /// Tries to get a . /// - /// The effect to be played. - public static void PlayEffect(byte effect) => PlayEffects(new[] { effect }); + /// Found . + /// Type of . + /// true if was successfully found. Otherwise, false. + public static bool TryGetWaveBase(out T spawnWave) + where T : SpawnableWaveBase => WaveManager.TryGet(out spawnWave); /// - /// Play an effect when a certain class spawns. + /// Tries to get a from a . /// - /// The effect to be played. - public static void PlayEffect(RespawnEffectType effect) => PlayEffects(new[] { effect }); + /// Team's . + /// Found . + /// true if was successfully found. Otherwise, false. + public static bool TryGetWaveBase(Faction faction, out SpawnableWaveBase spawnWave) + => WaveManager.TryGet(faction, out spawnWave); /// - /// Play effects when a certain class spawns. + /// Tries to get a from a . /// - /// The effects to be played. - public static void PlayEffects(byte[] effects) + /// Team's . + /// Found . + /// true if was successfully found. Otherwise, false. + public static bool TryGetWaveBase(SpawnableFaction faction, out SpawnableWaveBase spawnWave) { - foreach (RespawnEffectsController controller in RespawnEffectsController.AllControllers) - controller?.RpcPlayEffects(effects); + switch (faction) + { + case SpawnableFaction.NtfWave: + bool result = TryGetWaveBase(out NtfSpawnWave ntfSpawnWave); + spawnWave = ntfSpawnWave; + return result; + case SpawnableFaction.NtfMiniWave: + result = TryGetWaveBase(out NtfMiniWave ntfMiniWave); + spawnWave = ntfMiniWave; + return result; + case SpawnableFaction.ChaosWave: + result = TryGetWaveBase(out ChaosSpawnWave chaosSpawnWave); + spawnWave = chaosSpawnWave; + return result; + case SpawnableFaction.ChaosMiniWave: + result = TryGetWaveBase(out ChaosMiniWave chaosMiniWave); + spawnWave = chaosMiniWave; + return result; + } + + spawnWave = null; + return false; + } + + // TODO: Docs. + public static void AdvanceTime(Faction faction, float time) => WaveManager.AdvanceTimer(faction, time); + + // TODO: Docs. + public static void SpawnWave(SpawnableWaveBase wave) => WaveManager.Spawn(wave); + + // TODO: Docs. + public static void SpawnWave(Faction faction, bool mini) + where T : SpawnableWaveBase + { + if (TryGetWaveBase(out T wave)) + SpawnWave(wave); } /// /// Play effects when a certain class spawns. /// - /// The effects to be played. - public static void PlayEffects(RespawnEffectType[] effects) => PlayEffects(effects.Select(effect => (byte)effect).ToArray()); + /// The for which effects should be played. + public static void PlayEffect(SpawnableWaveBase wave) + { + WaveUpdateMessage.ServerSendUpdate(wave, UpdateMessageFlags.Trigger); + } /// /// Summons the NTF chopper. /// - public static void SummonNtfChopper() => PlayEffects(new[] { RespawnEffectType.SummonNtfChopper }); + public static void SummonNtfChopper() + { + if (TryGetWaveBase(Faction.FoundationStaff, out SpawnableWaveBase wave)) + PlayEffect(wave); + } /// /// Summons the van. /// - /// Whether to play the Chaos Insurgency spawn music. - public static void SummonChaosInsurgencyVan(bool playMusic = true) + public static void SummonChaosInsurgencyVan() { - PlayEffects( - playMusic - ? new[] - { - RespawnEffectType.PlayChaosInsurgencyMusic, - RespawnEffectType.SummonChaosInsurgencyVan, - } - : new[] - { - RespawnEffectType.SummonChaosInsurgencyVan, - }); + if (TryGetWaveBase(Faction.FoundationEnemy, out SpawnableWaveBase wave)) + PlayEffect(wave); } /// @@ -195,33 +227,60 @@ public static void SummonChaosInsurgencyVan(bool playMusic = true) /// /// The to grant tickets to. /// The amount of tickets to grant. - public static void GrantTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.GrantTokens(team, Math.Max(0, amount)); + public static void GrantTickets(Faction team, int amount) + { + if (TryGetWaveBase(team, out SpawnableWaveBase wave) && wave is ILimitedWave limitedWave) + limitedWave.RespawnTokens += amount; + } /// /// Removes tickets from a . /// /// The to remove tickets from. /// The amount of tickets to remove. - public static void RemoveTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.RemoveTokens(team, Math.Max(0, amount)); + public static void RemoveTickets(Faction team, int amount) + { + if (TryGetWaveBase(team, out SpawnableWaveBase wave) && wave is ILimitedWave limitedWave) + limitedWave.RespawnTokens = Math.Max(0, limitedWave.RespawnTokens - amount); + } /// /// Modify tickets from a . /// /// The to modify tickets from. /// The amount of tickets to modify. - public static void ModifyTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.ModifyTokens(team, amount); + public static void ModifyTickets(Faction team, int amount) + { + if (TryGetWaveBase(team, out SpawnableWaveBase wave) && wave is ILimitedWave limitedWave) + limitedWave.RespawnTokens = amount; + } + + /// + /// Gets the amount of tickets from a . + /// + /// 's faction. + /// Tickets of team or -1 if team doesn't depend on tickets. + public static int GetTickets(SpawnableFaction faction) + { + if (TryGetWaveBase(faction, out SpawnableWaveBase wave) && wave is ILimitedWave limitedWave) + return limitedWave.RespawnTokens; + + return -1; + } /// /// Forces a spawn of the given . /// /// The to spawn. - /// Whether effects will be played with the spawn. - public static void ForceWave(SpawnableTeamType team, bool playEffects = false) + public static void ForceWave(Faction team) { - if (playEffects) - RespawnEffectsController.ExecuteAllEffects(RespawnEffectsController.EffectType.Selection, team); + if (TryGetWaveBase(team, out SpawnableWaveBase wave)) + ForceWave(wave); + } - RespawnManager.Singleton.ForceSpawnTeam(team); + public static void ForceWave(SpawnableWaveBase wave) + { + WaveManager.Spawn(wave); } } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Roles/Scp079Role.cs b/EXILED/Exiled.API/Features/Roles/Scp079Role.cs index 2798eb50d..2480ca3d8 100644 --- a/EXILED/Exiled.API/Features/Roles/Scp079Role.cs +++ b/EXILED/Exiled.API/Features/Roles/Scp079Role.cs @@ -593,7 +593,7 @@ public void ActivateTesla(bool consumeEnergy = true) Scp079Camera cam = CurrentCameraSync.CurrentCamera; RewardManager.MarkRoom(cam.Room); - if (!TeslaGateController.Singleton.TeslaGates.TryGetFirst(x => RoomIdUtils.IsTheSameRoom(cam.Position, x.transform.position), out global::TeslaGate teslaGate)) + if (!global::TeslaGate.AllGates.TryGetFirst(x => RoomIdUtils.IsTheSameRoom(cam.Position, x.transform.position), out global::TeslaGate teslaGate)) return; if (consumeEnergy) diff --git a/EXILED/Exiled.API/Features/Roles/Scp106Role.cs b/EXILED/Exiled.API/Features/Roles/Scp106Role.cs index 24ff42992..48f3f04a0 100644 --- a/EXILED/Exiled.API/Features/Roles/Scp106Role.cs +++ b/EXILED/Exiled.API/Features/Roles/Scp106Role.cs @@ -13,7 +13,6 @@ namespace Exiled.API.Features.Roles using PlayerRoles; using PlayerRoles.PlayableScps; using PlayerRoles.PlayableScps.HumeShield; - using PlayerRoles.PlayableScps.Scp049; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.Subroutines; using PlayerStatsSystem; @@ -125,8 +124,12 @@ public float Vigor /// public bool IsSubmerged { - get => Base.IsSubmerged; - set => HuntersAtlasAbility.SetSubmerged(value); + get => HuntersAtlasAbility._syncSubmerged; + set + { + HuntersAtlasAbility._syncSubmerged = value; + HuntersAtlasAbility.ServerSendRpc(true); + } } /// @@ -149,11 +152,6 @@ public bool IsSubmerged /// public float SinkholeCurrentTime => SinkholeController.ElapsedToggle; - /// - /// Gets a value indicating the normalized state of the sinkhole. - /// - public float SinkholeNormalizedState => SinkholeController.NormalizedState; - /// /// Gets a value indicating whether SCP-106 is currently in the middle of an animation. /// @@ -169,63 +167,14 @@ public bool IsSubmerged /// public bool SinkholeState { - get => SinkholeController.State; - set => SinkholeController.State = value; + get => StalkAbility.StalkActive; + set => StalkAbility.StalkActive = value; } /// /// Gets the sinkhole target duration. /// - public float SinkholeTargetDuration => SinkholeController.TargetDuration; - - /// - /// Gets the speed multiplier of the sinkhole. - /// - public float SinkholeSpeedMultiplier => SinkholeController.SpeedMultiplier; - - // TODO: ReAdd Setter but before making an propper way to overwrite NW constant only when the propperty has been used -#pragma warning disable SA1623 // Property summary documentation should match accessors -#pragma warning disable SA1202 - /// - /// Gets or sets how mush cost the Ability Stalk will cost per tick when being stationary. - /// - internal float VigorStalkCostStationary { get; } = Scp106StalkAbility.VigorStalkCostStationary; - - /// - /// Gets or sets how mush cost the Ability Stalk will cost per tick when moving. - /// - internal float VigorStalkCostMoving { get; } = Scp106StalkAbility.VigorStalkCostMoving; - - /// - /// Gets or sets how mush vigor will be regenerate while moving per seconds. - /// - internal float VigorRegeneration { get; } = Scp106StalkAbility.VigorRegeneration; - - /// - /// Gets or sets the duration of Corroding effect. - /// - internal float CorrodingTime { get; } = Scp106Attack.CorrodingTime; - - /// - /// Gets or sets how mush vigor Scp106 will gain when being reward for having caught a player. - /// - internal float VigorCaptureReward { get; } = Scp106Attack.VigorCaptureReward; - - /// - /// Gets or sets how mush reduction cooldown Scp106 will gain when being reward for having caught a player. - /// - internal float CooldownReductionReward { get; } = Scp106Attack.CooldownReductionReward; - - /// - /// Gets or sets the cooldown duration of it's Sinkhole ability's. - /// - internal float SinkholeCooldownDuration { get; } = Scp106SinkholeController.CooldownDuration; - - /// - /// Gets or sets how mush vigor it's ability Hunter Atlas will cost per meter. - /// - internal float HuntersAtlasCostPerMeter { get; } = Scp106HuntersAtlasAbility.CostPerMeter; -#pragma warning restore SA1623 // Property summary documentation should match accessors + public float SinkholeTargetDuration => SinkholeController.TargetTransitionDuration; /// /// Gets or sets how mush damage Scp106 will dealt when attacking a player. @@ -254,10 +203,10 @@ public float CaptureCooldown /// public float RemainingSinkholeCooldown { - get => SinkholeController.Cooldown.Remaining; + get => SinkholeController._submergeCooldown.Remaining; set { - SinkholeController.Cooldown.Remaining = value; + SinkholeController._submergeCooldown.Remaining = value; SinkholeController.ServerSendRpc(true); } } @@ -267,8 +216,8 @@ public float RemainingSinkholeCooldown /// public bool IsStalking { - get => StalkAbility.IsActive; - set => StalkAbility.IsActive = value; + get => StalkAbility.StalkActive; + set => StalkAbility.ServerSetStalk(value); } /// @@ -294,7 +243,7 @@ public bool UsePortal(Vector3 position, float cost = 0f) return false; HuntersAtlasAbility._estimatedCost = cost; - HuntersAtlasAbility.SetSubmerged(true); + HuntersAtlasAbility._syncSubmerged = true; return true; } @@ -303,22 +252,24 @@ 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 will be capture. + 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; + Vigor += Scp106Attack.VigorCaptureReward; Attack.ReduceSinkholeCooldown(); Hitmarker.SendHitmarkerDirectly(Attack.Owner, 1f); player.EnableEffect(EffectType.PocketCorroding); + return true; } /// diff --git a/EXILED/Exiled.API/Features/Roles/Scp3114Role.cs b/EXILED/Exiled.API/Features/Roles/Scp3114Role.cs index 05a28e0f8..ab157b92c 100644 --- a/EXILED/Exiled.API/Features/Roles/Scp3114Role.cs +++ b/EXILED/Exiled.API/Features/Roles/Scp3114Role.cs @@ -7,7 +7,6 @@ namespace Exiled.API.Features.Roles { - using System; using System.Collections.Generic; using Exiled.API.Enums; @@ -158,22 +157,12 @@ public RoleTypeId StolenRole } } - /// - /// Gets or sets the SCP-3114's Ragdoll used for it's FakeIdentity. - /// - [Obsolete("Ragdoll in Role now has other meaning. Use IdentityRagdoll instead.")] - public new Ragdoll Ragdoll - { - get => IdentityRagdoll; - set => IdentityRagdoll = value; - } - /// /// Gets or sets the SCP-3114's Ragdoll used for it's FakeIdentity. /// public Ragdoll IdentityRagdoll { - get => Ragdoll.Get(Identity.CurIdentity.Ragdoll); + get => Features.Ragdoll.Get(Identity.CurIdentity.Ragdoll); set { Identity.CurIdentity.Ragdoll = value?.Base; diff --git a/EXILED/Exiled.API/Features/Round.cs b/EXILED/Exiled.API/Features/Round.cs index 81a6ccca3..d998c06a3 100644 --- a/EXILED/Exiled.API/Features/Round.cs +++ b/EXILED/Exiled.API/Features/Round.cs @@ -44,12 +44,12 @@ public static class Round /// /// Gets a value indicating whether the round is started. /// - public static bool IsStarted => ReferenceHub.LocalHub?.characterClassManager.RoundStarted ?? false; + public static bool IsStarted => ReferenceHub.TryGetHostHub(out ReferenceHub hub) && hub.characterClassManager.RoundStarted; /// /// Gets a value indicating whether the round in progress. /// - public static bool InProgress => ReferenceHub.LocalHub != null && RoundSummary.RoundInProgress(); + public static bool InProgress => ReferenceHub._localHubSet && RoundSummary.RoundInProgress(); /// /// Gets a value indicating whether the round is ended. @@ -68,12 +68,12 @@ public static class Round public static RoundSummary.SumInfo_ClassList LastClassList { get; internal set; } /// - /// Gets or sets a value indicating the amount of Chaos Targets remaining. + /// Gets or sets a value indicating the amount of Extra Targets remaining. /// - public static int ChaosTargetCount + public static int ExtraTargetCount { - get => RoundSummary.singleton.Network_chaosTargetCount; - set => RoundSummary.singleton.Network_chaosTargetCount = value; + get => RoundSummary.singleton.Network_extraTargets; + set => RoundSummary.singleton.Network_extraTargets = value; } /// @@ -122,14 +122,9 @@ public static int Kills } /// - /// Gets or sets the number of surviving SCPs. + /// Gets the number of surviving SCPs. /// - public static int SurvivingSCPs - { - get => RoundSummary.SurvivingSCPs; - [Obsolete("This value is rewritten by NW every time it's used", true)] - set => RoundSummary.SurvivingSCPs = value; - } + public static int SurvivingSCPs => RoundSummary.SurvivingSCPs; /// /// Gets or sets the number of kills made by SCPs. diff --git a/EXILED/Exiled.API/Features/Server.cs b/EXILED/Exiled.API/Features/Server.cs index af596f631..c79d0c4c1 100644 --- a/EXILED/Exiled.API/Features/Server.cs +++ b/EXILED/Exiled.API/Features/Server.cs @@ -267,14 +267,6 @@ public static bool ShutdownRedirect(ushort redirectPort) return true; } - /// - /// Runs a server command. - /// - /// The command to be run. - /// The running the command. - [Obsolete("Use Server.ExecuteCommand() instead.")] - public static void RunCommand(string command, CommandSender sender = null) => GameCore.Console.singleton.TypeCommand(command, sender); - /// /// Executes a server command. /// diff --git a/EXILED/Exiled.API/Features/Toys/AdminToy.cs b/EXILED/Exiled.API/Features/Toys/AdminToy.cs index 71cbc8557..01f54e8d2 100644 --- a/EXILED/Exiled.API/Features/Toys/AdminToy.cs +++ b/EXILED/Exiled.API/Features/Toys/AdminToy.cs @@ -98,7 +98,7 @@ public Quaternion Rotation set { AdminToyBase.transform.rotation = value; - AdminToyBase.NetworkRotation = new LowPrecisionQuaternion(value); + AdminToyBase.NetworkRotation = value; } } @@ -155,6 +155,7 @@ public static AdminToy Get(AdminToyBase adminToyBase) LightSourceToy lightSourceToy => new Light(lightSourceToy), PrimitiveObjectToy primitiveObjectToy => new Primitive(primitiveObjectToy), ShootingTarget shootingTarget => new ShootingTargetToy(shootingTarget), + SpeakerToy speakerToy => new Speaker(speakerToy), _ => throw new System.NotImplementedException() }; } diff --git a/EXILED/Exiled.API/Features/Toys/Light.cs b/EXILED/Exiled.API/Features/Toys/Light.cs index b1361a4c6..8e2a7642e 100644 --- a/EXILED/Exiled.API/Features/Toys/Light.cs +++ b/EXILED/Exiled.API/Features/Toys/Light.cs @@ -55,6 +55,33 @@ public float Range set => Base.NetworkLightRange = value; } + /// + /// Gets or sets the angle of the light. + /// + public float SpotAngle + { + get => Base.NetworkSpotAngle; + set => Base.NetworkSpotAngle = value; + } + + /// + /// Gets or sets the inner angle of the light. + /// + public float InnerSpotAngle + { + get => Base.NetworkInnerSpotAngle; + set => Base.NetworkInnerSpotAngle = value; + } + + /// + /// Gets or sets the shadow strength of the light. + /// + public float ShadowStrength + { + get => Base.NetworkShadowStrength; + set => Base.NetworkShadowStrength = value; + } + /// /// Gets or sets the color of the primitive. /// @@ -67,10 +94,19 @@ public Color Color /// /// Gets or sets a value indicating whether the light should cause shadows from other objects. /// - public bool ShadowEmission + public LightShape LightShape { - get => Base.NetworkLightShadows; - set => Base.NetworkLightShadows = value; + get => Base.NetworkLightShape; + set => Base.NetworkLightShape = value; + } + + /// + /// Gets or sets a value indicating whether the light should cause shadows from other objects. + /// + public LightType LightType + { + get => Base.NetworkLightType; + set => Base.NetworkLightType = value; } /// @@ -95,11 +131,12 @@ public static Light Create(Vector3? position = null, Vector3? rotation = null, V /// The new . public static Light Create(Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { - Light light = new(UnityEngine.Object.Instantiate(ToysHelper.LightBaseObject)); - - light.Position = position ?? Vector3.zero; - light.Rotation = Quaternion.Euler(rotation ?? Vector3.zero); - light.Scale = scale ?? Vector3.one; + Light light = new(UnityEngine.Object.Instantiate(ToysHelper.LightBaseObject)) + { + Position = position ?? Vector3.zero, + Rotation = Quaternion.Euler(rotation ?? Vector3.zero), + Scale = scale ?? Vector3.one, + }; if (spawn) light.Spawn(); diff --git a/EXILED/Exiled.API/Features/Toys/Speaker.cs b/EXILED/Exiled.API/Features/Toys/Speaker.cs new file mode 100644 index 000000000..dc03c3ff9 --- /dev/null +++ b/EXILED/Exiled.API/Features/Toys/Speaker.cs @@ -0,0 +1,84 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Toys +{ + using AdminToys; + + using Enums; + using Exiled.API.Interfaces; + + /// + /// A wrapper class for . + /// + public class Speaker : AdminToy, IWrapper + { + /// + /// Initializes a new instance of the class. + /// + /// The of the toy. + internal Speaker(SpeakerToy speakerToy) + : base(speakerToy, AdminToyType.Speaker) => Base = speakerToy; + + /// + /// Gets the base . + /// + public SpeakerToy Base { get; } + + /// + /// Gets or sets the volume of the audio source. + /// + /// + /// A representing the volume level of the audio source, + /// where 0.0 is silent and 1.0 is full volume. + /// + public float Volume + { + get => Base.NetworkVolume; + set => Base.NetworkVolume = value; + } + + /// + /// Gets or sets a value indicating whether the audio source is spatialized. + /// + /// + /// A where true means the audio source is spatial, allowing + /// for 3D audio positioning relative to the listener; false means it is non-spatial. + /// + public bool IsSpatial + { + get => Base.NetworkIsSpatial; + set => Base.NetworkIsSpatial = value; + } + + /// + /// Gets or sets the maximum distance at which the audio source can be heard. + /// + /// + /// A representing the maximum hearing distance for the audio source. + /// Beyond this distance, the audio will not be audible. + /// + public float MaxDistance + { + get => Base.NetworkMaxDistance; + set => Base.NetworkMaxDistance = value; + } + + /// + /// Gets or sets the minimum distance at which the audio source reaches full volume. + /// + /// + /// A representing the distance from the source at which the audio is heard at full volume. + /// Within this range, volume will not decrease with proximity. + /// + public float MinDistance + { + get => Base.NetworkMinDistance; + set => Base.NetworkMinDistance = value; + } + } +} diff --git a/EXILED/Exiled.API/Features/Warhead.cs b/EXILED/Exiled.API/Features/Warhead.cs index 52ecea92e..a7369cfab 100644 --- a/EXILED/Exiled.API/Features/Warhead.cs +++ b/EXILED/Exiled.API/Features/Warhead.cs @@ -113,7 +113,7 @@ public static WarheadStatus Status /// /// Gets a value indicating whether the warhead has already been detonated. /// - public static bool IsDetonated => Controller._alreadyDetonated; + public static bool IsDetonated => Controller.AlreadyDetonated; /// /// Gets a value indicating whether the warhead detonation is in progress. diff --git a/EXILED/Exiled.API/Features/Window.cs b/EXILED/Exiled.API/Features/Window.cs index 19e978148..2b3582567 100644 --- a/EXILED/Exiled.API/Features/Window.cs +++ b/EXILED/Exiled.API/Features/Window.cs @@ -132,10 +132,10 @@ public bool DisableScpDamage /// /// Gets or sets a value indicating whether this window is broken. /// - public BreakableWindow.BreakableWindowStatus SyncStatus + public bool SyncStatus { - get => Base.NetworksyncStatus; - set => Base.NetworksyncStatus = value; + get => Base.prevStatus; + set => Base.prevStatus = value; } /// diff --git a/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj b/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj index adc9595c8..9382489fb 100644 --- a/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj +++ b/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj @@ -43,6 +43,4 @@ if [[ ! -z "$EXILED_DEV_REFERENCES" ]]; then cp "$(OutputPath)$(AssemblyName).dll" "$EXILED_DEV_REFERENCES/Plugins/"; fi - - diff --git a/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs b/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs index 1c81585fa..2fc89ef33 100644 --- a/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs +++ b/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs @@ -30,20 +30,7 @@ public class OwnerEscapingEventArgs : EscapingEventArgs /// /// The instance. public OwnerEscapingEventArgs(Item item, EscapingEventArgs ev) - : this(item, ev.Player, ev.NewRole, ev.EscapeScenario, ev.RespawnTickets) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// - /// - /// - public OwnerEscapingEventArgs(Item item, Player player, RoleTypeId newRole, EscapeScenario escapeScenario, KeyValuePair respawnTickets = default) - : base(player, newRole, escapeScenario, respawnTickets) + : base(ev.Player, ev.NewRole, ev.EscapeScenario) { Item = item; } diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs index feba8be32..dcfd61f28 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs @@ -619,20 +619,17 @@ public virtual uint Spawn(IEnumerable spawnPoints, uint limit) spawned++; -#pragma warning disable CS0618 // Type or member is obsolete \\ TODO: REMOVE THIS - if (spawnPoint is DynamicSpawnPoint dynamicSpawnPoint && dynamicSpawnPoint.Location == SpawnLocationType.InsideLocker) + /*if (spawnPoint is DynamicSpawnPoint dynamicSpawnPoint && dynamicSpawnPoint.Location == SpawnLocationType.InsideLocker) { for (int i = 0; i < 50; i++) { - if (Map.Lockers is null) + if (Exiled.API.Features.Lockers.Locker.List is null) { Log.Debug($"{nameof(Spawn)}: Locker list is null."); continue; } - Locker locker = - Map.Lockers[ - Loader.Random.Next(Map.Lockers.Count)]; + Locker locker = Exiled.API.Features.Lockers.Locker.Random(); if (locker is null) { @@ -683,8 +680,20 @@ public virtual uint Spawn(IEnumerable spawnPoints, uint limit) } Log.Debug($"Spawned {Name} at {spawnPoint.Position} ({spawnPoint.Name})"); + }*/ + + Pickup? pickup = Spawn(spawnPoint.Position); + + if (pickup == null) + continue; + + if (spawnPoint is LockerSpawnPoint) + pickup.IsLocked = true; + + if (pickup.Is(out Exiled.API.Features.Pickups.FirearmPickup firearmPickup) && this is CustomWeapon customWeapon) + { + firearmPickup } -#pragma warning restore CS0618 // Type or member is obsolete } return spawned; diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs b/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs index 8151b4d55..728a81d31 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomWeapon.cs @@ -104,7 +104,7 @@ public override ItemType Type if (!Attachments.IsEmpty()) firearm.AddAttachment(Attachments); - byte ammo = firearm.Ammo; + int ammo = firearm.Ammo; firearm.MaxAmmo = ClipSize; Log.Debug($"{nameof(Name)}.{nameof(Spawn)}: Spawning weapon with {ammo} ammo."); Pickup? pickup = firearm.CreatePickup(position); @@ -214,7 +214,7 @@ private void OnInternalReloading(ReloadingWeaponEventArgs ev) Log.Debug($"{nameof(Name)}.{nameof(OnInternalReloading)}: Continuing with internal reload.."); ev.IsAllowed = false; - byte remainingClip = ((Firearm)ev.Player.CurrentItem).Ammo; + int remainingClip = ((Firearm)ev.Player.CurrentItem).Ammo; if (remainingClip >= ClipSize) return; @@ -229,7 +229,7 @@ private void OnInternalReloading(ReloadingWeaponEventArgs ev) return; } - ev.Player.Connection.Send(new RequestMessage(ev.Firearm.Serial, RequestType.Reload)); + ev.Firearm.Reload(true); byte amountToReload = (byte)Math.Min(ClipSize - remainingClip, ev.Player.Ammo[ammoType.GetItemType()]); diff --git a/EXILED/Exiled.Events/EventArgs/Map/PlacingBloodEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/PlacingBloodEventArgs.cs deleted file mode 100644 index 673b51915..000000000 --- a/EXILED/Exiled.Events/EventArgs/Map/PlacingBloodEventArgs.cs +++ /dev/null @@ -1,64 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.EventArgs.Map -{ - using API.Features; - - using Interfaces; - - using UnityEngine; - - /// - /// Contains all information before placing a blood decal. - /// - public class PlacingBloodEventArgs : IPlayerEvent, IDeniableEvent - { - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public PlacingBloodEventArgs(Player player, Player target, RaycastHit hit, bool isAllowed = true) - { - Player = player; - Target = target; - Position = hit.point; - IsAllowed = isAllowed; - } - - /// - /// Gets the who's placing the blood. - /// - public Player Player { get; } - - /// - /// Gets the target's instance. - /// - public Player Target { get; } - - /// - /// Gets or sets the blood placing position. - /// - public Vector3 Position { get; set; } - - /// - /// Gets or sets a value indicating whether the blood can be placed. - /// - public bool IsAllowed { get; set; } - } -} \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs index 2e8fed7e3..a662f3af2 100644 --- a/EXILED/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs @@ -8,7 +8,7 @@ namespace Exiled.Events.EventArgs.Map { using API.Features; - + using Exiled.API.Features.Items; using Interfaces; using UnityEngine; @@ -16,20 +16,21 @@ namespace Exiled.Events.EventArgs.Map /// /// Contains all information before placing a bullet hole decal. /// - public class PlacingBulletHoleEventArgs : IPlayerEvent, IDeniableEvent + public class PlacingBulletHoleEventArgs : IFirearmEvent, IPlayerEvent, IDeniableEvent { /// /// Initializes a new instance of the class. /// - /// - /// + /// + /// /// /// /// /// - public PlacingBulletHoleEventArgs(Player owner, RaycastHit hit) + public PlacingBulletHoleEventArgs(Firearm firearm, RaycastHit hit) { - Player = owner; + Firearm = firearm; + Player = Firearm.Owner; Position = hit.point; Rotation = Quaternion.LookRotation(hit.normal); } @@ -53,5 +54,11 @@ public PlacingBulletHoleEventArgs(Player owner, RaycastHit hit) /// Gets the decal owner. /// public Player Player { get; } + + /// + public Firearm Firearm { get; } + + /// + public Item Item => Firearm; } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Map/SpawningTeamVehicleEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/SpawningTeamVehicleEventArgs.cs index 16b31daac..d1b633b7b 100644 --- a/EXILED/Exiled.Events/EventArgs/Map/SpawningTeamVehicleEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Map/SpawningTeamVehicleEventArgs.cs @@ -5,6 +5,8 @@ // // ----------------------------------------------------------------------- +using Respawning.Waves; + namespace Exiled.Events.EventArgs.Map { using Exiled.Events.EventArgs.Interfaces; @@ -24,7 +26,7 @@ public class SpawningTeamVehicleEventArgs : IDeniableEvent /// /// /// - public SpawningTeamVehicleEventArgs(SpawnableTeamType team, bool isAllowed = true) + public SpawningTeamVehicleEventArgs(SpawnableWaveBase team, bool isAllowed = true) { Team = team; IsAllowed = isAllowed; @@ -33,7 +35,7 @@ public SpawningTeamVehicleEventArgs(SpawnableTeamType team, bool isAllowed = tru /// /// Gets or sets which vehicle should spawn. /// - public SpawnableTeamType Team { get; set; } + public SpawnableWaveBase Team { get; set; } /// /// Gets or sets a value indicating whether the vehicle can be spawned. diff --git a/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs index b8076e288..a10eea692 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs @@ -42,52 +42,6 @@ public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escap IsAllowed = escapeScenario is not EscapeScenario.CustomEscape; } - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escapeScenario, KeyValuePair respawnTickets) - : this(player, newRole, escapeScenario) - { - RespawnTickets = respawnTickets; - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// A that will be initialized with. - /// - /// - /// A that will be initialized with. - /// - public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escapeScenario, SpawnableTeamType teamToGrantTickets, float ticketsToGrant) - : this(player, newRole, escapeScenario) - { - if (teamToGrantTickets != SpawnableTeamType.None) - RespawnTickets = new KeyValuePair(teamToGrantTickets, ticketsToGrant); - } - /// /// Gets the player who's escaping. /// @@ -103,12 +57,6 @@ public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escap /// public EscapeScenario EscapeScenario { get; set; } - /// - /// Gets or sets the RespawnTickets that will represent the amount of tickets granted to a specific after the player escapes. - /// - /// - public KeyValuePair RespawnTickets { get; set; } - /// /// Gets or sets a value indicating whether the player can escape. /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs index 177b3c5a6..6a61a64b9 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs @@ -38,7 +38,7 @@ public class ShootingEventArgs : IPlayerEvent, IDeniableEvent, IFirearmEvent /// /// /// - public ShootingEventArgs(Player shooter, BaseFirearm firearm, ShotMessage msg) + public ShootingEventArgs(Player shooter, BaseFirearm firearm) { Player = shooter; Firearm = Item.Get(firearm).As(); diff --git a/EXILED/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs index da8aae174..48d137a32 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs @@ -40,7 +40,7 @@ public ElevatorTeleportingEventArgs(Player player, RoomIdentifier room, Elevator Player = player; Scp079 = player.Role.As(); Room = Room.Get(room); - Lift = Lift.Get(elevatorDoor.TargetPanel.AssignedChamber); + Lift = Lift.Get(elevatorDoor.Chamber); AuxiliaryPowerCost = auxiliaryPowerCost; IsAllowed = auxiliaryPowerCost <= Scp079.Energy; } diff --git a/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs index 84f53ffce..1f39abedb 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs @@ -12,7 +12,6 @@ namespace Exiled.Events.EventArgs.Scp330 using Interfaces; using InventorySystem.Items.Usables.Scp330; - using YamlDotNet.Core.Tokens; /// /// Contains all information before a player interacts with SCP-330. diff --git a/EXILED/Exiled.Events/EventArgs/Server/RespawnedTeamEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/RespawnedTeamEventArgs.cs index cbc6886cf..d3d62667a 100644 --- a/EXILED/Exiled.Events/EventArgs/Server/RespawnedTeamEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/RespawnedTeamEventArgs.cs @@ -13,6 +13,7 @@ namespace Exiled.Events.EventArgs.Server using Exiled.API.Features; using Exiled.Events.EventArgs.Interfaces; using Respawning; + using Respawning.Waves; /// /// Contains all information after team spawns. @@ -23,11 +24,11 @@ public class RespawnedTeamEventArgs : IExiledEvent /// Initializes a new instance of the class. /// /// - /// - public RespawnedTeamEventArgs(SpawnableTeamType team, IEnumerable hubs) + /// + public RespawnedTeamEventArgs(SpawnableWaveBase wave, IEnumerable hubs) { Players = hubs.Select(Player.Get); - Team = team; + Wave = wave; } /// @@ -38,6 +39,6 @@ public RespawnedTeamEventArgs(SpawnableTeamType team, IEnumerable /// /// Gets the spawned team. /// - public SpawnableTeamType Team { get; } + public SpawnableWaveBase Wave { get; } } } diff --git a/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs index ab0234c2a..eee756d7b 100644 --- a/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs @@ -5,6 +5,8 @@ // // ----------------------------------------------------------------------- +using Respawning.Waves; + namespace Exiled.Events.EventArgs.Server { using System.Collections.Generic; @@ -22,7 +24,6 @@ namespace Exiled.Events.EventArgs.Server /// public class RespawningTeamEventArgs : IDeniableEvent { - private SpawnableTeamType nextKnownTeam; private int maximumRespawnAmount; /// @@ -31,6 +32,9 @@ public class RespawningTeamEventArgs : IDeniableEvent /// /// /// + /// + /// + /// /// /// /// @@ -40,14 +44,12 @@ public class RespawningTeamEventArgs : IDeniableEvent /// /// /// - public RespawningTeamEventArgs(List players, int maxRespawn, SpawnableTeamType nextKnownTeam, bool isAllowed = true) + public RespawningTeamEventArgs(List players, Queue queue, int maxRespawn, SpawnableWaveBase nextKnownTeam, bool isAllowed = true) { Players = players; MaximumRespawnAmount = maxRespawn; - - this.nextKnownTeam = nextKnownTeam; - SpawnQueue = new(); - SpawnableTeam.GenerateQueue(SpawnQueue, players.Count); + SpawnQueue = queue; + NextKnownTeam = nextKnownTeam; IsAllowed = isAllowed; } @@ -77,30 +79,7 @@ public int MaximumRespawnAmount /// /// Gets or sets a value indicating what the next respawnable team is. /// - public SpawnableTeamType NextKnownTeam - { - get => nextKnownTeam; - set - { - nextKnownTeam = value; - - if (!RespawnManager.SpawnableTeams.TryGetValue(value, out SpawnableTeamHandlerBase spawnableTeam)) - { - MaximumRespawnAmount = 0; - return; - } - - MaximumRespawnAmount = spawnableTeam.MaxWaveSize; - if (RespawnManager.SpawnableTeams.TryGetValue(nextKnownTeam, out SpawnableTeamHandlerBase @base)) - @base.GenerateQueue(SpawnQueue, Players.Count); - } - } - - /// - /// Gets the current spawnable team. - /// - public SpawnableTeamHandlerBase SpawnableTeam - => RespawnManager.SpawnableTeams.TryGetValue(NextKnownTeam, out SpawnableTeamHandlerBase @base) ? @base : null; + public SpawnableWaveBase NextKnownTeam { get; set; } /// /// Gets or sets a value indicating whether the spawn can occur. diff --git a/EXILED/Exiled.Events/Events.cs b/EXILED/Exiled.Events/Events.cs index f11eab2e1..d06cb587c 100644 --- a/EXILED/Exiled.Events/Events.cs +++ b/EXILED/Exiled.Events/Events.cs @@ -60,7 +60,7 @@ public override void OnEnabled() PlayerAuthenticationManager.OnInstanceModeChanged -= RoleAssigner.CheckLateJoin; SceneManager.sceneUnloaded += Handlers.Internal.SceneUnloaded.OnSceneUnloaded; - MapGeneration.SeedSynchronizer.OnMapGenerated += Handlers.Internal.MapGenerated.OnMapGenerated; + MapGeneration.SeedSynchronizer.OnGenerationFinished += Handlers.Internal.MapGenerated.OnMapGenerated; UsableItemsController.ServerOnUsingCompleted += Handlers.Internal.Round.OnServerOnUsingCompleted; Handlers.Server.WaitingForPlayers += Handlers.Internal.Round.OnWaitingForPlayers; Handlers.Server.RestartingRound += Handlers.Internal.Round.OnRestartingRound; @@ -71,7 +71,7 @@ public override void OnEnabled() Handlers.Map.ChangedIntoGrenade += Handlers.Internal.ExplodingGrenade.OnChangedIntoGrenade; CharacterClassManager.OnRoundStarted += Handlers.Server.OnRoundStarted; - RespawnManager.ServerOnRespawned += Handlers.Server.OnRespawnedTeam; + WaveManager.OnWaveSpawned += Handlers.Server.OnRespawnedTeam; InventorySystem.InventoryExtensions.OnItemAdded += Handlers.Player.OnItemAdded; InventorySystem.InventoryExtensions.OnItemRemoved += Handlers.Player.OnItemRemoved; @@ -92,7 +92,7 @@ public override void OnDisabled() Unpatch(); SceneManager.sceneUnloaded -= Handlers.Internal.SceneUnloaded.OnSceneUnloaded; - MapGeneration.SeedSynchronizer.OnMapGenerated -= Handlers.Internal.MapGenerated.OnMapGenerated; + MapGeneration.SeedSynchronizer.OnGenerationFinished -= Handlers.Internal.MapGenerated.OnMapGenerated; UsableItemsController.ServerOnUsingCompleted -= Handlers.Internal.Round.OnServerOnUsingCompleted; Handlers.Server.WaitingForPlayers -= Handlers.Internal.Round.OnWaitingForPlayers; Handlers.Server.RestartingRound -= Handlers.Internal.Round.OnRestartingRound; @@ -106,7 +106,7 @@ public override void OnDisabled() InventorySystem.InventoryExtensions.OnItemAdded -= Handlers.Player.OnItemAdded; InventorySystem.InventoryExtensions.OnItemRemoved -= Handlers.Player.OnItemRemoved; - RespawnManager.ServerOnRespawned -= Handlers.Server.OnRespawnedTeam; + WaveManager.OnWaveSpawned -= Handlers.Server.OnRespawnedTeam; RagdollManager.OnRagdollSpawned -= Handlers.Internal.RagdollList.OnSpawnedRagdoll; RagdollManager.OnRagdollRemoved -= Handlers.Internal.RagdollList.OnRemovedRagdoll; ItemPickupBase.OnPickupAdded -= Handlers.Internal.PickupEvent.OnSpawnedPickup; diff --git a/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs b/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs index 68c47a99d..ef323edb7 100644 --- a/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs +++ b/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs @@ -90,9 +90,7 @@ private static void GenerateAttachments() } uint baseCode = 0; - - attachmentsSlots - .ForEach(slot => baseCode += attachmentIdentifiers + attachmentsSlots.ForEach(slot => baseCode += attachmentIdentifiers .Where(attachment => attachment.Slot == slot) .Min(slot => slot.Code)); diff --git a/EXILED/Exiled.Events/Handlers/Map.cs b/EXILED/Exiled.Events/Handlers/Map.cs index eaaf3703e..c617ba5e8 100644 --- a/EXILED/Exiled.Events/Handlers/Map.cs +++ b/EXILED/Exiled.Events/Handlers/Map.cs @@ -25,11 +25,6 @@ public static class Map /// public static Event PlacingBulletHole { get; set; } = new(); - /// - /// Invoked before placing blood. - /// - public static Event PlacingBlood { get; set; } = new(); - /// /// Invoked before announcing the light containment zone decontamination. /// @@ -121,12 +116,6 @@ public static class Map /// The instance. public static void OnPlacingBulletHole(PlacingBulletHoleEventArgs ev) => PlacingBulletHole.InvokeSafely(ev); - /// - /// Called before placing bloods. - /// - /// The instance. - public static void OnPlacingBlood(PlacingBloodEventArgs ev) => PlacingBlood.InvokeSafely(ev); - /// /// Called before announcing the light containment zone decontamination. /// diff --git a/EXILED/Exiled.Events/Handlers/Server.cs b/EXILED/Exiled.Events/Handlers/Server.cs index f7032f6ed..399a5fcfe 100644 --- a/EXILED/Exiled.Events/Handlers/Server.cs +++ b/EXILED/Exiled.Events/Handlers/Server.cs @@ -5,6 +5,8 @@ // // ----------------------------------------------------------------------- +using Respawning.Waves; + namespace Exiled.Events.Handlers { using System.Collections.Generic; @@ -165,7 +167,7 @@ public static class Server /// /// /// - public static void OnRespawnedTeam(SpawnableTeamType teamType, List hubs) => RespawnedTeam.InvokeSafely(new RespawnedTeamEventArgs(teamType, hubs)); + public static void OnRespawnedTeam(SpawnableWaveBase teamType, List hubs) => RespawnedTeam.InvokeSafely(new RespawnedTeamEventArgs(teamType, hubs)); /// /// Called before adding an unit name. diff --git a/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs b/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs index 3237e5603..29cabcadb 100644 --- a/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs +++ b/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs @@ -14,6 +14,7 @@ namespace Exiled.Events.Patches.Events.Map using API.Features.Pools; using Exiled.Events.EventArgs.Map; using Exiled.Events.Patches.Generic; + using Footprinting; using HarmonyLib; using InventorySystem.Items.ThrowableProjectiles; using UnityEngine; @@ -67,9 +68,9 @@ private static void ProcessEvent(FlashbangGrenade instance, float distance) Player player = Player.Get(referenceHub); if ((instance.transform.position - referenceHub.transform.position).sqrMagnitude >= distance) continue; - if (!ExiledEvents.Instance.Config.CanFlashbangsAffectThrower && instance.PreviousOwner.SameLife(new(referenceHub))) + if (!ExiledEvents.Instance.Config.CanFlashbangsAffectThrower && instance.PreviousOwner.LifeIdentifier != new Footprint(referenceHub).LifeIdentifier) continue; - if (!IndividualFriendlyFire.CheckFriendlyFirePlayer(instance.PreviousOwner, player.ReferenceHub) && !instance.PreviousOwner.SameLife(new(referenceHub))) + if (!IndividualFriendlyFire.CheckFriendlyFirePlayer(instance.PreviousOwner, player.ReferenceHub) && instance.PreviousOwner.LifeIdentifier != new Footprint(referenceHub).LifeIdentifier) continue; if (Physics.Linecast(instance.transform.position, player.CameraTransform.position, instance._blindingMask)) continue; diff --git a/EXILED/Exiled.Events/Patches/Events/Map/PlacingBlood.cs b/EXILED/Exiled.Events/Patches/Events/Map/PlacingBlood.cs deleted file mode 100644 index f8703fe0b..000000000 --- a/EXILED/Exiled.Events/Patches/Events/Map/PlacingBlood.cs +++ /dev/null @@ -1,110 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.Patches.Events.Map -{ - using System.Collections.Generic; - using System.Reflection.Emit; - - using API.Features.Pools; - using Exiled.Events.Attributes; - using Exiled.Events.EventArgs.Map; - - using HarmonyLib; - - using InventorySystem.Items.Firearms.Modules; - - using UnityEngine; - - using static HarmonyLib.AccessTools; - - using ExiledEvents = Exiled.Events.Events; - - /// - /// Patches . - /// Adds the event. - /// - [EventPatch(typeof(Handlers.Map), nameof(Handlers.Map.PlacingBlood))] - [HarmonyPatch(typeof(StandardHitregBase), nameof(StandardHitregBase.PlaceBloodDecal))] - internal static class PlacingBlood - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - Label returnLabel = generator.DefineLabel(); - - LocalBuilder ev = generator.DeclareLocal(typeof(PlacingBloodEventArgs)); - - // if (!ExiledEvents.Instance.Config.CanSpawnBlood) - // return; - // - // PlacingBloodEventArgs ev = new(Player.Get(this.Hub), Player.Get(target.NetworkId), hit, true); - // - // Handlers.Map.OnPlacingBlood(ev); - // - // if (!ev.IsAllowed) - // return; - // - // hit.point = ev.Position; - newInstructions.InsertRange( - 0, - new[] - { - // if (!ExiledEvents.Instance.Config.CanSpawnBlood) - // return; - new CodeInstruction(OpCodes.Call, PropertyGetter(typeof(ExiledEvents), nameof(ExiledEvents.Instance))), - new(OpCodes.Callvirt, PropertyGetter(typeof(ExiledEvents), nameof(ExiledEvents.Config))), - new(OpCodes.Callvirt, PropertyGetter(typeof(Config), nameof(Config.CanSpawnBlood))), - new(OpCodes.Brfalse_S, returnLabel), - - // Player.Get(this.Hub) - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(StandardHitregBase), nameof(StandardHitregBase.Hub))), - new(OpCodes.Call, Method(typeof(API.Features.Player), nameof(API.Features.Player.Get), new[] { typeof(ReferenceHub) })), - - // Player.Get(target.NetworkId) - new(OpCodes.Ldarg_3), - new(OpCodes.Callvirt, PropertyGetter(typeof(IDestructible), nameof(IDestructible.NetworkId))), - new(OpCodes.Call, Method(typeof(API.Features.Player), nameof(API.Features.Player.Get), new[] { typeof(uint) })), - - // hit - new(OpCodes.Ldarg_2), - - // true - new(OpCodes.Ldc_I4_1), - - // PlacingBloodEventArgs ev = new(Player, Player, RaycastHit, bool) - new(OpCodes.Newobj, GetDeclaredConstructors(typeof(PlacingBloodEventArgs))[0]), - new(OpCodes.Dup), - new(OpCodes.Dup), - new(OpCodes.Stloc_S, ev.LocalIndex), - - // Handlers.Map.OnPlacingBlood(ev) - new(OpCodes.Call, Method(typeof(Handlers.Map), nameof(Handlers.Map.OnPlacingBlood))), - - // if (!ev.isAllowed) - // return; - new(OpCodes.Callvirt, PropertyGetter(typeof(PlacingBloodEventArgs), nameof(PlacingBloodEventArgs.IsAllowed))), - new(OpCodes.Brfalse_S, returnLabel), - - // hit.info = ev.Position - new(OpCodes.Ldarga_S, 2), - new(OpCodes.Ldloc_S, ev.LocalIndex), - new(OpCodes.Callvirt, PropertyGetter(typeof(PlacingBloodEventArgs), nameof(PlacingBloodEventArgs.Position))), - new(OpCodes.Callvirt, PropertySetter(typeof(RaycastHit), nameof(RaycastHit.point))), - }); - - newInstructions[newInstructions.Count - 1].labels.Add(returnLabel); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } -} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs b/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs index fd20be131..d3b603620 100644 --- a/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs +++ b/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs @@ -11,16 +11,12 @@ namespace Exiled.Events.Patches.Events.Map using System.Reflection.Emit; using API.Features.Pools; - + using Decals; using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Map; - using Handlers; - using HarmonyLib; - using InventorySystem.Items.Firearms.Modules; - using UnityEngine; using static HarmonyLib.AccessTools; @@ -28,11 +24,11 @@ namespace Exiled.Events.Patches.Events.Map using Player = API.Features.Player; /// - /// Patches . + /// Patches . /// Adds the event. /// [EventPatch(typeof(Map), nameof(Map.PlacingBulletHole))] - [HarmonyPatch(typeof(StandardHitregBase), nameof(StandardHitregBase.PlaceBulletholeDecal))] + [HarmonyPatch(typeof(ImpactEffectsModule), nameof(ImpactEffectsModule.ServerSendImpactDecal))] internal static class PlacingBulletHole { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) @@ -48,15 +44,15 @@ private static IEnumerable Transpiler(IEnumerable // ----------------------------------------------------------------------- +using Respawning.Waves; + namespace Exiled.Events.Patches.Events.Map { using System.Collections.Generic; @@ -21,11 +23,11 @@ namespace Exiled.Events.Patches.Events.Map using static HarmonyLib.AccessTools; /// - /// Patches . + /// Patches . /// Adds the event. /// [EventPatch(typeof(Handlers.Map), nameof(Handlers.Map.SpawningTeamVehicle))] - [HarmonyPatch(typeof(RespawnEffectsController), nameof(RespawnEffectsController.ExecuteAllEffects))] + [HarmonyPatch(typeof(WaveUpdateMessage), nameof(WaveUpdateMessage.ServerSendUpdate))] internal static class SpawningTeamVehicle { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) @@ -42,8 +44,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(EquipDequipModifierExtensions), nameof(EquipDequipModifierExtensions.CanEquip)))) + offset; + int offset = 1; + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Bne_Un_S) + offset; newInstructions.InsertRange( index, diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs b/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs index d89fa4676..37cbdc9e7 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs @@ -14,16 +14,13 @@ namespace Exiled.Events.Patches.Events.Player using API.Features; using API.Features.Pools; - using API.Features.Roles; using Exiled.Events.EventArgs.Player; - using HarmonyLib; - using InventorySystem; + using InventorySystem.Items; using InventorySystem.Items.Armor; using InventorySystem.Items.Pickups; - using PlayerRoles; using static HarmonyLib.AccessTools; @@ -238,7 +235,7 @@ private static void ChangeInventory(ChangingRoleEventArgs ev) } foreach (ItemType item in ev.Items) - inventory.ServerAddItem(item); + inventory.ServerAddItem(item, ItemAddReason.StartingItem); foreach (KeyValuePair keyValuePair in ev.Ammo) inventory.ServerAddAmmo(keyValuePair.Key, keyValuePair.Value); diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs b/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs index 9ecb86df8..3966f55c3 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs @@ -19,11 +19,11 @@ namespace Exiled.Events.Patches.Events.Player using static HarmonyLib.AccessTools; /// - /// Patches . + /// Patches . /// Adds the event. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.EnteringKillerCollision))] - [HarmonyPatch(typeof(CheckpointKiller), nameof(CheckpointKiller.OnTriggerEnter))] + [HarmonyPatch(typeof(PitKiller), nameof(PitKiller.OnTriggerEnter))] internal static class EnteringKillerCollision { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs index 9bf3bb35f..be16ad190 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs @@ -63,14 +63,8 @@ private static IEnumerable Transpiler(IEnumerable cctor.GetParameters().Any(param => param.ParameterType == typeof(SpawnableTeamType)))), + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(EscapingEventArgs))[0]), new(OpCodes.Dup), new(OpCodes.Dup), new(OpCodes.Stloc, ev.LocalIndex), @@ -89,20 +83,6 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(RespawnTokensManager), nameof(RespawnTokensManager.GrantTokens)))) + offset; - labels = newInstructions[index].ExtractLabels(); - newInstructions.RemoveRange(index, 3); - newInstructions.InsertRange( - index, - new CodeInstruction[] - { - // GrantAllTickets(ev) - new CodeInstruction(OpCodes.Ldloc, ev.LocalIndex).WithLabels(labels), - new(OpCodes.Call, Method(typeof(EscapingAndEscaped), nameof(GrantAllTickets))), - }); - offset = 4; index = newInstructions.FindIndex(x => x.Is(OpCodes.Stfld, Field(typeof(Escape.EscapeMessage), nameof(Escape.EscapeMessage.EscapeTime)))) + offset; @@ -127,10 +107,6 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } - - private static void GrantAllTickets(EscapingEventArgs ev) - { - if (Enum.IsDefined(typeof(SpawnableTeamType), ev.RespawnTickets.Key) && ev.RespawnTickets.Key != SpawnableTeamType.None) - RespawnTokensManager.ModifyTokens(ev.RespawnTickets.Key, ev.RespawnTickets.Value); - } } /// diff --git a/EXILED/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs b/EXILED/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs index 585552f93..7da404755 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs @@ -14,20 +14,18 @@ namespace Exiled.Events.Patches.Events.Player using API.Features.Pools; using Exiled.API.Features.Items; - using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Player; - using Handlers; - using HarmonyLib; - using InventorySystem.Items; + using InventorySystem.Items.Firearms; using InventorySystem.Items.Firearms.BasicMessages; using PluginAPI.Events; using static HarmonyLib.AccessTools; + /* TODO /// /// Patches . /// Adds , , @@ -39,7 +37,7 @@ namespace Exiled.Events.Patches.Events.Player [EventPatch(typeof(Player), nameof(Player.DryfiringWeapon))] [EventPatch(typeof(Player), nameof(Player.AimingDownSight))] [EventPatch(typeof(Player), nameof(Player.TogglingWeaponFlashlight))] - [HarmonyPatch(typeof(FirearmBasicMessagesHandler), nameof(FirearmBasicMessagesHandler.ServerRequestReceived))] + [HarmonyPatch(typeof(FirearmUtils), nameof())] internal static class FirearmRequestReceived { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) @@ -272,4 +270,5 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } } + */ } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Player/InteractingElevator.cs b/EXILED/Exiled.Events/Patches/Events/Player/InteractingElevator.cs index f1394242f..7c886013f 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/InteractingElevator.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/InteractingElevator.cs @@ -28,17 +28,16 @@ namespace Exiled.Events.Patches.Events.Player /// Adds the event. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.InteractingElevator))] - [HarmonyPatch(typeof(ElevatorManager), nameof(ElevatorManager.ServerReceiveMessage))] + [HarmonyPatch(typeof(ElevatorChamber), nameof(ElevatorChamber.ServerInteract))] internal class InteractingElevator { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); - Label @break = (Label)newInstructions.FindLast(i => i.opcode == OpCodes.Leave_S).operand; + Label returnLabel = generator.DefineLabel(); - int offset = -2; - int index = newInstructions.FindLastIndex(i => i.opcode == OpCodes.Newobj) + offset; + newInstructions[newInstructions.Count - 1].labels.Add(returnLabel); // InteractingElevatorEventArgs ev = new(Player.Get(referenceHub), elevatorChamber, true); // @@ -46,16 +45,14 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable // ----------------------------------------------------------------------- +using System; + namespace Exiled.Events.Patches.Events.Player { #pragma warning disable SA1402 // File may only contain a single type @@ -29,11 +31,11 @@ namespace Exiled.Events.Patches.Events.Player using Item = API.Features.Items.Item; /// - /// Patches . + /// Patches . /// Adds the events. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Shot))] - [HarmonyPatch(typeof(SingleBulletHitreg), nameof(SingleBulletHitreg.ServerProcessRaycastHit))] + [HarmonyPatch(typeof(HitscanHitregModuleBase), nameof(HitscanHitregModuleBase.ServerProcessTargetHit))] internal static class Shot { /// @@ -47,7 +49,7 @@ internal static class Shot /// If the shot is allowed. internal static bool ProcessShot(ReferenceHub player, Firearm firearm, RaycastHit hit, IDestructible destructible, ref float damage) { - ShotEventArgs shotEvent = new(Player.Get(player), Item.Get(firearm).Cast(), hit, destructible, damage); + ShotEventArgs shotEvent = new(Player.Get(player), Item.Get(firearm), hit, destructible, damage); Handlers.Player.OnShot(shotEvent); @@ -64,30 +66,29 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(FirearmBaseStats), nameof(FirearmBaseStats.DamageAtDistance)))) + offset; + int offset = 1; + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Stloc_0) + offset; newInstructions.InsertRange( index, new CodeInstruction[] { // this.Hub - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(StandardHitregBase), nameof(StandardHitregBase.Hub))), + new(OpCodes.Ldarg_1), + new(OpCodes.Callvirt, PropertyGetter(typeof(HitboxIdentity), nameof(HitboxIdentity.TargetHub))), // this.Firearm new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(StandardHitregBase), nameof(StandardHitregBase.Firearm))), + new(OpCodes.Callvirt, PropertyGetter(typeof(SingleBulletHitscan), nameof(SingleBulletHitscan.Firearm))), // hit new(OpCodes.Ldarg_2), // destructible - new(OpCodes.Ldloc_0), + new(OpCodes.Ldloc_1), // damage - new(OpCodes.Ldloca_S, 1), + new(OpCodes.Ldloca_S, 0), new(OpCodes.Call, Method(typeof(Shot), nameof(ProcessShot), new[] { typeof(ReferenceHub), typeof(Firearm), typeof(RaycastHit), typeof(IDestructible), typeof(float).MakeByRefType(), })), @@ -96,7 +97,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(StandardHitregBase), nameof(StandardHitregBase.PlaceBulletholeDecal)))) + offset; @@ -131,94 +132,7 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); - } - } - - /// - /// Patches . - /// Adds the events. - /// - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Shot))] - [HarmonyPatch(typeof(BuckshotHitreg), nameof(BuckshotHitreg.ShootPellet))] - internal static class ShotBuckshot - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - Label returnLabel = generator.DefineLabel(); - - int offset = -3; - int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(StandardHitregBase), nameof(StandardHitregBase.PlaceBulletholeDecal)))) + offset; - - newInstructions.InsertRange( - index, - new CodeInstruction[] - { - // this.Hub - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(BuckshotHitreg), nameof(BuckshotHitreg.Hub))), - - // this.Firearm - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(BuckshotHitreg), nameof(BuckshotHitreg.Firearm))), - - // hit - new(OpCodes.Ldloc_2), - - // destructible - new(OpCodes.Ldloc_3), - - // damage - new(OpCodes.Ldc_R4, 0f), - new(OpCodes.Stloc_S, 4), - new(OpCodes.Ldloca_S, 4), - - new(OpCodes.Call, Method(typeof(Shot), nameof(Shot.ProcessShot), new[] { typeof(ReferenceHub), typeof(Firearm), typeof(RaycastHit), typeof(IDestructible), typeof(float).MakeByRefType(), })), - - // if (!ev.CanHurt) - // return; - new(OpCodes.Brfalse_S, returnLabel), - }); - - offset = 0; - index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldsfld) + offset; - - newInstructions.InsertRange( - index, - new CodeInstruction[] - { - // this.Hub - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(BuckshotHitreg), nameof(BuckshotHitreg.Hub))), - - // this.Firearm - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(BuckshotHitreg), nameof(BuckshotHitreg.Firearm))), - - // hit - new(OpCodes.Ldloc_2), - - // destructible - new(OpCodes.Ldloc_3), - - // damage - new(OpCodes.Ldloca_S, 4), - - new(OpCodes.Call, Method(typeof(Shot), nameof(Shot.ProcessShot), new[] { typeof(ReferenceHub), typeof(Firearm), typeof(RaycastHit), typeof(IDestructible), typeof(float).MakeByRefType(), })), - - // if (!ev.CanHurt) - // return; - new(OpCodes.Brfalse_S, returnLabel), - }); + });*/ newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); @@ -229,12 +143,13 @@ private static IEnumerable Transpiler(IEnumerable /// Patches . /// Adds the events. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Shot))] - [HarmonyPatch(typeof(DisruptorHitreg), nameof(DisruptorHitreg.ServerPerformShot))] + [HarmonyPatch(typeof(DisruptorHitregModule), nameof(DisruptorHitregModule.ServerProcessTargetHit))] internal static class ShotDisruptor { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) @@ -315,4 +230,5 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } } + */ } diff --git a/EXILED/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs b/EXILED/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs index 46ef344a2..d98ce08c8 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs @@ -25,7 +25,7 @@ namespace Exiled.Events.Patches.Events.Scp106 /// To add the event. /// [EventPatch(typeof(Handlers.Scp106), nameof(Handlers.Scp106.ExitStalking))] - [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.IsActive), MethodType.Setter)] + [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.StalkActive), MethodType.Setter)] public class ExitStalking { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs b/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs index e4f6e8e06..9ba430942 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs @@ -37,7 +37,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)PropertyGetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.IsActive))) + offset; + int index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertyGetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.StalkActive))) + offset; newInstructions.InsertRange( index, new CodeInstruction[] @@ -66,7 +66,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)PropertySetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.IsActive))) + offset; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertySetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.StalkActive))) + offset; newInstructions.InsertRange( index, new CodeInstruction[] diff --git a/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs b/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs index 28b657a45..9d1787ea1 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs @@ -7,13 +7,14 @@ namespace Exiled.Events.Patches.Events.Scp330 { + using InventorySystem.Items; + #pragma warning disable SA1402 #pragma warning disable SA1313 using System.Collections.Generic; using System.Reflection.Emit; - using Exiled.API.Features.Items; using Exiled.API.Features.Pools; using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Scp330; @@ -125,7 +126,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.LoadsField(Field(typeof(Scp330Interobject), nameof(Scp330Interobject._takenCandies)))) + offset; + instruction => instruction.LoadsField(Field(typeof(Scp330Interobject), nameof(Scp330Interobject._previousUses)))) + offset; Label notSeverLabel = newInstructions[index].labels[0]; @@ -159,7 +160,7 @@ private static bool ServerProcessPickup(ReferenceHub player, CandyKindID candy, { if (!Scp330Bag.TryGetBag(player, out bag)) { - player.inventory.ServerAddItem(ItemType.SCP330); + player.inventory.ServerAddItem(ItemType.SCP330, ItemAddReason.AdminCommand); if (!Scp330Bag.TryGetBag(player, out bag)) return false; diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RespawningTeam.cs b/EXILED/Exiled.Events/Patches/Events/Server/RespawningTeam.cs index a4d077c1f..ea2f3546f 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RespawningTeam.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RespawningTeam.cs @@ -17,27 +17,29 @@ namespace Exiled.Events.Patches.Events.Server using Exiled.Events.EventArgs.Server; using Exiled.Events.Handlers; using HarmonyLib; + using PlayerRoles; using Respawning; using Respawning.NamingRules; + using Respawning.Waves; using static HarmonyLib.AccessTools; using Player = API.Features.Player; /// - /// Patch the . + /// Patch the . /// Adds the event. /// [EventPatch(typeof(Server), nameof(Server.RespawningTeam))] - [HarmonyPatch(typeof(RespawnManager), nameof(RespawnManager.Spawn))] + [HarmonyPatch(typeof(WaveSpawner), nameof(WaveSpawner.SpawnWave))] internal static class RespawningTeam { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); - int offset = -6; - int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(UnitNamingRule), nameof(UnitNamingRule.TryGetNamingRule)))) + offset; + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(SpawnableWaveBase), nameof(SpawnableWaveBase.PopulateQueue)))) + offset; LocalBuilder ev = generator.DeclareLocal(typeof(RespawningTeamEventArgs)); @@ -48,15 +50,14 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable i.opcode == OpCodes.Callvirt && (MethodInfo)i.operand == Method(typeof(SpawnableTeamHandlerBase), nameof(SpawnableTeamHandlerBase.GenerateQueue))) + offset, 7); + // wave = ev.NextKnownTeam; + new(OpCodes.Callvirt, PropertyGetter(typeof(RespawningTeamEventArgs), nameof(RespawningTeamEventArgs.NextKnownTeam))), + new(OpCodes.Starg_S, 1), + }); for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; @@ -118,5 +115,12 @@ private static IEnumerable Transpiler(IEnumerable GetPlayers(List hubs) => hubs.Select(Player.Get).ToList(); private static List GetHubs(List players) => players.Select(player => player.ReferenceHub).ToList(); + + private static void RefillQueue(Queue newQueue) + { + WaveSpawner.SpawnQueue.Clear(); + foreach (RoleTypeId role in newQueue) + WaveSpawner.SpawnQueue.Enqueue(role); + } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs index 39d087a60..e9295a33c 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs @@ -68,9 +68,9 @@ private static IEnumerable Transpiler(IEnumerable x.Calls(PropertyGetter(typeof(RoundSummary), nameof(RoundSummary.ChaosTargetCount)))) + offset; + index = newInstructions.FindIndex(x => x.Calls(PropertyGetter(typeof(RoundSummary), nameof(RoundSummary.Network_extraTargets)))) + offset; Label label = (Label)newInstructions[index].operand; newInstructions.RemoveAt(index); diff --git a/EXILED/Exiled.Events/Patches/Fixes/Fix106RegenerationWithScp244.cs b/EXILED/Exiled.Events/Patches/Fixes/Fix106RegenerationWithScp244.cs index c9c27135f..7cc7da66c 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/Fix106RegenerationWithScp244.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/Fix106RegenerationWithScp244.cs @@ -12,10 +12,10 @@ namespace Exiled.Events.Patches.Fixes using API.Features.Pools; using CustomPlayerEffects; + using Exiled.API.Features; + using Exiled.API.Features.Roles; using HarmonyLib; using InventorySystem.Items.Usables.Scp244.Hypothermia; - using PlayerRoles; - using PlayerRoles.PlayableScps.Scp106; using static HarmonyLib.AccessTools; @@ -48,8 +48,8 @@ private static IEnumerable Transpiler(IEnumerable // ----------------------------------------------------------------------- +using Footprinting; + namespace Exiled.Events.Patches.Fixes { using System.Collections.Generic; @@ -20,7 +22,7 @@ namespace Exiled.Events.Patches.Fixes using static HarmonyLib.AccessTools; /// - /// Patches the delegate. + /// Patches the delegate. /// Fixes open doors getting easily broke. /// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/198). /// diff --git a/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs b/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs index dfa33014e..79aba61f5 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs @@ -95,6 +95,7 @@ public Scp3114FriendlyFireFix2(Footprint attacker, float damage) public override float Damage { get; set; } public override string ServerLogsText { get; } + #pragma warning restore SA1600 // Elements should be documented private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/EXILED/Exiled.Events/Patches/Fixes/WeaponAttachmentDesyncFix.cs b/EXILED/Exiled.Events/Patches/Fixes/WeaponAttachmentDesyncFix.cs index 10849eedf..2e7709a65 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/WeaponAttachmentDesyncFix.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/WeaponAttachmentDesyncFix.cs @@ -18,8 +18,10 @@ namespace Exiled.Events.Patches.Fixes using static HarmonyLib.AccessTools; + // TODO Possibly can be deleted + /* /// - /// Patches . + /// Patches . /// Fixes if a plugin gives you an weapon that you do not have ammo for, your attachments will not correctly appear on said weapon. /// [HarmonyPatch(typeof(AttachmentsServerHandler), nameof(AttachmentsServerHandler.SetupProvidedWeapon))] @@ -98,5 +100,5 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } - } + }*/ } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Generic/AddRespawnTargetMultiplierConfig.cs b/EXILED/Exiled.Events/Patches/Generic/AddRespawnTargetMultiplierConfig.cs deleted file mode 100644 index c8b3700c6..000000000 --- a/EXILED/Exiled.Events/Patches/Generic/AddRespawnTargetMultiplierConfig.cs +++ /dev/null @@ -1,54 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.Patches.Generic.Scp079API -{ - using System.Collections.Generic; - using System.Reflection.Emit; - - using API.Features.Pools; - using HarmonyLib; - - using static HarmonyLib.AccessTools; - - using Scp049Role = API.Features.Roles.Scp049Role; - - /// - /// Patches . - /// Adds the as NW config. - /// - [HarmonyPatch(typeof(RoundSummary), nameof(RoundSummary.ServerOnRespawned))] - internal class AddRespawnTargetMultiplierConfig - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - // replace "this.ChaosTargetCount += (int)((double)respawnedPlayers.Count * 0.75);" - // with " this.ChaosTargetCount += (int)((double)respawnedPlayers.Count * ConfigFile.ServerConfig.GetDouble("respawn_target_multiplier", 0.75);" - int offset = 0; - int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldc_R8) + offset; - newInstructions.RemoveAt(index); - - newInstructions.InsertRange( - index, - new CodeInstruction[] - { - // ConfigFile.ServerConfig.GetDouble("respawn_target_multiplier", 0.75); - new(OpCodes.Ldsfld, Field(typeof(GameCore.ConfigFile), nameof(GameCore.ConfigFile.ServerConfig))), - new(OpCodes.Ldstr, "respawn_target_multiplier"), - new(OpCodes.Ldc_R8, RoundSummary.RespawnTargetMultiplier), - new(OpCodes.Call, Method(typeof(YamlConfig), nameof(YamlConfig.GetDouble))), - }); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } -} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Generic/FirearmDistribution.cs b/EXILED/Exiled.Events/Patches/Generic/FirearmDistribution.cs new file mode 100644 index 000000000..30deefa44 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Generic/FirearmDistribution.cs @@ -0,0 +1,27 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic +{ +#pragma warning disable SA1313 + using Exiled.API.Features.Pickups; + using HarmonyLib; + + using BaseFirearm = InventorySystem.Items.Firearms.FirearmPickup; + + /// + /// Patch to add . + /// + [HarmonyPatch(typeof(BaseFirearm), nameof(BaseFirearm.OnDistributed))] + internal static class FirearmDistribution + { + private static void Postfix(BaseFirearm __instance) + { + Pickup.Get(__instance).IsDistributed = true; + } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs b/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs index 5cf9fd956..d95b88a87 100644 --- a/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs +++ b/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs @@ -97,7 +97,7 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref // Only check friendlyFire if the FootPrint hasn't changed (Fix for Grenade not dealing damage because it's from a dead player) // TODO rework FriendlyFireRule to make it compatible with Footprint - if (!attackerFootprint.SameLife(new Footprint(attackerFootprint.Hub))) + if (!attackerFootprint.Equals(new Footprint(attackerFootprint.Hub))) return false; // Check if attackerFootprint.Hub or victimHub is null and log debug information diff --git a/EXILED/Exiled.Events/Patches/Generic/LiftList.cs b/EXILED/Exiled.Events/Patches/Generic/LiftList.cs index 83c3d5a1e..2b0e448e8 100644 --- a/EXILED/Exiled.Events/Patches/Generic/LiftList.cs +++ b/EXILED/Exiled.Events/Patches/Generic/LiftList.cs @@ -7,26 +7,24 @@ namespace Exiled.Events.Patches.Generic { - using System.Collections.Generic; - using API.Features; using HarmonyLib; using Interactables.Interobjects; /// - /// Patches . + /// Patches . /// - [HarmonyPatch(typeof(ElevatorManager), nameof(ElevatorManager.RefreshChambers))] + [HarmonyPatch(typeof(ElevatorManager), nameof(ElevatorManager.SpawnAllChambers))] internal class LiftList { private static void Postfix() { Lift.ElevatorChamberToLift.Clear(); - foreach (KeyValuePair lift in ElevatorManager.SpawnedChambers) + foreach (ElevatorChamber lift in ElevatorChamber.AllChambers) { - _ = new Lift(lift.Value); + _ = new Lift(lift); } } } diff --git a/EXILED/Exiled.Events/Patches/Generic/PocketDimensionTeleportList.cs b/EXILED/Exiled.Events/Patches/Generic/PocketDimensionTeleportList.cs new file mode 100644 index 000000000..f53790764 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Generic/PocketDimensionTeleportList.cs @@ -0,0 +1,29 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic +{ +#pragma warning disable SA1313 + using API.Features; + + using HarmonyLib; + + /// + /// Patches . + /// + [HarmonyPatch] + internal class PocketDimensionTeleportList + { + [HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.Awake))] + [HarmonyPostfix] + private static void Adding(PocketDimensionTeleport __instance) => _ = Map.TeleportsValue.AddItem(__instance); + + [HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.OnDestroy))] + [HarmonyPostfix] + private static void Removing(PocketDimensionTeleport __instance) => Map.TeleportsValue.Remove(__instance); + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Generic/TeleportList.cs b/EXILED/Exiled.Events/Patches/Generic/TeleportList.cs deleted file mode 100644 index 40520ec27..000000000 --- a/EXILED/Exiled.Events/Patches/Generic/TeleportList.cs +++ /dev/null @@ -1,26 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.Patches.Generic -{ - using API.Features; - using HarmonyLib; - using MapGeneration; - - /// - /// Patches . - /// - [HarmonyPatch(typeof(ImageGenerator), nameof(ImageGenerator.GenerateMap))] - internal class TeleportList - { - private static void Prefix() - { - Map.TeleportsValue.Clear(); - Map.TeleportsValue.AddRange(UnityEngine.Object.FindObjectsOfType()); - } - } -} \ No newline at end of file diff --git a/EXILED/Exiled.Loader/AutoUpdateFiles.cs b/EXILED/Exiled.Loader/AutoUpdateFiles.cs index 6f947df3f..2b2aff96d 100644 --- a/EXILED/Exiled.Loader/AutoUpdateFiles.cs +++ b/EXILED/Exiled.Loader/AutoUpdateFiles.cs @@ -17,6 +17,6 @@ public static class AutoUpdateFiles /// /// Gets which SCP: SL version generated Exiled. /// - public static readonly Version RequiredSCPSLVersion = new(13, 5, 0, 1); + public static readonly Version RequiredSCPSLVersion = new(14, 0, 0, 0); } } \ No newline at end of file diff --git a/EXILED/Exiled.Loader/AutoUpdateFiles.tt b/EXILED/Exiled.Loader/AutoUpdateFiles.tt index 6c38d3d4c..07176b7f8 100644 --- a/EXILED/Exiled.Loader/AutoUpdateFiles.tt +++ b/EXILED/Exiled.Loader/AutoUpdateFiles.tt @@ -1,6 +1,6 @@ // ----------------------------------------------------------------------- -// -// Copyright (c) Exiled Team. All rights reserved. +// +// Copyright (c) ExMod Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. // // ----------------------------------------------------------------------- diff --git a/EXILED/Exiled.Permissions/Extensions/Permissions.cs b/EXILED/Exiled.Permissions/Extensions/Permissions.cs index 6d5708bf3..b03271b4b 100644 --- a/EXILED/Exiled.Permissions/Extensions/Permissions.cs +++ b/EXILED/Exiled.Permissions/Extensions/Permissions.cs @@ -21,7 +21,7 @@ namespace Exiled.Permissions.Extensions using Features; using Properties; - + using Query; using RemoteAdmin; using YamlDotNet.Core; @@ -176,7 +176,7 @@ public static bool CheckPermission(this CommandSender sender, string permission) { return true; } - else if (sender is PlayerCommandSender || sender is UserPrint) + else if (sender is PlayerCommandSender || sender is QueryCommandSender) { if (Player.Get(sender.SenderId) is not Player player) return false; diff --git a/EXILED/docs/articles/SCPSLRessources/NW_Documentation.md b/EXILED/docs/articles/SCPSLRessources/NW_Documentation.md index 819221096..d08dbef3d 100644 --- a/EXILED/docs/articles/SCPSLRessources/NW_Documentation.md +++ b/EXILED/docs/articles/SCPSLRessources/NW_Documentation.md @@ -25,28 +25,33 @@ Last Update (13.5.0.1) - [Damage Handlers](#damagehandlers) - [AchievementName](#achievementname) - [ActionCategory](#actioncategory) -- [ActionModuleResponse](#actionmoduleresponse) - [ActionName](#actionname) - [Activity](#activity) - [AdminFlags](#adminflags) - [AlphaPanelOperations](#alphapaneloperations) +- [AnimItemLayer3p](#animitemlayer3p) +- [AnimState3p](#animstate3p) - [AttachmentDescriptiveAdvantages](#attachmentdescriptiveadvantages) - [AttachmentDescriptiveDownsides](#attachmentdescriptivedownsides) - [AttachmentEditorsTranslation](#attachmenteditorstranslation) - [AttachmentName](#attachmentname) - [AttachmentParam](#attachmentparam) +- [AttachmentParamState](#attachmentparamstate) - [AttachmentSlot](#attachmentslot) +- [AttachmentStatus](#attachmentstatus) - [AttackResult](#attackresult) - [AttackType](#attacktype) - [AttackType](#attacktype) -- [AudioMixerChannelType](#audiomixerchanneltype) - [AuthenticationResponseFlags](#authenticationresponseflags) +- [Authorization](#authorization) - [AutoHideType](#autohidetype) +- [AutosyncInstantiationStatus](#autosyncinstantiationstatus) - [BadgePreferences](#badgepreferences) - [BadgeVisibilityPreferences](#badgevisibilitypreferences) - [BanType](#bantype) - [BlockedInteraction](#blockedinteraction) - [BroadcastFlags](#broadcastflags) +- [BuoyancyMode](#buoyancymode) - [CallType](#calltype) - [CandyKindID](#candykindid) - [CassieAnnouncementType](#cassieannouncementtype) @@ -54,15 +59,19 @@ Last Update (13.5.0.1) - [CentralAuthPreauthFlags](#centralauthpreauthflags) - [ChallengeState](#challengestate) - [ChallengeType](#challengetype) +- [ChamberState](#chamberstate) - [CheckpointErrorType](#checkpointerrortype) - [CheckpointSequenceStage](#checkpointsequencestage) +- [ClientFlags](#clientflags) - [ClientInstanceMode](#clientinstancemode) +- [ClientReceivedContentType](#clientreceivedcontenttype) - [ClientSwitchState](#clientswitchstate) - [ClientType](#clienttype) - [CloudState](#cloudstate) - [CmdTeleportData](#cmdteleportdata) - [CollectionDeserializeToBehaviour](#collectiondeserializetobehaviour) - [CollisionsDisablingReasons](#collisionsdisablingreasons) +- [ColorMode](#colormode) - [CommandOperationMode](#commandoperationmode) - [Condition](#condition) - [ConfigShare](#configshare) @@ -72,7 +81,6 @@ Last Update (13.5.0.1) - [ConnectRequestResult](#connectrequestresult) - [ConsoleLogType](#consolelogtype) - [ConsumeError](#consumeerror) -- [CurrentAction](#currentaction) - [CursorOverrideMode](#cursoroverridemode) - [DataType](#datatype) - [DebugLevel](#debuglevel) @@ -91,26 +99,35 @@ Last Update (13.5.0.1) - [DoorDamageType](#doordamagetype) - [DoorLockMode](#doorlockmode) - [DoorLockReason](#doorlockreason) +- [DropdownEntryType](#dropdownentrytype) - [DtoaMode](#dtoamode) - [EffectClassification](#effectclassification) -- [EffectType](#effecttype) - [ElevatorGroup](#elevatorgroup) - [ElevatorSequence](#elevatorsequence) +- [EmotionBlendshape](#emotionblendshape) +- [EmotionPresetType](#emotionpresettype) - [EncryptedChannel](#encryptedchannel) - [Entry](#entry) - [EscapeScenarioType](#escapescenariotype) - [EType](#etype) +- [ExampleId](#exampleid) +- [ExampleId](#exampleid) +- [ExampleId](#exampleid) +- [ExplosionType](#explosiontype) - [FacilityZone](#facilityzone) - [Faction](#faction) - [FailReason](#failreason) - [FalloffType](#fallofftype) - [FastDtoaMode](#fastdtoamode) - [FilmmakerBlendPreset](#filmmakerblendpreset) -- [FirearmAudioFlags](#firearmaudioflags) -- [FirearmStatusFlags](#firearmstatusflags) +- [FirearmAnim](#firearmanim) +- [FirearmCategory](#firearmcategory) +- [FirearmWorldmodelType](#firearmworldmodeltype) +- [FiringState](#firingstate) - [Flags](#flags) - [Flags](#flags) - [FogType](#fogtype) +- [FoldoutMode](#foldoutmode) - [FootstepLoudness](#footsteploudness) - [FpcViewMode](#fpcviewmode) - [FreezingMode](#freezingmode) @@ -136,11 +153,15 @@ Last Update (13.5.0.1) - [HotkeysTranslation](#hotkeystranslation) - [HttpQueryMode](#httpquerymode) - [IcomText](#icomtext) +- [IconType](#icontype) - [IndicatorType](#indicatortype) - [InputActivationMode](#inputactivationmode) - [IntercomState](#intercomstate) +- [InventoryGuiAction](#inventoryguiaction) +- [InventoryGuiTranslation](#inventoryguitranslation) - [InvisibilityFlags](#invisibilityflags) - [IPAddressType](#ipaddresstype) +- [ItemAddReason](#itemaddreason) - [ItemCategory](#itemcategory) - [ItemDescriptionType](#itemdescriptiontype) - [ItemTierFlags](#itemtierflags) @@ -155,12 +176,20 @@ Last Update (13.5.0.1) - [LocalAddrType](#localaddrtype) - [LoggingState](#loggingstate) - [MainBoolsSettings](#mainboolssettings) +- [MapGenerationPhase](#mapgenerationphase) - [MappingLifetime](#mappinglifetime) +- [MessageHeader](#messageheader) +- [MessageHeader](#messageheader) - [MessageImportance](#messageimportance) +- [MessageType](#messagetype) +- [MessageType](#messagetype) - [MiscControlsSetting](#misccontrolssetting) - [MiscPrivacySetting](#miscprivacysetting) - [MiscVideoSetting](#miscvideosetting) +- [MixerChannel](#mixerchannel) - [Mode](#mode) +- [Mode](#mode) +- [ModifierMode](#modifiermode) - [Modules](#modules) - [NatAddressType](#nataddresstype) - [NetLogLevel](#netloglevel) @@ -175,6 +204,7 @@ Last Update (13.5.0.1) - [OpusCtlGetRequest](#opusctlgetrequest) - [OpusCtlSetRequest](#opusctlsetrequest) - [OpusStatusCode](#opusstatuscode) +- [OtherCondition](#othercondition) - [OutputCodes](#outputcodes) - [PacketProperty](#packetproperty) - [ParameterMixingMode](#parametermixingmode) @@ -188,6 +218,7 @@ Last Update (13.5.0.1) - [PlayerMovementState](#playermovementstate) - [PlayerPermissions](#playerpermissions) - [PlayerSorting](#playersorting) +- [PopupState](#popupstate) - [PortMapper](#portmapper) - [PrimitiveFlags](#primitiveflags) - [ProcessCreationFlags](#processcreationflags) @@ -195,22 +226,29 @@ Last Update (13.5.0.1) - [RadioCommand](#radiocommand) - [RadioRangeLevel](#radiorangelevel) - [RejectionReason](#rejectionreason) +- [RemoteAdminResponseFlags](#remoteadminresponseflags) +- [RemovalMode](#removalmode) - [ReproProjectAssetType](#reproprojectassettype) - [RequestType](#requesttype) -- [RequestType](#requesttype) -- [RespawnSequencePhase](#respawnsequencephase) +- [RespawnSetting](#respawnsetting) - [ResurrectError](#resurrecterror) - [RoleChangeReason](#rolechangereason) - [RoleSpawnFlags](#rolespawnflags) - [RoleTypeId](#roletypeid) - [RoomName](#roomname) - [RoomShape](#roomshape) -- [RoomType](#roomtype) +- [RootCullablePriority](#rootcullablepriority) - [RoundRestartType](#roundrestarttype) +- [RpcHeader](#rpcheader) - [RpcStateMsg](#rpcstatemsg) - [RpcType](#rpctype) - [RpcType](#rpctype) - [RpcType](#rpctype) +- [RpcType](#rpctype) +- [RpcType](#rpctype) +- [RpcType](#rpctype) +- [RpcType](#rpctype) +- [RpcType](#rpctype) - [ScanSequenceStep](#scansequencestep) - [Scp0492SoundId](#scp0492soundid) - [Scp079HudTranslation](#scp079hudtranslation) @@ -218,6 +256,7 @@ Last Update (13.5.0.1) - [Scp096HitResult](#scp096hitresult) - [Scp096HudTranslation](#scp096hudtranslation) - [Scp096RageState](#scp096ragestate) +- [Scp1344Status](#scp1344status) - [Scp173SoundId](#scp173soundid) - [Scp244State](#scp244state) - [Scp3114HudTranslation](#scp3114hudtranslation) @@ -231,25 +270,34 @@ Last Update (13.5.0.1) - [SecurityLevel](#securitylevel) - [SensitivitySetting](#sensitivitysetting) - [ServerLogType](#serverlogtype) +- [ServerOperativeSystem](#serveroperativesystem) - [ServerRateLimit](#serverratelimit) +- [ServerReceivedContentType](#serverreceivedcontenttype) - [ServerShutdownState](#servershutdownstate) +- [ServerType](#servertype) - [SettingType](#settingtype) - [ShutdownResult](#shutdownresult) +- [SpawnableRoomConnectorType](#spawnableroomconnectortype) - [SpawnableTeamType](#spawnableteamtype) - [SpectatableListElementType](#spectatablelistelementtype) - [SpectatorSpawnReason](#spectatorspawnreason) - [States](#states) - [StatusType](#statustype) +- [SteamLobbyPrivacy](#steamlobbyprivacy) +- [StorageLocation](#storagelocation) - [StructureType](#structuretype) - [SubtitleType](#subtitletype) +- [SyncDataFlags](#syncdataflags) - [SyncMode](#syncmode) - [TargetButton](#targetbutton) - [Team](#team) -- [ThirdpersonItemAnimationName](#thirdpersonitemanimationname) - [TrackerMessage](#trackermessage) -- [TriggerState](#triggerstate) +- [TransitionStatus](#transitionstatus) +- [TurnStatus](#turnstatus) - [UISetting](#uisetting) - [UnconnectedMessageType](#unconnectedmessagetype) +- [UpdateMessageFlags](#updatemessageflags) +- [UserResponseMode](#userresponsemode) - [ValidationError](#validationerror) - [ValidationError](#validationerror) - [ValidationError](#validationerror) @@ -262,6 +310,10 @@ Last Update (13.5.0.1) - [VoiceChatSupportMode](#voicechatsupportmode) - [VoiceLinesName](#voicelinesname) - [VolumeSliderSetting](#volumeslidersetting) +- [WarheadScenarioType](#warheadscenariotype) +- [WaveQueueState](#wavequeuestate) +- [WearableElements](#wearableelements) +- [WearableSlot](#wearableslot) - [WorkstationStatus](#workstationstatus) ### AchievementName @@ -302,6 +354,24 @@ Last Update (13.5.0.1) [30] = IllPassThanks [31] = Overcurrent [32] = PropertyOfChaos + [33] = Overtime + [34] = RuleBreaker + [35] = CompleteTheMission + [36] = ArmyOfOne + [37] = LMGG + [38] = OnSpeakingTerms + [39] = HatsOffToYou + [40] = Hawkeye + [41] = AmnesticAmbush + [42] = AfterlifeCommunicator + [43] = TheEnemyOfMyEnemy + [44] = SignalLost + [45] = ThinkFast + [46] = TrilateralTermination + [47] = MutuallyAssuredDestruction + [48] = UndeadSpaceProgram + [49] = ArizonaRanger + [50] = Matador ``` @@ -322,18 +392,6 @@ Last Update (13.5.0.1) -### ActionModuleResponse - -
InventorySystem.Items.Firearms.Modules.ActionModuleResponse - -``` - [0] = Idle - [1] = Shoot - [2] = Dry -``` - -
- ### ActionName
ActionName @@ -360,7 +418,7 @@ Last Update (13.5.0.1) [18] = Noclip [19] = GameConsole [21] = InspectItem - [22] = RevolverCockHammer + [22] = WeaponAlt [23] = ThrowItem [27] = HideGUI [28] = NoClipFogToggle @@ -413,6 +471,37 @@ Last Update (13.5.0.1)
+### AnimItemLayer3p + +
InventorySystem.Items.Thirdperson.AnimItemLayer3p + +``` + [0] = Left + [1] = Right + [2] = Middle + [3] = Additive + [4] = PreMovement +``` + +
+ +### AnimState3p + +
InventorySystem.Items.Thirdperson.AnimState3p + +``` + [0] = Override0 + [1] = Override1 + [2] = Override2 + [3] = Additive0 + [4] = Additive1 + [5] = Additive2 + [6] = RunForward + [7] = SprintForward +``` + +
+ ### AttachmentDescriptiveAdvantages
InventorySystem.Items.Firearms.Attachments.AttachmentDescriptiveAdvantages @@ -423,6 +512,7 @@ Last Update (13.5.0.1) [4] = AmmoCounter [8] = FlashSuppression [16] = NightVision + [32] = ShotgunShells ```
@@ -434,6 +524,7 @@ Last Update (13.5.0.1) ``` [0] = None [2] = Laser + [4] = NoHeadshots ``` @@ -547,6 +638,21 @@ Last Update (13.5.0.1) [19] = AmmoConsumptionMultiplier [20] = ReloadSpeedMultiplier [21] = PreventReload + [22] = RunningInaccuracyMultiplier + [23] = DoubleActionSpeedMultiplier +``` + + + +### AttachmentParamState + +
InventorySystem.Items.Firearms.Attachments.AttachmentParamState + +``` + [0] = Disabled + [2] = UserInterface + [4] = SilentlyActive + [6] = ActiveAndDisplayed ```
@@ -569,6 +675,19 @@ Last Update (13.5.0.1) +### AttachmentStatus + +
InventorySystem.Items.Firearms.Extensions.ConditionalEvaluator+AttachmentStatus + +``` + [0] = Disabled + [1] = Enabled + [2] = EnabledAndReady + [3] = EnabledAndNotReady +``` + +
+ ### AttackResult
PlayerRoles.PlayableScps.Subroutines.AttackResult @@ -607,29 +726,27 @@ Last Update (13.5.0.1)
-### AudioMixerChannelType +### AuthenticationResponseFlags -
AudioPooling.AudioMixerChannelType +
CentralAuth.AuthenticationResponseFunctions+AuthenticationResponseFlags ``` - [0] = DefaultSfx - [1] = Interface - [2] = Weapons - [3] = VoiceChat - [4] = NoDucking + [1] = AuthToken + [2] = BadgeToken + [4] = DoNotTrack + [8] = HideBadge ```
-### AuthenticationResponseFlags +### Authorization -
CentralAuth.AuthenticationResponseFunctions+AuthenticationResponseFlags +
InventorySystem.Items.Firearms.Modules.IReloadUnloadValidatorModule+Authorization ``` - [1] = AuthToken - [2] = BadgeToken - [4] = DoNotTrack - [8] = HideBadge + [0] = Idle + [1] = Allowed + [2] = Vetoed ```
@@ -646,6 +763,19 @@ Last Update (13.5.0.1)
+### AutosyncInstantiationStatus + +
InventorySystem.Items.Autosync.AutosyncInstantiationStatus + +``` + [0] = Unspecified + [1] = Template + [2] = InventoryInstance + [3] = SimulatedInstance +``` + +
+ ### BadgePreferences
ServerRoles+BadgePreferences @@ -693,6 +823,7 @@ Last Update (13.5.0.1) [8] = GrabItems [16] = ItemPrimaryAction [48] = ItemUsage + [64] = UndisarmPlayers [255] = All ``` @@ -710,6 +841,21 @@ Last Update (13.5.0.1)
+### BuoyancyMode + +
WaterPhysics.BuoyancyMode + +``` + [0] = SuperHeavy + [1] = NonBuoyant + [2] = ShortTimeFloaters + [3] = LongTimeFloaters + [4] = Floater + [5] = SuperLight +``` + +
+ ### CallType
LiteNetLib.Utils.NetSerializer+CallType @@ -806,6 +952,18 @@ Last Update (13.5.0.1)
+### ChamberState + +
InventorySystem.Items.Firearms.Modules.CylinderAmmoModule+ChamberState + +``` + [0] = Empty + [1] = Live + [2] = Discharged +``` + +
+ ### CheckpointErrorType
Interactables.Interobjects.CheckpointDoor+CheckpointErrorType @@ -831,6 +989,22 @@ Last Update (13.5.0.1)
+### ClientFlags + +
Query.QueryHandshake+ClientFlags + +``` + [0] = None + [1] = SuppressRaResponses + [2] = SubscribeServerConsole + [4] = SubscribeServerLogs + [8] = RemoteAdminMetadata + [16] = RestrictPermissions + [32] = SpecifyLogUsername +``` + +
+ ### ClientInstanceMode
CentralAuth.ClientInstanceMode @@ -840,6 +1014,22 @@ Last Update (13.5.0.1) [1] = ReadyClient [2] = Host [3] = DedicatedServer + [4] = Dummy +``` + +
+ +### ClientReceivedContentType + +
Query.QueryMessage+ClientReceivedContentType + +``` + [0] = ConsoleString + [1] = CommandException + [2] = QueryMessage + [3] = RemoteAdminSerializedResponse + [4] = RemoteAdminPlaintextResponse + [5] = RemoteAdminUnsuccessfulPlaintextResponse ```
@@ -912,6 +1102,18 @@ Last Update (13.5.0.1)
+### ColorMode + +
InventorySystem.Drawers.AlertContent+ColorMode + +``` + [0] = White + [1] = Role + [2] = Accented +``` + +
+ ### CommandOperationMode
Misc+CommandOperationMode @@ -1037,18 +1239,6 @@ Last Update (13.5.0.1)
-### CurrentAction - -
InventorySystem.Items.Firearms.Modules.TubularMagazineAmmoManager+CurrentAction - -``` - [0] = Idle - [1] = Reloading - [2] = Unloading -``` - -
- ### CursorOverrideMode
CursorManagement.CursorOverrideMode @@ -1122,6 +1312,7 @@ Last Update (13.5.0.1) [1] = Bullet [2] = Blood [3] = Buckshot + [4] = GlassCrack ```
@@ -1286,6 +1477,7 @@ Last Update (13.5.0.1) [4] = Grenade [8] = Weapon [16] = Scp096 + [32] = ParticleDisruptor ``` @@ -1323,6 +1515,20 @@ Last Update (13.5.0.1) +### DropdownEntryType + +
UserSettings.ServerSpecific.SSDropdownSetting+DropdownEntryType + +``` + [0] = Regular + [1] = Scrollable + [2] = ScrollableLoop + [3] = Hybrid + [4] = HybridLoop +``` + +
+ ### DtoaMode
Utf8Json.Internal.DoubleConversion.DoubleToStringConverter+DtoaMode @@ -1346,20 +1552,9 @@ Last Update (13.5.0.1)
-### EffectType - -
Respawning.RespawnEffectsController+EffectType - -``` - [0] = Selection - [1] = UponRespawn -``` - -
- ### ElevatorGroup -
Interactables.Interobjects.ElevatorManager+ElevatorGroup +
Interactables.Interobjects.ElevatorGroup ``` [0] = GateA @@ -1368,8 +1563,9 @@ Last Update (13.5.0.1) [3] = LczA02 [4] = LczB01 [5] = LczB02 - [6] = Nuke + [6] = Nuke01 [7] = Scp049 + [8] = Nuke02 ```
@@ -1388,6 +1584,54 @@ Last Update (13.5.0.1)
+### EmotionBlendshape + +
PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers.EmotionBlendshape + +``` + [0] = Undefined + [1] = Frown + [2] = BrowRaise + [3] = EyeTapLeft + [4] = EyeTapRight + [5] = EyeCloseLeft + [6] = EyeCloseRight + [7] = EyeOpenLeft + [8] = EyeOpenRight + [9] = EyesBottom + [10] = Worried + [11] = MouthOpen + [12] = JawDrop + [13] = Grin + [14] = SmileOpen + [15] = Disgusted + [16] = Angry + [17] = LipsTop + [18] = LipsNormalBottom + [19] = LipsStretchBottom + [20] = Ogre + [21] = Chad + [22] = MixClosedEyes +``` + +
+ +### EmotionPresetType + +
PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers.EmotionPresetType + +``` + [0] = Neutral + [1] = Happy + [2] = AwkwardSmile + [3] = Scared + [4] = Angry + [5] = Chad + [6] = Ogre +``` + +
+ ### EncryptedChannel
EncryptedChannelManager+EncryptedChannel @@ -1443,6 +1687,77 @@ Last Update (13.5.0.1)
+### ExampleId + +
UserSettings.ServerSpecific.Examples.SSAbilitiesExample+ExampleId + +``` + [0] = SpeedBoostKey + [1] = SpeedBoostToggle + [2] = HealAlly +``` + +
+ +### ExampleId + +
UserSettings.ServerSpecific.Examples.SSLightSpawnerExample+ExampleId + +``` + [0] = IntensitySlider + [1] = RangeSlider + [2] = ColorPresetDropdown + [3] = CustomColor + [4] = ColorInfo + [5] = ShadowType + [6] = ShadowStrength + [7] = LightType + [8] = LightShape + [9] = SpotAngle + [10] = InnerSpotAngle + [11] = ConfirmButton + [12] = DestroyAllButton +``` + +
+ +### ExampleId + +
UserSettings.ServerSpecific.Examples.SSPrimitiveSpawnerExample+ExampleId + +``` + [0] = ConfirmButton + [1] = DestroyAllButton + [2] = TypeDropdown + [3] = ColorPresetDropdown + [4] = ColorField + [5] = ColorAlphaSlider + [6] = CollisionsToggle + [7] = RendererToggle + [8] = ColorInfo + [9] = ScaleSliderX + [10] = ScaleSliderY + [11] = ScaleSliderZ +``` + +
+ +### ExplosionType + +
ExplosionType + +``` + [0] = Grenade + [1] = SCP018 + [2] = PinkCandy + [3] = Cola + [4] = Disruptor + [5] = Jailbird + [6] = Custom +``` + +
+ ### FacilityZone
MapGeneration.FacilityZone @@ -1523,30 +1838,54 @@ Last Update (13.5.0.1)
-### FirearmAudioFlags +### FirearmAnim -
InventorySystem.Items.Firearms.FirearmAudioFlags +
InventorySystem.Items.Firearms.Thirdperson.FirearmThirdpersonItem+FirearmAnim ``` - [0] = None - [2] = ScaleDistance - [4] = IsGunshot - [8] = SendToPlayers - [16] = UseDedicatedAudioChannel + [0] = Ads + [1] = Hip + [2] = Reload ```
-### FirearmStatusFlags +### FirearmCategory -
InventorySystem.Items.Firearms.FirearmStatusFlags +
InventorySystem.Items.Firearms.FirearmCategory + +``` + [0] = Unclassified + [1] = Pistol + [2] = Revolver + [3] = SubmachineGun + [4] = Rifle + [5] = LightMachineGun + [6] = Shotgun +``` + +
+ +### FirearmWorldmodelType + +
InventorySystem.Items.Firearms.FirearmWorldmodelType + +``` + [0] = Pickup + [1] = Thirdperson + [2] = Presentation +``` + +
+ +### FiringState + +
InventorySystem.Items.Firearms.Modules.DisruptorActionModule+FiringState ``` [0] = None - [2] = Cocked - [4] = MagazineInserted - [8] = FlashlightEnabled - [16] = Chambered + [1] = FiringRapid + [2] = FiringSingle ```
@@ -1598,6 +1937,20 @@ Last Update (13.5.0.1)
+### FoldoutMode + +
UserSettings.ServerSpecific.SSTextArea+FoldoutMode + +``` + [0] = NotCollapsable + [1] = CollapseOnEntry + [2] = ExtendOnEntry + [3] = CollapsedByDefault + [4] = ExtendedByDefault +``` + +
+ ### FootstepLoudness
PlayerRoles.FirstPersonControl.Thirdperson.AnimatedCharacterModel+FootstepLoudness @@ -1975,6 +2328,20 @@ Last Update (13.5.0.1)
+### IconType + +
InventorySystem.Items.Firearms.Extensions.DisruptorDualCamExtension+IconType + +``` + [0] = None + [1] = DesintegratorMode + [2] = BurstMode + [3] = CriticalWarn + [4] = CrashWarn +``` + +
+ ### IndicatorType
PlayerRoles.PlayableScps.Scp079.Map.Scp079TeammateIndicators+IndicatorType @@ -2012,6 +2379,52 @@ Last Update (13.5.0.1)
+### InventoryGuiAction + +
InventorySystem.GUI.InventoryGuiAction + +``` + [0] = None + [1] = Drop + [2] = Select +``` + +
+ +### InventoryGuiTranslation + +
InventorySystem.GUI.InventoryGuiTranslation + +``` + [0] = FirearmAmmo + [1] = FirearmDamage + [2] = FirearmFireRate + [3] = FirearmHipAcc + [4] = FirearmAdsAcc + [5] = Weight + [6] = Length + [7] = DropAmmo + [8] = ArmorHelmetEfficacy + [9] = ArmorVestEfficacy + [10] = ArmorStaminaUsage + [11] = ArmorMovementSpeed + [12] = ArmorItemLimits + [13] = ArmorAmmoLimits + [14] = ArmorTotal + [15] = ArmorPenetration + [16] = RunningInaccuracy + [17] = MarshmallowCackleHint + [18] = RemainingCharge + [19] = RemainingAmmo + [20] = MicroHidPrimaryHint + [21] = MicroHidSecondaryHint + [22] = DisruptorToggleModeHint + [23] = JailbirdAttackHint + [24] = JailbirdChargeHint +``` + +
+ ### InvisibilityFlags
PlayerRoles.Visibility.InvisibilityFlags @@ -2039,6 +2452,21 @@ Last Update (13.5.0.1)
+### ItemAddReason + +
InventorySystem.Items.ItemAddReason + +``` + [0] = Undefined + [1] = PickedUp + [2] = AdminCommand + [3] = StartingItem + [4] = Scp914Upgrade + [5] = StatusEffect +``` + +
+ ### ItemCategory
ItemCategory @@ -2051,7 +2479,7 @@ Last Update (13.5.0.1) [4] = Firearm [5] = Grenade [6] = SCPItem - [7] = MicroHID + [7] = SpecialWeapon [8] = Ammo [9] = Armor ``` @@ -2146,6 +2574,7 @@ Last Update (13.5.0.1) [52] = GunFRMG0 [53] = GunA7 [54] = Lantern + [55] = SCP1344 [-1] = None ``` @@ -2315,6 +2744,21 @@ Last Update (13.5.0.1)
+### MapGenerationPhase + +
MapGeneration.MapGenerationPhase + +``` + [0] = ParentRoomRegistration + [1] = RelativePositioningWaypoints + [2] = ComplexDecorationsAndClutter + [3] = SimpleDecorations + [4] = CullingCaching + [5] = SpawnableStructures +``` + +
+ ### MappingLifetime
LiteNetLib4Mirror.Open.Nat.MappingLifetime @@ -2328,6 +2772,35 @@ Last Update (13.5.0.1)
+### MessageHeader + +
InventorySystem.Items.Firearms.Modules.AnimatorReloaderModuleBase+MessageHeader + +``` + [0] = Custom + [1] = Reload + [2] = Unload + [3] = Stop + [4] = RequestRejected +``` + +
+ +### MessageHeader + +
InventorySystem.Items.Firearms.Modules.AutomaticActionModule+MessageHeader + +``` + [0] = CmdShoot + [1] = RpcPublicSync + [2] = RpcResponse + [3] = RpcFire + [4] = RpcDryFire + [5] = RpcNewPlayerSync +``` + +
+ ### MessageImportance
MessageImportance @@ -2341,6 +2814,40 @@ Last Update (13.5.0.1)
+### MessageType + +
InventorySystem.Items.Firearms.Modules.DisruptorActionModule+MessageType + +``` + [0] = RpcRequireReloadTrue + [1] = RpcRequireReloadFalse + [2] = RpcRequireReloadFullResync + [3] = RpcStartFiring + [4] = RpcOnShot + [5] = CmdRequestStartFiring + [6] = CmdConfirmDischarge +``` + +
+ +### MessageType + +
InventorySystem.Items.Firearms.Modules.DoubleActionModule+MessageType + +``` + [0] = RpcNewPlayerResync + [1] = RpcSetCockedTrue + [2] = RpcSetCockedFalse + [3] = RpcFire + [4] = RpcDryFire + [5] = CmdUpdatePulling + [6] = CmdShoot + [7] = StartPulling + [8] = StartCocking +``` + +
+ ### MiscControlsSetting
UserSettings.ControlsSettings.MiscControlsSetting @@ -2383,6 +2890,32 @@ Last Update (13.5.0.1) [1] = ExplosionShake [2] = HeadBobbing [3] = FlashbangDarkMode + [4] = ShowNeedles +``` + +
+ +### MixerChannel + +
AudioPooling.MixerChannel + +``` + [0] = DefaultSfx + [1] = Interface + [2] = Weapons + [3] = VoiceChat + [4] = NoDucking +``` + +
+ +### Mode + +
InventorySystem.Items.Firearms.Extensions.ViewmodelReloadOnlyLayerExtension+Mode + +``` + [0] = DuringReloadsAndUnloads + [1] = OutsideReloadsAndUnloads ```
@@ -2392,13 +2925,26 @@ Last Update (13.5.0.1)
InventorySystem.Items.Autosync.AutosyncRpc+Mode ``` - [0] = Local + [0] = SpecificClient [1] = AllClients [2] = Conditional ```
+### ModifierMode + +
InventorySystem.Items.Firearms.Modules.Misc.StatModifier+ModifierMode + +``` + [0] = Inactive + [1] = Add + [2] = Multiply + [3] = Override +``` + +
+ ### Modules
ServerLogs+Modules @@ -2409,9 +2955,12 @@ Last Update (13.5.0.1) [2] = ClassChange [3] = Permissions [4] = Administrative - [5] = Logger + [5] = GameLogic [6] = DataAccess [7] = Detector + [8] = Throwable + [9] = Door + [10] = Elevator ```
@@ -2603,6 +3152,19 @@ Last Update (13.5.0.1)
+### OtherCondition + +
InventorySystem.Items.Firearms.Extensions.ConditionalEvaluator+OtherCondition + +``` + [0] = Equipped + [1] = Firstperson + [2] = Pickup + [3] = Thirdperson +``` + +
+ ### OutputCodes
ServerOutput.OutputCodes @@ -2695,6 +3257,8 @@ Last Update (13.5.0.1) [5] = AOQuality [6] = BloodDecalsEnabled [7] = BulletDecalsEnabled + [8] = BloodDecalsLimit + [9] = BulletDecalsLimits ```
@@ -2818,6 +3382,7 @@ Last Update (13.5.0.1) [67108864] = Effects [134217728] = FriendlyFireDetectorImmunity [268435456] = FriendlyFireDetectorTempDisable + [536870912] = ServerLogLiveFeed ``` @@ -2835,6 +3400,19 @@ Last Update (13.5.0.1) +### PopupState + +
Interactables.Interobjects.PopupInterobject+PopupState + +``` + [0] = Off + [1] = Enabling + [2] = On + [3] = Disabling +``` + +
+ ### PortMapper
LiteNetLib4Mirror.Open.Nat.PortMapper @@ -2953,6 +3531,28 @@ Last Update (13.5.0.1)
+### RemoteAdminResponseFlags + +
RemoteAdminResponse+RemoteAdminResponseFlags + +``` + [1] = Successful + [2] = LogInConsole +``` + +
+ +### RemovalMode + +
InventorySystem.Items.Firearms.Extensions.WorldmodelMagazineExtension+RemovalMode + +``` + [0] = DeactivateObject + [1] = SetScaleZero +``` + +
+ ### ReproProjectAssetType
ReproProjectAssetType @@ -2979,33 +3579,13 @@ Last Update (13.5.0.1)
-### RequestType - -
InventorySystem.Items.Firearms.BasicMessages.RequestType - -``` - [0] = Unload - [1] = Reload - [2] = AdsIn - [3] = AdsOut - [4] = Dryfire - [5] = ToggleFlashlight - [6] = ReloadStop - [7] = RequestStatuses - [8] = Inspect -``` - -
- -### RespawnSequencePhase +### RespawnSetting -
Respawning.RespawnManager+RespawnSequencePhase +
Respawning.Graphics.RespawnSetting ``` - [0] = RespawnCooldown - [1] = SelectingTeam - [2] = PlayingEntryAnimations - [3] = SpawningSelectedTeam + [0] = RespawnInterfaceVisible + [1] = ObjectiveFeedVisible ```
@@ -3039,6 +3619,7 @@ Last Update (13.5.0.1) [6] = Revived [7] = RemoteAdmin [8] = Destroyed + [9] = RespawnMiniwave ```
@@ -3085,6 +3666,7 @@ Last Update (13.5.0.1) [21] = Overwatch [22] = Filmmaker [23] = Scp3114 + [24] = Destroyed [-1] = None ``` @@ -3152,17 +3734,14 @@ Last Update (13.5.0.1) -### RoomType +### RootCullablePriority -
MapGeneration.ImageGenerator+RoomType +
ProgressiveCulling.RootCullablePriority ``` - [0] = Straight - [1] = Curve - [2] = RoomT - [3] = Cross - [4] = Endoff - [5] = Prison + [0] = PreCull + [1] = Rooms + [2] = Dynamic ```
@@ -3179,6 +3758,17 @@ Last Update (13.5.0.1)
+### RpcHeader + +
InventorySystem.Items.Firearms.Modules.AnimationToggleableReloaderModule+RpcHeader + +``` + [0] = SyncLoadable + [1] = Cancel +``` + +
+ ### RpcStateMsg
PlayerRoles.PlayableScps.Scp939.Mimicry.MimicPointController+RpcStateMsg @@ -3218,6 +3808,18 @@ Last Update (13.5.0.1) ### RpcType +
PlayerRoles.PlayableScps.Scp106.Scp106StalkAbility+RpcType + +``` + [0] = StalkActive + [1] = StalkInactive + [2] = NotEnoughVigor +``` + +
+ +### RpcType +
InventorySystem.Items.MarshmallowMan.MarshmallowItem+RpcType ``` @@ -3228,6 +3830,57 @@ Last Update (13.5.0.1)
+### RpcType + +
InventorySystem.Items.Firearms.Modules.EventBasedEquipperModule+RpcType + +``` + [0] = SeedSync + [1] = FirstTimeTrue + [2] = FirstTimeFalse + [3] = ResyncAllFirstTime +``` + +
+ +### RpcType + +
InventorySystem.Items.Firearms.Modules.ImpactEffectsModule+RpcType + +``` + [0] = ImpactDecal + [1] = TracerDefault + [2] = TracerOverride + [3] = PlayerHit +``` + +
+ +### RpcType + +
InventorySystem.Items.Firearms.Modules.PumpActionModule+RpcType + +``` + [0] = ResyncOne + [1] = ResyncAll + [2] = Shoot + [3] = SchedulePump +``` + +
+ +### RpcType + +
InventorySystem.Items.Firearms.Attachments.FlashlightAttachment+RpcType + +``` + [0] = Enabled + [1] = Disabled + [2] = FullResync +``` + +
+ ### ScanSequenceStep
PlayerRoles.PlayableScps.Scp079.Scp079ScannerSequence+ScanSequenceStep @@ -3412,6 +4065,24 @@ Last Update (13.5.0.1)
+### Scp1344Status + +
InventorySystem.Items.Usables.Scp1344.Scp1344Status + +``` + [0] = Idle + [1] = Equipping + [2] = Activating + [3] = Stabbing + [4] = Active + [5] = Dropping + [6] = Deactivating + [7] = CancelingDeactivation + [8] = Inspecting +``` + +
+ ### Scp173SoundId
PlayerRoles.PlayableScps.Scp173.Scp173AudioPlayer+Scp173SoundId @@ -3630,10 +4301,22 @@ Last Update (13.5.0.1) [3] = KillLog [4] = GameEvent [5] = InternalMessage - [6] = RateLimit + [6] = AuthRateLimit [7] = Teamkill [8] = Suicide [9] = AdminChat + [10] = Query +``` + +
+ +### ServerOperativeSystem + +
Steam.ServerOperativeSystem + +``` + [108] = Linux + [119] = Windows ```
@@ -3649,6 +4332,16 @@ Last Update (13.5.0.1)
+### ServerReceivedContentType + +
Query.QueryMessage+ServerReceivedContentType + +``` + [0] = Command +``` + +
+ ### ServerShutdownState
ServerShutdown+ServerShutdownState @@ -3662,6 +4355,18 @@ Last Update (13.5.0.1)
+### ServerType + +
Steam.ServerType + +``` + [100] = Dedicated + [108] = Listen + [112] = SourceTV +``` + +
+ ### SettingType
UserSettings.GUIElements.UserSettingDependency+Dependency+SettingType @@ -3686,6 +4391,31 @@ Last Update (13.5.0.1)
+### SpawnableRoomConnectorType + +
MapGeneration.RoomConnectors.SpawnableRoomConnectorType + +``` + [0] = None + [1] = EzStandardDoor + [2] = HczStandardDoor + [3] = LczStandardDoor + [4] = HczOneSidedWall + [5] = HczTwoSidedWall + [6] = OpenHallway + [7] = OpenHallwayClutterA + [8] = OpenHallwayClutterB + [9] = OpenHallwayClutterC + [10] = OpenHallwayConstructA + [11] = HczBulkDoor + [12] = OpenHallwayClutterD + [13] = OpenHallwayClutterE + [14] = OpenHallwayClutterF + [15] = OpenHallwayClutterG +``` + +
+ ### SpawnableTeamType
Respawning.SpawnableTeamType @@ -3748,6 +4478,30 @@ Last Update (13.5.0.1)
+### SteamLobbyPrivacy + +
UserSettings.OtherSettings.SteamLobbyPrivacy + +``` + [0] = Private + [1] = Friends + [2] = Public +``` + +
+ +### StorageLocation + +
FavoriteAndHistory+StorageLocation + +``` + [0] = History + [1] = Favorites + [2] = IPHistory +``` + +
+ ### StructureType
MapGeneration.Distributors.StructureType @@ -3759,6 +4513,7 @@ Last Update (13.5.0.1) [3] = Scp079Generator [4] = SmallWallCabinet [5] = Workstation + [6] = ExperimentalWeaponLocker ```
@@ -3802,6 +4557,23 @@ Last Update (13.5.0.1) +### SyncDataFlags + +
InventorySystem.Items.Firearms.Modules.AutomaticActionModule+SyncDataFlags + +``` + [0] = None + [1] = AmmoChamberedBit0 + [2] = AmmoChamberedBit1 + [4] = AmmoChamberedBit2 + [8] = AmmoChamberedBit3 + [15] = AmmoChamberedFilter + [16] = Cocked + [32] = BoltLocked +``` + +
+ ### SyncMode
PlayerStatsSystem.SyncedStatBase+SyncMode @@ -3846,31 +4618,6 @@ Last Update (13.5.0.1)
-### ThirdpersonItemAnimationName - -
InventorySystem.Items.Thirdperson.ThirdpersonItemAnimationName - -``` - [0] = Override0 - [1] = Override1 - [2] = Override2 - [3] = IdlePoseAdditive - [4] = SprintLeftAdditive - [5] = SprintRightAdditive - [6] = SprintStraightAdditive - [7] = SprintBackAdditive - [8] = WalkLeftAdditive - [9] = WalkRightAdditive - [10] = WalkStraightAdditive - [11] = WalkBackAdditive - [12] = PrimaryAdditive - [13] = SecAdditive0 - [14] = SecAdditive1 - [15] = SecAdditive2 -``` - -
- ### TrackerMessage
PlayerRoles.PlayableScps.Scp079.Scp079ScannerSequence+TrackerMessage @@ -3885,14 +4632,26 @@ Last Update (13.5.0.1)
-### TriggerState +### TransitionStatus + +
PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers.InventorySubcontroller+TransitionStatus + +``` + [0] = RetractingPrevious + [1] = EquippingNew + [2] = Done +``` + +
+ +### TurnStatus -
InventorySystem.Items.Firearms.Modules.DoubleAction+TriggerState +
PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers.IdlePoseRetainerSubcontroller+TurnStatus ``` - [0] = Released - [1] = Pulling - [2] = SearLock + [0] = Idle + [1] = TurningRight + [2] = TurningLeft ```
@@ -3909,6 +4668,8 @@ Last Update (13.5.0.1) [4] = HideIP [5] = FlashTaskbar [6] = PhotosensitivityDoNotShow + [7] = ImperialUnits + [8] = InaccuracyAsDispersion ```
@@ -3924,6 +4685,33 @@ Last Update (13.5.0.1) +### UpdateMessageFlags + +
Respawning.UpdateMessageFlags + +``` + [0] = None + [1] = Timer + [2] = Pause + [4] = Trigger + [8] = Tokens + [11] = All +``` + +
+ +### UserResponseMode + +
UserSettings.ServerSpecific.ServerSpecificSettingBase+UserResponseMode + +``` + [0] = None + [1] = ChangeOnly + [2] = AcquisitionAndChange +``` + +
+ ### ValidationError
PlayerRoles.PlayableScps.Scp079.Scp079BlackoutRoomAbility+ValidationError @@ -4095,6 +4883,54 @@ Last Update (13.5.0.1)
+### WarheadScenarioType + +
WarheadScenarioType + +``` + [0] = Start + [1] = Resume + [2] = DeadmanSwitch +``` + +
+ +### WaveQueueState + +
Respawning.WaveManager+WaveQueueState + +``` + [0] = Idle + [1] = WaveSelected + [2] = WaveSpawning +``` + +
+ +### WearableElements + +
PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers.WearableElements + +``` + [0] = None + [1] = Scp268Hat + [2] = Scp1344Goggles +``` + +
+ +### WearableSlot + +
InventorySystem.Items.WearableSlot + +``` + [0] = Body + [1] = Eyes + [2] = Hat +``` + +
+ ### WorkstationStatus
InventorySystem.Items.Firearms.Attachments.WorkstationController+WorkstationStatus @@ -4148,6 +4984,7 @@ Last Update (13.5.0.1) | 21 | Overwatch | Dead | None | Draw | | 22 | Filmmaker | Dead | None | Draw | | 23 | Scp3114 | SCPs | Scp | Anomalies | +| 24 | Destroyed | Dead | None | Draw | ```
From d0bd2f75b052a1a77db697a03ef50bb084093e62 Mon Sep 17 00:00:00 2001 From: VALERA771 <72030575+VALERA771@users.noreply.github.com> Date: Tue, 26 Nov 2024 23:01:09 +0300 Subject: [PATCH 007/102] finals (#196) * finals * fix --- EXILED/Exiled.API/Enums/DoorType.cs | 3 +-- EXILED/Exiled.API/Features/Player.cs | 3 +-- .../Exiled.CustomItems/API/Features/CustomItem.cs | 2 +- .../EventArgs/Map/PlacingBulletHoleEventArgs.cs | 4 ++-- .../EventArgs/Map/SpawningTeamVehicleEventArgs.cs | 3 +-- .../EventArgs/Player/EscapedEventArgs.cs | 15 +-------------- .../EventArgs/Player/ShootingEventArgs.cs | 8 ++++---- .../EventArgs/Server/RespawningTeamEventArgs.cs | 5 +---- EXILED/Exiled.Events/Handlers/Server.cs | 6 +++--- .../Patches/Events/Item/ChangingAmmo.cs | 7 +++++-- .../Patches/Events/Item/ReceivingPreference.cs | 3 ++- .../Patches/Events/Map/ExplodingFragGrenade.cs | 2 +- .../Patches/Events/Map/PlacingBulletHole.cs | 3 ++- .../Patches/Events/Map/SpawningTeamVehicle.cs | 14 +++++++++----- .../Patches/Events/Player/DamagingDoor.cs | 2 +- .../Events/Player/EnteringKillerCollision.cs | 3 +-- .../Patches/Events/Player/EscapingAndEscaped.cs | 1 - .../Patches/Events/Player/Hurting.cs | 2 +- .../Patches/Events/Player/InteractingElevator.cs | 2 +- .../Exiled.Events/Patches/Events/Player/Joined.cs | 2 +- .../Patches/Events/Player/Shooting.cs | 7 +++++-- .../Exiled.Events/Patches/Events/Player/Shot.cs | 2 -- .../Patches/Events/Player/Spawning.cs | 2 +- .../Patches/Events/Player/SpawningRagdoll.cs | 3 ++- .../Patches/Events/Scp106/Stalking.cs | 4 +--- .../Patches/Events/Scp914/UpgradingPlayer.cs | 2 +- .../Patches/Events/Server/SelectingRespawnTeam.cs | 5 +++-- .../Exiled.Events/Patches/Fixes/ArmorDropPatch.cs | 2 +- .../Fixes/FixOnAddedBeingCallAfterOnRemoved.cs | 2 +- .../Patches/Fixes/FixPickupPreviousOwner.cs | 2 +- .../Patches/Fixes/NWFixDetonationTimer.cs | 2 +- .../Patches/Fixes/NWFixScp096BreakingDoor.cs | 5 ++--- .../Patches/Generic/PickupControlPatch.cs | 2 +- EXILED/Exiled.Example/Events/PlayerHandler.cs | 3 ++- 34 files changed, 61 insertions(+), 72 deletions(-) diff --git a/EXILED/Exiled.API/Enums/DoorType.cs b/EXILED/Exiled.API/Enums/DoorType.cs index 04f38c19d..745557a6a 100644 --- a/EXILED/Exiled.API/Enums/DoorType.cs +++ b/EXILED/Exiled.API/Enums/DoorType.cs @@ -8,8 +8,7 @@ namespace Exiled.API.Enums { using Exiled.API.Features.Doors; - - using static Interactables.Interobjects.ElevatorManager; + using Interactables.Interobjects; /// /// Unique identifier for the different types of doors. diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 6a67717b1..ddad6ca4c 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -45,7 +45,6 @@ namespace Exiled.API.Features using MEC; using Mirror; using Mirror.LiteNetLib4Mirror; - using NorthwoodLib; using PlayerRoles; using PlayerRoles.FirstPersonControl; using PlayerRoles.RoleAssign; @@ -1323,7 +1322,7 @@ public static Player Get(string args) if (!player.IsVerified || player.Nickname is null) continue; - if (!player.Nickname.Contains(args, StringComparison.OrdinalIgnoreCase)) + if (!player.Nickname.ToLower().Contains(args.ToLower())) continue; string secondString = player.Nickname; diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs index dcfd61f28..a01621fbb 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs @@ -692,7 +692,7 @@ public virtual uint Spawn(IEnumerable spawnPoints, uint limit) if (pickup.Is(out Exiled.API.Features.Pickups.FirearmPickup firearmPickup) && this is CustomWeapon customWeapon) { - firearmPickup + // set MaxAmmo if synced TODO } } diff --git a/EXILED/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs index a662f3af2..8a066fbaf 100644 --- a/EXILED/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs @@ -27,9 +27,9 @@ public class PlacingBulletHoleEventArgs : IFirearmEvent, IPlayerEvent, IDeniable /// /// /// - public PlacingBulletHoleEventArgs(Firearm firearm, RaycastHit hit) + public PlacingBulletHoleEventArgs(Item firearm, RaycastHit hit) { - Firearm = firearm; + Firearm = firearm.As(); Player = Firearm.Owner; Position = hit.point; Rotation = Quaternion.LookRotation(hit.normal); diff --git a/EXILED/Exiled.Events/EventArgs/Map/SpawningTeamVehicleEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/SpawningTeamVehicleEventArgs.cs index d1b633b7b..2e455ff30 100644 --- a/EXILED/Exiled.Events/EventArgs/Map/SpawningTeamVehicleEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Map/SpawningTeamVehicleEventArgs.cs @@ -5,12 +5,11 @@ // // ----------------------------------------------------------------------- -using Respawning.Waves; - namespace Exiled.Events.EventArgs.Map { using Exiled.Events.EventArgs.Interfaces; using Respawning; + using Respawning.Waves; /// /// Contains all information before the server spawns a team's respawn vehicle. diff --git a/EXILED/Exiled.Events/EventArgs/Player/EscapedEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/EscapedEventArgs.cs index 9f74663cd..6b470210c 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/EscapedEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/EscapedEventArgs.cs @@ -28,13 +28,10 @@ public class EscapedEventArgs : IPlayerEvent /// /// /// - /// , . - public EscapedEventArgs(Player player, EscapeScenario escapeScenario, Role role, KeyValuePair kvp) + public EscapedEventArgs(Player player, EscapeScenario escapeScenario, Role role) { Player = player; EscapeScenario = escapeScenario; - Team = kvp.Key; - Tickets = kvp.Value; OldRole = role; EscapeTime = (int)Math.Ceiling(role.ActiveTime.TotalSeconds); } @@ -47,16 +44,6 @@ public EscapedEventArgs(Player player, EscapeScenario escapeScenario, Role role, /// public EscapeScenario EscapeScenario { get; } - /// - /// Gets the that gained tickets for this escape. - /// - public SpawnableTeamType Team { get; } - - /// - /// Gets the amount of tickets gained for this escape. - /// - public float Tickets { get; } - /// /// Gets the previous role for this player. /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs index 6a61a64b9..c348e649b 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs @@ -35,14 +35,12 @@ public class ShootingEventArgs : IPlayerEvent, IDeniableEvent, IFirearmEvent /// /// /// - /// - /// - /// public ShootingEventArgs(Player shooter, BaseFirearm firearm) { Player = shooter; Firearm = Item.Get(firearm).As(); - ShotMessage = msg; + + // ShotMessage = msg; } /// @@ -58,6 +56,7 @@ public ShootingEventArgs(Player shooter, BaseFirearm firearm) /// public Item Item => Firearm; + /* /// /// Gets or sets the for the event. /// @@ -104,6 +103,7 @@ public uint TargetNetId }; } } + */ /// /// Gets or sets a value indicating whether the shot can be fired. diff --git a/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs index eee756d7b..f475591a6 100644 --- a/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs @@ -5,18 +5,15 @@ // // ----------------------------------------------------------------------- -using Respawning.Waves; - namespace Exiled.Events.EventArgs.Server { using System.Collections.Generic; using Exiled.API.Features; using Exiled.Events.EventArgs.Interfaces; - using PlayerRoles; - using Respawning; + using Respawning.Waves; /// /// Contains all information before spawning a wave of or diff --git a/EXILED/Exiled.Events/Handlers/Server.cs b/EXILED/Exiled.Events/Handlers/Server.cs index 399a5fcfe..a48d599a2 100644 --- a/EXILED/Exiled.Events/Handlers/Server.cs +++ b/EXILED/Exiled.Events/Handlers/Server.cs @@ -5,13 +5,13 @@ // // ----------------------------------------------------------------------- -using Respawning.Waves; - namespace Exiled.Events.Handlers { using System.Collections.Generic; using Respawning; + using Respawning.Waves; + #pragma warning disable SA1623 // Property summary documentation should match accessors using Exiled.Events.EventArgs.Player; @@ -165,7 +165,7 @@ public static class Server /// /// Called after team spawns. /// - /// + /// /// public static void OnRespawnedTeam(SpawnableWaveBase teamType, List hubs) => RespawnedTeam.InvokeSafely(new RespawnedTeamEventArgs(teamType, hubs)); diff --git a/EXILED/Exiled.Events/Patches/Events/Item/ChangingAmmo.cs b/EXILED/Exiled.Events/Patches/Events/Item/ChangingAmmo.cs index 2d020b250..7ef8824da 100644 --- a/EXILED/Exiled.Events/Patches/Events/Item/ChangingAmmo.cs +++ b/EXILED/Exiled.Events/Patches/Events/Item/ChangingAmmo.cs @@ -23,13 +23,15 @@ namespace Exiled.Events.Patches.Events.Item using static HarmonyLib.AccessTools; /// - /// Patches . + /// Patches . /// Adds the event. /// [EventPatch(typeof(Item), nameof(Item.ChangingAmmo))] - [HarmonyPatch(typeof(Firearm), nameof(Firearm.Status), MethodType.Setter)] + + // [HarmonyPatch(typeof(Firearm), nameof(Firearm.Status), MethodType.Setter)] internal static class ChangingAmmo { + /* private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); @@ -137,5 +139,6 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } + */ } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Item/ReceivingPreference.cs b/EXILED/Exiled.Events/Patches/Events/Item/ReceivingPreference.cs index 1558c49fe..96b9907b3 100644 --- a/EXILED/Exiled.Events/Patches/Events/Item/ReceivingPreference.cs +++ b/EXILED/Exiled.Events/Patches/Events/Item/ReceivingPreference.cs @@ -39,7 +39,8 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldloc_1); + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ret) + offset; LocalBuilder ev = generator.DeclareLocal(typeof(ReceivingPreferenceEventArgs)); LocalBuilder curCode = generator.DeclareLocal(typeof(uint)); diff --git a/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs b/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs index 60faf8a97..37a8bef64 100644 --- a/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs +++ b/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs @@ -26,7 +26,7 @@ namespace Exiled.Events.Patches.Events.Map using static HarmonyLib.AccessTools; /// - /// Patches . + /// Patches . /// Adds the event. /// [EventPatch(typeof(Handlers.Map), nameof(Handlers.Map.ExplodingGrenade))] diff --git a/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs b/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs index d3b603620..180fb3e81 100644 --- a/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs +++ b/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs @@ -16,6 +16,7 @@ namespace Exiled.Events.Patches.Events.Map using Exiled.Events.EventArgs.Map; using Handlers; using HarmonyLib; + using InventorySystem.Items; using InventorySystem.Items.Firearms.Modules; using UnityEngine; @@ -47,7 +48,7 @@ private static IEnumerable Transpiler(IEnumerable // ----------------------------------------------------------------------- -using Respawning.Waves; - namespace Exiled.Events.Patches.Events.Map { using System.Collections.Generic; @@ -38,12 +36,18 @@ private static IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Newobj) + offset; - newInstructions.InsertRange(0, new CodeInstruction[] + newInstructions.InsertRange(index, new[] { + new(OpCodes.Stloc_S, msg.LocalIndex), + // if (type != RespawnEffectsController.EffectType.Selection) // goto continueLabel; - new(OpCodes.Ldarg_0), + new(OpCodes.Ldloc_S, msg.LocalIndex), new(OpCodes.Callvirt, PropertyGetter(typeof(WaveUpdateMessage), nameof(WaveUpdateMessage.IsTrigger))), new(OpCodes.Brfalse_S, continueLabel), @@ -72,7 +76,7 @@ private static IEnumerable Transpiler(IEnumerable - /// Patch the . + /// Patch the . /// Adds the event. /// [EventPatch(typeof(Player), nameof(Player.DamagingDoor))] diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs b/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs index 3966f55c3..828bfc4d3 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs @@ -32,8 +32,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj) + offset; + int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldloc_0); newInstructions.InsertRange( index, diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs index be16ad190..dc8d8b40c 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingAndEscaped.cs @@ -40,7 +40,6 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - List [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.InteractingElevator))] diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Joined.cs b/EXILED/Exiled.Events/Patches/Events/Player/Joined.cs index 380ff77b4..75fc346a8 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Joined.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Joined.cs @@ -39,7 +39,7 @@ internal static void CallEvent(ReferenceHub hub, out Player player) #endif Player.UnverifiedPlayers.Add(hub.gameObject, player); - if (ReferenceHub.HostHub == null) + if (ReferenceHub._hostHub == null) { Server.Host = player; } diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs b/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs index ca42451f5..3c779e704 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs @@ -24,13 +24,15 @@ namespace Exiled.Events.Patches.Events.Player using static HarmonyLib.AccessTools; /// - /// Patches . + /// Patches . /// Adds the events. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Shooting))] - [HarmonyPatch(typeof(FirearmBasicMessagesHandler), nameof(FirearmBasicMessagesHandler.ServerShotReceived))] + + // [HarmonyPatch(typeof(FirearmBasicMessagesHandler), nameof(FirearmBasicMessagesHandler.ServerShotReceived))] internal static class Shooting { + /* private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); @@ -85,5 +87,6 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } + */ } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs b/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs index 5da946087..dc9b0ba03 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs @@ -5,8 +5,6 @@ // // ----------------------------------------------------------------------- -using System; - namespace Exiled.Events.Patches.Events.Player { #pragma warning disable SA1402 // File may only contain a single type diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs b/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs index a0f5c3147..e5ea08d1f 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs @@ -23,7 +23,7 @@ namespace Exiled.Events.Patches.Events.Player using static HarmonyLib.AccessTools; /// - /// Patches delegate. + /// Patches delegate. /// Adds the event. /// Fix for spawning in void. /// diff --git a/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs b/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs index 8732772db..2f9651160 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs @@ -72,7 +72,8 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.operand == (object)PropertySetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.StalkActive))) + offset; newInstructions.InsertRange( - index, + newInstructions.Count - 1, new CodeInstruction[] { // Player.Get(this.Owner); diff --git a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs index 35ee37384..385a98155 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs @@ -24,7 +24,7 @@ namespace Exiled.Events.Patches.Events.Scp914 using Scp914 = Handlers.Scp914; /// - /// Patches + /// Patches /// to add the and event. /// [EventPatch(typeof(Scp914), nameof(Scp914.UpgradingPlayer))] diff --git a/EXILED/Exiled.Events/Patches/Events/Server/SelectingRespawnTeam.cs b/EXILED/Exiled.Events/Patches/Events/Server/SelectingRespawnTeam.cs index 8e95b2c56..b416a51f6 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/SelectingRespawnTeam.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/SelectingRespawnTeam.cs @@ -24,10 +24,11 @@ namespace Exiled.Events.Patches.Events.Server using static HarmonyLib.AccessTools; /// - /// Patches to add the event. + /// Patches to add the event. /// [EventPatch(typeof(Handlers.Server), nameof(Handlers.Server.SelectingRespawnTeam))] - [HarmonyPatch(typeof(RespawnManager), nameof(RespawnManager.Update))] + + // [HarmonyPatch(typeof(WaveManager), nameof(RespawnManager.Update))] TODO Idk which method to patch internal static class SelectingRespawnTeam { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/EXILED/Exiled.Events/Patches/Fixes/ArmorDropPatch.cs b/EXILED/Exiled.Events/Patches/Fixes/ArmorDropPatch.cs index be35fc38e..0ed2949c6 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/ArmorDropPatch.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/ArmorDropPatch.cs @@ -21,7 +21,7 @@ namespace Exiled.Events.Patches.Fixes /// /// Patches to fix https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/230 bug. /// - [HarmonyPatch(typeof(BodyArmorUtils), nameof(BodyArmorUtils.RemoveEverythingExceedingLimits))] + [HarmonyPatch(typeof(BodyArmorUtils), nameof(BodyArmorUtils.RemoveEverythingExceedingLimits), typeof(Inventory), typeof(BodyArmor), typeof(bool), typeof(bool))] internal static class ArmorDropPatch { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/EXILED/Exiled.Events/Patches/Fixes/FixOnAddedBeingCallAfterOnRemoved.cs b/EXILED/Exiled.Events/Patches/Fixes/FixOnAddedBeingCallAfterOnRemoved.cs index 9f5b19c0b..571b9350a 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/FixOnAddedBeingCallAfterOnRemoved.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/FixOnAddedBeingCallAfterOnRemoved.cs @@ -21,7 +21,7 @@ namespace Exiled.Events.Patches.Fixes using static HarmonyLib.AccessTools; /// - /// Patches . + /// Patches . /// Fix than NW call before for AmmoItem. /// [HarmonyPatch(typeof(InventoryExtensions), nameof(InventoryExtensions.ServerAddItem))] diff --git a/EXILED/Exiled.Events/Patches/Fixes/FixPickupPreviousOwner.cs b/EXILED/Exiled.Events/Patches/Fixes/FixPickupPreviousOwner.cs index d555c8f51..24d743e6e 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/FixPickupPreviousOwner.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/FixPickupPreviousOwner.cs @@ -37,7 +37,7 @@ private static IEnumerable Transpiler(IEnumerable Math.Abs(d.TimeToDetonate - ConfigFile.ServerConfig.GetInt("warhead_tminus_start_duration", 90))).First()); + networkInfo.ScenarioId = (byte)Array.IndexOf(AlphaWarheadController.Singleton._startScenarios, AlphaWarheadController.Singleton._startScenarios.OrderBy(d => Math.Abs(d.TimeToDetonate - ConfigFile.ServerConfig.GetInt("warhead_tminus_start_duration", 90))).First()); AlphaWarheadController.Singleton.NetworkInfo = networkInfo; return; diff --git a/EXILED/Exiled.Events/Patches/Fixes/NWFixScp096BreakingDoor.cs b/EXILED/Exiled.Events/Patches/Fixes/NWFixScp096BreakingDoor.cs index 8360e824c..5a9f29b9a 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/NWFixScp096BreakingDoor.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/NWFixScp096BreakingDoor.cs @@ -5,14 +5,13 @@ // // ----------------------------------------------------------------------- -using Footprinting; - namespace Exiled.Events.Patches.Fixes { using System.Collections.Generic; using System.Reflection.Emit; using API.Features.Pools; + using Footprinting; using HarmonyLib; using Interactables.Interobjects; using Interactables.Interobjects.DoorUtils; @@ -34,7 +33,7 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); Label ret = generator.DefineLabel(); - int offset = -4; + int offset = -5; int index = newInstructions.FindIndex(x => x.operand == (object)Method(typeof(IDamageableDoor), nameof(IDamageableDoor.ServerDamage))) + offset; newInstructions.InsertRange(index, new[] diff --git a/EXILED/Exiled.Events/Patches/Generic/PickupControlPatch.cs b/EXILED/Exiled.Events/Patches/Generic/PickupControlPatch.cs index 86b6835cb..a1c98e0a7 100644 --- a/EXILED/Exiled.Events/Patches/Generic/PickupControlPatch.cs +++ b/EXILED/Exiled.Events/Patches/Generic/PickupControlPatch.cs @@ -31,7 +31,7 @@ namespace Exiled.Events.Patches.Generic #pragma warning disable SA1402 /// File may only contain a single type. /// - /// Patches to save scale for pickups and control property. + /// Patches to save scale for pickups and control property. /// [HarmonyPatch(typeof(InventoryExtensions), nameof(InventoryExtensions.ServerCreatePickup), typeof(ItemBase), typeof(PickupSyncInfo), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(Action))] internal static class PickupControlPatch diff --git a/EXILED/Exiled.Example/Events/PlayerHandler.cs b/EXILED/Exiled.Example/Events/PlayerHandler.cs index 235868706..9f37aecb1 100644 --- a/EXILED/Exiled.Example/Events/PlayerHandler.cs +++ b/EXILED/Exiled.Example/Events/PlayerHandler.cs @@ -157,7 +157,8 @@ public void OnUsingItem(UsingItemEventArgs ev) /// public void OnShooting(ShootingEventArgs ev) { - Log.Info($"{ev.Player.Nickname} is shooting a {ev.Player.CurrentItem.Type}! Target Pos: {ev.ShotPosition} Target object ID: {ev.TargetNetId} Allowed: {ev.IsAllowed}"); + // Log.Info($"{ev.Player.Nickname} is shooting a {ev.Player.CurrentItem.Type}! Target Pos: {ev.ShotPosition} Target object ID: {ev.TargetNetId} Allowed: {ev.IsAllowed}"); + // TODO we need to fix this cuz... we need to fix it } /// From 2d12d9838838ba323a30160b8e2f04f82e82a81c Mon Sep 17 00:00:00 2001 From: VALERA771 <72030575+VALERA771@users.noreply.github.com> Date: Tue, 26 Nov 2024 23:02:06 +0300 Subject: [PATCH 008/102] v9.0.0-alpha.1 --- EXILED/EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/EXILED.props b/EXILED/EXILED.props index 62d6e57cd..8e0f7c3a0 100644 --- a/EXILED/EXILED.props +++ b/EXILED/EXILED.props @@ -15,7 +15,7 @@ - 8.14.1 + 9.0.0-alpha.1 false From dc296693bc36dead714774ebaa46047226e70fde Mon Sep 17 00:00:00 2001 From: VALERA771 Date: Tue, 26 Nov 2024 23:43:19 +0300 Subject: [PATCH 009/102] ooops --- EXILED/Exiled.API/Enums/DoorType.cs | 2 +- EXILED/Exiled.API/Enums/RespawnEffectType.cs | 2 -- EXILED/Exiled.API/Features/Items/Firearm.cs | 10 ++------- .../Exiled.API/Features/Items/Flashlight.cs | 1 - EXILED/Exiled.API/Features/Npc.cs | 8 ++++++- EXILED/Exiled.API/Features/Pickups/Pickup.cs | 2 +- .../Pickups/Projectiles/Projectile.cs | 4 ++-- .../Pickups/Projectiles/Scp018Projectile.cs | 2 +- EXILED/Exiled.API/Features/Respawn.cs | 22 ++++++++++++++++--- 9 files changed, 33 insertions(+), 20 deletions(-) diff --git a/EXILED/Exiled.API/Enums/DoorType.cs b/EXILED/Exiled.API/Enums/DoorType.cs index 745557a6a..e8d6b7fed 100644 --- a/EXILED/Exiled.API/Enums/DoorType.cs +++ b/EXILED/Exiled.API/Enums/DoorType.cs @@ -268,7 +268,7 @@ public enum DoorType ElevatorGateB, /// - /// Represents the Elevator door for . + /// Represents the Elevator door for . /// ElevatorNuke, diff --git a/EXILED/Exiled.API/Enums/RespawnEffectType.cs b/EXILED/Exiled.API/Enums/RespawnEffectType.cs index d26f7be26..672abb197 100644 --- a/EXILED/Exiled.API/Enums/RespawnEffectType.cs +++ b/EXILED/Exiled.API/Enums/RespawnEffectType.cs @@ -14,8 +14,6 @@ namespace Exiled.API.Enums /// /// Layers game respawn effects. /// - /// - /// public enum RespawnEffectType { /// diff --git a/EXILED/Exiled.API/Features/Items/Firearm.cs b/EXILED/Exiled.API/Features/Items/Firearm.cs index 0ec5a6493..554ccc3c6 100644 --- a/EXILED/Exiled.API/Features/Items/Firearm.cs +++ b/EXILED/Exiled.API/Features/Items/Firearm.cs @@ -5,8 +5,6 @@ // // ----------------------------------------------------------------------- -using MEC; - namespace Exiled.API.Features.Items { using System; @@ -14,15 +12,11 @@ namespace Exiled.API.Features.Items using System.Linq; using CameraShaking; - using Enums; - using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; using Exiled.API.Structs; - using Extensions; - using InventorySystem; using InventorySystem.Items; using InventorySystem.Items.Firearms; @@ -31,7 +25,7 @@ namespace Exiled.API.Features.Items using InventorySystem.Items.Firearms.BasicMessages; using InventorySystem.Items.Firearms.Modules; using InventorySystem.Items.Pickups; - + using MEC; using UnityEngine; using BaseFirearm = InventorySystem.Items.Firearms.Firearm; @@ -139,7 +133,6 @@ public int MaxAmmo /// public AmmoType AmmoType => (Base.Modules.OfType().FirstOrDefault()?.AmmoType ?? ItemType.None).GetAmmoType(); - /// /// Gets a value indicating whether the firearm is being aimed. /// @@ -660,6 +653,7 @@ internal override void ChangeOwner(Player oldOwner, Player newOwner) Base._footprintCacheSet = false; } + /// internal override void ReadPickupInfo(Pickup pickup) { base.ReadPickupInfo(pickup); diff --git a/EXILED/Exiled.API/Features/Items/Flashlight.cs b/EXILED/Exiled.API/Features/Items/Flashlight.cs index 0e9de906b..93a3876ca 100644 --- a/EXILED/Exiled.API/Features/Items/Flashlight.cs +++ b/EXILED/Exiled.API/Features/Items/Flashlight.cs @@ -45,7 +45,6 @@ internal Flashlight(ItemType type) /// Can be or . public new ToggleableLightItemBase Base { get; } - /// /// Gets or sets a value indicating whether the item is emitting light. /// diff --git a/EXILED/Exiled.API/Features/Npc.cs b/EXILED/Exiled.API/Features/Npc.cs index d31b0b530..d7d7d6d78 100644 --- a/EXILED/Exiled.API/Features/Npc.cs +++ b/EXILED/Exiled.API/Features/Npc.cs @@ -133,7 +133,13 @@ public override Vector3 Position /// The NPC associated with the NetworkConnection, or null if not found. public static new Npc? Get(NetworkConnection conn) => Player.Get(conn) as Npc; - // TODO: Write docs. + /// + /// Docs. + /// + /// Docs1. + /// Docs2. + /// Docs3. + /// Docs4. public static Npc Create(string name, RoleTypeId role, Vector3 position) { // TODO: Test this. diff --git a/EXILED/Exiled.API/Features/Pickups/Pickup.cs b/EXILED/Exiled.API/Features/Pickups/Pickup.cs index 286e7cf7b..2deb4f484 100644 --- a/EXILED/Exiled.API/Features/Pickups/Pickup.cs +++ b/EXILED/Exiled.API/Features/Pickups/Pickup.cs @@ -128,7 +128,7 @@ internal Pickup(ItemType type) public Room Room => Room.FindParentRoom(GameObject); /// - /// Gets or sets the pickup's PhysicsModule. + /// Gets the pickup's PhysicsModule. /// public PickupStandardPhysics PhysicsModule => Base.PhysicsModule as PickupStandardPhysics; diff --git a/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs b/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs index 7abab57d6..fa78c214e 100644 --- a/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs +++ b/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs @@ -122,7 +122,7 @@ public static Projectile Create(ProjectileType projectiletype) /// The rotation to spawn the . /// Whether the should be in active state after spawn. /// An optional previous owner of the item. - /// The . See documentation of for more information on casting. + /// The . See documentation of for more information on casting. public static Projectile CreateAndSpawn(ProjectileType type, Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) => Create(type).Spawn(position, rotation, shouldBeActive, previousOwner); /// @@ -134,7 +134,7 @@ public static Projectile Create(ProjectileType projectiletype) /// Whether the should be in active state after spawn. /// An optional previous owner of the item. /// The specified type. - /// The . See documentation of for more information on casting. + /// The . See documentation of for more information on casting. public static Projectile CreateAndSpawn(ProjectileType type, Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) where T : Projectile => CreateAndSpawn(type, position, rotation, shouldBeActive, previousOwner) as T; diff --git a/EXILED/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs b/EXILED/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs index 6bb476370..f33d935a9 100644 --- a/EXILED/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs +++ b/EXILED/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs @@ -50,7 +50,7 @@ internal Scp018Projectile() public new BaseScp018Projectile Base { get; } /// - /// Gets or sets the pickup's PhysicsModule. + /// Gets the pickup's PhysicsModule. /// public new Scp018Physics PhysicsModule => Base.PhysicsModule as Scp018Physics; diff --git a/EXILED/Exiled.API/Features/Respawn.cs b/EXILED/Exiled.API/Features/Respawn.cs index 1f3774f43..d43ac4e1a 100644 --- a/EXILED/Exiled.API/Features/Respawn.cs +++ b/EXILED/Exiled.API/Features/Respawn.cs @@ -181,13 +181,25 @@ public static bool TryGetWaveBase(SpawnableFaction faction, out SpawnableWaveBas return false; } - // TODO: Docs. + /// + /// Docs. + /// + /// Docs1. + /// Docs2. public static void AdvanceTime(Faction faction, float time) => WaveManager.AdvanceTimer(faction, time); - // TODO: Docs. + /// + /// Docs. + /// + /// Docs1. public static void SpawnWave(SpawnableWaveBase wave) => WaveManager.Spawn(wave); - // TODO: Docs. + /// + /// Docs. + /// + /// Docs1. + /// Docs2. + /// Docs3. public static void SpawnWave(Faction faction, bool mini) where T : SpawnableWaveBase { @@ -278,6 +290,10 @@ public static void ForceWave(Faction team) ForceWave(wave); } + /// + /// Docs. + /// + /// Docs1. public static void ForceWave(SpawnableWaveBase wave) { WaveManager.Spawn(wave); From 17ee6da7671843f4d1b9382907a8bafa18abc4b6 Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 26 Nov 2024 22:27:43 +0100 Subject: [PATCH 010/102] Debug --- EXILED/Exiled.API/Features/Camera.cs | 2 +- EXILED/Exiled.API/Features/Doors/Door.cs | 2 +- EXILED/Exiled.API/Features/Room.cs | 4 ++-- EXILED/Exiled.API/Features/Window.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/EXILED/Exiled.API/Features/Camera.cs b/EXILED/Exiled.API/Features/Camera.cs index 5db5dd28f..300a73193 100644 --- a/EXILED/Exiled.API/Features/Camera.cs +++ b/EXILED/Exiled.API/Features/Camera.cs @@ -137,7 +137,7 @@ internal Camera(Scp079Camera camera079) Base = camera079; Camera079ToCamera.Add(camera079, this); Type = GetCameraType(); -#if Debug +#if DEBUG if (Type is CameraType.Unknown) Log.Error($"[CAMERATYPE UNKNOWN] {this}"); #endif diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index 315142c53..262e90f09 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -59,7 +59,7 @@ internal Door(DoorVariant door, List rooms) } Type = GetDoorType(); -#if Debug +#if DEBUG if (Type is DoorType.Unknown) Log.Error($"[DOORTYPE UNKNOWN] {this}"); #endif diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index fafb1d418..04de1ba04 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -493,12 +493,12 @@ private void InternalCreate() RoomIdentifierToRoom.Add(Identifier, this); Zone = FindZone(gameObject); -#if Debug +#if DEBUG if (Type is RoomType.Unknown) Log.Error($"[ZONETYPE UNKNOWN] {this}"); #endif Type = FindType(gameObject); -#if Debug +#if DEBUG if (Type is RoomType.Unknown) Log.Error($"[ROOMTYPE UNKNOWN] {this}"); #endif diff --git a/EXILED/Exiled.API/Features/Window.cs b/EXILED/Exiled.API/Features/Window.cs index 2b3582567..001d05dc5 100644 --- a/EXILED/Exiled.API/Features/Window.cs +++ b/EXILED/Exiled.API/Features/Window.cs @@ -38,7 +38,7 @@ internal Window(BreakableWindow window, Room room) Base = window; Room = room; Type = GetGlassType(); -#if Debug +#if DEBUG if (Type is GlassType.Unknown) Log.Error($"[GLASSTYPE UNKNOWN] {this}"); #endif From d7c3e6b7d79f5e234dec70750a776cd67b197c6c Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 26 Nov 2024 22:28:12 +0100 Subject: [PATCH 011/102] Fix --- EXILED/Exiled.API/Features/Doors/Door.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index 262e90f09..bac0fe322 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -60,7 +60,7 @@ internal Door(DoorVariant door, List rooms) Type = GetDoorType(); #if DEBUG - if (Type is DoorType.Unknown) + if (Type is DoorType.UnknownDoor or DoorType.UnknownGate or DoorType.UnknownElevator) Log.Error($"[DOORTYPE UNKNOWN] {this}"); #endif } From f95c3dc52d44ef6167572d9914b36f12f1fc0fe3 Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 26 Nov 2024 23:33:13 +0100 Subject: [PATCH 012/102] More API Stuff --- EXILED/Exiled.API/Enums/CameraType.cs | 11 +++++++++++ EXILED/Exiled.API/Enums/DamageType.cs | 5 +++++ .../Exiled.API/Extensions/DamageTypeExtensions.cs | 1 + EXILED/Exiled.API/Features/Camera.cs | 13 +++++++++++++ 4 files changed, 30 insertions(+) diff --git a/EXILED/Exiled.API/Enums/CameraType.cs b/EXILED/Exiled.API/Enums/CameraType.cs index 26685fa8e..f5e0c7e47 100644 --- a/EXILED/Exiled.API/Enums/CameraType.cs +++ b/EXILED/Exiled.API/Enums/CameraType.cs @@ -124,6 +124,17 @@ public enum CameraType Hcz173ContChamber, Hcz173Hallway, HczCurve, + HczJunkMain, + HczJunkHallway, + HczCornerDeep, + HczDSS08, + HczMicroHIDStairs, + HczPipesHallway, + HczWarheadStarboardElevator, + HczMicroHIDMain, + HczWarheadTopElevators, + HczWarheadConnector, + HczWarheadPortElevator, #endregion } } diff --git a/EXILED/Exiled.API/Enums/DamageType.cs b/EXILED/Exiled.API/Enums/DamageType.cs index f9d1617f6..fd4916f56 100644 --- a/EXILED/Exiled.API/Enums/DamageType.cs +++ b/EXILED/Exiled.API/Enums/DamageType.cs @@ -249,5 +249,10 @@ public enum DamageType /// Damage caused by the marshmallow man. /// Marshmallow, + + /// + /// Damage caused by . + /// + Scp1344, } } diff --git a/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs b/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs index aba321a8d..a225cbab6 100644 --- a/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs +++ b/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs @@ -80,6 +80,7 @@ public static class DamageTypeExtensions { DeathTranslations.MicroHID, DamageType.MicroHid }, { DeathTranslations.Hypothermia, DamageType.Hypothermia }, { DeathTranslations.MarshmallowMan, DamageType.Marshmallow }, + { DeathTranslations.Scp1344, DamageType.Scp1344 }, }; private static readonly Dictionary ItemConversionInternal = new() diff --git a/EXILED/Exiled.API/Features/Camera.cs b/EXILED/Exiled.API/Features/Camera.cs index 300a73193..989bff634 100644 --- a/EXILED/Exiled.API/Features/Camera.cs +++ b/EXILED/Exiled.API/Features/Camera.cs @@ -124,6 +124,19 @@ public class Camera : IWrapper, IWorldSpace ["SURFACE AIRLOCK"] = CameraType.SurfaceAirlock, ["SURFACE BRIDGE"] = CameraType.SurfaceBridge, ["TUNNEL ENTRANCE"] = CameraType.TunnelEntrance, + + // new + ["JUNK MAIN"] = CameraType.HczJunkMain, + ["JUNK HALLWAY"] = CameraType.HczJunkHallway, + ["CORNER DEEP"] = CameraType.HczCornerDeep, + ["DSS-08"] = CameraType.HczDSS08, + ["MICROHID STAIRS"] = CameraType.HczMicroHIDStairs, + ["PIPES HALLWAY"] = CameraType.HczPipesHallway, + ["WARHEAD STARBOARD ELEVATOR"] = CameraType.HczWarheadStarboardElevator, + ["MICROHID MAIN"] = CameraType.HczMicroHIDMain, + ["WARHEAD TOP ELEVATORS"] = CameraType.HczWarheadTopElevators, + ["WARHEAD CONNECTOR"] = CameraType.HczWarheadConnector, + ["WARHEAD PORT ELEVATOR"] = CameraType.HczWarheadPortElevator, }; private Room room; From 31072203b71aff23e7140e3851f0337873c3f5ca Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 26 Nov 2024 23:51:02 +0100 Subject: [PATCH 013/102] Updating API --- EXILED/Exiled.API/Enums/CameraType.cs | 2 ++ EXILED/Exiled.API/Enums/DoorType.cs | 17 +++++++++++------ EXILED/Exiled.API/Features/Camera.cs | 2 ++ EXILED/Exiled.API/Features/Doors/Door.cs | 7 ++++--- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/EXILED/Exiled.API/Enums/CameraType.cs b/EXILED/Exiled.API/Enums/CameraType.cs index f5e0c7e47..3da1f461e 100644 --- a/EXILED/Exiled.API/Enums/CameraType.cs +++ b/EXILED/Exiled.API/Enums/CameraType.cs @@ -135,6 +135,8 @@ public enum CameraType HczWarheadTopElevators, HczWarheadConnector, HczWarheadPortElevator, + HczMicroHIDLab, + HczPipesMain, #endregion } } diff --git a/EXILED/Exiled.API/Enums/DoorType.cs b/EXILED/Exiled.API/Enums/DoorType.cs index e8d6b7fed..b7150ae03 100644 --- a/EXILED/Exiled.API/Enums/DoorType.cs +++ b/EXILED/Exiled.API/Enums/DoorType.cs @@ -158,19 +158,19 @@ public enum DoorType HeavyContainmentDoor, /// - /// Represents the HID door. + /// Represents the HID_CHAMBER door. /// - HID, + HIDChamber, /// - /// Represents the HID_LEFT door. + /// Represents the HID_UPPER door. /// - HIDLeft, + HIDUpper, /// - /// Represents the HID_RIGHT door. + /// Represents the HID_LOWER door. /// - HIDRight, + HIDLower, /// /// Represents the INTERCOM door. @@ -306,5 +306,10 @@ public enum DoorType /// Represents the New Gate where Scp173 spawn in the . /// Scp173NewGate, + + /// + /// Represents the ESCAPE_FINAL door. + /// + EscapeFinal, } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Camera.cs b/EXILED/Exiled.API/Features/Camera.cs index 989bff634..29afdac44 100644 --- a/EXILED/Exiled.API/Features/Camera.cs +++ b/EXILED/Exiled.API/Features/Camera.cs @@ -132,8 +132,10 @@ public class Camera : IWrapper, IWorldSpace ["DSS-08"] = CameraType.HczDSS08, ["MICROHID STAIRS"] = CameraType.HczMicroHIDStairs, ["PIPES HALLWAY"] = CameraType.HczPipesHallway, + ["PIPES MAIN"] = CameraType.HczPipesMain, ["WARHEAD STARBOARD ELEVATOR"] = CameraType.HczWarheadStarboardElevator, ["MICROHID MAIN"] = CameraType.HczMicroHIDMain, + ["MICROHID LAB"] = CameraType.HczMicroHIDLab, ["WARHEAD TOP ELEVATORS"] = CameraType.HczWarheadTopElevators, ["WARHEAD CONNECTOR"] = CameraType.HczWarheadConnector, ["WARHEAD PORT ELEVATOR"] = CameraType.HczWarheadPortElevator, diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index bac0fe322..d77dda83b 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -641,7 +641,7 @@ private DoorType GetDoorType() "NUKE_ARMORY" => DoorType.NukeArmory, "LCZ_ARMORY" => DoorType.LczArmory, "SURFACE_NUKE" => DoorType.NukeSurface, - "HID" => DoorType.HID, + "HID_CHAMBER" => DoorType.HIDChamber, "HCZ_ARMORY" => DoorType.HczArmory, "096" => DoorType.Scp096, "049_ARMORY" => DoorType.Scp049Armory, @@ -654,8 +654,8 @@ private DoorType GetDoorType() "SERVERS_BOTTOM" => DoorType.ServersBottom, "173_CONNECTOR" => DoorType.Scp173Connector, "LCZ_WC" => DoorType.LczWc, - "HID_RIGHT" => DoorType.HIDRight, - "HID_LEFT" => DoorType.HIDLeft, + "HID_UPPER" => DoorType.HIDUpper, + "HID_LOWER" => DoorType.HIDLower, "173_ARMORY" => DoorType.Scp173Armory, "173_GATE" => DoorType.Scp173Gate, "GR18" => DoorType.GR18Gate, @@ -664,6 +664,7 @@ private DoorType GetDoorType() "330_CHAMBER" => DoorType.Scp330Chamber, "GR18_INNER" => DoorType.GR18Inner, "939_CRYO" => DoorType.Scp939Cryo, + "ESCAPE_FINAL" => DoorType.EscapeFinal, // Doors spawned by the DoorSpawnPoint component "LCZ_CAFE" => DoorType.LczCafe, From bd1994763fc7f1f9ea29354400f3708f5c2013e5 Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 26 Nov 2024 23:52:40 +0100 Subject: [PATCH 014/102] RoomType --- EXILED/Exiled.API/Enums/RoomType.cs | 5 +++++ EXILED/Exiled.API/Features/Room.cs | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.API/Enums/RoomType.cs b/EXILED/Exiled.API/Enums/RoomType.cs index 370bac2af..78d16befb 100644 --- a/EXILED/Exiled.API/Enums/RoomType.cs +++ b/EXILED/Exiled.API/Enums/RoomType.cs @@ -283,5 +283,10 @@ public enum RoomType /// Heavy Containment Elevator Zone's System B room. /// HczElevatorB, + + /// + /// Lazy TODO. + /// + HczCrossRoomWater, } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index 04de1ba04..31f62adbe 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -429,19 +429,20 @@ private static RoomType FindType(GameObject gameObject) "LCZ_372" => RoomType.LczGlassBox, "LCZ_ChkpA" => RoomType.LczCheckpointA, "HCZ_079" => RoomType.Hcz079, - "HCZ_Room3ar" => RoomType.HczArmory, + "HCZ_TArmory" => RoomType.HczArmory, "HCZ_Testroom" => RoomType.HczTestRoom, "HCZ_Hid" => RoomType.HczHid, "HCZ_049" => RoomType.Hcz049, "HCZ_Crossing" => RoomType.HczCrossing, "HCZ_106" => RoomType.Hcz106, "HCZ_Nuke" => RoomType.HczNuke, - "HCZ_Tesla" => RoomType.HczTesla, + "HCZ_Tesla_Rework" => RoomType.HczTesla, "HCZ_Servers" => RoomType.HczServers, "HCZ_Room3" => RoomType.HczTCross, "HCZ_457" => RoomType.Hcz096, "HCZ_Curve" => RoomType.HczCurve, "HCZ_Straight" => RoomType.HczStraight, + "HCZ_Crossroom_Water" => RoomType.HczCrossRoomWater, "EZ_Endoof" => RoomType.EzVent, "EZ_Intercom" => RoomType.EzIntercom, "EZ_GateA" => RoomType.EzGateA, From cee097e9c06dc2ac1efacf47bee2dde528e21170 Mon Sep 17 00:00:00 2001 From: Yamato Date: Tue, 26 Nov 2024 23:58:26 +0100 Subject: [PATCH 015/102] oupsy --- EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs b/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs index a225cbab6..14daacc0a 100644 --- a/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs +++ b/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs @@ -49,6 +49,7 @@ public static class DamageTypeExtensions { DeathTranslations.MicroHID.Id, DamageType.MicroHid }, { DeathTranslations.Hypothermia.Id, DamageType.Hypothermia }, { DeathTranslations.MarshmallowMan.Id, DamageType.Marshmallow }, + { DeathTranslations.Scp1344.Id, DamageType.Scp1344 }, }; private static readonly Dictionary TranslationConversionInternal = new() From 71cf637ea6c3921cc0408af9a14235950910cd66 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Tue, 26 Nov 2024 20:46:34 -0500 Subject: [PATCH 016/102] Master to Exiled 9 (#208) * Delete .github/dependabot.yml * Update push_nuget.yml * Update dev.yml --- .github/dependabot.yml | 11 ----------- .github/workflows/dev.yml | 2 ++ .github/workflows/push_nuget.yml | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) delete mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 4d67329a6..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,11 +0,0 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file - -version: 2 -updates: - - package-ecosystem: "nuget" # See documentation for possible values - directory: "./EXILED" # Location of package manifests - schedule: - interval: "weekly" diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 16ff4dafa..7ee77d48a 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -4,9 +4,11 @@ on: push: branches: - dev + - scpsl14 pull_request: branches: - dev + - scpsl14 workflow_dispatch: defaults: diff --git a/.github/workflows/push_nuget.yml b/.github/workflows/push_nuget.yml index 87acc59b8..5150b0c7e 100644 --- a/.github/workflows/push_nuget.yml +++ b/.github/workflows/push_nuget.yml @@ -10,7 +10,7 @@ defaults: working-directory: ./EXILED env: - EXILED_REFERENCES_URL: https://ExMod-Team.github.io/SL-References/Master.zip + EXILED_REFERENCES_URL: https://ExMod-Team.github.io/SL-References/Dev.zip EXILED_REFERENCES_PATH: ${{ github.workspace }}/EXILED/References jobs: From ed8a22efed8a5ddabab092f6b7074f115987d1a0 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Tue, 26 Nov 2024 22:43:54 -0500 Subject: [PATCH 017/102] Patch fix 1 (#225) PositionSpawnScp0492Fix patch #223 Scp3114FriendlyFireFix #224 --- .gitignore | 5 +- .../Patches/Fixes/PositionSpawnScp0492Fix.cs | 56 -------- .../Patches/Fixes/Scp3114FriendlyFireFix.cs | 125 ------------------ 3 files changed, 4 insertions(+), 182 deletions(-) diff --git a/.gitignore b/.gitignore index ecdece2bb..958e3428c 100644 --- a/.gitignore +++ b/.gitignore @@ -373,4 +373,7 @@ NuGet.config _site/ # JSON Schemas -JSON/ \ No newline at end of file +JSON/ + +# Mac DS_Store +.DS_Store \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Fixes/PositionSpawnScp0492Fix.cs b/EXILED/Exiled.Events/Patches/Fixes/PositionSpawnScp0492Fix.cs index def76276e..e69de29bb 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/PositionSpawnScp0492Fix.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/PositionSpawnScp0492Fix.cs @@ -1,56 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.Patches.Fixes -{ - using System.Collections.Generic; - using System.Reflection.Emit; - - using API.Features; - using API.Features.Pools; - using Exiled.Events.EventArgs.Player; - - using HarmonyLib; - - using PlayerRoles.PlayableScps.Scp049; - - using UnityEngine; - - using static HarmonyLib.AccessTools; - - /// - /// Patches delegate. - /// Removes useless position setter for Scp0492. - /// - [HarmonyPatch(typeof(Scp049ResurrectAbility), nameof(Scp049ResurrectAbility.ServerComplete))] - internal static class PositionSpawnScp0492Fix - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - Label continueLabel = generator.DefineLabel(); - - LocalBuilder player = generator.DeclareLocal(typeof(Player)); - LocalBuilder eventArgs = generator.DeclareLocal(typeof(SpawningEventArgs)); - - const int toRemove = 7; - - const int offset = -1; - int index = newInstructions.FindLastIndex(instruction => instruction.Calls(PropertyGetter(typeof(Component), nameof(Component.transform)))) + offset; - - newInstructions[index + toRemove].MoveLabelsFrom(newInstructions[index]); - - newInstructions.RemoveRange(index, toRemove); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } -} diff --git a/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs b/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs index 79aba61f5..e69de29bb 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs @@ -1,125 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.Patches.Fixes -{ -#pragma warning disable SA1402 // File may only contain a single type - using System.Collections.Generic; - using System.Reflection.Emit; - - using API.Features.Pools; - - using Exiled.API.Features; - - using Footprinting; - using HarmonyLib; - using InventorySystem.Items.Pickups; - using InventorySystem.Items.ThrowableProjectiles; - using PlayerRoles; - using PlayerStatsSystem; - - using static HarmonyLib.AccessTools; - - /// - /// Patches the delegate. - /// Fix Throwing a ghostlight with Scp in the room stun 079. - /// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/55). - /// - [HarmonyPatch(typeof(Scp2176Projectile), nameof(Scp2176Projectile.ServerShatter))] - internal class Scp3114FriendlyFireFix - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - Label cnt = generator.DefineLabel(); - - int offset = 0; - int index = newInstructions.FindIndex(x => x.LoadsField(Field(typeof(RoomLightController), nameof(RoomLightController.Instances)))) + offset; - - Label skip = newInstructions[index].labels[0]; - - offset = -3; - index += offset; - - newInstructions.InsertRange(index, new[] - { - // if (this.PreviousOwner.Role.GetTeam() is Team.SCPs) - new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Ldfld, Field(typeof(Scp2176Projectile), nameof(Scp2176Projectile.PreviousOwner))), - new(OpCodes.Ldfld, Field(typeof(Footprint), nameof(Footprint.Role))), - new(OpCodes.Call, Method(typeof(PlayerRolesUtils), nameof(PlayerRolesUtils.GetTeam), new[] { typeof(RoleTypeId) })), - new(OpCodes.Ldc_I4_0), - new(OpCodes.Ceq), - - new(OpCodes.Brfalse_S, cnt), - - new(OpCodes.Pop), - new(OpCodes.Br_S, skip), - - new CodeInstruction(OpCodes.Nop).WithLabels(cnt), - }); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } - - /// - /// Patches the delegate. - /// Fix Throwing a ghostlight with Scp in the room stun 079. - /// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/55). - /// - [HarmonyPatch(typeof(CollisionDetectionPickup), nameof(CollisionDetectionPickup.ProcessCollision))] - internal class Scp3114FriendlyFireFix2 : AttackerDamageHandler - { -#pragma warning disable SA1600 // Elements should be documented - public Scp3114FriendlyFireFix2(Footprint attacker, float damage) - { - Attacker = attacker; - Damage = damage; - AllowSelfDamage = false; - ServerLogsText = "Scp3114 Fix"; - } - - public override Footprint Attacker { get; set; } - - public override bool AllowSelfDamage { get; } - - public override float Damage { get; set; } - - public override string ServerLogsText { get; } - -#pragma warning restore SA1600 // Elements should be documented - - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - int offset = 0; - int index = newInstructions.FindLastIndex(x => x.opcode == OpCodes.Ldnull) + offset; - - // replace null with new Scp3114FriendlyFireFix2(this.PreviousOwner, num2) - newInstructions.RemoveAt(index); - newInstructions.InsertRange(index, new CodeInstruction[] - { - // new Scp3114FriendlyFireFix2(this.PreviousOwner, num2) - new(OpCodes.Ldarg_0), - new(OpCodes.Ldfld, Field(typeof(CollisionDetectionPickup), nameof(CollisionDetectionPickup.PreviousOwner))), - new(OpCodes.Ldloc_3), - new(OpCodes.Newobj, GetDeclaredConstructors(typeof(Scp3114FriendlyFireFix2))[0]), - }); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } -} From ffaf2ede78595d2ce1780a9336f31dafd84709a3 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Wed, 27 Nov 2024 00:55:11 -0500 Subject: [PATCH 018/102] Fix EnteringKillerCollision.cs (#228) --- .../Patches/Events/Player/EnteringKillerCollision.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs b/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs index 828bfc4d3..59259d210 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/EnteringKillerCollision.cs @@ -32,7 +32,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Ldloc_0); + int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldarg_0); newInstructions.InsertRange( index, From 3e3e66137b80ab81b05845c67cdf26e715467747 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Wed, 27 Nov 2024 01:38:20 -0500 Subject: [PATCH 019/102] Fix PlacingBulletHole (#229) * Fix PlacingBulletHole --- EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs b/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs index 180fb3e81..16a1b96e8 100644 --- a/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs +++ b/EXILED/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs @@ -8,6 +8,8 @@ namespace Exiled.Events.Patches.Events.Map { using System.Collections.Generic; + using System.Linq; + using System.Reflection; using System.Reflection.Emit; using API.Features.Pools; @@ -48,7 +50,7 @@ private static IEnumerable Transpiler(IEnumerable x.Name == "Get").First()), // hit new(OpCodes.Ldarg_2), From 6879f5ac847707abbe00290e385723636b5b371b Mon Sep 17 00:00:00 2001 From: X <24619207+Undid-Iridium@users.noreply.github.com> Date: Wed, 27 Nov 2024 01:56:19 -0500 Subject: [PATCH 020/102] Room toString fix (#214) --- EXILED/Exiled.API/Features/Room.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index 31f62adbe..505b12b79 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -395,7 +395,7 @@ public void UnlockAll() /// Returns the Room in a human-readable format. /// /// A string containing Room-related data. - public override string ToString() => $"{Type} ({Zone}) [{Doors.Count}] *{Cameras.Count}* |{TeslaGate != null}|"; + public override string ToString() => $"{Type} ({Zone}) [{Doors?.Count}] *{Cameras?.Count}* |{TeslaGate != null}|"; /// /// Factory method to create and add a component to a Transform. From 0e49b622b5e976844fa22f94397107cb9dc7ce09 Mon Sep 17 00:00:00 2001 From: Qidan475 Date: Wed, 27 Nov 2024 13:56:43 +0700 Subject: [PATCH 021/102] 14.0 role fixes (#209) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix host being kicked out due to nre * add new role "destoyed" * stylecop 😭 --- EXILED/Exiled.API/Features/Player.cs | 2 +- .../Features/Roles/DestroyedRole.cs | 36 +++++++++++++++++++ EXILED/Exiled.API/Features/Roles/Role.cs | 2 ++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 EXILED/Exiled.API/Features/Roles/DestroyedRole.cs diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index ddad6ca4c..80a09d4aa 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -584,7 +584,7 @@ public Role Role get => role ??= Role.Create(RoleManager.CurrentRole); internal set { - PreviousRole = role.Type; + PreviousRole = role?.Type ?? RoleTypeId.None; role = value; } } diff --git a/EXILED/Exiled.API/Features/Roles/DestroyedRole.cs b/EXILED/Exiled.API/Features/Roles/DestroyedRole.cs new file mode 100644 index 000000000..42e6cfe34 --- /dev/null +++ b/EXILED/Exiled.API/Features/Roles/DestroyedRole.cs @@ -0,0 +1,36 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Roles +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + + using PlayerRoles; + using PlayerRoles.Voice; + + /// + /// Defines a role that represents players with destroyed role. + /// + internal class DestroyedRole : Role + { + /// + /// Initializes a new instance of the class. + /// + /// the base . + internal DestroyedRole(PlayerRoleBase baseRole) + : base(baseRole) + { + } + + /// + public override RoleTypeId Type { get; } = RoleTypeId.Destroyed; + } +} diff --git a/EXILED/Exiled.API/Features/Roles/Role.cs b/EXILED/Exiled.API/Features/Roles/Role.cs index 6edc4f409..0b636e95f 100644 --- a/EXILED/Exiled.API/Features/Roles/Role.cs +++ b/EXILED/Exiled.API/Features/Roles/Role.cs @@ -18,6 +18,7 @@ namespace Exiled.API.Features.Roles using PlayerRoles.PlayableScps.Scp049.Zombies; using UnityEngine; + using DestroyedGameRole = PlayerRoles.DestroyedRole; using FilmmakerGameRole = PlayerRoles.Filmmaker.FilmmakerRole; using HumanGameRole = PlayerRoles.HumanRole; using NoneGameRole = PlayerRoles.NoneRole; @@ -228,6 +229,7 @@ public virtual void Set(RoleTypeId newRole, SpawnReason reason, RoleSpawnFlags s HumanGameRole humanRole => new HumanRole(humanRole), FilmmakerGameRole filmmakerRole => new FilmMakerRole(filmmakerRole), NoneGameRole noneRole => new NoneRole(noneRole), + DestroyedGameRole destroyedRole => new DestroyedRole(destroyedRole), _ => null, }; } From f6c3b24bac97a18835315885256c65fa21edd7c9 Mon Sep 17 00:00:00 2001 From: X <24619207+Undid-Iridium@users.noreply.github.com> Date: Wed, 27 Nov 2024 02:20:08 -0500 Subject: [PATCH 022/102] Hcz bulk door fix (#207) * Probably works * Probably works --- EXILED/Exiled.API/Enums/DoorType.cs | 5 +++++ EXILED/Exiled.API/Features/Doors/Door.cs | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Enums/DoorType.cs b/EXILED/Exiled.API/Enums/DoorType.cs index b7150ae03..3b96b3ea4 100644 --- a/EXILED/Exiled.API/Enums/DoorType.cs +++ b/EXILED/Exiled.API/Enums/DoorType.cs @@ -156,6 +156,11 @@ public enum DoorType /// Represents any heavy containment styled door. /// HeavyContainmentDoor, + + /// + /// Represents any heavy containment styled door. + /// + HeavyBulkDoor, /// /// Represents the HID_CHAMBER door. diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index d77dda83b..45638cacf 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -589,6 +589,17 @@ private DoorType GetDoorType() if (Nametag is null) { string doorName = GameObject.name.GetBefore(' '); + // Log.Error($"What is door type {doorName} versus {GameObject.name}"); + //Temp, Exiled should not be using a space identifier but I am on vacation + if (doorName.Equals("HCZ")) + { + doorName = GameObject.name.GetBefore('('); + } + // Log.Error($"What is door type {doorName} versus {GameObject.name}"); + // Correct behavior would be to just cut (clone) off the end + // If you want, have two item definitions - 1 - HCZ doors group + // 2 - HCZ specific door (HCZ - Breakable, Blastdoor, etc) + return doorName switch { "LCZ" => Room?.Type switch @@ -596,7 +607,8 @@ private DoorType GetDoorType() RoomType.LczAirlock => (Base.GetComponentInParent() != null) ? DoorType.Airlock : DoorType.LightContainmentDoor, _ => DoorType.LightContainmentDoor, }, - "HCZ" => DoorType.HeavyContainmentDoor, + "HCZ BreakableDoor" => DoorType.HeavyContainmentDoor, + "HCZ BulkDoor" => DoorType.HeavyBulkDoor, "EZ" => DoorType.EntranceDoor, "Prison" => DoorType.PrisonDoor, "914" => DoorType.Scp914Door, From b6adf8283fbc8f025b1fb6fd148c48c9e5236543 Mon Sep 17 00:00:00 2001 From: X <24619207+Undid-Iridium@users.noreply.github.com> Date: Wed, 27 Nov 2024 02:59:19 -0500 Subject: [PATCH 023/102] Scp3144 severed hands fix (#205) * Probably works * On vacation, rushed it * Yamato cleanup req * Stylecop? --- EXILED/Exiled.API/Enums/DamageType.cs | 12 ++++++------ EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs | 4 ++-- .../Features/DamageHandlers/GenericDamageHandler.cs | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/EXILED/Exiled.API/Enums/DamageType.cs b/EXILED/Exiled.API/Enums/DamageType.cs index fd4916f56..add8d86ca 100644 --- a/EXILED/Exiled.API/Enums/DamageType.cs +++ b/EXILED/Exiled.API/Enums/DamageType.cs @@ -120,6 +120,11 @@ public enum DamageType /// SeveredHands, + /// + /// Damage caused by severed eyes. + /// + SeveredEyes, + /// /// Damage caused by a custom source. /// @@ -249,10 +254,5 @@ public enum DamageType /// Damage caused by the marshmallow man. ///
Marshmallow, - - /// - /// Damage caused by . - /// - Scp1344, } -} +} \ No newline at end of file diff --git a/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs b/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs index 14daacc0a..bb2a246f1 100644 --- a/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs +++ b/EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs @@ -49,7 +49,7 @@ public static class DamageTypeExtensions { DeathTranslations.MicroHID.Id, DamageType.MicroHid }, { DeathTranslations.Hypothermia.Id, DamageType.Hypothermia }, { DeathTranslations.MarshmallowMan.Id, DamageType.Marshmallow }, - { DeathTranslations.Scp1344.Id, DamageType.Scp1344 }, + { DeathTranslations.Scp1344.Id, DamageType.SeveredEyes }, }; private static readonly Dictionary TranslationConversionInternal = new() @@ -81,7 +81,7 @@ public static class DamageTypeExtensions { DeathTranslations.MicroHID, DamageType.MicroHid }, { DeathTranslations.Hypothermia, DamageType.Hypothermia }, { DeathTranslations.MarshmallowMan, DamageType.Marshmallow }, - { DeathTranslations.Scp1344, DamageType.Scp1344 }, + { DeathTranslations.Scp1344, DamageType.SeveredEyes }, }; private static readonly Dictionary ItemConversionInternal = new() diff --git a/EXILED/Exiled.API/Features/DamageHandlers/GenericDamageHandler.cs b/EXILED/Exiled.API/Features/DamageHandlers/GenericDamageHandler.cs index 64efd0c86..b146521a5 100644 --- a/EXILED/Exiled.API/Features/DamageHandlers/GenericDamageHandler.cs +++ b/EXILED/Exiled.API/Features/DamageHandlers/GenericDamageHandler.cs @@ -90,6 +90,9 @@ public GenericDamageHandler(Player player, Player attacker, float damage, Damage case DamageType.SeveredHands: Base = new UniversalDamageHandler(damage, DeathTranslations.SeveredHands, cassieAnnouncement); break; + case DamageType.SeveredEyes: + Base = new UniversalDamageHandler(damage, DeathTranslations.Scp1344, cassieAnnouncement); + break; case DamageType.Warhead: Base = new WarheadDamageHandler(); break; From 53c2beff83987e9591fcb3916aebbeeabb355520 Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 27 Nov 2024 10:53:28 +0100 Subject: [PATCH 024/102] Fix --- EXILED/Exiled.API/Enums/DoorType.cs | 2 +- .../Exiled.API/Extensions/StringExtensions.cs | 4 +- EXILED/Exiled.API/Features/Camera.cs | 2 +- EXILED/Exiled.API/Features/Doors/Door.cs | 37 ++++++------------- EXILED/Exiled.API/Features/Room.cs | 8 ++-- EXILED/Exiled.API/Features/Window.cs | 2 +- 6 files changed, 21 insertions(+), 34 deletions(-) diff --git a/EXILED/Exiled.API/Enums/DoorType.cs b/EXILED/Exiled.API/Enums/DoorType.cs index 3b96b3ea4..52fb3ef34 100644 --- a/EXILED/Exiled.API/Enums/DoorType.cs +++ b/EXILED/Exiled.API/Enums/DoorType.cs @@ -156,7 +156,7 @@ public enum DoorType /// Represents any heavy containment styled door. ///
HeavyContainmentDoor, - + /// /// Represents any heavy containment styled door. /// diff --git a/EXILED/Exiled.API/Extensions/StringExtensions.cs b/EXILED/Exiled.API/Extensions/StringExtensions.cs index 2d0f9a0d7..1cc8dc7c3 100644 --- a/EXILED/Exiled.API/Extensions/StringExtensions.cs +++ b/EXILED/Exiled.API/Extensions/StringExtensions.cs @@ -119,10 +119,10 @@ public static string ToString(this IEnumerable enumerable, bool showIndex /// Name without brackets. public static string RemoveBracketsOnEndOfName(this string name) { - int bracketStart = name.IndexOf('(') - 1; + int bracketStart = name.IndexOf('('); if (bracketStart > 0) - name = name.Remove(bracketStart, name.Length - bracketStart); + name = name.Remove(bracketStart, name.Length - bracketStart).TrimEnd(); return name; } diff --git a/EXILED/Exiled.API/Features/Camera.cs b/EXILED/Exiled.API/Features/Camera.cs index 29afdac44..0c90edf56 100644 --- a/EXILED/Exiled.API/Features/Camera.cs +++ b/EXILED/Exiled.API/Features/Camera.cs @@ -154,7 +154,7 @@ internal Camera(Scp079Camera camera079) Type = GetCameraType(); #if DEBUG if (Type is CameraType.Unknown) - Log.Error($"[CAMERATYPE UNKNOWN] {this}"); + Log.Error($"[CAMERATYPE UNKNOWN] {this} BASE = {Base}"); #endif } diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index 45638cacf..bfdede33d 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -61,7 +61,7 @@ internal Door(DoorVariant door, List rooms) Type = GetDoorType(); #if DEBUG if (Type is DoorType.UnknownDoor or DoorType.UnknownGate or DoorType.UnknownElevator) - Log.Error($"[DOORTYPE UNKNOWN] {this}"); + Log.Error($"[DOORTYPE UNKNOWN] {this} BASE = {Base}"); #endif } @@ -557,7 +557,7 @@ public void Lock(DoorLockType lockType) /// Returns the Door in a human-readable format. ///
/// A string containing Door-related data. - public override string ToString() => $"{Type} ({Zone}) [{Room}] *{DoorLockType}* ={RequiredPermissions.RequiredPermissions}="; + public override string ToString() => $"{Type} ({Zone}) [{Room}] *{DoorLockType}* ={RequiredPermissions?.RequiredPermissions}="; /// /// Creates the door object associated with a specific . @@ -588,50 +588,37 @@ private DoorType GetDoorType() { if (Nametag is null) { - string doorName = GameObject.name.GetBefore(' '); - // Log.Error($"What is door type {doorName} versus {GameObject.name}"); - //Temp, Exiled should not be using a space identifier but I am on vacation - if (doorName.Equals("HCZ")) - { - doorName = GameObject.name.GetBefore('('); - } - // Log.Error($"What is door type {doorName} versus {GameObject.name}"); - // Correct behavior would be to just cut (clone) off the end - // If you want, have two item definitions - 1 - HCZ doors group - // 2 - HCZ specific door (HCZ - Breakable, Blastdoor, etc) + string doorName = GameObject.name.GetBefore('(').TrimEnd(); return doorName switch { - "LCZ" => Room?.Type switch - { - RoomType.LczAirlock => (Base.GetComponentInParent() != null) ? DoorType.Airlock : DoorType.LightContainmentDoor, - _ => DoorType.LightContainmentDoor, - }, + "LCZ PortallessBreakableDoor" => DoorType.Airlock, + "LCZ BreakableDoor" => DoorType.LightContainmentDoor, "HCZ BreakableDoor" => DoorType.HeavyContainmentDoor, "HCZ BulkDoor" => DoorType.HeavyBulkDoor, - "EZ" => DoorType.EntranceDoor, - "Prison" => DoorType.PrisonDoor, - "914" => DoorType.Scp914Door, - "Intercom" => Room?.Type switch + "EZ BreakableDoor" => DoorType.EntranceDoor, + "Prison BreakableDoor" => DoorType.PrisonDoor, + "914 Door" => DoorType.Scp914Door, + "Intercom BreakableDoor" => Room?.Type switch { RoomType.HczEzCheckpointA => DoorType.CheckpointArmoryA, RoomType.HczEzCheckpointB => DoorType.CheckpointArmoryB, _ => DoorType.UnknownDoor, }, - "Unsecured" => Room?.Type switch + "Unsecured Pryable GateDoor" => Room?.Type switch { RoomType.EzCheckpointHallway => DoorType.CheckpointGate, RoomType.Hcz049 => Position.y < -805 ? DoorType.Scp049Gate : DoorType.Scp173NewGate, _ => DoorType.UnknownGate, }, - "Elevator" => (Base as Interactables.Interobjects.ElevatorDoor)?.Group switch + "Elevator Door" or "Nuke Elevator Door" or "Elevator Door 02" => (Base as Interactables.Interobjects.ElevatorDoor)?.Group switch { - ElevatorGroup.Nuke01 or ElevatorGroup.Nuke02 => DoorType.ElevatorNuke, ElevatorGroup.Scp049 => DoorType.ElevatorScp049, ElevatorGroup.GateB => DoorType.ElevatorGateB, ElevatorGroup.GateA => DoorType.ElevatorGateA, ElevatorGroup.LczA01 or ElevatorGroup.LczA02 => DoorType.ElevatorLczA, ElevatorGroup.LczB01 or ElevatorGroup.LczB02 => DoorType.ElevatorLczB, + ElevatorGroup.Nuke01 or ElevatorGroup.Nuke02 => DoorType.ElevatorNuke, _ => DoorType.UnknownElevator, }, _ => DoorType.UnknownDoor, diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index 505b12b79..c268db76c 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -431,7 +431,7 @@ private static RoomType FindType(GameObject gameObject) "HCZ_079" => RoomType.Hcz079, "HCZ_TArmory" => RoomType.HczArmory, "HCZ_Testroom" => RoomType.HczTestRoom, - "HCZ_Hid" => RoomType.HczHid, + "HCZ_MicroHID_New" => RoomType.HczHid, "HCZ_049" => RoomType.Hcz049, "HCZ_Crossing" => RoomType.HczCrossing, "HCZ_106" => RoomType.Hcz106, @@ -495,13 +495,13 @@ private void InternalCreate() Zone = FindZone(gameObject); #if DEBUG - if (Type is RoomType.Unknown) - Log.Error($"[ZONETYPE UNKNOWN] {this}"); + if (Zone is ZoneType.Unspecified or ZoneType.Other) + Log.Error($"[ZONETYPE UNKNOWN] {this} Zone : {Identifier?.Zone}"); #endif Type = FindType(gameObject); #if DEBUG if (Type is RoomType.Unknown) - Log.Error($"[ROOMTYPE UNKNOWN] {this}"); + Log.Error($"[ROOMTYPE UNKNOWN] {this} Name : {gameObject?.name} Shape : {Identifier?.Shape}"); #endif RoomLightControllersValue.AddRange(gameObject.GetComponentsInChildren()); diff --git a/EXILED/Exiled.API/Features/Window.cs b/EXILED/Exiled.API/Features/Window.cs index 001d05dc5..79a7f5acf 100644 --- a/EXILED/Exiled.API/Features/Window.cs +++ b/EXILED/Exiled.API/Features/Window.cs @@ -40,7 +40,7 @@ internal Window(BreakableWindow window, Room room) Type = GetGlassType(); #if DEBUG if (Type is GlassType.Unknown) - Log.Error($"[GLASSTYPE UNKNOWN] {this}"); + Log.Error($"[GLASSTYPE UNKNOWN] {this} BASE = {Base}"); #endif } From 60b0dcab3c58e8fd958480eb4b9d3f55bbb5de9c Mon Sep 17 00:00:00 2001 From: Yamato Date: Wed, 27 Nov 2024 10:54:32 +0100 Subject: [PATCH 025/102] Intended --- EXILED/Exiled.API/Features/Room.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index c268db76c..4a3d38eab 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -495,7 +495,7 @@ private void InternalCreate() Zone = FindZone(gameObject); #if DEBUG - if (Zone is ZoneType.Unspecified or ZoneType.Other) + if (Zone is ZoneType.Unspecified) Log.Error($"[ZONETYPE UNKNOWN] {this} Zone : {Identifier?.Zone}"); #endif Type = FindType(gameObject); From ad3c9387eb5b458ca59c590e2ce839f1f66f462d Mon Sep 17 00:00:00 2001 From: X <24619207+Undid-Iridium@users.noreply.github.com> Date: Wed, 27 Nov 2024 04:55:48 -0500 Subject: [PATCH 026/102] Scp330Interobject fix (#231) --- EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs b/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs index 9d1787ea1..e3cf087f6 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs @@ -61,7 +61,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Wed, 27 Nov 2024 18:46:43 +0100 Subject: [PATCH 027/102] New Prefabs (#239) * Delete .github/dependabot.yml * Update push_nuget.yml * Update dev.yml * Prefab Revamp --------- Co-authored-by: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> --- EXILED/Exiled.API/Enums/PrefabType.cs | 67 ++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.API/Enums/PrefabType.cs b/EXILED/Exiled.API/Enums/PrefabType.cs index a11f6aff6..7ec8a851c 100644 --- a/EXILED/Exiled.API/Enums/PrefabType.cs +++ b/EXILED/Exiled.API/Enums/PrefabType.cs @@ -16,10 +16,10 @@ public enum PrefabType { #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable SA1602 // Enumeration items should be documented - [Prefab(1883254029, "Player")] + [Prefab(3816198336, "Player")] Player, - [Prefab(2295511789, "EZ BreakableDoor")] + [Prefab(1883254029, "EZ BreakableDoor")] EZBreakableDoor, [Prefab(2295511789, "HCZ BreakableDoor")] @@ -28,6 +28,42 @@ public enum PrefabType [Prefab(3038351124, "LCZ BreakableDoor")] LCZBreakableDoor, + [Prefab(400539138, "HCZ OneSided")] + HCZOneSided, + + [Prefab(2060920286, "HCZ TwoSided")] + HCZTwoSided, + + [Prefab(3343949480, "OpenHallway")] + HCZOpenHallway, + + [Prefab(3999209566, "OpenHallway Construct A")] + HCZOpenHallway_Construct_A, + + [Prefab(38976586, "OpenHallway Clutter A")] + HCZOpenHallway_Clutter_A, + + [Prefab(1687661105, "OpenHallway Clutter B")] + HCZOpenHallway_Clutter_B, + + [Prefab(147203050, "OpenHallway Clutter C")] + HCZOpenHallway_Clutter_C, + + [Prefab(1102032353, "OpenHallway Clutter D")] + HCZOpenHallway_Clutter_D, + + [Prefab(2490430134, "OpenHallway Clutter E")] + HCZOpenHallway_Clutter_E, + + [Prefab(2673083832, "OpenHallway Clutter F")] + HCZOpenHallway_Clutter_F, + + [Prefab(2536312960, "OpenHallway Clutter G")] + HCZOpenHallway_Clutter_G, + + [Prefab(2176035362, "HCZ BulkDoor")] + HCZBulkDoor, + [Prefab(1704345398, "sportTargetPrefab")] SportTarget, @@ -46,6 +82,9 @@ public enum PrefabType [Prefab(3956448839, "LightSourceToy")] LightSourceToy, + [Prefab(712426663, "SpeakerToy")] + SpeakerToy, + [Prefab(2672653014, "RegularKeycardPickup")] RegularKeycardPickup, @@ -55,6 +94,9 @@ public enum PrefabType [Prefab(248357067, "RadioPickup")] RadioPickup, + [Prefab(1925130715, "FirearmPickup")] + FirearmPickup, + [Prefab(1925130715, "Com15Pickup")] Com15Pickup, @@ -181,6 +223,9 @@ public enum PrefabType [Prefab(3532394942, "LanternPickup")] LanternPickup, + [Prefab(4143962266, "SCP1344Pickup")] + Scp1344Pickup, + [Prefab(825024811, "Amnestic Cloud Hazard")] AmnesticCloudHazard, @@ -208,9 +253,18 @@ public enum PrefabType [Prefab(3372339835, "Scp1576PedestalStructure Variant")] Scp1576PedestalStructure, + [Prefab(2399831573, "AntiScp207PedestalStructure Variant")] + AntiScp207PedestalStructure, + + [Prefab(1763950070, "Scp1344PedestalStructure Variant")] + Scp1344PedestalStructure, + [Prefab(2830750618, "LargeGunLockerStructure")] LargeGunLockerStructure, + [Prefab(2372810204, "Experimental Weapon Locker")] + ExperimentalLockerStructure, + [Prefab(3352879624, "RifleRackStructure")] RifleRackStructure, @@ -273,5 +327,14 @@ public enum PrefabType [Prefab(3721192489, "Scp3114_Ragdoll")] Scp3114Ragdoll, + + [Prefab(2588580243, "ElevatorChamber")] + ElevatorChamber, + + [Prefab(1757973841, "ElevatorChamber_Gates")] + ElevatorChamber_Gates, + + [Prefab(912031041, "ElevatorChamberNuke")] + ElevatorChamberNuke, } } \ No newline at end of file From aae593b675d064d94a905d4f283fb680b93ff0b7 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:34:35 -0500 Subject: [PATCH 028/102] Fix UpgradingItem patch (#242) --- EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingItem.cs b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingItem.cs index d69fa44bc..64393ad83 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingItem.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingItem.cs @@ -51,7 +51,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Wed, 27 Nov 2024 17:39:29 -0300 Subject: [PATCH 029/102] Fixing SpawningEventArg (#245) * Fixing SpawningEventArg * Remove OldRole due the changes in 14.0 * Adding NewRole --- .../EventArgs/Player/SpawningEventArgs.cs | 18 ++-- .../Patches/Events/Player/Spawning.cs | 86 ++++++++++++------- 2 files changed, 68 insertions(+), 36 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/SpawningEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/SpawningEventArgs.cs index 1e4c28346..21221d8cd 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/SpawningEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/SpawningEventArgs.cs @@ -7,11 +7,13 @@ namespace Exiled.Events.EventArgs.Player { + using System; + using System.Runtime.CompilerServices; + using Exiled.API.Features; using Exiled.API.Features.Roles; using Exiled.Events.EventArgs.Interfaces; using PlayerRoles; - using UnityEngine; /// @@ -31,15 +33,15 @@ public class SpawningEventArgs : IPlayerEvent /// /// /// - /// - /// the spawned player's old role. + /// + /// the spawned player's new role. /// - public SpawningEventArgs(Player player, Vector3 position, float rotation, PlayerRoleBase oldRole) + public SpawningEventArgs(Player player, Vector3 position, float rotation, PlayerRoleBase newRole) { Player = player; Position = position; HorizontalRotation = rotation; - OldRole = Role.Create(oldRole); + NewRole = Role.Create(newRole); } /// @@ -66,6 +68,12 @@ public SpawningEventArgs(Player player, Vector3 position, float rotation, Player /// /// Gets the player's old role. /// + [Obsolete("Removed because the method is no longer provide OldRole since version 14.0. Use Player.Role instead")] public Role OldRole { get; } + + /// + /// Gets the player's new role. + /// + public Role NewRole { get; } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs b/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs index e5ea08d1f..f740e1637 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs @@ -7,17 +7,18 @@ namespace Exiled.Events.Patches.Events.Player { + using System.Collections.Generic; using System.Reflection; + using System.Reflection.Emit; - using API.Features; + using Exiled.API.Features; + using Exiled.API.Features.Pools; + using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Player; - + using Exiled.Events.EventArgs.Server; using HarmonyLib; - using PlayerRoles; - using PlayerRoles.FirstPersonControl; using PlayerRoles.FirstPersonControl.Spawnpoints; - using UnityEngine; using static HarmonyLib.AccessTools; @@ -27,43 +28,66 @@ namespace Exiled.Events.Patches.Events.Player /// Adds the event. /// Fix for spawning in void. /// - [HarmonyPatch] + [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Spawning))] + [HarmonyPatch(typeof(RoleSpawnpointManager), nameof(RoleSpawnpointManager.SetPosition))] internal static class Spawning { - private static MethodInfo TargetMethod() + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { - return Method(TypeByName("PlayerRoles.FirstPersonControl.Spawnpoints.RoleSpawnpointManager").GetNestedTypes(all)[1], "b__2_0"); - } + List newInstructions = ListPool.Pool.Get(instructions); - private static bool Prefix(ReferenceHub hub, PlayerRoleBase prevRole, PlayerRoleBase newRole) - { - if (newRole.ServerSpawnReason == RoleChangeReason.Destroyed || !Player.TryGet(hub, out Player player)) - return true; + int offset = -1; + + // Locate the call to `Transform.position` setter to determine where to insert new instructions. + MethodInfo setPositionMethod = PropertySetter(typeof(Transform), nameof(Transform.position)); + int index = newInstructions.FindIndex(instr => + instr.opcode == OpCodes.Callvirt && instr.operand as MethodInfo == setPositionMethod) + offset; - Vector3 oldPosition = hub.transform.position; - float oldRotation = (prevRole as IFpcRole)?.FpcModule.MouseLook.CurrentVertical ?? 0; + // Declare the `SpawningEventArgs` local variable. + LocalBuilder ev = generator.DeclareLocal(typeof(SpawningEventArgs)); - if (newRole is IFpcRole fpcRole) + newInstructions.InsertRange( + index, + new[] { - if (newRole.ServerSpawnFlags.HasFlag(RoleSpawnFlags.UseSpawnpoint) && fpcRole.SpawnpointHandler != null && fpcRole.SpawnpointHandler.TryGetSpawnpoint(out Vector3 position, out float horizontalRot)) - { - oldPosition = position; - oldRotation = horizontalRot; - } + // Load `ReferenceHub` (argument 0) and get `Player`. + new CodeInstruction(OpCodes.Ldarg_0), // Load `hub` (first argument passed to the method). + new CodeInstruction(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // Call Player.Get(hub) to get the Player instance. - SpawningEventArgs ev = new(player, oldPosition, oldRotation, prevRole); + // Load `position` (local variable 2). + new CodeInstruction(OpCodes.Ldloc_2), - Handlers.Player.OnSpawning(ev); + // Load `rotation` (local variable 3). + new CodeInstruction(OpCodes.Ldloc_3), - player.Position = ev.Position; - fpcRole.FpcModule.MouseLook.CurrentHorizontal = ev.HorizontalRotation; - } - else - { - Handlers.Player.OnSpawning(new(player, oldPosition, oldRotation, prevRole)); - } + // Load `newRole` (argument 1). + new CodeInstruction(OpCodes.Ldarg_1), // Load `newRole` from argument 1. + + // Create a new instance of `SpawningEventArgs`. + new CodeInstruction(OpCodes.Newobj, GetDeclaredConstructors(typeof(SpawningEventArgs))[0]), + + // Duplicate the object to store it and pass it around. + new CodeInstruction(OpCodes.Dup), // Duplicate the `SpawningEventArgs` object. + new CodeInstruction(OpCodes.Stloc, ev.LocalIndex), // Store the duplicated object in a local variable. + + // Call `Handlers.Player.OnSpawning`. + new CodeInstruction(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnSpawning))), + + // Modify `position` from `ev.Position`. + new CodeInstruction(OpCodes.Ldloc, ev.LocalIndex), // Load the `SpawningEventArgs` object stored in the local variable. + new CodeInstruction(OpCodes.Call, PropertyGetter(typeof(SpawningEventArgs), nameof(SpawningEventArgs.Position))), // Get the `Position` property from `SpawningEventArgs`. + new CodeInstruction(OpCodes.Stloc_2), // Store the position value back in the local variable 2 (`position`). + + // Modify `rotation` from `ev.HorizontalRotation`. + new CodeInstruction(OpCodes.Ldloc, ev.LocalIndex), // Load the `SpawningEventArgs` object again. + new CodeInstruction(OpCodes.Call, PropertyGetter(typeof(SpawningEventArgs), nameof(SpawningEventArgs.HorizontalRotation))), // Get the `HorizontalRotation` property from `SpawningEventArgs`. + new CodeInstruction(OpCodes.Stloc_3), // Store the rotation value back in the local variable 3 (`rotation`). + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; - return false; + ListPool.Pool.Return(newInstructions); } } } \ No newline at end of file From 4c1b9146ad727cf6938f1d04d9a40830f5f8e8fc Mon Sep 17 00:00:00 2001 From: Mike <146554836+MikeSus1@users.noreply.github.com> Date: Thu, 28 Nov 2024 00:49:51 +0100 Subject: [PATCH 030/102] CustomItems and CustomRoles fix (#236) --- EXILED/Exiled.CustomItems/API/Features/CustomItem.cs | 2 +- EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs index a01621fbb..aa096dc85 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs @@ -1011,7 +1011,7 @@ protected virtual void ShowSelectedMessage(Player player) private void OnInternalOwnerChangingRole(ChangingRoleEventArgs ev) { - if (ev.Reason == SpawnReason.Escaped) + if (ev.Reason is SpawnReason.Escaped or SpawnReason.Destroyed) return; foreach (Item item in ev.Player.Items.ToList()) diff --git a/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs b/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs index 56f3e5895..b8217fb41 100644 --- a/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs +++ b/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs @@ -926,6 +926,9 @@ private void OnInternalSpawning(SpawningEventArgs ev) private void OnInternalChangingRole(ChangingRoleEventArgs ev) { + if(ev.Reason == SpawnReason.Destroyed) + return; + if (Check(ev.Player) && ((ev.NewRole == RoleTypeId.Spectator && !KeepRoleOnDeath) || (ev.NewRole != RoleTypeId.Spectator && ev.NewRole != Role && !KeepRoleOnChangingRole))) { RemoveRole(ev.Player); From 8b4b3bdb3cce5eeef020cd14dee71ab56ebf1edb Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Thu, 28 Nov 2024 00:55:53 -0500 Subject: [PATCH 031/102] Fix UpgradingPlayer patch (#247) --- .../Patches/Events/Scp914/UpgradingPlayer.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs index 385a98155..79fdb2a4e 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs @@ -66,10 +66,10 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Thu, 28 Nov 2024 15:04:07 -0500 Subject: [PATCH 032/102] Readd fixes (#254) #244 and #253 --------- Co-authored-by: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> --- EXILED/Exiled.API/Features/Map.cs | 11 +-- .../Exiled.API/Features/Roles/Scp106Role.cs | 2 +- EXILED/Exiled.API/Features/Window.cs | 4 +- .../EventArgs/Player/SpawningEventArgs.cs | 3 +- .../Scp914/UpgradingPlayerEventArgs.cs | 8 +- .../Server/RespawningTeamEventArgs.cs | 25 +++--- .../Handlers/Internal/MapGenerated.cs | 47 +--------- .../Exiled.Events/Handlers/Internal/Round.cs | 48 ++++++++++ .../Patches/Events/Map/FillingLocker.cs | 2 +- .../Patches/Events/Map/SpawningTeamVehicle.cs | 16 +--- .../Events/Player/ChangingRoleAndSpawned.cs | 87 ++++++++++--------- .../Patches/Events/Player/Joined.cs | 6 +- .../Patches/Events/Player/Shooting.cs | 33 +++---- .../Patches/Events/Player/Spawning.cs | 7 +- .../Patches/Events/Player/SpawningRagdoll.cs | 14 ++- .../Patches/Events/Scp106/ExitStalking.cs | 20 ++--- .../Patches/Events/Scp914/UpgradingPlayer.cs | 34 +++----- .../Patches/Events/Server/RespawningTeam.cs | 40 ++++----- .../Patches/Events/Server/RoundEnd.cs | 19 +--- .../Events/Server/WaitingForPlayers.cs | 32 +++++++ .../Fixes/Fix106RegenerationWithScp244.cs | 72 --------------- .../Generic/PocketDimensionTeleportList.cs | 2 +- 22 files changed, 224 insertions(+), 308 deletions(-) create mode 100644 EXILED/Exiled.Events/Patches/Events/Server/WaitingForPlayers.cs delete mode 100644 EXILED/Exiled.Events/Patches/Fixes/Fix106RegenerationWithScp244.cs diff --git a/EXILED/Exiled.API/Features/Map.cs b/EXILED/Exiled.API/Features/Map.cs index d3950db22..3448910b8 100644 --- a/EXILED/Exiled.API/Features/Map.cs +++ b/EXILED/Exiled.API/Features/Map.cs @@ -7,6 +7,7 @@ namespace Exiled.API.Features { +#pragma warning disable SA1401 using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -43,6 +44,11 @@ namespace Exiled.API.Features /// public static class Map { + /// + /// Gets a list of s on the map. + /// + internal static List TeleportsValue = new(); + private static AmbientSoundPlayer ambientSoundPlayer; private static SqueakSpawner squeakSpawner; @@ -114,11 +120,6 @@ public static bool IsDecontaminationEnabled /// public static SqueakSpawner SqueakSpawner => squeakSpawner ??= Object.FindObjectOfType(); - /// - /// Gets a list of s on the map. - /// - internal static List TeleportsValue { get; } = new(); - /// /// Broadcasts a message to all players. /// diff --git a/EXILED/Exiled.API/Features/Roles/Scp106Role.cs b/EXILED/Exiled.API/Features/Roles/Scp106Role.cs index 48f3f04a0..067ee6964 100644 --- a/EXILED/Exiled.API/Features/Roles/Scp106Role.cs +++ b/EXILED/Exiled.API/Features/Roles/Scp106Role.cs @@ -168,7 +168,7 @@ public bool IsSubmerged public bool SinkholeState { get => StalkAbility.StalkActive; - set => StalkAbility.StalkActive = value; + set => StalkAbility.ServerSetStalk(value); } /// diff --git a/EXILED/Exiled.API/Features/Window.cs b/EXILED/Exiled.API/Features/Window.cs index 79a7f5acf..f0765b732 100644 --- a/EXILED/Exiled.API/Features/Window.cs +++ b/EXILED/Exiled.API/Features/Window.cs @@ -220,7 +220,9 @@ public void DamageWindow(float amount, DamageHandlerBase handler) RoomType.LczGlassBox => GlassType.GR18, RoomType.LczPlants => GlassType.Plants, RoomType.Hcz049 => GlassType.Scp049, - RoomType.Hcz079 => Recontainer.Base._activatorGlass == Base ? GlassType.Scp079Trigger : GlassType.Scp079, + + // TODO: Recontainer.Base._activatorGlass == Base ? GlassType.Scp079Trigger : GlassType.Scp079 + RoomType.Hcz079 => GlassType.Scp079, RoomType.HczHid => GlassType.MicroHid, RoomType.HczTestRoom => GlassType.TestRoom, RoomType.HczEzCheckpointA => GlassType.HczEzCheckpointA, diff --git a/EXILED/Exiled.Events/EventArgs/Player/SpawningEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/SpawningEventArgs.cs index 21221d8cd..bc543dc58 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/SpawningEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/SpawningEventArgs.cs @@ -8,7 +8,6 @@ namespace Exiled.Events.EventArgs.Player { using System; - using System.Runtime.CompilerServices; using Exiled.API.Features; using Exiled.API.Features.Roles; @@ -76,4 +75,4 @@ public SpawningEventArgs(Player player, Vector3 position, float rotation, Player /// public Role NewRole { get; } } -} \ No newline at end of file +} diff --git a/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingPlayerEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingPlayerEventArgs.cs index 9dedafb5a..cf4487ecc 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingPlayerEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingPlayerEventArgs.cs @@ -31,16 +31,16 @@ public class UpgradingPlayerEventArgs : IPlayerEvent, IDeniableEvent /// /// /// - /// - /// + /// + /// /// - public UpgradingPlayerEventArgs(Player player, bool upgradeItems, bool heldOnly, Scp914KnobSetting setting, Vector3 moveVector) + public UpgradingPlayerEventArgs(Player player, bool upgradeItems, bool heldOnly, Scp914KnobSetting setting, Vector3 outputPos) { Player = player; UpgradeItems = upgradeItems; HeldOnly = heldOnly; KnobSetting = setting; - OutputPosition = player.Position + moveVector; + OutputPosition = outputPos; } /// diff --git a/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs index f475591a6..963d06351 100644 --- a/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs @@ -29,25 +29,19 @@ public class RespawningTeamEventArgs : IDeniableEvent /// /// /// - /// - /// - /// /// /// /// - /// + /// /// /// - /// - /// - /// - public RespawningTeamEventArgs(List players, Queue queue, int maxRespawn, SpawnableWaveBase nextKnownTeam, bool isAllowed = true) + public RespawningTeamEventArgs(List players, int maxRespawn, SpawnableWaveBase wave) { Players = players; MaximumRespawnAmount = maxRespawn; - SpawnQueue = queue; - NextKnownTeam = nextKnownTeam; - IsAllowed = isAllowed; + SpawnQueue = WaveSpawner.SpawnQueue; + Wave = wave; + IsAllowed = true; } /// @@ -74,9 +68,14 @@ public int MaximumRespawnAmount } /// - /// Gets or sets a value indicating what the next respawnable team is. + /// Gets or sets a value indicating what the next wave is. + /// + public SpawnableWaveBase Wave { get; set; } + + /// + /// Gets a value indicating what the next respawnable team is. /// - public SpawnableWaveBase NextKnownTeam { get; set; } + public SpawnableTeamType NextKnownTeam => Wave.TargetFaction.GetSpawnableTeam(); /// /// Gets or sets a value indicating whether the spawn can occur. diff --git a/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs b/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs index ef323edb7..6c71d3a83 100644 --- a/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs +++ b/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs @@ -54,52 +54,7 @@ public static void OnMapGenerated() PlayerRoles.RoleAssign.HumanSpawner.Handlers[PlayerRoles.Team.OtherAlive] = new PlayerRoles.RoleAssign.OneRoleHumanSpawner(PlayerRoles.RoleTypeId.Tutorial); PlayerRoles.RoleAssign.HumanSpawner.Handlers[PlayerRoles.Team.Dead] = new PlayerRoles.RoleAssign.OneRoleHumanSpawner(PlayerRoles.RoleTypeId.Spectator); - GenerateAttachments(); - Timing.CallDelayed(1, GenerateCache); - } - - private static void GenerateCache() - { - Handlers.Map.OnGenerated(); - - Timing.CallDelayed(0.1f, Handlers.Server.OnWaitingForPlayers); - } - - private static void GenerateAttachments() - { - foreach (FirearmType firearmType in EnumUtils.Values) - { - if (firearmType == FirearmType.None) - continue; - - if (Item.Create(firearmType.GetItemType()) is not Firearm firearm) - continue; - - Firearm.ItemTypeToFirearmInstance.Add(firearmType, firearm); - - List attachmentIdentifiers = ListPool.Pool.Get(); - HashSet attachmentsSlots = HashSetPool.Pool.Get(); - - uint code = 1; - - foreach (Attachment attachment in firearm.Attachments) - { - attachmentsSlots.Add(attachment.Slot); - attachmentIdentifiers.Add(new(code, attachment.Name, attachment.Slot)); - code *= 2U; - } - - uint baseCode = 0; - attachmentsSlots.ForEach(slot => baseCode += attachmentIdentifiers - .Where(attachment => attachment.Slot == slot) - .Min(slot => slot.Code)); - - Firearm.BaseCodesValue.Add(firearmType, baseCode); - Firearm.AvailableAttachmentsValue.Add(firearmType, attachmentIdentifiers.ToArray()); - - ListPool.Pool.Return(attachmentIdentifiers); - HashSetPool.Pool.Return(attachmentsSlots); - } + Timing.CallDelayed(1, Handlers.Map.OnGenerated); } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Handlers/Internal/Round.cs b/EXILED/Exiled.Events/Handlers/Internal/Round.cs index 5c9ff4c5f..7f64274c5 100644 --- a/EXILED/Exiled.Events/Handlers/Internal/Round.cs +++ b/EXILED/Exiled.Events/Handlers/Internal/Round.cs @@ -7,21 +7,31 @@ namespace Exiled.Events.Handlers.Internal { + using System.Collections.Generic; using System.Linq; using CentralAuth; + + using Exiled.API.Enums; using Exiled.API.Extensions; using Exiled.API.Features; + using Exiled.API.Features.Items; + using Exiled.API.Features.Pools; using Exiled.API.Features.Roles; + using Exiled.API.Structs; using Exiled.Events.EventArgs.Player; using Exiled.Events.EventArgs.Scp049; using Exiled.Loader; using Exiled.Loader.Features; using InventorySystem; + using InventorySystem.Items.Firearms.Attachments; + using InventorySystem.Items.Firearms.Attachments.Components; using InventorySystem.Items.Usables; using PlayerRoles; using PlayerRoles.RoleAssign; + using Utils.NonAllocLINQ; + /// /// Handles some round clean-up events and some others related to players. /// @@ -33,6 +43,7 @@ internal static class Round /// public static void OnWaitingForPlayers() { + GenerateAttachments(); MultiAdminFeatures.CallEvent(MultiAdminFeatures.EventType.WAITING_FOR_PLAYERS); if (Events.Instance.Config.ShouldReloadConfigsAtRoundRestart) @@ -93,5 +104,42 @@ public static void OnVerified(VerifiedEventArgs ev) ev.Player.SendFakeSyncVar(room.RoomLightControllerNetIdentity, typeof(RoomLightController), nameof(RoomLightController.NetworkLightsEnabled), false); } } + + private static void GenerateAttachments() + { + foreach (FirearmType firearmType in EnumUtils.Values) + { + if (firearmType == FirearmType.None) + continue; + + if (Item.Create(firearmType.GetItemType()) is not Firearm firearm) + continue; + + Firearm.ItemTypeToFirearmInstance.Add(firearmType, firearm); + + List attachmentIdentifiers = ListPool.Pool.Get(); + HashSet attachmentsSlots = HashSetPool.Pool.Get(); + + uint code = 1; + + foreach (Attachment attachment in firearm.Attachments) + { + attachmentsSlots.Add(attachment.Slot); + attachmentIdentifiers.Add(new(code, attachment.Name, attachment.Slot)); + code *= 2U; + } + + uint baseCode = 0; + attachmentsSlots.ForEach(slot => baseCode += attachmentIdentifiers + .Where(attachment => attachment.Slot == slot) + .Min(slot => slot.Code)); + + Firearm.BaseCodesValue.Add(firearmType, baseCode); + Firearm.AvailableAttachmentsValue.Add(firearmType, attachmentIdentifiers.ToArray()); + + ListPool.Pool.Return(attachmentIdentifiers); + HashSetPool.Pool.Return(attachmentsSlots); + } + } } } diff --git a/EXILED/Exiled.Events/Patches/Events/Map/FillingLocker.cs b/EXILED/Exiled.Events/Patches/Events/Map/FillingLocker.cs index 2ec49178a..a884b6c88 100644 --- a/EXILED/Exiled.Events/Patches/Events/Map/FillingLocker.cs +++ b/EXILED/Exiled.Events/Patches/Events/Map/FillingLocker.cs @@ -44,7 +44,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable list = new(); + List list = new List(); if (inventory.TryGetBodyArmor(out BodyArmor bodyArmor)) + { bodyArmor.DontRemoveExcessOnDrop = true; + } - while (inventory.UserInventory.Items.Count > 0) + HashSet hashSet = HashSetPool.Pool.Get(); + foreach (KeyValuePair item2 in inventory.UserInventory.Items) { - int startCount = inventory.UserInventory.Items.Count; - ushort key = inventory.UserInventory.Items.ElementAt(0).Key; - ItemPickupBase item = inventory.ServerDropItem(key); - - // If the list wasn't changed, we need to manually remove the item to avoid a softlock. - if (startCount == inventory.UserInventory.Items.Count) - inventory.UserInventory.Items.Remove(key); + if (item2.Value is Scp1344Item scp1344Item) + { + scp1344Item.Status = Scp1344Status.Idle; + } else - list.Add(item); + { + hashSet.Add(item2.Key); + } } + foreach (ushort item3 in hashSet) + { + list.Add(inventory.ServerDropItem(item3)); + } + + HashSetPool.Pool.Return(hashSet); InventoryItemProvider.PreviousInventoryPickups[ev.Player.ReferenceHub] = list; } - else + + if (!flag) { while (inventory.UserInventory.Items.Count > 0) { - int startCount = inventory.UserInventory.Items.Count; - ushort key = inventory.UserInventory.Items.ElementAt(0).Key; - inventory.ServerRemoveItem(key, null); - - // If the list wasn't changed, we need to manually remove the item to avoid a softlock. - if (startCount == inventory.UserInventory.Items.Count) - inventory.UserInventory.Items.Remove(key); + inventory.ServerRemoveItem(inventory.UserInventory.Items.ElementAt(0).Key, null); } inventory.UserInventory.ReserveAmmo.Clear(); inventory.SendAmmoNextFrame = true; } - foreach (ItemType item in ev.Items) - inventory.ServerAddItem(item, ItemAddReason.StartingItem); + if (!StartingInventories.DefinedInventories.TryGetValue(ev.NewRole, out InventoryRoleInfo value)) + { + return; + } - foreach (KeyValuePair keyValuePair in ev.Ammo) - inventory.ServerAddAmmo(keyValuePair.Key, keyValuePair.Value); + foreach (KeyValuePair item in value.Ammo) + { + inventory.ServerAddAmmo(item.Key, item.Value); + } - foreach (KeyValuePair item in inventory.UserInventory.Items) - InventoryItemProvider.OnItemProvided?.Invoke(ev.Player.ReferenceHub, item.Value); + for (int i = 0; i < value.Items.Length; i++) + { + ItemBase arg = inventory.ServerAddItem(value.Items[i], ItemAddReason.StartingItem, 0); + InventoryItemProvider.OnItemProvided?.Invoke(ev.Player.ReferenceHub, arg); + } - InventoryItemProvider.SpawnPreviousInventoryPickups(ev.Player.ReferenceHub); + InventoryItemProvider.InventoriesToReplenish.Enqueue(ev.Player.ReferenceHub); } catch (Exception exception) { @@ -251,4 +258,4 @@ private static void ChangeInventory(ChangingRoleEventArgs ev) } } } -} \ No newline at end of file +} diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Joined.cs b/EXILED/Exiled.Events/Patches/Events/Player/Joined.cs index 75fc346a8..18421e504 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Joined.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Joined.cs @@ -39,11 +39,7 @@ internal static void CallEvent(ReferenceHub hub, out Player player) #endif Player.UnverifiedPlayers.Add(hub.gameObject, player); - if (ReferenceHub._hostHub == null) - { - Server.Host = player; - } - else + if (ReferenceHub._hostHub != null) { Handlers.Player.OnJoined(new JoinedEventArgs(player)); } diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs b/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs index 3c779e704..fc1265b8e 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs @@ -18,8 +18,10 @@ namespace Exiled.Events.Patches.Events.Player using HarmonyLib; + using InventorySystem.Items.Firearms; using InventorySystem.Items.Firearms.BasicMessages; using InventorySystem.Items.Firearms.Modules; + using InventorySystem.Items.Firearms.Modules.Misc; using static HarmonyLib.AccessTools; @@ -29,41 +31,33 @@ namespace Exiled.Events.Patches.Events.Player /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Shooting))] - // [HarmonyPatch(typeof(FirearmBasicMessagesHandler), nameof(FirearmBasicMessagesHandler.ServerShotReceived))] + [HarmonyPatch(typeof(ShotBacktrackData), nameof(ShotBacktrackData.ProcessShot))] internal static class Shooting { - /* private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); - Label isAllowedLabel = generator.DefineLabel(); Label returnLabel = generator.DefineLabel(); - LocalBuilder ev = generator.DeclareLocal(typeof(ShootingEventArgs)); - - int offset = -2; - int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(IActionModule), nameof(IActionModule.ServerAuthorizeShot)))) + offset; + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Stloc_2) + offset; newInstructions.InsertRange( index, new[] { - // Player.Get(referenceHub) - new CodeInstruction(OpCodes.Ldloc_0).MoveLabelsFrom(newInstructions[index]), + // Player.Get(firearm.Owner) + new(OpCodes.Ldarg_1), + new(OpCodes.Callvirt, PropertyGetter(typeof(Firearm), nameof(Firearm.Owner))), new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // firearm - new(OpCodes.Ldloc_1), - - // msg - new(OpCodes.Ldarg_1), + new CodeInstruction(OpCodes.Ldarg_1).MoveLabelsFrom(newInstructions[index]), - // ShootingEventArgs ev = new(Player, firearm, ShotMessage) + // ShootingEventArgs ev = new(Player, firearm) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ShootingEventArgs))[0]), new(OpCodes.Dup), - new(OpCodes.Dup), - new(OpCodes.Stloc, ev.LocalIndex), // Handlers.Player.OnShooting(ev) new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnShooting))), @@ -72,12 +66,6 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } - */ } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs b/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs index f740e1637..af8b3a6c2 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Spawning.cs @@ -15,7 +15,6 @@ namespace Exiled.Events.Patches.Events.Player using Exiled.API.Features.Pools; using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Player; - using Exiled.Events.EventArgs.Server; using HarmonyLib; using PlayerRoles.FirstPersonControl.Spawnpoints; @@ -39,9 +38,7 @@ private static IEnumerable Transpiler(IEnumerable - instr.opcode == OpCodes.Callvirt && instr.operand as MethodInfo == setPositionMethod) + offset; + int index = newInstructions.FindIndex(instr => instr.Calls(PropertySetter(typeof(Transform), nameof(Transform.position)))) + offset; // Declare the `SpawningEventArgs` local variable. LocalBuilder ev = generator.DeclareLocal(typeof(SpawningEventArgs)); @@ -90,4 +87,4 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } } -} \ No newline at end of file +} diff --git a/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs b/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs index 2f9651160..d38f91595 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/SpawningRagdoll.cs @@ -45,17 +45,19 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(PropertySetter(typeof(BasicRagdoll), nameof(BasicRagdoll.NetworkInfo)))) + offset; newInstructions.InsertRange(index, new CodeInstruction[] { - // RagdollInfo loads into stack before il inject + // ragdoll.NetworkInfo + new(OpCodes.Ldloc_1), + new(OpCodes.Callvirt, PropertyGetter(typeof(BasicRagdoll), nameof(BasicRagdoll.NetworkInfo))), // true new(OpCodes.Ldc_I4_1), - // SpawningRagdollEventArgs ev = new(RagdollInfo, bool) + // SpawningRagdollEventArgs ev = new(ragdoll, RagdollInfo, bool) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(SpawningRagdollEventArgs))[0]), new(OpCodes.Dup), new(OpCodes.Dup), @@ -71,7 +73,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable event. /// [EventPatch(typeof(Handlers.Scp106), nameof(Handlers.Scp106.ExitStalking))] - [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.StalkActive), MethodType.Setter)] + [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.ServerSetStalk))] public class ExitStalking { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) @@ -36,20 +36,22 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj) + offset; + + int offset = -2; + int index = newInstructions.FindIndex(instruction => instruction.Calls(PropertySetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.StalkActive)))) + offset; + newInstructions.InsertRange( index, new CodeInstruction[] { // if (value is false) continue; new CodeInstruction(OpCodes.Ldarg_1).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Ldc_I4_0), + new(OpCodes.Ldc_I4_1), new(OpCodes.Beq_S, continueLabel), // Player.Get(this.Owner); new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106HuntersAtlasAbility), nameof(Scp106HuntersAtlasAbility.Owner))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.Owner))), new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // true @@ -58,8 +60,6 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj) + offset; - newInstructions[index].labels.Add(continueLabel); + new CodeInstruction(OpCodes.Nop).WithLabels(continueLabel), + }); newInstructions[newInstructions.Count - 1].labels.Add(returnLabel); diff --git a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs index 79fdb2a4e..18394fda4 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs @@ -36,27 +36,21 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - // Find override position - const int offset = -3; - int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(FpcExtensionMethods), nameof(FpcExtensionMethods.TryOverridePosition)))) + offset; - Label returnLabel = generator.DefineLabel(); LocalBuilder curSetting = generator.DeclareLocal(typeof(Scp914KnobSetting)); LocalBuilder ev = generator.DeclareLocal(typeof(UpgradingPlayerEventArgs)); - // Move labels from override - 3 position (Right after a branch) - List Surface = 8, + /// + /// The Pocket Dimension. + /// + Pocket = 16, + /// /// An unknown type of zone. /// - Other = 16, + Other = 32, } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Respawn.cs b/EXILED/Exiled.API/Features/Respawn.cs index d43ac4e1a..1aecd920c 100644 --- a/EXILED/Exiled.API/Features/Respawn.cs +++ b/EXILED/Exiled.API/Features/Respawn.cs @@ -228,6 +228,7 @@ public static void SummonNtfChopper() /// /// Summons the van. /// + /// This will also trigger Music effect. public static void SummonChaosInsurgencyVan() { if (TryGetWaveBase(Faction.FoundationEnemy, out SpawnableWaveBase wave)) diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index 4a3d38eab..d21aee638 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -434,14 +434,14 @@ private static RoomType FindType(GameObject gameObject) "HCZ_MicroHID_New" => RoomType.HczHid, "HCZ_049" => RoomType.Hcz049, "HCZ_Crossing" => RoomType.HczCrossing, - "HCZ_106" => RoomType.Hcz106, + "HCZ_106_Rework" => RoomType.Hcz106, "HCZ_Nuke" => RoomType.HczNuke, "HCZ_Tesla_Rework" => RoomType.HczTesla, "HCZ_Servers" => RoomType.HczServers, - "HCZ_Room3" => RoomType.HczTCross, - "HCZ_457" => RoomType.Hcz096, - "HCZ_Curve" => RoomType.HczCurve, - "HCZ_Straight" => RoomType.HczStraight, + "HCZ_Room3" or "HCZ_Intersection_Junk" or "HCZ_Intersection" => RoomType.HczTCross, + "HCZ_096" => RoomType.Hcz096, + "HCZ_Curve" or "HCZ_Corner_Deep" => RoomType.HczCurve, + "HCZ_Straight_C" or "HCZ_Straight" or "HCZ_Straight_PipeRoom" or "HCZ_Straight Variant" => RoomType.HczStraight, "HCZ_Crossroom_Water" => RoomType.HczCrossRoomWater, "EZ_Endoof" => RoomType.EzVent, "EZ_Intercom" => RoomType.EzIntercom, @@ -451,7 +451,8 @@ private static RoomType FindType(GameObject gameObject) "EZ_PCs" => RoomType.EzPcs, "EZ_Crossing" => RoomType.EzCrossing, "EZ_CollapsedTunnel" => RoomType.EzCollapsedTunnel, - "EZ_Smallrooms2" => RoomType.EzConference, + "EZ_Smallrooms2" or "EZ_Smallrooms1" => RoomType.EzConference, + "EZ_Chef" => RoomType.EzChef, "EZ_Straight" => RoomType.EzStraight, "EZ_Cafeteria" => RoomType.EzCafeteria, "EZ_upstairs" => RoomType.EzUpstairsPcs, @@ -461,14 +462,13 @@ private static RoomType FindType(GameObject gameObject) "PocketWorld" => RoomType.Pocket, "Outside" => RoomType.Surface, "HCZ_939" => RoomType.Hcz939, - "EZ Part" => RoomType.EzCheckpointHallway, + "EZ_HCZ_Checkpoint Part" => RoomType.EzCheckpointHallway, "HCZ_ChkpA" => RoomType.HczElevatorA, "HCZ_ChkpB" => RoomType.HczElevatorB, - "HCZ Part" => gameObject.transform.parent.name switch + "HCZ_EZ_Checkpoint Part" => gameObject.transform.position.z switch { - "HCZ_EZ_Checkpoint (A)" => RoomType.HczEzCheckpointA, - "HCZ_EZ_Checkpoint (B)" => RoomType.HczEzCheckpointB, - _ => RoomType.Unknown + > 80 => RoomType.HczEzCheckpointA, + _ => RoomType.HczEzCheckpointB }, _ => RoomType.Unknown, }; @@ -478,6 +478,9 @@ private static ZoneType FindZone(GameObject gameObject) { Transform transform = gameObject.transform; + if (gameObject.name == "PocketWorld") + return ZoneType.Pocket; + return transform.parent?.name.RemoveBracketsOnEndOfName() switch { "HeavyRooms" => ZoneType.HeavyContainment, From f861858bc211f1f00758d8f00d2ed4cafc673ab5 Mon Sep 17 00:00:00 2001 From: X <24619207+Undid-Iridium@users.noreply.github.com> Date: Thu, 28 Nov 2024 20:23:11 -0500 Subject: [PATCH 034/102] Scp330 bag fix (#256) --- EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs b/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs index e3cf087f6..6971695c9 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs @@ -85,7 +85,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Thu, 28 Nov 2024 20:57:14 -0500 Subject: [PATCH 035/102] Update RestartingRound.cs (#258) --- .../Patches/Events/Server/RestartingRound.cs | 66 ++++--------------- 1 file changed, 11 insertions(+), 55 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RestartingRound.cs b/EXILED/Exiled.Events/Patches/Events/Server/RestartingRound.cs index 39dc587c1..ab4ef8b26 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RestartingRound.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RestartingRound.cs @@ -12,7 +12,10 @@ namespace Exiled.Events.Patches.Events.Server using System.Reflection.Emit; using API.Features.Pools; + using CustomPlayerEffects.Danger; + using Exiled.API.Enums; using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Player; using GameCore; using HarmonyLib; @@ -20,70 +23,23 @@ namespace Exiled.Events.Patches.Events.Server using RoundRestarting; using static HarmonyLib.AccessTools; + using static PlayerList; /// /// Patches . /// Adds the event. /// [EventPatch(typeof(Handlers.Server), nameof(Handlers.Server.RestartingRound))] - [HarmonyPatch(typeof(RoundRestart), nameof(RoundRestart.InitiateRoundRestart))] + [HarmonyPatch(typeof(RoundRestart), nameof(RoundRestart.IsRoundRestarting), MethodType.Setter)] internal static class RestartingRound { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + // TODO: Convert to transpiler and bring back old features + private static void Prefix(bool value) { - List newInstructions = ListPool.Pool.Get(instructions); + if (!value || value == RoundRestart.IsRoundRestarting) + return; - newInstructions.InsertRange( - 0, - new CodeInstruction[] - { - // Handlers.Server.OnRestartingRound() - new(OpCodes.Call, Method(typeof(Handlers.Server), nameof(Handlers.Server.OnRestartingRound))), - - // API.Features.Log.Debug("Round restarting", Loader.ShouldDebugBeShown) - new(OpCodes.Ldstr, "Round restarting"), - new(OpCodes.Call, Method(typeof(API.Features.Log), nameof(API.Features.Log.Debug), new[] { typeof(string) })), - }); - - const int offset = 1; - int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Brfalse); - - newInstructions.InsertRange( - index + offset, - new CodeInstruction[] - { - // if (ServerStatic.StopNextRound == ServerStatic.NextRoundAction.Restart) -> goto normal round restart - new(OpCodes.Call, PropertyGetter(typeof(ServerStatic), nameof(ServerStatic.StopNextRound))), - new(OpCodes.Ldc_I4_1), - new(OpCodes.Beq_S, newInstructions[index].operand), - - // if (ShouldServerRestart()) -> goto normal round restart - new(OpCodes.Call, Method(typeof(RestartingRound), nameof(ShouldServerRestart))), - new(OpCodes.Brtrue, newInstructions[index].operand), - }); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - - private static bool ShouldServerRestart() - { - bool flag = false; - - try - { - int num = ConfigFile.ServerConfig.GetInt("restart_after_rounds"); - - flag = num > 0 && RoundRestart.UptimeRounds >= num; - } - catch (Exception ex) - { - ServerConsole.AddLog("Failed to check the restart_after_rounds config value: " + ex.Message, ConsoleColor.Red); - } - - return flag; + Handlers.Server.OnRestartingRound(); } } -} \ No newline at end of file +} From 44abdc174549a20cef7b9dccc2af4f9a55c942b8 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Thu, 28 Nov 2024 20:57:52 -0500 Subject: [PATCH 036/102] Version bump --- EXILED/EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/EXILED.props b/EXILED/EXILED.props index 8e0f7c3a0..64eee57f1 100644 --- a/EXILED/EXILED.props +++ b/EXILED/EXILED.props @@ -15,7 +15,7 @@ - 9.0.0-alpha.1 + 9.0.0-alpha.2 false From 871b45759b0cfa11e65d375b9861f791c11ddc09 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Fri, 29 Nov 2024 01:36:05 -0500 Subject: [PATCH 037/102] Fix InteractingScp330 (#261) --- .../Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs index 1f39abedb..dc39d420c 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs @@ -34,6 +34,7 @@ public InteractingScp330EventArgs(Player player, int usage) ShouldSever = usage >= 2; ShouldPlaySound = true; IsAllowed = Player.IsHuman; + Candy = Scp330Candies.GetRandom(); if (Scp330Bag.TryGetBag(player.ReferenceHub, out Scp330Bag scp330Bag)) { From e362521567a9a342137cde673d0048c4b53b230c Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Fri, 29 Nov 2024 22:55:21 +0100 Subject: [PATCH 038/102] Fix `Exiled.Events.EventArgs.Scp079.ElevatorTeleportingEventArgs` & Lift.List empty (#268) * fix: scp079 elevator event & lift list empty * fix: lift capacity --- EXILED/Exiled.API/Features/Lift.cs | 2 +- .../Scp079/ElevatorTeleportingEventArgs.cs | 6 +- .../Events/Scp079/ElevatorTeleporting.cs | 108 ++++++++---------- .../Exiled.Events/Patches/Generic/LiftList.cs | 19 ++- 4 files changed, 59 insertions(+), 76 deletions(-) diff --git a/EXILED/Exiled.API/Features/Lift.cs b/EXILED/Exiled.API/Features/Lift.cs index c74942490..53160f9a6 100644 --- a/EXILED/Exiled.API/Features/Lift.cs +++ b/EXILED/Exiled.API/Features/Lift.cs @@ -33,7 +33,7 @@ public class Lift : IWrapper, IWorldSpace /// /// A containing all known s and their corresponding . /// - internal static readonly Dictionary ElevatorChamberToLift = new(8, new ComponentsEqualityComparer()); + internal static readonly Dictionary ElevatorChamberToLift = new(9, new ComponentsEqualityComparer()); /// /// Internal list that contains all ElevatorDoor for current group. diff --git a/EXILED/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs index 48d137a32..85907c0db 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs @@ -29,18 +29,18 @@ public class ElevatorTeleportingEventArgs : IScp079Event, IRoomEvent, IDeniableE /// /// /// - /// + /// /// /// /// /// /// - public ElevatorTeleportingEventArgs(Player player, RoomIdentifier room, ElevatorDoor elevatorDoor, float auxiliaryPowerCost) + public ElevatorTeleportingEventArgs(Player player, RoomIdentifier room, ElevatorChamber elevatorChamber, float auxiliaryPowerCost) { Player = player; Scp079 = player.Role.As(); Room = Room.Get(room); - Lift = Lift.Get(elevatorDoor.Chamber); + Lift = Lift.Get(elevatorChamber); AuxiliaryPowerCost = auxiliaryPowerCost; IsAllowed = auxiliaryPowerCost <= Scp079.Energy; } diff --git a/EXILED/Exiled.Events/Patches/Events/Scp079/ElevatorTeleporting.cs b/EXILED/Exiled.Events/Patches/Events/Scp079/ElevatorTeleporting.cs index 5f25d8984..2173ed5f0 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp079/ElevatorTeleporting.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp079/ElevatorTeleporting.cs @@ -14,11 +14,8 @@ namespace Exiled.Events.Patches.Events.Scp079 using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Scp079; using Exiled.Events.Handlers; - using HarmonyLib; - using Mirror; - using PlayerRoles.PlayableScps.Scp079; using PlayerRoles.PlayableScps.Scp079.Cameras; using PlayerRoles.Subroutines; @@ -40,71 +37,58 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); Label returnLabel = generator.DefineLabel(); - LocalBuilder ev = generator.DeclareLocal(typeof(ElevatorTeleportingEventArgs)); - int offset = 0; - int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldloc_3) + offset; - - // ElevatorTeleportingEventArgs ev = new(Player.Get(base.Owner), base.CurrentCamSync.CurrentCamera.Room, elevatorDoor, (float)this._cost); - // - // Handlers.Scp079.OnElevatorTeleporting(ev); - // - // if (!ev.IsAllowed) - // return; - newInstructions.InsertRange( - index, - new CodeInstruction[] - { - // Player.Get(base.Owner) - new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Call, PropertyGetter(typeof(StandardSubroutine), nameof(StandardSubroutine.Owner))), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - - // base.CurrentCamSync.CurrentCamera.Room - new(OpCodes.Ldarg_0), - new(OpCodes.Call, PropertyGetter(typeof(Scp079AbilityBase), nameof(Scp079AbilityBase.CurrentCamSync))), - new(OpCodes.Callvirt, PropertyGetter(typeof(Scp079CurrentCameraSync), nameof(Scp079CurrentCameraSync.CurrentCamera))), - new(OpCodes.Callvirt, PropertyGetter(typeof(Scp079Camera), nameof(Scp079Camera.Room))), - - // elevatorDoor - new(OpCodes.Ldloc_3), - - // (float)this._cost - new(OpCodes.Ldarg_0), - new(OpCodes.Ldfld, Field(typeof(Scp079ElevatorStateChanger), nameof(Scp079ElevatorStateChanger._cost))), - new(OpCodes.Conv_R4), - - // ElevatorTeleportingEventArgs ev = new(Player, RoomIdentifier, ElevatorDoor, float) - new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ElevatorTeleportingEventArgs))[0]), - new(OpCodes.Dup), - new(OpCodes.Dup), - new(OpCodes.Stloc_S, ev.LocalIndex), - - // Scp079.OnElevatorTeleporting(ev); - new(OpCodes.Call, Method(typeof(Scp079), nameof(Scp079.OnElevatorTeleporting))), - - // if (!ev.IsAllowed) - // return; - new(OpCodes.Callvirt, PropertyGetter(typeof(ElevatorTeleportingEventArgs), nameof(ElevatorTeleportingEventArgs.IsAllowed))), - new(OpCodes.Brfalse, returnLabel), - }); - - // Replace "(float)this._cost" with "ev.AuxiliaryPowerCost" + int offset = -3; + int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldloc_2) + offset; + + newInstructions.InsertRange(index, new[] + { + // Player.Get(base.Owner) + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Call, PropertyGetter(typeof(StandardSubroutine), nameof(StandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + + // base.CurrentCamSync.CurrentCamera.Room + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(Scp079AbilityBase), nameof(Scp079AbilityBase.CurrentCamSync))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp079CurrentCameraSync), nameof(Scp079CurrentCameraSync.CurrentCamera))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp079Camera), nameof(Scp079Camera.Room))), + + // chamber + new(OpCodes.Ldloc_2), + + // (float)this._cost + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079ElevatorStateChanger), nameof(Scp079ElevatorStateChanger._cost))), + new(OpCodes.Conv_R4), + + // ElevatorTeleportingEventArgs ev = new(Player, RoomIdentifier, ElevatorChamber, float) + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ElevatorTeleportingEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), + + // Scp079.OnElevatorTeleporting(ev); + new(OpCodes.Call, Method(typeof(Scp079), nameof(Scp079.OnElevatorTeleporting))), + + // if (!ev.IsAllowed) + // return; + new(OpCodes.Callvirt, PropertyGetter(typeof(ElevatorTeleportingEventArgs), nameof(ElevatorTeleportingEventArgs.IsAllowed))), + new(OpCodes.Brfalse, returnLabel), + }); + offset = -1; - index = newInstructions.FindLastIndex( - instruction => instruction.LoadsField(Field(typeof(Scp079ElevatorStateChanger), nameof(Scp079ElevatorStateChanger._cost)))) + offset; + index = newInstructions.FindLastIndex(instruction => instruction.LoadsField(Field(typeof(Scp079ElevatorStateChanger), nameof(Scp079ElevatorStateChanger._cost)))) + offset; newInstructions.RemoveRange(index, 3); - newInstructions.InsertRange( - index, - new CodeInstruction[] - { - // ev.AuxiliaryPowerCost - new(OpCodes.Ldloc, ev.LocalIndex), - new(OpCodes.Callvirt, PropertyGetter(typeof(ElevatorTeleportingEventArgs), nameof(ElevatorTeleportingEventArgs.AuxiliaryPowerCost))), - }); + newInstructions.InsertRange(index, new CodeInstruction[] + { + // ev.AuxiliaryPowerCost + new(OpCodes.Ldloc, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ElevatorTeleportingEventArgs), nameof(ElevatorTeleportingEventArgs.AuxiliaryPowerCost))), + }); newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); diff --git a/EXILED/Exiled.Events/Patches/Generic/LiftList.cs b/EXILED/Exiled.Events/Patches/Generic/LiftList.cs index 2b0e448e8..d4b212dcd 100644 --- a/EXILED/Exiled.Events/Patches/Generic/LiftList.cs +++ b/EXILED/Exiled.Events/Patches/Generic/LiftList.cs @@ -7,25 +7,24 @@ namespace Exiled.Events.Patches.Generic { +#pragma warning disable SA1313 // Parameter names should begin with lower-case letter using API.Features; using HarmonyLib; using Interactables.Interobjects; /// - /// Patches . + /// Patches to control . /// - [HarmonyPatch(typeof(ElevatorManager), nameof(ElevatorManager.SpawnAllChambers))] + [HarmonyPatch] internal class LiftList { - private static void Postfix() - { - Lift.ElevatorChamberToLift.Clear(); + [HarmonyPatch(typeof(ElevatorChamber), nameof(ElevatorChamber.Start))] + [HarmonyPostfix] + private static void Adding(ElevatorChamber __instance) => _ = new Lift(__instance); - foreach (ElevatorChamber lift in ElevatorChamber.AllChambers) - { - _ = new Lift(lift); - } - } + [HarmonyPatch(typeof(ElevatorChamber), nameof(ElevatorChamber.OnDestroy))] + [HarmonyPostfix] + private static void Removing(ElevatorChamber __instance) => Lift.ElevatorChamberToLift.Remove(__instance); } } \ No newline at end of file From 0a210ce9ac162d991c57dcea28305f72b38bc864 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Sat, 30 Nov 2024 05:52:01 +0100 Subject: [PATCH 039/102] Fix Flashbang & HE (#270) --- EXILED/Exiled.API/Extensions/RoleExtensions.cs | 17 +++++++++++++++++ EXILED/Exiled.API/Features/Roles/Role.cs | 5 +++++ .../Patches/Events/Map/ExplodingFlashGrenade.cs | 10 +++++----- .../Patches/Generic/IndividualFriendlyFire.cs | 5 +++-- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index e86805f00..407e26565 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -13,6 +13,7 @@ namespace Exiled.API.Extensions using Enums; using Exiled.API.Features.Spawn; + using Footprinting; using InventorySystem; using InventorySystem.Configs; using PlayerRoles; @@ -27,6 +28,22 @@ namespace Exiled.API.Extensions /// public static class RoleExtensions { + /// + /// Compares LifeIdentifier. + /// + /// The footprint to compare. + /// The other footprint. + /// If LifeIdentifier is the same (same role). + public static bool CompareLife(this Footprint footprint, Footprint other) => footprint.LifeIdentifier == other.LifeIdentifier; + + /// + /// Compares LifeIdentifier. + /// + /// The footprint to compare. + /// The hub to compare to. + /// If LifeIdentifier is the same (same role). + public static bool CompareLife(this Footprint footprint, ReferenceHub other) => footprint.LifeIdentifier == other.roleManager.CurrentRole.UniqueLifeIdentifier; + /// /// Gets a role's . /// diff --git a/EXILED/Exiled.API/Features/Roles/Role.cs b/EXILED/Exiled.API/Features/Roles/Role.cs index 0b636e95f..ef6d8dcea 100644 --- a/EXILED/Exiled.API/Features/Roles/Role.cs +++ b/EXILED/Exiled.API/Features/Roles/Role.cs @@ -114,6 +114,11 @@ protected Role(PlayerRoleBase baseRole) ///
public bool IsValid => Owner != null && Owner.IsConnected && Base == Owner.RoleManager.CurrentRole; + /// + /// Gets the life identifier for the role. + /// + public int LifeIdentifier => Base.UniqueLifeIdentifier; + /// /// Gets a random spawn position of this role. /// diff --git a/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs b/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs index 29cabcadb..bfb61c181 100644 --- a/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs +++ b/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs @@ -12,6 +12,7 @@ namespace Exiled.Events.Patches.Events.Map using API.Features; using API.Features.Pools; + using Exiled.API.Extensions; using Exiled.Events.EventArgs.Map; using Exiled.Events.Patches.Generic; using Footprinting; @@ -63,14 +64,13 @@ private static IEnumerable Transpiler(IEnumerable targetToAffect = ListPool.Pool.Get(); - foreach (ReferenceHub referenceHub in ReferenceHub.AllHubs) + foreach (Player player in Player.List) { - Player player = Player.Get(referenceHub); - if ((instance.transform.position - referenceHub.transform.position).sqrMagnitude >= distance) + if ((instance.transform.position - player.Position).sqrMagnitude >= distance) continue; - if (!ExiledEvents.Instance.Config.CanFlashbangsAffectThrower && instance.PreviousOwner.LifeIdentifier != new Footprint(referenceHub).LifeIdentifier) + if (!ExiledEvents.Instance.Config.CanFlashbangsAffectThrower && instance.PreviousOwner.CompareLife(player.ReferenceHub)) continue; - if (!IndividualFriendlyFire.CheckFriendlyFirePlayer(instance.PreviousOwner, player.ReferenceHub) && instance.PreviousOwner.LifeIdentifier != new Footprint(referenceHub).LifeIdentifier) + if (!IndividualFriendlyFire.CheckFriendlyFirePlayer(instance.PreviousOwner, player.ReferenceHub) && !instance.PreviousOwner.CompareLife(player.ReferenceHub)) continue; if (Physics.Linecast(instance.transform.position, player.CameraTransform.position, instance._blindingMask)) continue; diff --git a/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs b/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs index d95b88a87..d8ae22934 100644 --- a/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs +++ b/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs @@ -7,6 +7,8 @@ namespace Exiled.Events.Patches.Generic { + using Exiled.API.Extensions; + #pragma warning disable SA1402 using System; using System.Collections.Generic; @@ -96,8 +98,7 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref return true; // Only check friendlyFire if the FootPrint hasn't changed (Fix for Grenade not dealing damage because it's from a dead player) - // TODO rework FriendlyFireRule to make it compatible with Footprint - if (!attackerFootprint.Equals(new Footprint(attackerFootprint.Hub))) + if (!attackerFootprint.CompareLife(new Footprint(attackerFootprint.Hub))) return false; // Check if attackerFootprint.Hub or victimHub is null and log debug information From 8d13ff49f2435338f4d9d6a43832ccecbcc7de01 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Fri, 29 Nov 2024 23:58:27 -0500 Subject: [PATCH 040/102] Fix Shot event (#263) --- EXILED/Exiled.Events/Patches/Events/Player/Shot.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs b/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs index dc9b0ba03..6a9c4e201 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs @@ -71,19 +71,20 @@ private static IEnumerable Transpiler(IEnumerable Date: Sat, 30 Nov 2024 01:07:41 -0500 Subject: [PATCH 041/102] Fix ChangingItem patch (#272) --- EXILED/Exiled.Events/Patches/Events/Player/ChangingItem.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ChangingItem.cs b/EXILED/Exiled.Events/Patches/Events/Player/ChangingItem.cs index d4ee8d7d3..fa964cad8 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/ChangingItem.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/ChangingItem.cs @@ -41,8 +41,9 @@ private static IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Bne_Un_S) + offset; + const int offset = 3; + int index = newInstructions.FindIndex( + instruction => instruction.Calls(PropertyGetter(typeof(ItemBase), nameof(ItemBase.AllowEquip)))) + offset; newInstructions.InsertRange( index, From 12b599cb6c6488f49565287ffceaa469ac822a12 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Sat, 30 Nov 2024 01:54:46 -0500 Subject: [PATCH 042/102] Fix Stalking event (#273) --- .../EventArgs/Scp106/StalkingEventArgs.cs | 6 +-- .../Patches/Events/Scp106/Stalking.cs | 43 +++---------------- 2 files changed, 10 insertions(+), 39 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs index 1ed03bc42..dcfac59af 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs @@ -24,12 +24,11 @@ public class StalkingEventArgs : IScp106Event, IDeniableEvent /// Initializes a new instance of the class. ///
/// - /// - public StalkingEventArgs(Player player, bool isAllowed = true) + public StalkingEventArgs(Player player) { Player = player; Scp106 = player.Role.As(); - IsAllowed = isAllowed; + IsAllowed = true; MinimumVigor = Scp106StalkAbility.MinVigorToSubmerge; } @@ -66,6 +65,7 @@ public float Vigor /// /// Gets or sets a value indicating whether SCP-106 can stalk. /// + /// IsAllowed doesn't indicate whether vigor is sufficient for Stalking. needs to be changed to override the base game check. public bool IsAllowed { get; set; } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs b/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs index 977f8075c..2ffad3da9 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs @@ -36,48 +36,19 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)PropertyGetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.StalkActive))) + offset; + int offset = -1; + int index = newInstructions.FindIndex(instruction => instruction.Calls(PropertyGetter(typeof(Scp106VigorAbilityBase), nameof(Scp106VigorAbilityBase.VigorAmount)))) + offset; newInstructions.InsertRange( index, new CodeInstruction[] { + // Inserted before vigor amount check // Player.Get(this.Owner); new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106HuntersAtlasAbility), nameof(Scp106HuntersAtlasAbility.Owner))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.Owner))), new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - // true - new(OpCodes.Ldc_I4_1), - - // StalkingEventArgs ev = new(Player, isAllowed) - new(OpCodes.Newobj, GetDeclaredConstructors(typeof(StalkingEventArgs))[0]), - new(OpCodes.Dup), - new(OpCodes.Dup), - new(OpCodes.Stloc_S, ev.LocalIndex), - - // Handlers.Scp106.OnFinishingRecall(ev) - new(OpCodes.Call, Method(typeof(Handlers.Scp106), nameof(Handlers.Scp106.OnStalking))), - - // if (!ev.IsAllowed) - // return; - new(OpCodes.Callvirt, PropertyGetter(typeof(StalkingEventArgs), nameof(StalkingEventArgs.IsAllowed))), - new(OpCodes.Brfalse_S, returnLabel), - }); - - newInstructions.InsertRange( - newInstructions.Count - 1, - new CodeInstruction[] - { - // Player.Get(this.Owner); - new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106HuntersAtlasAbility), nameof(Scp106HuntersAtlasAbility.Owner))), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - - // true - new(OpCodes.Ldc_I4_1), - - // StalkingEventArgs ev = new(Player, isAllowed) + // StalkingEventArgs ev = new(Player) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(StalkingEventArgs))[0]), new(OpCodes.Dup), new(OpCodes.Dup), @@ -87,7 +58,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Sat, 30 Nov 2024 03:56:49 -0500 Subject: [PATCH 043/102] Version bump --- EXILED/EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/EXILED.props b/EXILED/EXILED.props index 64eee57f1..bf96b2e25 100644 --- a/EXILED/EXILED.props +++ b/EXILED/EXILED.props @@ -15,7 +15,7 @@ - 9.0.0-alpha.2 + 9.0.0-alpha.3 false From 426643f89bf7c4d88068cd4a6eb67cb507d33930 Mon Sep 17 00:00:00 2001 From: Rysik5318 <72207886+Rysik5318@users.noreply.github.com> Date: Sat, 30 Nov 2024 13:44:13 +0400 Subject: [PATCH 044/102] Add Door.Repair (#260) * Add Repair Door * Update Door.cs * Update EXILED/Exiled.API/Features/Doors/BreakableDoor.cs Co-authored-by: VALERA771 <72030575+VALERA771@users.noreply.github.com> * Update EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs Co-authored-by: VALERA771 <72030575+VALERA771@users.noreply.github.com> --------- Co-authored-by: VALERA771 <72030575+VALERA771@users.noreply.github.com> --- EXILED/Exiled.API/Features/Doors/BreakableDoor.cs | 5 +++++ EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs | 5 +++++ EXILED/Exiled.API/Features/Doors/Door.cs | 6 +----- EXILED/Exiled.API/Interfaces/IDamageableDoor.cs | 5 +++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/EXILED/Exiled.API/Features/Doors/BreakableDoor.cs b/EXILED/Exiled.API/Features/Doors/BreakableDoor.cs index 9148067dd..862332c89 100644 --- a/EXILED/Exiled.API/Features/Doors/BreakableDoor.cs +++ b/EXILED/Exiled.API/Features/Doors/BreakableDoor.cs @@ -92,6 +92,11 @@ public bool IgnoreRemoteAdmin set => Base._nonInteractable = value; } + /// + /// Repair the door. + /// + public void Repair() => Base.ServerRepair(); + /// /// Damages the door. /// diff --git a/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs b/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs index 9681290d8..837bd5ff7 100644 --- a/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs +++ b/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs @@ -133,6 +133,11 @@ public DoorDamageType IgnoredDamage ///
internal List SubDoorsValue { get; } = new(); + /// + /// Repair the door. + /// + public void Repair() => Base.ServerRepair(); + /// /// Toggles the state of the doors from . /// diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index bfdede33d..5334419c0 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -14,17 +14,13 @@ 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; using Mirror; using UnityEngine; - using static Interactables.Interobjects.ElevatorManager; - using BaseBreakableDoor = Interactables.Interobjects.BreakableDoor; using BaseKeycardPermissions = Interactables.Interobjects.DoorUtils.KeycardPermissions; using Breakable = BreakableDoor; @@ -640,7 +636,6 @@ private DoorType GetDoorType() "NUKE_ARMORY" => DoorType.NukeArmory, "LCZ_ARMORY" => DoorType.LczArmory, "SURFACE_NUKE" => DoorType.NukeSurface, - "HID_CHAMBER" => DoorType.HIDChamber, "HCZ_ARMORY" => DoorType.HczArmory, "096" => DoorType.Scp096, "049_ARMORY" => DoorType.Scp049Armory, @@ -653,6 +648,7 @@ private DoorType GetDoorType() "SERVERS_BOTTOM" => DoorType.ServersBottom, "173_CONNECTOR" => DoorType.Scp173Connector, "LCZ_WC" => DoorType.LczWc, + "HID_CHAMBER" => DoorType.HIDChamber, "HID_UPPER" => DoorType.HIDUpper, "HID_LOWER" => DoorType.HIDLower, "173_ARMORY" => DoorType.Scp173Armory, diff --git a/EXILED/Exiled.API/Interfaces/IDamageableDoor.cs b/EXILED/Exiled.API/Interfaces/IDamageableDoor.cs index d5de3d106..f98eebde9 100644 --- a/EXILED/Exiled.API/Interfaces/IDamageableDoor.cs +++ b/EXILED/Exiled.API/Interfaces/IDamageableDoor.cs @@ -39,6 +39,11 @@ public interface IDamageableDoor ///
public DoorDamageType IgnoredDamage { get; set; } + /// + /// Repair the door. + /// + public void Repair(); + /// /// Damages the door. /// From ce3762701a82d60252ed953c6f7951bee7a7bf7a Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Sat, 30 Nov 2024 05:58:09 -0500 Subject: [PATCH 045/102] Update IndividualFriendlyFire.cs (#274) --- EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs b/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs index d8ae22934..05c78cc3e 100644 --- a/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs +++ b/EXILED/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs @@ -212,7 +212,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.LoadsField(Field(typeof(ReferenceHub), nameof(ReferenceHub.networkIdentity)))) + offset; + instruction => instruction.Calls(PropertyGetter(typeof(AttackerDamageHandler), nameof(AttackerDamageHandler.Attacker)))) + offset; LocalBuilder ffMulti = generator.DeclareLocal(typeof(float)); From 691fb20a51b3189bdd549b6fcb756d1b41849d07 Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Sat, 30 Nov 2024 12:30:53 +0100 Subject: [PATCH 046/102] fix: rework prefab helper (#266) --- EXILED/Exiled.API/Features/PrefabHelper.cs | 100 ++++++++++-------- EXILED/Exiled.Events/Events.cs | 2 + .../Handlers/Internal/ClientStarted.cs | 53 ++++++++++ .../Handlers/Internal/MapGenerated.cs | 15 --- 4 files changed, 111 insertions(+), 59 deletions(-) create mode 100644 EXILED/Exiled.Events/Handlers/Internal/ClientStarted.cs diff --git a/EXILED/Exiled.API/Features/PrefabHelper.cs b/EXILED/Exiled.API/Features/PrefabHelper.cs index 4fe664cc5..c80d2ab20 100644 --- a/EXILED/Exiled.API/Features/PrefabHelper.cs +++ b/EXILED/Exiled.API/Features/PrefabHelper.cs @@ -9,8 +9,6 @@ namespace Exiled.API.Features { using System; using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Linq; using System.Reflection; using Exiled.API.Enums; @@ -23,18 +21,21 @@ namespace Exiled.API.Features ///
public static class PrefabHelper { - private static readonly Dictionary Stored = new(); + /// + /// A containing all and their corresponding . + /// + internal static readonly Dictionary Prefabs = new(Enum.GetValues(typeof(PrefabType)).Length); /// - /// Gets a dictionary of to . + /// Gets a of and their corresponding . /// - public static ReadOnlyDictionary PrefabToGameObject => new(Stored); + public static IReadOnlyDictionary PrefabToGameObject => Prefabs; /// - /// Gets the prefab attribute of a prefab type. + /// Gets the from a . /// - /// The prefab type. - /// The . + /// The . + /// The corresponding . public static PrefabAttribute GetPrefabAttribute(this PrefabType prefabType) { Type type = prefabType.GetType(); @@ -42,64 +43,75 @@ public static PrefabAttribute GetPrefabAttribute(this PrefabType prefabType) } /// - /// Gets the prefab of the specified . + /// Gets the of the specified . + /// + /// The . + /// Returns the . + public static GameObject GetPrefab(PrefabType prefabType) + { + if (Prefabs.TryGetValue(prefabType, out GameObject prefab)) + return prefab; + + return null; + } + + /// + /// Tries to get the of the specified . + /// + /// The . + /// The of the . + /// Returns true if the was found. + public static bool TryGetPrefab(PrefabType prefabType, out GameObject gameObject) + { + gameObject = GetPrefab(prefabType); + return gameObject is not null; + } + + /// + /// Gets a from the of the specified . /// - /// The to get prefab of. - /// The to get. - /// Returns the prefab component as {T}. - public static T GetPrefab(PrefabType type) + /// The . + /// The type. + /// Returns the . + public static T GetPrefab(PrefabType prefabType) where T : Component { - if (!Stored.TryGetValue(type, out GameObject gameObject) || !gameObject.TryGetComponent(out T component)) - return null; + if (Prefabs.TryGetValue(prefabType, out GameObject prefab) && prefab.TryGetComponent(out T component)) + return component; - return component; + return null; } /// - /// Spawns a prefab on server. + /// Spawns the of the specified . /// - /// The prefab type. - /// The position to spawn the prefab. - /// The rotation of the prefab. - /// The instantied. + /// The . + /// The position where the will spawn. + /// The rotation of the . + /// Returns the instantied. public static GameObject Spawn(PrefabType prefabType, Vector3 position = default, Quaternion rotation = default) { - if (!Stored.TryGetValue(prefabType, out GameObject gameObject)) + if (!TryGetPrefab(prefabType, out GameObject gameObject)) return null; + GameObject newGameObject = UnityEngine.Object.Instantiate(gameObject, position, rotation); NetworkServer.Spawn(newGameObject); return newGameObject; } /// - /// Spawns a prefab on server. + /// Spawns the of the specified . /// - /// The prefab type. - /// The position to spawn the prefab. - /// The rotation of the prefab. + /// The . + /// The position where the will spawn. + /// The rotation of the . /// The type. - /// The instantied. + /// Returns the of the . public static T Spawn(PrefabType prefabType, Vector3 position = default, Quaternion rotation = default) where T : Component { - T obj = UnityEngine.Object.Instantiate(GetPrefab(prefabType), position, rotation); - NetworkServer.Spawn(obj.gameObject); - return obj; - } - - /// - /// Loads all prefabs. - /// - internal static void LoadPrefabs() - { - Stored.Clear(); - - foreach (PrefabType prefabType in EnumUtils.Values) - { - PrefabAttribute attribute = prefabType.GetPrefabAttribute(); - Stored.Add(prefabType, NetworkClient.prefabs.FirstOrDefault(prefab => prefab.Key == attribute.AssetId || prefab.Value.name.Contains(attribute.Name)).Value); - } + GameObject gameObject = Spawn(prefabType, position, rotation); + return gameObject?.GetComponent(); } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Events.cs b/EXILED/Exiled.Events/Events.cs index d06cb587c..fcdd47cf1 100644 --- a/EXILED/Exiled.Events/Events.cs +++ b/EXILED/Exiled.Events/Events.cs @@ -59,6 +59,7 @@ public override void OnEnabled() Log.Info($"{(Config.UseDynamicPatching ? "Non-event" : "All")} patches completed in {watch.Elapsed}"); PlayerAuthenticationManager.OnInstanceModeChanged -= RoleAssigner.CheckLateJoin; + CustomNetworkManager.OnClientStarted += Handlers.Internal.ClientStarted.OnClientStarted; SceneManager.sceneUnloaded += Handlers.Internal.SceneUnloaded.OnSceneUnloaded; MapGeneration.SeedSynchronizer.OnGenerationFinished += Handlers.Internal.MapGenerated.OnMapGenerated; UsableItemsController.ServerOnUsingCompleted += Handlers.Internal.Round.OnServerOnUsingCompleted; @@ -91,6 +92,7 @@ public override void OnDisabled() Unpatch(); + CustomNetworkManager.OnClientStarted -= Handlers.Internal.ClientStarted.OnClientStarted; SceneManager.sceneUnloaded -= Handlers.Internal.SceneUnloaded.OnSceneUnloaded; MapGeneration.SeedSynchronizer.OnGenerationFinished -= Handlers.Internal.MapGenerated.OnMapGenerated; UsableItemsController.ServerOnUsingCompleted -= Handlers.Internal.Round.OnServerOnUsingCompleted; diff --git a/EXILED/Exiled.Events/Handlers/Internal/ClientStarted.cs b/EXILED/Exiled.Events/Handlers/Internal/ClientStarted.cs new file mode 100644 index 000000000..a260cf495 --- /dev/null +++ b/EXILED/Exiled.Events/Handlers/Internal/ClientStarted.cs @@ -0,0 +1,53 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Handlers.Internal +{ + using System.Collections.Generic; + using System.Linq; + + using Exiled.API.Enums; + using Exiled.API.Features; + using Exiled.API.Features.Attributes; + using Mirror; + using PlayerRoles.Ragdolls; + using UnityEngine; + + /// + /// Handles on client started event. + /// + internal static class ClientStarted + { + /// + /// Called once when the client is started. + /// + public static void OnClientStarted() + { + PrefabHelper.Prefabs.Clear(); + + Dictionary prefabs = new(); + + foreach (KeyValuePair prefab in NetworkClient.prefabs) + { + if(!prefabs.ContainsKey(prefab.Key)) + prefabs.Add(prefab.Key, prefab.Value); + } + + foreach (NetworkIdentity ragdollPrefab in RagdollManager.AllRagdollPrefabs) + { + if(!prefabs.ContainsKey(ragdollPrefab.assetId)) + prefabs.Add(ragdollPrefab.assetId, ragdollPrefab.gameObject); + } + + foreach (PrefabType prefabType in EnumUtils.Values) + { + PrefabAttribute attribute = prefabType.GetPrefabAttribute(); + PrefabHelper.Prefabs.Add(prefabType, prefabs.FirstOrDefault(prefab => prefab.Key == attribute.AssetId || prefab.Value.name.Contains(attribute.Name)).Value); + } + } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs b/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs index 6c71d3a83..8014a45e9 100644 --- a/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs +++ b/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs @@ -7,25 +7,11 @@ namespace Exiled.Events.Handlers.Internal { - using System; - using System.Collections.Generic; - using System.Linq; - using API.Features; - using API.Features.Items; - using API.Features.Pools; - using API.Structs; - - using Exiled.API.Enums; - using Exiled.API.Extensions; using Exiled.API.Features.Lockers; - using InventorySystem.Items.Firearms.Attachments; - using InventorySystem.Items.Firearms.Attachments.Components; using MEC; - using Utils.NonAllocLINQ; - /// /// Handles event. /// @@ -46,7 +32,6 @@ internal static class MapGenerated public static void OnMapGenerated() { Map.ClearCache(); - PrefabHelper.LoadPrefabs(); Locker.ClearCache(); // TODO: Fix For (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/377) From e8436964e0a4759794d86e178e688830794746ea Mon Sep 17 00:00:00 2001 From: X <24619207+Undid-Iridium@users.noreply.github.com> Date: Sat, 30 Nov 2024 09:06:45 -0500 Subject: [PATCH 047/102] Round end fix (#232) * Maybe fixes it - Network ExtraTarget changed to ExtraTarget >0 * Stylecop * Stylecop * Grab referencehub --------- Co-authored-by: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> --- .../Exiled.Events/Patches/Events/Server/RoundEnd.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs index 9412f3fb9..9088c7ed3 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs @@ -9,6 +9,7 @@ namespace Exiled.Events.Patches.Events.Server { using System; using System.Collections.Generic; + using System.Linq; using System.Reflection; using System.Reflection.Emit; @@ -36,8 +37,15 @@ internal static class RoundEnd private static MethodInfo TargetMethod() { - PrivateType = typeof(RoundSummary).GetNestedTypes(all)[6]; - return Method(PrivateType, "MoveNext"); + PrivateType = typeof(RoundSummary).GetNestedTypes(all) + .FirstOrDefault(currentType => currentType.Name.Contains("_ProcessServerSideCode")); + if (PrivateType == null) + throw new Exception("State machine type for _ProcessServerSideCode not found."); + MethodInfo moveNextMethod = PrivateType.GetMethod("MoveNext", all); + + if (moveNextMethod == null) + throw new Exception("MoveNext method not found in the state machine type."); + return moveNextMethod; } private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) @@ -71,7 +79,6 @@ private static IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Ldfld && x.operand == (object)Field(typeof(RoundSummary), nameof(RoundSummary._roundEnded))) + offset; - LocalBuilder evEndingRound = generator.DeclareLocal(typeof(EndingRoundEventArgs)); newInstructions.InsertRange( From 9f935712b7d4e6579f0ac342d884962fe011b1a2 Mon Sep 17 00:00:00 2001 From: Yamato Date: Sat, 30 Nov 2024 16:20:41 +0100 Subject: [PATCH 048/102] OnlyWayToCheckThis --- EXILED/Exiled.API/Features/Window.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/EXILED/Exiled.API/Features/Window.cs b/EXILED/Exiled.API/Features/Window.cs index f0765b732..a84767e1e 100644 --- a/EXILED/Exiled.API/Features/Window.cs +++ b/EXILED/Exiled.API/Features/Window.cs @@ -220,9 +220,7 @@ public void DamageWindow(float amount, DamageHandlerBase handler) RoomType.LczGlassBox => GlassType.GR18, RoomType.LczPlants => GlassType.Plants, RoomType.Hcz049 => GlassType.Scp049, - - // TODO: Recontainer.Base._activatorGlass == Base ? GlassType.Scp079Trigger : GlassType.Scp079 - RoomType.Hcz079 => GlassType.Scp079, + RoomType.Hcz079 => Base._preventScpDamage ? GlassType.Scp079Trigger : GlassType.Scp079, RoomType.HczHid => GlassType.MicroHid, RoomType.HczTestRoom => GlassType.TestRoom, RoomType.HczEzCheckpointA => GlassType.HczEzCheckpointA, From f0899299b42e95ed87a3694996d2692c15d10d59 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Sat, 30 Nov 2024 21:26:16 +0100 Subject: [PATCH 049/102] Delete Exiled.API (#280) --- EXILED/Exiled.Loader/Loader.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index a0e78dccf..783a1137e 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -121,6 +121,7 @@ public Loader() public static void LoadPlugins() { File.Delete(Path.Combine(Paths.Plugins, "Exiled.Updater.dll")); + File.Delete(Path.Combine(Paths.Dependencies, "Exiled.API.dll")); foreach (string assemblyPath in Directory.GetFiles(Paths.Plugins, "*.dll")) { From 936ef36dfb9fb5442397a7f7aaf2dccf93820345 Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Sat, 30 Nov 2024 21:26:33 +0100 Subject: [PATCH 050/102] fix: player comparison (#279) --- EXILED/Exiled.API/Features/Player.cs | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 80a09d4aa..788493ca9 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -3724,6 +3724,37 @@ public void SetCooldownItem(float time, ItemType itemType) /// The projectile that will create the effect. public void ExplodeEffect(ProjectileType projectileType) => Map.ExplodeEffect(Position, projectileType); + /// + public override bool Equals(object obj) + { + Player player = obj as Player; + return (object)player != null && ReferenceHub == player.ReferenceHub; + } + + /// + public override int GetHashCode() + { + return ReferenceHub.GetHashCode(); + } + + /// + /// Returns whether the two players are the same. + /// + /// The first player instance. + /// The second player instance. + /// if the values are equal. +#pragma warning disable SA1201 + public static bool operator ==(Player player1, Player player2) => player1?.Equals(player2) ?? player2 is null; + + /// + /// Returns whether the two players are different. + /// + /// The first player instance. + /// The second player instance. + /// if the values are not equal. + public static bool operator !=(Player player1, Player player2) => !(player1 == player2); +#pragma warning restore SA1201 + /// /// Converts the player in a human-readable format. /// From a7bd4db98bd7abdfbf387f42cb95ce0b2db7784e Mon Sep 17 00:00:00 2001 From: Rysik5318 <72207886+Rysik5318@users.noreply.github.com> Date: Sun, 1 Dec 2024 00:30:58 +0400 Subject: [PATCH 051/102] Add Scp1344 Events and Scp1344 Item (#264) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add Scp1344 * Update Scp1344.cs * Update Scp1344.cs * Update Scp1344.cs * Update Scp1344.cs * Add Scp1344 Events * Cringe * Проzчитался веzде * Ебёмся с HarmonyPatch день 1 * Update Status.cs * Update Status.cs * О боже... * Забыл * Oops * Да я ебал * Add Events * Oops * Oops v3 * Fix HarmonyPatch * Update Deactivating.cs * Fix Patch * Cringe --------- Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com> --- EXILED/Exiled.API/Features/Items/Item.cs | 5 ++ EXILED/Exiled.API/Features/Items/Scp1344.cs | 83 +++++++++++++++++++ .../EventArgs/Interfaces/IScp1344Event.cs | 22 +++++ .../Scp1344/ChangedStatusEventArgs.cs | 55 ++++++++++++ .../Scp1344/ChangingStatusEventArgs.cs | 64 ++++++++++++++ .../EventArgs/Scp1344/DeactivatedEventArgs.cs | 44 ++++++++++ .../Scp1344/DeactivatingEventArgs.cs | 49 +++++++++++ .../Scp1344/TryingDeactivatingEventArgs.cs | 49 +++++++++++ EXILED/Exiled.Events/Handlers/Scp1344.cs | 75 +++++++++++++++++ .../Patches/Events/Scp1344/Deactivating.cs | 73 ++++++++++++++++ .../Patches/Events/Scp1344/Status.cs | 42 ++++++++++ 11 files changed, 561 insertions(+) create mode 100644 EXILED/Exiled.API/Features/Items/Scp1344.cs create mode 100644 EXILED/Exiled.Events/EventArgs/Interfaces/IScp1344Event.cs create mode 100644 EXILED/Exiled.Events/EventArgs/Scp1344/ChangedStatusEventArgs.cs create mode 100644 EXILED/Exiled.Events/EventArgs/Scp1344/ChangingStatusEventArgs.cs create mode 100644 EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatedEventArgs.cs create mode 100644 EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatingEventArgs.cs create mode 100644 EXILED/Exiled.Events/EventArgs/Scp1344/TryingDeactivatingEventArgs.cs create mode 100644 EXILED/Exiled.Events/Handlers/Scp1344.cs create mode 100644 EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs create mode 100644 EXILED/Exiled.Events/Patches/Events/Scp1344/Status.cs diff --git a/EXILED/Exiled.API/Features/Items/Item.cs b/EXILED/Exiled.API/Features/Items/Item.cs index 308c75758..7cff7ab1e 100644 --- a/EXILED/Exiled.API/Features/Items/Item.cs +++ b/EXILED/Exiled.API/Features/Items/Item.cs @@ -26,6 +26,7 @@ namespace Exiled.API.Features.Items using InventorySystem.Items.ThrowableProjectiles; using InventorySystem.Items.ToggleableLights; using InventorySystem.Items.Usables; + using InventorySystem.Items.Usables.Scp1344; using InventorySystem.Items.Usables.Scp1576; using InventorySystem.Items.Usables.Scp244; using InventorySystem.Items.Usables.Scp330; @@ -205,6 +206,7 @@ public static Item Get(ItemBase itemBase) Scp330Bag scp330Bag => new Scp330(scp330Bag), Scp244Item scp244Item => new Scp244(scp244Item), Scp1576Item scp1576 => new Scp1576(scp1576), + Scp1344Item scp1344 => new Scp1344(scp1344), BaseConsumable consumable => new Consumable(consumable), _ => new Usable(usable), }, @@ -272,6 +274,7 @@ public static T Get(ushort serial) ///
- SCP-330 can be casted to . ///
- SCP-2176 can be casted to the class. ///
- SCP-1576 can be casted to the class. + ///
- SCP-1344 can be casted to the class. ///
- Jailbird can be casted to the class. /// /// @@ -300,6 +303,7 @@ ItemType.KeycardGuard or ItemType.KeycardJanitor or ItemType.KeycardO5 or ItemTy ItemType.SCP330 => new Scp330(), ItemType.SCP2176 => new Scp2176(owner), ItemType.SCP1576 => new Scp1576(), + ItemType.SCP1344 => new Scp1344(), ItemType.Jailbird => new Jailbird(), _ => new Item(type), }; @@ -325,6 +329,7 @@ ItemType.KeycardGuard or ItemType.KeycardJanitor or ItemType.KeycardO5 or ItemTy ///
- SCP-330 can be casted to . ///
- SCP-2176 can be casted to the class. ///
- SCP-1576 can be casted to the class. + ///
- SCP-1344 can be casted to the class. ///
- Jailbird can be casted to the class. ///
/// diff --git a/EXILED/Exiled.API/Features/Items/Scp1344.cs b/EXILED/Exiled.API/Features/Items/Scp1344.cs new file mode 100644 index 000000000..805ff2d74 --- /dev/null +++ b/EXILED/Exiled.API/Features/Items/Scp1344.cs @@ -0,0 +1,83 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Items +{ + using Exiled.API.Interfaces; + using InventorySystem.Items.Usables; + using InventorySystem.Items.Usables.Scp1344; + using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; + + /// + /// A wrapper class for . + /// + public class Scp1344 : Usable, IWrapper + { + /// + /// Initializes a new instance of the class. + /// + /// The base class. + public Scp1344(Scp1344Item itemBase) + : base(itemBase) + { + Base = itemBase; + } + + /// + /// Initializes a new instance of the class. + /// + internal Scp1344() + : this((Scp1344Item)Server.Host.Inventory.CreateItemInstance(new(ItemType.SCP1344, 0), false)) + { + } + + /// + /// Gets the that this class is encapsulating. + /// + public new Scp1344Item Base { get; } + + /// + /// Gets a value indicating whether it can be started to use. + /// + public bool CanStartUsing => Base.CanStartUsing; + + /// + /// Gets or sets the status of Scp1344. + /// + public Scp1344Status Status + { + get => Base.Status; + set => Base.Status = value; + } + + /// + /// Forcefully Deactivate SCP-1344. + /// + /// Drop or not the item. + public void Deactivate(bool dropItem = false) + { + if (Status is not(Scp1344Status.Active or Scp1344Status.Stabbing or Scp1344Status.Dropping)) + { + return; + } + + Base.Owner.DisableWearables(WearableElements.Scp1344Goggles); + Base.ActivateFinalEffects(); + Status = Scp1344Status.Idle; + + if (dropItem) + { + Base.ServerDropItem(true); + } + } + + /// + /// Forcefully activated SCP-1344. + /// + public void Actived() => Status = Scp1344Status.Stabbing; + } +} diff --git a/EXILED/Exiled.Events/EventArgs/Interfaces/IScp1344Event.cs b/EXILED/Exiled.Events/EventArgs/Interfaces/IScp1344Event.cs new file mode 100644 index 000000000..c2009ae7d --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Interfaces/IScp1344Event.cs @@ -0,0 +1,22 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Interfaces +{ + using Exiled.API.Features.Items; + + /// + /// Event args used for all related events. + /// + public interface IScp1344Event : IItemEvent + { + /// + /// Gets the triggering the event. + /// + public Scp1344 Scp1344 { get; } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Scp1344/ChangedStatusEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp1344/ChangedStatusEventArgs.cs new file mode 100644 index 000000000..11afddf79 --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Scp1344/ChangedStatusEventArgs.cs @@ -0,0 +1,55 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp1344 +{ + using Exiled.API.Features.Items; + using Exiled.Events.EventArgs.Interfaces; + using InventorySystem.Items.Usables.Scp1344; + + /// + /// Contains all information after SCP-1344 status changing. + /// + public class ChangedStatusEventArgs : IScp1344Event, IPlayerEvent, IDeniableEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + public ChangedStatusEventArgs(Item item, Scp1344Status scp1344Status) + { + Item = item; + Scp1344 = item as Scp1344; + Player = item.Owner; + Scp1344Status = scp1344Status; + } + + /// + /// Gets the new state. + /// + public Scp1344Status Scp1344Status { get; } + + /// + /// Gets the item. + /// + public Item Item { get; } + + /// + /// Gets the player in owner of the item. + /// + public Exiled.API.Features.Player Player { get; } + + /// + /// Gets Scp1344 item. + /// + public Scp1344 Scp1344 { get; } + + /// + public bool IsAllowed { get; set; } + } +} diff --git a/EXILED/Exiled.Events/EventArgs/Scp1344/ChangingStatusEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp1344/ChangingStatusEventArgs.cs new file mode 100644 index 000000000..89329e073 --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Scp1344/ChangingStatusEventArgs.cs @@ -0,0 +1,64 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp1344 +{ + using Exiled.API.Features.Items; + using Exiled.Events.EventArgs.Interfaces; + using InventorySystem.Items.Usables.Scp1344; + + /// + /// Contains all information before SCP-1344 status changing. + /// + public class ChangingStatusEventArgs : IPlayerEvent, IScp1344Event, IDeniableEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + public ChangingStatusEventArgs(Item item, Scp1344Status scp1344StatusNew, Scp1344Status scp1344StatusOld, bool isAllowed = true) + { + Item = item; + Scp1344 = item as Scp1344; + Player = item.Owner; + Scp1344StatusNew = scp1344StatusNew; + Scp1344StatusOld = scp1344StatusOld; + IsAllowed = isAllowed; + } + + /// + /// Gets the current status. + /// + public Scp1344Status Scp1344StatusOld { get; } + + /// + /// Gets or sets the new state. + /// + public Scp1344Status Scp1344StatusNew { get; set; } + + /// + /// Gets the item. + /// + public Item Item { get; } + + /// + /// Gets the player in owner of the item. + /// + public Exiled.API.Features.Player Player { get; } + + /// + /// Gets Scp1344 item. + /// + public Scp1344 Scp1344 { get; } + + /// + public bool IsAllowed { get; set; } + } +} diff --git a/EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatedEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatedEventArgs.cs new file mode 100644 index 000000000..79ec6925e --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatedEventArgs.cs @@ -0,0 +1,44 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp1344 +{ + using Exiled.API.Features.Items; + using Exiled.Events.EventArgs.Interfaces; + + /// + /// Contains all information after deactivating. + /// + public class DeactivatedEventArgs : IPlayerEvent, IScp1344Event + { + /// + /// Initializes a new instance of the class. + /// + /// + public DeactivatedEventArgs(Item item) + { + Item = item; + Scp1344 = item as Scp1344; + Player = item.Owner; + } + + /// + /// Gets the item. + /// + public Item Item { get; } + + /// + /// Gets the player in owner of the item. + /// + public Exiled.API.Features.Player Player { get; } + + /// + /// Gets Scp1344 item. + /// + public Scp1344 Scp1344 { get; } + } +} diff --git a/EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatingEventArgs.cs new file mode 100644 index 000000000..96bcbc211 --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Scp1344/DeactivatingEventArgs.cs @@ -0,0 +1,49 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp1344 +{ + using Exiled.API.Features.Items; + using Exiled.Events.EventArgs.Interfaces; + + /// + /// Contains all information before deactivating. + /// + public class DeactivatingEventArgs : IPlayerEvent, IScp1344Event, IDeniableEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + public DeactivatingEventArgs(Item item, bool isAllowed = true) + { + Item = item; + Scp1344 = item as Scp1344; + Player = item.Owner; + IsAllowed = isAllowed; + } + + /// + /// Gets the item. + /// + public Item Item { get; } + + /// + /// Gets the player in owner of the item. + /// + public Exiled.API.Features.Player Player { get; } + + /// + /// Gets Scp1344 item. + /// + public Scp1344 Scp1344 { get; } + + /// + public bool IsAllowed { get; set; } + } +} diff --git a/EXILED/Exiled.Events/EventArgs/Scp1344/TryingDeactivatingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp1344/TryingDeactivatingEventArgs.cs new file mode 100644 index 000000000..f236851f1 --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Scp1344/TryingDeactivatingEventArgs.cs @@ -0,0 +1,49 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp1344 +{ + using Exiled.API.Features.Items; + using Exiled.Events.EventArgs.Interfaces; + + /// + /// Contains all information before trying deactivating. + /// + public class TryingDeactivatingEventArgs : IPlayerEvent, IScp1344Event, IDeniableEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + public TryingDeactivatingEventArgs(Item item, bool isAllowed = true) + { + Item = item; + Scp1344 = item as Scp1344; + Player = item.Owner; + IsAllowed = isAllowed; + } + + /// + /// Gets the item. + /// + public Item Item { get; } + + /// + /// Gets the player in owner of the item. + /// + public Exiled.API.Features.Player Player { get; } + + /// + /// Gets Scp1344 item. + /// + public Scp1344 Scp1344 { get; } + + /// + public bool IsAllowed { get; set; } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Handlers/Scp1344.cs b/EXILED/Exiled.Events/Handlers/Scp1344.cs new file mode 100644 index 000000000..e3cd688c7 --- /dev/null +++ b/EXILED/Exiled.Events/Handlers/Scp1344.cs @@ -0,0 +1,75 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Handlers +{ +#pragma warning disable SA1623 // Property summary documentation should match accessors + + using Exiled.Events.EventArgs.Scp1344; + using Exiled.Events.Features; + + /// + /// SCP-1344 related events. + /// + public static class Scp1344 + { + /// + /// Invoked before SCP-1344 status changing. + /// + public static Event ChangingStatus { get; set; } = new(); + + /// + /// Invoked after SCP-1344 status changing. + /// + public static Event ChangedStatus { get; set; } = new(); + + /// + /// Invoked after trying deactivating SCP-1344. + /// + public static Event TryingDeactivating { get; set; } = new(); + + /// + /// Invoked before deactivating SCP-1344. + /// + public static Event Deactivating { get; set; } = new(); + + /// + /// Invoked after deactivating SCP-1344. + /// + public static Event Deactivated { get; set; } = new(); + + /// + /// Called after deactivating SCP-1344. + /// + /// The instance. + public static void OnDeactivated(DeactivatedEventArgs ev) => Deactivated.InvokeSafely(ev); + + /// + /// Called before deactivating SCP-1344. + /// + /// The instance. + public static void OnDeactivating(DeactivatingEventArgs ev) => Deactivating.InvokeSafely(ev); + + /// + /// Called after trying deactivating SCP-1344. + /// + /// The instance. + public static void OnTryingDeactivating(TryingDeactivatingEventArgs ev) => TryingDeactivating.InvokeSafely(ev); + + /// + /// Called before SCP-1344 status changing. + /// + /// The instance. + public static void OnChangingStatus(ChangingStatusEventArgs ev) => ChangingStatus.InvokeSafely(ev); + + /// + /// Called after SCP-1344 status changing. + /// + /// The instance. + public static void OnChangedStatus(ChangedStatusEventArgs ev) => ChangedStatus.InvokeSafely(ev); + } +} diff --git a/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs b/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs new file mode 100644 index 000000000..e1b306609 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs @@ -0,0 +1,73 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +#pragma warning disable SA1313 // Parameter names should begin with lower-case letter + +namespace Exiled.Events.Patches.Events.Scp1344 +{ + using Exiled.API.Features.Items; + using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Scp1344; + using HarmonyLib; + using InventorySystem.Items.Usables.Scp1344; + using InventorySystem.Items.Usables.Scp244; + using UnityEngine; + + /// + /// Patches . + /// Adds the event, + /// event and + /// event. + /// + [EventPatch(typeof(Handlers.Scp1344), nameof(Handlers.Scp1344.TryingDeactivating))] + [EventPatch(typeof(Handlers.Scp1344), nameof(Handlers.Scp1344.Deactivating))] + [EventPatch(typeof(Handlers.Scp1344), nameof(Handlers.Scp1344.Deactivated))] + [HarmonyPatch(typeof(Scp1344Item), nameof(Scp1344Item.ServerUpdateDeactivating))] + internal static class Deactivating + { + private static bool Prefix(ref Scp1344Item __instance) + { + if (__instance._useTime == 0) + { + var ev = new TryingDeactivatingEventArgs(Item.Get(__instance)); + Exiled.Events.Handlers.Scp1344.OnTryingDeactivating(ev); + + if (!ev.IsAllowed) + { + return StopDeactivation(__instance); + } + } + + if (__instance._useTime + Time.deltaTime >= 5.1f) + { + var deactivating = new DeactivatingEventArgs(Item.Get(__instance)); + Exiled.Events.Handlers.Scp1344.OnDeactivating(deactivating); + + if (!deactivating.IsAllowed) + { + return StopDeactivation(__instance); + } + + __instance.ActivateFinalEffects(); + __instance.ServerDropItem(__instance); + + var ev = new DeactivatedEventArgs(Item.Get(__instance)); + Exiled.Events.Handlers.Scp1344.OnDeactivated(ev); + return false; + } + + return true; + } + + private static bool StopDeactivation(Scp1344Item instance) + { + instance.Status = Scp1344Status.Active; + instance.ServerSetStatus(Scp1344Status.Active); + return false; + } + } +} diff --git a/EXILED/Exiled.Events/Patches/Events/Scp1344/Status.cs b/EXILED/Exiled.Events/Patches/Events/Scp1344/Status.cs new file mode 100644 index 000000000..bfe734986 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Events/Scp1344/Status.cs @@ -0,0 +1,42 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +#pragma warning disable SA1313 // Parameter names should begin with lower-case letter + +namespace Exiled.Events.Patches.Events.Scp1344 +{ + using Exiled.API.Features.Items; + using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Scp1344; + using HarmonyLib; + using InventorySystem.Items.Usables.Scp1344; + + /// + /// Patches . + /// Adds the event and + /// event. + /// + [EventPatch(typeof(Handlers.Scp1344), nameof(Handlers.Scp1344.ChangingStatus))] + [EventPatch(typeof(Handlers.Scp1344), nameof(Handlers.Scp1344.ChangedStatus))] + [HarmonyPatch(typeof(Scp1344Item), nameof(Scp1344Item.Status), MethodType.Setter)] + internal static class Status + { + private static bool Prefix(Scp1344Item __instance, ref Scp1344Status value) + { + ChangingStatusEventArgs ev = new(Item.Get(__instance), value, __instance._status); + Handlers.Scp1344.OnChangingStatus(ev); + value = ev.Scp1344StatusNew; + return ev.IsAllowed; + } + + private static void Postfix(Scp1344Item __instance, ref Scp1344Status value) + { + ChangedStatusEventArgs ev = new(Item.Get(__instance), value); + Handlers.Scp1344.OnChangedStatus(ev); + } + } +} \ No newline at end of file From 1a4e1a68f775429198c012928f2dbe009fab80ab Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Sun, 1 Dec 2024 05:49:56 +0100 Subject: [PATCH 052/102] fix: on shot event (#278) --- .../EventArgs/Player/ShotEventArgs.cs | 66 +++--- .../Patches/Events/Player/Shot.cs | 193 ++---------------- 2 files changed, 53 insertions(+), 206 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/ShotEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ShotEventArgs.cs index 18ff833b4..1b0650720 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/ShotEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/ShotEventArgs.cs @@ -10,7 +10,7 @@ namespace Exiled.Events.EventArgs.Player using API.Features; using Exiled.API.Features.Items; using Interfaces; - + using InventorySystem.Items.Firearms.Modules; using UnityEngine; /// @@ -21,29 +21,34 @@ public class ShotEventArgs : IPlayerEvent, IFirearmEvent /// /// Initializes a new instance of the class. /// - /// - /// + /// + /// The instance. /// /// /// /// - /// The hit. - /// - /// + /// + /// /// - /// - /// + /// + /// /// - public ShotEventArgs(Player shooter, Firearm firearm, RaycastHit hit, IDestructible destructible, float damage) + public ShotEventArgs(HitscanHitregModuleBase instance, InventorySystem.Items.Firearms.Firearm firearm, Ray ray, float maxDistance) { - Player = shooter; - Firearm = firearm; - Damage = damage; - Distance = hit.distance; - Position = hit.point; - RaycastHit = hit; - - if (destructible is HitboxIdentity identity) + Player = Player.Get(firearm.Owner); + Firearm = Item.Get(firearm); + MaxDistance = maxDistance; + + if (!Physics.Raycast(ray, out RaycastHit hitInfo, maxDistance, HitscanHitregModuleBase.HitregMask)) + return; + + Distance = hitInfo.distance; + Position = hitInfo.point; + Damage = hitInfo.collider.TryGetComponent(out IDestructible component) ? instance.DamageAtDistance(hitInfo.distance) : 0f; + Destructible = component; + RaycastHit = hitInfo; + + if (component is HitboxIdentity identity) { Hitbox = identity; Target = Player.Get(Hitbox.TargetHub); @@ -64,24 +69,29 @@ public ShotEventArgs(Player shooter, Firearm firearm, RaycastHit hit, IDestructi public Item Item => Firearm; /// - /// Gets the hitbox type of the shot. Can be !. + /// Gets the max distance of the shot. /// - public HitboxIdentity Hitbox { get; } + public float MaxDistance { get; } /// - /// Gets or sets the inflicted damage. + /// Gets the shot distance. Can be 0.0f if the raycast doesn't hit collider. /// - public float Damage { get; set; } + public float Distance { get; } /// - /// Gets the shot distance. + /// Gets the shot position. Can be if the raycast doesn't hit collider. /// - public float Distance { get; } + public Vector3 Position { get; } /// - /// Gets the shot position. + /// Gets the component of the hit collider. Can be . /// - public Vector3 Position { get; } + public IDestructible Destructible { get; } + + /// + /// Gets the inflicted damage. + /// + public float Damage { get; } /// /// Gets the raycast result. @@ -89,13 +99,13 @@ public ShotEventArgs(Player shooter, Firearm firearm, RaycastHit hit, IDestructi public RaycastHit RaycastHit { get; } /// - /// Gets the target of the shot. Can be !. + /// Gets the target of the shot. Can be . /// public Player Target { get; } /// - /// Gets or sets a value indicating whether the shot can hurt the target. + /// Gets the component of the hit collider. Can be . /// - public bool CanHurt { get; set; } = true; + public HitboxIdentity Hitbox { get; } } } diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs b/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs index 6a9c4e201..d3d4dcc9c 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs @@ -7,218 +7,56 @@ namespace Exiled.Events.Patches.Events.Player { -#pragma warning disable SA1402 // File may only contain a single type - using System.Collections.Generic; using System.Reflection.Emit; - using API.Features; using API.Features.Pools; - - using EventArgs.Player; using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Player; using HarmonyLib; - - using InventorySystem.Items.Firearms; using InventorySystem.Items.Firearms.Modules; - using UnityEngine; - using static HarmonyLib.AccessTools; - using Item = API.Features.Items.Item; - /// - /// Patches . - /// Adds the events. + /// Patches . + /// Adds the event. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Shot))] - [HarmonyPatch(typeof(HitscanHitregModuleBase), nameof(HitscanHitregModuleBase.ServerProcessTargetHit))] + [HarmonyPatch(typeof(HitscanHitregModuleBase), nameof(HitscanHitregModuleBase.ServerPerformHitscan))] internal static class Shot { - /// - /// Process shot. - /// - /// The player. - /// The firearm. - /// The raycast hit. - /// The destructible. - /// The damage. - /// If the shot is allowed. - internal static bool ProcessShot(ReferenceHub player, Firearm firearm, RaycastHit hit, IDestructible destructible, ref float damage) - { - ShotEventArgs shotEvent = new(Player.Get(player), Item.Get(firearm), hit, destructible, damage); - - Handlers.Player.OnShot(shotEvent); - - if (shotEvent.CanHurt) - damage = shotEvent.Damage; - - return shotEvent.CanHurt; - } - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); Label returnLabel = generator.DefineLabel(); - Label jump = generator.DefineLabel(); - int offset = 1; - int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Stloc_0) + offset; + int offset = 3; + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ldarg_2) + offset; newInstructions.InsertRange( index, new CodeInstruction[] { - // (IDestructible as HitboxIdentity).TargetHub - new(OpCodes.Ldarg_1), - new(OpCodes.Isinst, typeof(HitboxIdentity)), - new(OpCodes.Callvirt, PropertyGetter(typeof(HitboxIdentity), nameof(HitboxIdentity.TargetHub))), + // instance + new(OpCodes.Ldarg_0), // this.Firearm new(OpCodes.Ldarg_0), new(OpCodes.Callvirt, PropertyGetter(typeof(HitscanHitregModuleBase), nameof(HitscanHitregModuleBase.Firearm))), - // RaycastHit - new(OpCodes.Ldarg_2), - - // destructible + // ray new(OpCodes.Ldarg_1), - // damage - new(OpCodes.Ldloca_S, 0), - - new(OpCodes.Call, Method(typeof(Shot), nameof(ProcessShot), new[] { typeof(ReferenceHub), typeof(Firearm), typeof(RaycastHit), typeof(IDestructible), typeof(float).MakeByRefType(), })), - - // if (!ev.CanHurt) - // return; - new(OpCodes.Brfalse_S, returnLabel), - }); - - /*offset = -3; - index = newInstructions.FindLastIndex( - instruction => instruction.Calls(Method(typeof(StandardHitregBase), nameof(StandardHitregBase.PlaceBulletholeDecal)))) + offset; - - // replace the original goto label - newInstructions.FindAll(instruction => instruction.opcode == OpCodes.Brfalse).ForEach(instruction => instruction.operand = jump); - - newInstructions.InsertRange( - index, - new[] - { - new CodeInstruction(OpCodes.Nop).WithLabels(jump), - - // this.Hub - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(StandardHitregBase), nameof(StandardHitregBase.Hub))), - - // this.Firearm - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(StandardHitregBase), nameof(StandardHitregBase.Firearm))), - - // hit - new(OpCodes.Ldarg_2), - - // destructible - new(OpCodes.Ldnull), - - // damage - new(OpCodes.Ldc_R4, 0f), - new(OpCodes.Stloc_S, 1), - new(OpCodes.Ldloca_S, 1), - - // Shot.ProcessShot - new(OpCodes.Call, Method(typeof(Shot), nameof(ProcessShot), new[] { typeof(ReferenceHub), typeof(Firearm), typeof(RaycastHit), typeof(IDestructible), typeof(float).MakeByRefType(), })), - new(OpCodes.Pop), - });*/ - - newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } - - /* TODO - /// - /// Patches . - /// Adds the events. - /// - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Shot))] - [HarmonyPatch(typeof(DisruptorHitregModule), nameof(DisruptorHitregModule.ServerProcessTargetHit))] - internal static class ShotDisruptor - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - Label returnLabel = generator.DefineLabel(); - - int offset = -3; - int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(DisruptorHitreg), nameof(DisruptorHitreg.CreateExplosion)))) + offset; - - newInstructions.InsertRange( - index, - new CodeInstruction[] - { - // this.Hub - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(DisruptorHitreg), nameof(DisruptorHitreg.Hub))), - - // this.Firearm - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(DisruptorHitreg), nameof(DisruptorHitreg.Firearm))), - - // hit - new(OpCodes.Ldloc_S, 7), - - // destructible - new(OpCodes.Ldloc_S, 8), - - // damage - new(OpCodes.Ldc_R4, 0f), - new(OpCodes.Stloc_S, 9), - new(OpCodes.Ldloca_S, 9), - - new(OpCodes.Call, Method(typeof(Shot), nameof(Shot.ProcessShot), new[] { typeof(ReferenceHub), typeof(Firearm), typeof(RaycastHit), typeof(IDestructible), typeof(float).MakeByRefType(), })), - - // if (!ev.CanHurt) - // return; - new(OpCodes.Brfalse_S, returnLabel), - }); - - offset = -5; - index = newInstructions.FindLastIndex(instruction => instruction.Calls(Method(typeof(IDestructible), nameof(IDestructible.Damage)))) + offset; - - newInstructions.InsertRange( - index, - new[] - { - // this.Hub - new CodeInstruction(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(DisruptorHitreg), nameof(DisruptorHitreg.Hub))), - - // this.Firearm - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(DisruptorHitreg), nameof(DisruptorHitreg.Firearm))), - - // hit - new(OpCodes.Ldloc_S, 7), - - // destructible - new(OpCodes.Ldloc_S, 8), - - // damage - new(OpCodes.Ldloca_S, 9), + // maxDistance + new(OpCodes.Ldloc_0), - new(OpCodes.Call, Method(typeof(Shot), nameof(Shot.ProcessShot), new[] { typeof(ReferenceHub), typeof(Firearm), typeof(RaycastHit), typeof(IDestructible), typeof(float).MakeByRefType(), })), + // ShotEventArgs ev = new(HitscanHitregModuleBase, Firearm, Ray, float) + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ShotEventArgs))[0]), - // if (!ev.CanHurt) - // return; - new(OpCodes.Brfalse_S, returnLabel), + // Handlers.Player.OnShot(ev) + new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnShot))), }); newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); @@ -229,5 +67,4 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } } - */ } From fe042b6dc57ec0cd0b9e66cb479ae2b81dc2e054 Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Sun, 1 Dec 2024 05:52:38 +0100 Subject: [PATCH 053/102] fix: voice-chatting event (#281) --- EXILED/Exiled.Events/Patches/Events/Player/VoiceChatting.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/VoiceChatting.cs b/EXILED/Exiled.Events/Patches/Events/Player/VoiceChatting.cs index 309cd0a10..a6d49a70f 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/VoiceChatting.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/VoiceChatting.cs @@ -77,7 +77,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Sun, 1 Dec 2024 10:48:28 -0500 Subject: [PATCH 054/102] Fix ChangingRoleAndSpawned (#282) --- .../Patches/Events/Player/ChangingRoleAndSpawned.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs b/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs index 5e7b1d0d1..ad159f736 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs @@ -186,7 +186,7 @@ private static void ChangeInventory(ChangingRoleEventArgs ev) { try { - if (!NetworkServer.active || !ev.SpawnFlags.HasFlag(RoleSpawnFlags.AssignInventory)) + if (!NetworkServer.active || ev == null || !ev.SpawnFlags.HasFlag(RoleSpawnFlags.AssignInventory)) { return; } From cb8fd924f775948a4c03f28e803063a8036ff4f2 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Mon, 2 Dec 2024 03:11:47 -0500 Subject: [PATCH 055/102] Exiled loader fix and version number display style change (#290) --- EXILED/Exiled.Loader/Loader.cs | 4 ++-- EXILED/Exiled.Loader/Updater.cs | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index 783a1137e..1a8a55c7c 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -46,6 +46,7 @@ public Loader() Log.Warn("You are running a public beta build. It is not compatible with another version of the game."); #endif + Log.SendRaw($"Exiled.API - Version {PluginAPI.Loader.AssemblyLoader.Dependencies.FirstOrDefault(x => x.GetName().Name == "Exiled.API").GetCustomAttribute().InformationalVersion}", ConsoleColor.DarkRed); Log.SendRaw($"{Assembly.GetExecutingAssembly().GetName().Name} - Version {Assembly.GetExecutingAssembly().GetCustomAttribute().InformationalVersion}", ConsoleColor.DarkRed); if (MultiAdminFeatures.MultiAdminUsed) @@ -145,8 +146,7 @@ public static void LoadPlugins() AssemblyInformationalVersionAttribute attribute = plugin.Assembly.GetCustomAttribute(); - Log.Info($"Loaded plugin {plugin.Name}@{(plugin.Version is not null ? $"{plugin.Version.Major}.{plugin.Version.Minor}.{plugin.Version.Build}" : attribute is not null ? attribute.InformationalVersion : string.Empty)}"); - + Log.Info($"Loaded plugin {plugin.Name}@{(attribute is not null ? attribute.InformationalVersion : plugin.Version is not null ? $"{plugin.Version.Major}.{plugin.Version.Minor}.{plugin.Version.Build}" : string.Empty)}"); Server.PluginAssemblies.Add(assembly, plugin); Plugins.Add(plugin); } diff --git a/EXILED/Exiled.Loader/Updater.cs b/EXILED/Exiled.Loader/Updater.cs index 49ee5adc6..448adfd6c 100644 --- a/EXILED/Exiled.Loader/Updater.cs +++ b/EXILED/Exiled.Loader/Updater.cs @@ -16,6 +16,7 @@ namespace Exiled.Loader using System.Reflection; using System.Runtime.InteropServices; using System.Text; + using System.Threading; using Exiled.API.Features; using Exiled.Loader.GHApi; @@ -112,9 +113,16 @@ internal static Updater Initialize(Config config) /// internal void CheckUpdate() { - using HttpClient client = CreateHttpClient(); - if (Busy = FindUpdate(client, !File.Exists(Path.Combine(Paths.Dependencies, "Exiled.API.dll")), out NewVersion newVersion)) - Update(client, newVersion); + try + { + using HttpClient client = CreateHttpClient(); + if (Busy = FindUpdate(client, !PluginAPI.Loader.AssemblyLoader.Dependencies.Exists(x => x.GetName().Name == "Exiled.API"), out NewVersion newVersion)) + Update(client, newVersion); + } + catch (Exception e) + { + Log.Error(e); + } } /// @@ -144,6 +152,7 @@ private bool FindUpdate(HttpClient client, bool forced, out NewVersion newVersio { try { + Thread.Sleep(5000); // Wait for the assemblies to load ExiledLib smallestVersion = ExiledLib.Min(); Log.Info($"Found the smallest version of Exiled - {smallestVersion.Library.GetName().Name}:{smallestVersion.Version}"); From 609e60af11f287e11f39c9d38e6ab440a6dc05d3 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Mon, 2 Dec 2024 03:12:40 -0500 Subject: [PATCH 056/102] Version bump --- EXILED/EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/EXILED.props b/EXILED/EXILED.props index bf96b2e25..2d1f11bec 100644 --- a/EXILED/EXILED.props +++ b/EXILED/EXILED.props @@ -15,7 +15,7 @@ - 9.0.0-alpha.3 + 9.0.0-alpha.4 false From 76f6ec4e62915962940d28902a78612c7822e9b0 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:19:10 +0100 Subject: [PATCH 057/102] MoreRoomType (#267) * MoreRoomType * Oups --- EXILED/Exiled.API/Enums/DoorType.cs | 7 +++- EXILED/Exiled.API/Enums/RoomType.cs | 42 +++++++++++++++++++++++- EXILED/Exiled.API/Features/Doors/Door.cs | 3 +- EXILED/Exiled.API/Features/Room.cs | 21 +++++++++--- 4 files changed, 65 insertions(+), 8 deletions(-) diff --git a/EXILED/Exiled.API/Enums/DoorType.cs b/EXILED/Exiled.API/Enums/DoorType.cs index 52fb3ef34..6b3498baa 100644 --- a/EXILED/Exiled.API/Enums/DoorType.cs +++ b/EXILED/Exiled.API/Enums/DoorType.cs @@ -235,7 +235,12 @@ public enum DoorType /// /// Represents the Gate in the Checkpoint between EZ and HCZ. /// - CheckpointGate, + CheckpointGateA, + + /// + /// Represents the Gate in the Checkpoint between EZ and HCZ. + /// + CheckpointGateB, /// /// Represents the Gate in the Checkpoint between EZ and HCZ. diff --git a/EXILED/Exiled.API/Enums/RoomType.cs b/EXILED/Exiled.API/Enums/RoomType.cs index 380db04d0..4402ae7e3 100644 --- a/EXILED/Exiled.API/Enums/RoomType.cs +++ b/EXILED/Exiled.API/Enums/RoomType.cs @@ -272,7 +272,12 @@ public enum RoomType /// /// Entrance Zone's straight hall before the entrance/heavy checkpoint. /// - EzCheckpointHallway, + EzCheckpointHallwayA, + + /// + /// Entrance Zone's straight hall before the entrance/heavy checkpoint. + /// + EzCheckpointHallwayB, /// /// Heavy Containment Zone's test room's straight hall. @@ -293,5 +298,40 @@ public enum RoomType /// Lazy TODO. /// HczCrossRoomWater, + + /// + /// Lazy TODO. + /// + HczCornerDeep, + + /// + /// Lazy TODO. + /// + HczIntersectionJunk, + + /// + /// Lazy TODO. + /// + HczIntersection, + + /// + /// Lazy TODO. + /// + HczStraightC, + + /// + /// Lazy TODO. + /// + HczStraightPipeRoom, + + /// + /// Lazy TODO. + /// + HczStraightVariant, + + /// + /// Lazy TODO. + /// + EzSmallrooms, } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index 5334419c0..c15e5c3b4 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -603,7 +603,8 @@ private DoorType GetDoorType() }, "Unsecured Pryable GateDoor" => Room?.Type switch { - RoomType.EzCheckpointHallway => DoorType.CheckpointGate, + RoomType.EzCheckpointHallwayA => DoorType.CheckpointGateA, + RoomType.EzCheckpointHallwayB => DoorType.CheckpointGateB, RoomType.Hcz049 => Position.y < -805 ? DoorType.Scp049Gate : DoorType.Scp173NewGate, _ => DoorType.UnknownGate, }, diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index d21aee638..d1361ac07 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -438,10 +438,16 @@ private static RoomType FindType(GameObject gameObject) "HCZ_Nuke" => RoomType.HczNuke, "HCZ_Tesla_Rework" => RoomType.HczTesla, "HCZ_Servers" => RoomType.HczServers, - "HCZ_Room3" or "HCZ_Intersection_Junk" or "HCZ_Intersection" => RoomType.HczTCross, + "HCZ_Room3" => RoomType.HczTCross, + "HCZ_Intersection_Junk" => RoomType.HczIntersectionJunk, + "HCZ_Intersection" => RoomType.HczIntersectionJunk, "HCZ_096" => RoomType.Hcz096, - "HCZ_Curve" or "HCZ_Corner_Deep" => RoomType.HczCurve, - "HCZ_Straight_C" or "HCZ_Straight" or "HCZ_Straight_PipeRoom" or "HCZ_Straight Variant" => RoomType.HczStraight, + "HCZ_Curve" => RoomType.HczCurve, + "HCZ_Corner_Deep" => RoomType.HczCornerDeep, + "HCZ_Straight_C" => RoomType.HczStraightC, + "HCZ_Straight" => RoomType.HczStraight, + "HCZ_Straight_PipeRoom"=> RoomType.HczStraightPipeRoom, + "HCZ_Straight Variant" => RoomType.HczStraightVariant, "HCZ_Crossroom_Water" => RoomType.HczCrossRoomWater, "EZ_Endoof" => RoomType.EzVent, "EZ_Intercom" => RoomType.EzIntercom, @@ -451,7 +457,8 @@ private static RoomType FindType(GameObject gameObject) "EZ_PCs" => RoomType.EzPcs, "EZ_Crossing" => RoomType.EzCrossing, "EZ_CollapsedTunnel" => RoomType.EzCollapsedTunnel, - "EZ_Smallrooms2" or "EZ_Smallrooms1" => RoomType.EzConference, + "EZ_Smallrooms1" => RoomType.EzConference, + "EZ_Smallrooms2" => RoomType.EzSmallrooms, "EZ_Chef" => RoomType.EzChef, "EZ_Straight" => RoomType.EzStraight, "EZ_Cafeteria" => RoomType.EzCafeteria, @@ -462,7 +469,11 @@ private static RoomType FindType(GameObject gameObject) "PocketWorld" => RoomType.Pocket, "Outside" => RoomType.Surface, "HCZ_939" => RoomType.Hcz939, - "EZ_HCZ_Checkpoint Part" => RoomType.EzCheckpointHallway, + "EZ_HCZ_Checkpoint Part" => gameObject.transform.position.z switch + { + > 80 => RoomType.EzCheckpointHallwayA, + _ => RoomType.EzCheckpointHallwayB, + }, "HCZ_ChkpA" => RoomType.HczElevatorA, "HCZ_ChkpB" => RoomType.HczElevatorB, "HCZ_EZ_Checkpoint Part" => gameObject.transform.position.z switch From 4c88127465a210b7fd82a784ac98f195262de4a1 Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:48:54 +0100 Subject: [PATCH 058/102] fix: no var (#292) --- EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs b/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs index e1b306609..9cf35fe60 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp1344/Deactivating.cs @@ -33,7 +33,7 @@ private static bool Prefix(ref Scp1344Item __instance) { if (__instance._useTime == 0) { - var ev = new TryingDeactivatingEventArgs(Item.Get(__instance)); + TryingDeactivatingEventArgs ev = new(Item.Get(__instance)); Exiled.Events.Handlers.Scp1344.OnTryingDeactivating(ev); if (!ev.IsAllowed) @@ -44,7 +44,7 @@ private static bool Prefix(ref Scp1344Item __instance) if (__instance._useTime + Time.deltaTime >= 5.1f) { - var deactivating = new DeactivatingEventArgs(Item.Get(__instance)); + DeactivatingEventArgs deactivating = new(Item.Get(__instance)); Exiled.Events.Handlers.Scp1344.OnDeactivating(deactivating); if (!deactivating.IsAllowed) @@ -55,7 +55,7 @@ private static bool Prefix(ref Scp1344Item __instance) __instance.ActivateFinalEffects(); __instance.ServerDropItem(__instance); - var ev = new DeactivatedEventArgs(Item.Get(__instance)); + DeactivatedEventArgs ev = new(Item.Get(__instance)); Exiled.Events.Handlers.Scp1344.OnDeactivated(ev); return false; } From f182d33c5290640cd6578d6f6a14585e6039e2e8 Mon Sep 17 00:00:00 2001 From: Hachiko <177346249+intjiraya@users.noreply.github.com> Date: Tue, 3 Dec 2024 11:20:23 +0300 Subject: [PATCH 059/102] Removing typeLookupTable (#269) --- .../API/Features/CustomItem.cs | 43 ++++--------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs index aa096dc85..1ad086c77 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs @@ -53,7 +53,6 @@ namespace Exiled.CustomItems.API.Features /// public abstract class CustomItem { - private static Dictionary typeLookupTable = new(); private static Dictionary stringLookupTable = new(); private static Dictionary idLookupTable = new(); @@ -159,16 +158,11 @@ public virtual ItemType Type } /// - /// Gets a with a specific type. + /// Retrieves a collection of instances that match a specified type. /// /// The type. - /// The matching the search, if not registered. - public static CustomItem? Get(Type t) - { - if (!typeLookupTable.ContainsKey(t)) - typeLookupTable.Add(t, Registered.FirstOrDefault(i => i.GetType() == t)); - return typeLookupTable[t]; - } + /// An containing all registered of the specified type. + public static IEnumerable Get(Type t) => Registered.Where(i => i.GetType() == t); /// /// Tries to get a with a specific ID. @@ -201,16 +195,16 @@ public static bool TryGet(string name, out CustomItem? customItem) } /// - /// Tries to get a with a specific type. + /// Attempts to retrieve a collection of instances of a specified type. /// /// The of the item to look for. - /// The found , if not registered. - /// Returns a value indicating whether the was found. - public static bool TryGet(Type t, out CustomItem? customItem) + /// An output parameter that will contain the found instances, or an empty collection if none are registered. + /// A boolean value indicating whether any instances of the specified type were found. + public static bool TryGet(Type t, out IEnumerable customItems) { - customItem = Get(t); + customItems = Get(t); - return customItem is not null; + return customItems.Any(); } /// @@ -345,23 +339,6 @@ public static bool TryGive(Player player, uint id, bool displayMessage = true) return true; } - /// - /// Gives to a specific a specic . - /// - /// The to give the item to. - /// The of the item to give. - /// Indicates a value whether will be called when the player receives the or not. - /// Returns a value indicating if the player was given the or not. - public static bool TryGive(Player player, Type t, bool displayMessage = true) - { - if (!TryGet(t, out CustomItem? item)) - return false; - - item?.Give(player, displayMessage); - - return true; - } - /// /// Registers all the 's present in the current assembly. /// @@ -770,7 +747,6 @@ public virtual void Give(Player player, Item item, bool displayMessage = true) /// public virtual void Init() { - typeLookupTable.Add(GetType(), this); stringLookupTable.Add(Name, this); idLookupTable.Add(Id, this); @@ -784,7 +760,6 @@ public virtual void Destroy() { UnsubscribeEvents(); - typeLookupTable.Remove(GetType()); stringLookupTable.Remove(Name); idLookupTable.Remove(Id); } From b61f9355791be4047da7842e2b2b5120b4eb06a5 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Tue, 3 Dec 2024 10:09:49 +0100 Subject: [PATCH 060/102] Few fix of fix (#287) * Fix * Fix --- .../Fixes/Fix106RegenerationWithScp244.cs | 72 ++++++++++ .../Patches/Fixes/NWFixDetonationTimer.cs | 2 +- .../Patches/Fixes/PositionSpawnScp0492Fix.cs | 0 .../Patches/Fixes/Scp3114FriendlyFireFix.cs | 124 ++++++++++++++++++ 4 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 EXILED/Exiled.Events/Patches/Fixes/Fix106RegenerationWithScp244.cs delete mode 100644 EXILED/Exiled.Events/Patches/Fixes/PositionSpawnScp0492Fix.cs diff --git a/EXILED/Exiled.Events/Patches/Fixes/Fix106RegenerationWithScp244.cs b/EXILED/Exiled.Events/Patches/Fixes/Fix106RegenerationWithScp244.cs new file mode 100644 index 000000000..15da68148 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Fixes/Fix106RegenerationWithScp244.cs @@ -0,0 +1,72 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Fixes +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + using CustomPlayerEffects; + using HarmonyLib; + using InventorySystem.Items.Usables.Scp244.Hypothermia; + using PlayerRoles; + using PlayerRoles.PlayableScps.Scp106; + + using static HarmonyLib.AccessTools; + + /// + /// Patches the delegate. + /// Fix than SCP-106 regenerates slower in SCP-244 even if they are in stalk. + /// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/367). + /// + [HarmonyPatch(typeof(Hypothermia), nameof(Hypothermia.Update))] + internal class Fix106RegenerationWithScp244 + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder scp106Role = generator.DeclareLocal(typeof(Scp106Role)); + Label continueLabel = generator.DefineLabel(); + + int offset = 1; + int index = newInstructions.FindLastIndex(x => x.operand == (object)Method(typeof(SpawnProtected), nameof(SpawnProtected.CheckPlayer))) + offset; + + Label skip = (Label)newInstructions[index].operand; + + index += offset; + + newInstructions[index].labels.Add(continueLabel); + + newInstructions.InsertRange(index, new[] + { + // Scp106Role scp106Role = base.Hub.roleManager.CurrentRole as Scp106Role; + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Callvirt, PropertyGetter(typeof(StatusEffectBase), nameof(StatusEffectBase.Hub))), + new CodeInstruction(OpCodes.Ldfld, Field(typeof(ReferenceHub), nameof(ReferenceHub.roleManager))), + new CodeInstruction(OpCodes.Callvirt, PropertyGetter(typeof(PlayerRoleManager), nameof(PlayerRoleManager.CurrentRole))), + new CodeInstruction(OpCodes.Isinst, typeof(Scp106Role)), + new CodeInstruction(OpCodes.Stloc_S, scp106Role.LocalIndex), + + // if (scp106Role is null) goto continueLabel + new CodeInstruction(OpCodes.Ldloc_S, scp106Role.LocalIndex), + new CodeInstruction(OpCodes.Brfalse_S, continueLabel), + + // if (!scp106Role.IsStalking) goto skip + new CodeInstruction(OpCodes.Ldloc_S, scp106Role.LocalIndex), + new CodeInstruction(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.IsStalking))), + new CodeInstruction(OpCodes.Brtrue_S, skip), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Fixes/NWFixDetonationTimer.cs b/EXILED/Exiled.Events/Patches/Fixes/NWFixDetonationTimer.cs index 2d51cfcae..0eeafc3c0 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/NWFixDetonationTimer.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/NWFixDetonationTimer.cs @@ -23,7 +23,7 @@ internal class NWFixDetonationTimer private static void Postfix() { AlphaWarheadSyncInfo networkInfo = default; - networkInfo.ScenarioId = (byte)Array.IndexOf(AlphaWarheadController.Singleton._startScenarios, AlphaWarheadController.Singleton._startScenarios.OrderBy(d => Math.Abs(d.TimeToDetonate - ConfigFile.ServerConfig.GetInt("warhead_tminus_start_duration", 90))).First()); + networkInfo.ScenarioId = (byte)Array.IndexOf(AlphaWarheadController.Singleton._startScenarios, AlphaWarheadController.Singleton._startScenarios.OrderBy(d => Math.Abs(d.TimeToDetonate - ConfigFile.ServerConfig.GetByte("warhead_tminus_start_duration", 90))).First()); AlphaWarheadController.Singleton.NetworkInfo = networkInfo; return; diff --git a/EXILED/Exiled.Events/Patches/Fixes/PositionSpawnScp0492Fix.cs b/EXILED/Exiled.Events/Patches/Fixes/PositionSpawnScp0492Fix.cs deleted file mode 100644 index e69de29bb..000000000 diff --git a/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs b/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs index e69de29bb..3d9b4d2ac 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs @@ -0,0 +1,124 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Fixes +{ +#pragma warning disable SA1402 // File may only contain a single type + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + + using Exiled.API.Features; + + using Footprinting; + using HarmonyLib; + using InventorySystem.Items.Pickups; + using InventorySystem.Items.ThrowableProjectiles; + using PlayerRoles; + using PlayerStatsSystem; + + using static HarmonyLib.AccessTools; + + /// + /// Patches the delegate. + /// Fix Throwing a ghostlight with Scp in the room stun 079. + /// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/55). + /// + [HarmonyPatch(typeof(Scp2176Projectile), nameof(Scp2176Projectile.ServerShatter))] + internal class Scp3114FriendlyFireFix + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + Label cnt = generator.DefineLabel(); + + int offset = 0; + int index = newInstructions.FindIndex(x => x.LoadsField(Field(typeof(RoomLightController), nameof(RoomLightController.Instances)))) + offset; + + Label skip = newInstructions[index].labels[0]; + + offset = -4; + index += offset; + + newInstructions.InsertRange(index, new[] + { + // if (this.PreviousOwner.Role.GetTeam() is Team.SCPs) + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Ldfld, Field(typeof(Scp2176Projectile), nameof(Scp2176Projectile.PreviousOwner))), + new(OpCodes.Ldfld, Field(typeof(Footprint), nameof(Footprint.Role))), + new(OpCodes.Call, Method(typeof(PlayerRolesUtils), nameof(PlayerRolesUtils.GetTeam), new[] { typeof(RoleTypeId) })), + new(OpCodes.Ldc_I4_0), + new(OpCodes.Ceq), + + new(OpCodes.Brfalse_S, cnt), + + new(OpCodes.Pop), + new(OpCodes.Br_S, skip), + + new CodeInstruction(OpCodes.Nop).WithLabels(cnt), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } + + /// + /// Patches the delegate. + /// Fix Throwing a ghostlight with Scp in the room stun 079. + /// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/55). + /// + [HarmonyPatch(typeof(CollisionDetectionPickup), nameof(CollisionDetectionPickup.ProcessCollision))] + internal class Scp3114FriendlyFireFix2 : AttackerDamageHandler + { +#pragma warning disable SA1600 // Elements should be documented + public Scp3114FriendlyFireFix2(Footprint attacker, float damage) + { + Attacker = attacker; + Damage = damage; + AllowSelfDamage = false; + ServerLogsText = "Scp3114 Fix"; + } + + public override Footprint Attacker { get; set; } + + public override bool AllowSelfDamage { get; } + + public override float Damage { get; set; } + + public override string ServerLogsText { get; } +#pragma warning restore SA1600 // Elements should be documented + + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + int offset = 0; + int index = newInstructions.FindLastIndex(x => x.opcode == OpCodes.Ldnull) + offset; + + // replace null with new Scp3114FriendlyFireFix2(this.PreviousOwner, num2) + newInstructions.RemoveAt(index); + newInstructions.InsertRange(index, new CodeInstruction[] + { + // new Scp3114FriendlyFireFix2(this.PreviousOwner, num2) + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(CollisionDetectionPickup), nameof(CollisionDetectionPickup.PreviousOwner))), + new(OpCodes.Ldloc_3), + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(Scp3114FriendlyFireFix2))[0]), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file From e84b3764870ff51647fe3401832eb49f6d2b7c7a Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 3 Dec 2024 15:07:54 +0000 Subject: [PATCH 061/102] feat: timed waves (#286) * feat: timed waves * feat: get all wave timers Not specific to factions and stuff * feat: name and mini wave checks * feat: unpause on timer * feat: get wave by type * fix: small bugs --------- Co-authored-by: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> --- EXILED/Exiled.API/Features/Waves/TimedWave.cs | 188 +++++++++++++++ EXILED/Exiled.API/Features/Waves/WaveTimer.cs | 217 ++++++++++++++++++ 2 files changed, 405 insertions(+) create mode 100644 EXILED/Exiled.API/Features/Waves/TimedWave.cs create mode 100644 EXILED/Exiled.API/Features/Waves/WaveTimer.cs diff --git a/EXILED/Exiled.API/Features/Waves/TimedWave.cs b/EXILED/Exiled.API/Features/Waves/TimedWave.cs new file mode 100644 index 000000000..e8e91583b --- /dev/null +++ b/EXILED/Exiled.API/Features/Waves/TimedWave.cs @@ -0,0 +1,188 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Waves +{ + using System.Collections.Generic; + + using System.Linq; + + using PlayerRoles; + + using Respawning; + + using Respawning.Waves; + + /// + /// Represents a timed wave. + /// + public class TimedWave + { + private readonly TimeBasedWave timedWave; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The that this class should be based off of. + /// + public TimedWave(TimeBasedWave wave) + { + timedWave = wave; + } + + /// + /// Gets the name of the wave timer. + /// + public string Name => timedWave.GetType().Name; + + /// + /// Gets a value indicating whether the wave is a mini wave. + /// + public bool IsMiniWave => timedWave is IMiniWave; + + /// + /// Gets the wave timer instance. + /// + public WaveTimer Timer => new(timedWave.Timer); + + /// + /// Gets the faction of this wave. + /// + public Faction Faction => timedWave.TargetFaction; + + /// + /// Gets the team of this wave. + /// + public SpawnableTeamType Team => timedWave.TargetFaction.GetSpawnableTeam(); + + /// + /// Gets the maximum amount of people that can spawn in this wave. + /// + public int MaxAmount => timedWave.MaxWaveSize; + + /// + /// Get the timed waves for the specified faction. + /// + /// + /// The faction to get the waves for. + /// + /// + /// The waves if found. + /// + /// + /// A value indicating whether the wave were found. + /// + public static bool TryGetTimedWaves(Faction faction, out List waves) + { + List spawnableWaveBases = WaveManager.Waves.Where(w => w is TimeBasedWave wave && wave.TargetFaction == faction).ToList(); + if(!spawnableWaveBases.Any()) + { + waves = null; + return false; + } + + waves = spawnableWaveBases.Select(w => new TimedWave((TimeBasedWave)w)).ToList(); + return true; + } + + /// + /// Get the timed wave for the specified team. + /// + /// + /// The team to get the wave for. + /// + /// + /// The waves if found. + /// + /// + /// A value indicating whether the wave were found. + /// + public static bool TryGetTimedWaves(SpawnableTeamType team, out List waves) + { + if (team == SpawnableTeamType.None) + { + waves = null; + return false; + } + + Faction faction = team == SpawnableTeamType.NineTailedFox ? Faction.FoundationStaff : Faction.FoundationEnemy; + + return TryGetTimedWaves(faction, out waves); + } + + /// + /// Get the timed wave for the specified type. + /// + /// + /// The wave type to get. + /// + /// + /// The type of wave to get. Must be a . I.e. or . + /// + /// + /// A value indicating whether the wave was found. + /// + public static bool TryGetTimedWave(out TimedWave wave) + where T : TimeBasedWave + { + foreach (SpawnableWaveBase waveBase in WaveManager.Waves) + { + if (waveBase is not TimeBasedWave timeWave || timeWave.GetType() != typeof(T)) + continue; + + wave = new(timeWave); + return true; + } + + wave = null; + return false; + } + + /// + /// Get all timed waves. + /// + /// + /// A list of all timed waves. + /// + public static List GetTimedWaves() + { + List waves = new(); + foreach (SpawnableWaveBase wave in WaveManager.Waves) + { + if (wave is TimeBasedWave timeBasedWave) + { + waves.Add(new (timeBasedWave)); + } + } + + return waves; + } + + /// + /// Destroys this wave. + /// + public void Destroy() + { + timedWave.Destroy(); + } + + /// + /// Populates this wave with the specified amount of roles. + /// + /// + /// The queue to populate. + /// + /// + /// The amount of people to populate. + /// + public void PopulateQueue(Queue queue, int amount) + { + timedWave.PopulateQueue(queue, amount); + } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Waves/WaveTimer.cs b/EXILED/Exiled.API/Features/Waves/WaveTimer.cs new file mode 100644 index 000000000..203f4a1cd --- /dev/null +++ b/EXILED/Exiled.API/Features/Waves/WaveTimer.cs @@ -0,0 +1,217 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Waves +{ + using System; + + using System.Collections.Generic; + + using System.Linq; + + using PlayerRoles; + + using Respawning; + + using Respawning.Waves; + + /// + /// Represents a wave timer. + /// + public class WaveTimer + { + /// + /// Get the native . + /// + private readonly Respawning.Waves.WaveTimer waveTimer; + + /// + /// Initializes a new instance of the class. + /// + /// The that this class should be based off of. + public WaveTimer(Respawning.Waves.WaveTimer wave) + { + waveTimer = wave; + } + + /// + /// Gets the name of the wave timer. + /// + public string Name => waveTimer._wave.GetType().Name; + + /// + /// Gets a value indicating whether the wave is a mini wave. + /// + public bool IsMiniWave => waveTimer._wave is IMiniWave; + + /// + /// Gets the amount of time left before the wave spawns. + /// + public TimeSpan TimeLeft => TimeSpan.FromSeconds(waveTimer.TimeLeft); + + /// + /// Gets the amount of time passed since the last wave spawned. + /// + public TimeSpan TimePassed => TimeSpan.FromSeconds(waveTimer.TimePassed); + + /// + /// Gets the amount of time left before this wave unpause. + /// + public TimeSpan PauseTimeLeft => TimeSpan.FromSeconds(waveTimer.PauseTimeLeft); + + /// + /// Gets the amount of time this wave has been paused for. + /// + public TimeSpan PausedFor => TimeSpan.FromSeconds(waveTimer._pauseTimer); + + /// + /// Gets a value indicating whether this wave is paused. + /// + public bool IsPaused => waveTimer.IsPaused; + + /// + /// Gets a value indicating whether this wave is ready to spawn. + /// + public bool IsReady => waveTimer.IsReadyToSpawn; + + /// + /// Gets a value indicating whether this wave is out of respawns. + /// + public bool IsRespawnable => !waveTimer.IsOutOfRespawns; + + /// + /// Gets the default amount of time between a respawn of this wave. + /// + public float DefaultSpawnInterval => waveTimer.DefaultSpawnInterval; + + /// + /// Gets the actual amount of time between a respawn of this wave. + /// + public float SpawnInterval => waveTimer.SpawnIntervalSeconds; + + /// + /// Get the wave timers for the specified faction. + /// + /// The faction. + /// The waves, if any. + /// A bool indicating if waves were found. + public static bool TryGetWaveTimers(Faction faction, out List waves) + { + if (!TimedWave.TryGetTimedWaves(faction, out List timedWaves)) + { + waves = null; + return false; + } + + waves = timedWaves.Select(wave => wave.Timer).ToList(); + return true; + } + + /// + /// Gets the wave timers for the specified team. + /// + /// The team. + /// The waves, if any. + /// A bool indicating if waves were found. + public static bool TryGetWaveTimers(SpawnableTeamType team, out List waves) + { + if (!TimedWave.TryGetTimedWaves(team, out List timedWaves)) + { + waves = null; + return false; + } + + waves = timedWaves.Select(wave => wave.Timer).ToList(); + return true; + } + + /// + /// Gets all wave timers. + /// + /// A list of all wave timers. + public static List GetWaveTimers() + { + return TimedWave.GetTimedWaves().Select(l => l.Timer).ToList(); + } + + /// + /// Destroys this wave timer. + /// + public void Destroy() + { + waveTimer.Destroy(); + } + + /// + /// Pauses this wave timer. + /// + /// + /// The amount of time to pause this wave timer for. + /// + public void Pause(float seconds) + { + waveTimer.Pause(seconds); + } + + /// + /// Unpauses this wave timer. + /// + public void Unpause() + { + waveTimer.Pause(0); + } + + /// + /// Resets this wave timer. + /// + /// + /// A value indicating whether the should be reset. + /// + public void Reset(bool resetInterval = true) + { + waveTimer.Reset(resetInterval); + } + + /// + /// Update the timer. + /// + public void Update() + { + waveTimer.Update(); + } + + /// + /// Add time to the wave timer. + /// + /// + /// The amount of time to add in seconds. + /// + public void AddTime(float seconds) + { + waveTimer.AddTime(seconds); + } + + /// + /// Set the amount of time before the wave spawns. + /// + /// + /// The amount of time before the wave spawns. + /// + public void SetTime(TimeSpan time) => SetTime((float)time.TotalSeconds); + + /// + /// Set the amount of time before the wave spawns. + /// + /// + /// The amount of time before the wave spawns, in seconds. + /// + public void SetTime(float seconds) + { + waveTimer.SetTime(seconds); + } + } +} \ No newline at end of file From cb679787fa282df01f3137032e4e09e58bfff704 Mon Sep 17 00:00:00 2001 From: Banalny-Banan <133122450+Banalny-Banan@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:21:21 +0200 Subject: [PATCH 062/102] New Shot patch (#289) * New Shot patch * Tested, added ev.CanSpawnImpactEffects --- .../EventArgs/Player/ShotEventArgs.cs | 83 +++++++------- .../Patches/Events/Player/Shot.cs | 105 +++++++++++++++--- 2 files changed, 130 insertions(+), 58 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/ShotEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ShotEventArgs.cs index 1b0650720..0eb6a5c69 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/ShotEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/ShotEventArgs.cs @@ -19,49 +19,36 @@ namespace Exiled.Events.EventArgs.Player public class ShotEventArgs : IPlayerEvent, IFirearmEvent { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// - /// The instance. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public ShotEventArgs(HitscanHitregModuleBase instance, InventorySystem.Items.Firearms.Firearm firearm, Ray ray, float maxDistance) + /// Hitreg module that calculated the shot. + /// Raycast hit info. + /// The firearm used. + /// The IDestructible that was hit. Can be null. + public ShotEventArgs(HitscanHitregModuleBase hitregModule, RaycastHit hitInfo, InventorySystem.Items.Firearms.Firearm firearm, IDestructible destructible) { - Player = Player.Get(firearm.Owner); + HitregModule = hitregModule; + RaycastHit = hitInfo; + Destructible = destructible; Firearm = Item.Get(firearm); - MaxDistance = maxDistance; - - if (!Physics.Raycast(ray, out RaycastHit hitInfo, maxDistance, HitscanHitregModuleBase.HitregMask)) - return; - Distance = hitInfo.distance; - Position = hitInfo.point; - Damage = hitInfo.collider.TryGetComponent(out IDestructible component) ? instance.DamageAtDistance(hitInfo.distance) : 0f; - Destructible = component; - RaycastHit = hitInfo; + Player = Firearm.Owner; + Damage = Destructible is not null ? HitregModule.DamageAtDistance(hitInfo.distance) : 0f; - if (component is HitboxIdentity identity) + if (Destructible is HitboxIdentity hitboxIdentity) { - Hitbox = identity; + Hitbox = hitboxIdentity; Target = Player.Get(Hitbox.TargetHub); } } /// - /// Gets the player who shot. + /// Gets the player who fired the shot. /// public Player Player { get; } /// - /// Gets the firearm used to shoot. + /// Gets the firearm used to fire the shot. /// public Firearm Firearm { get; } @@ -69,43 +56,53 @@ public ShotEventArgs(HitscanHitregModuleBase instance, InventorySystem.Items.Fir public Item Item => Firearm; /// - /// Gets the max distance of the shot. + /// Gets the firearm hitreg module responsible for the shot. /// - public float MaxDistance { get; } + public HitscanHitregModuleBase HitregModule { get; } /// - /// Gets the shot distance. Can be 0.0f if the raycast doesn't hit collider. + /// Gets the raycast info. /// - public float Distance { get; } + public RaycastHit RaycastHit { get; } /// - /// Gets the shot position. Can be if the raycast doesn't hit collider. + /// Gets the bullet travel distance. /// - public Vector3 Position { get; } + public float Distance => RaycastHit.distance; /// - /// Gets the component of the hit collider. Can be . + /// Gets the position of the hit. /// - public IDestructible Destructible { get; } + public Vector3 Position => RaycastHit.point; /// - /// Gets the inflicted damage. + /// Gets the firearm base damage at the hit distance. Actual inflicted damage may vary. /// public float Damage { get; } /// - /// Gets the raycast result. + /// Gets the target player. Can be null. /// - public RaycastHit RaycastHit { get; } + public Player Target { get; } /// - /// Gets the target of the shot. Can be . + /// Gets the component of the target player that was hit. Can be null. /// - public Player Target { get; } + public HitboxIdentity Hitbox { get; } /// - /// Gets the component of the hit collider. Can be . + /// Gets the component of the hit collider. Can be null. /// - public HitboxIdentity Hitbox { get; } + public IDestructible Destructible { get; } + + /// + /// Gets or sets a value indicating whether the shot can deal damage. + /// + public bool CanHurt { get; set; } = true; + + /// + /// Gets or sets a value indicating whether the shot can produce impact effects (e.g. bullet holes). + /// + public bool CanSpawnImpactEffects { get; set; } = true; } } diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs b/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs index d3d4dcc9c..07206dc3b 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs @@ -8,6 +8,7 @@ namespace Exiled.Events.Patches.Events.Player { using System.Collections.Generic; + using System.Reflection; using System.Reflection.Emit; using API.Features.Pools; @@ -15,6 +16,7 @@ namespace Exiled.Events.Patches.Events.Player using Exiled.Events.EventArgs.Player; using HarmonyLib; using InventorySystem.Items.Firearms.Modules; + using UnityEngine; using static HarmonyLib.AccessTools; @@ -26,37 +28,110 @@ namespace Exiled.Events.Patches.Events.Player [HarmonyPatch(typeof(HitscanHitregModuleBase), nameof(HitscanHitregModuleBase.ServerPerformHitscan))] internal static class Shot { + private static void ProcessRaycastMiss(HitscanHitregModuleBase hitregModule, Ray ray, float maxDistance) + { + RaycastHit hit = new() + { + distance = maxDistance, + point = ray.GetPoint(maxDistance), + normal = -ray.direction, + }; + + var ev = new ShotEventArgs(hitregModule, hit, hitregModule.Firearm, null); + Handlers.Player.OnShot(ev); + } + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); - Label returnLabel = generator.DefineLabel(); - - int offset = 3; - int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ldarg_2) + offset; + /* + IL_0020: ldarg.1 // targetRay + IL_0021: ldloca.s hitInfo + IL_0023: ldloc.0 // maxDistance + IL_0024: ldsfld class CachedLayerMask InventorySystem.Items.Firearms.Modules.HitscanHitregModuleBase::HitregMask + IL_0029: call int32 CachedLayerMask::op_Implicit(class CachedLayerMask) + IL_002e: call bool [UnityEngine.PhysicsModule]UnityEngine.Physics::Raycast(valuetype [UnityEngine.CoreModule]UnityEngine.Ray, valuetype [UnityEngine.PhysicsModule]UnityEngine.RaycastHit&, float32, int32) + IL_0033: brtrue.s IL_0037 + [] <= Here + */ + MethodInfo raycastMethod = Method(typeof(Physics), nameof(Physics.Raycast), new[] { typeof(Ray), typeof(RaycastHit).MakeByRefType(), typeof(float), typeof(int) }); + int raycastFailIndex = newInstructions.FindIndex(i => i.Calls(raycastMethod)) + 2; newInstructions.InsertRange( - index, + raycastFailIndex, new CodeInstruction[] { - // instance + // ProcessRaycastMiss(this, targetRay, maxDistance); new(OpCodes.Ldarg_0), + new(OpCodes.Ldarg_1), + new(OpCodes.Ldloc_0), + new(OpCodes.Call, Method(typeof(Shot), nameof(ProcessRaycastMiss))), + }); - // this.Firearm - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(HitscanHitregModuleBase), nameof(HitscanHitregModuleBase.Firearm))), + /* + IL_0037: ldloca.s hitInfo + IL_0039: call instance class [UnityEngine.PhysicsModule]UnityEngine.Collider [UnityEngine.PhysicsModule]UnityEngine.RaycastHit::get_collider() + IL_003e: ldloca.s component + IL_0040: callvirt instance bool [UnityEngine.CoreModule]UnityEngine.Component::TryGetComponent(!!0/*class IDestructible* /&) + [] <= Here // This position is reached whether IDestructible is found or not. + IL_0045: brfalse.s IL_005e + */ + int destructibleGetIndex = newInstructions.FindIndex(i => i.operand is MethodInfo { Name: nameof(Component.TryGetComponent) }) + 1; - // ray - new(OpCodes.Ldarg_1), + Label continueLabel = generator.DefineLabel(); - // maxDistance - new(OpCodes.Ldloc_0), + LocalBuilder ev = generator.DeclareLocal(typeof(ShotEventArgs)); - // ShotEventArgs ev = new(HitscanHitregModuleBase, Firearm, Ray, float) + newInstructions.InsertRange( + destructibleGetIndex, + new[] + { + // var ev = new ShotEventArgs(this, hitInfo, firearm, component); + new(OpCodes.Ldarg_0), // this + new(OpCodes.Ldloc_1), // hitInfo + new(OpCodes.Ldarg_0), // this.Firearm + new(OpCodes.Callvirt, PropertyGetter(typeof(HitscanHitregModuleBase), nameof(HitscanHitregModuleBase.Firearm))), + new(OpCodes.Ldloc_2), // component new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ShotEventArgs))[0]), + new(OpCodes.Dup), // Leave ShotEventArgs on the stack + new(OpCodes.Stloc_S, ev.LocalIndex), - // Handlers.Player.OnShot(ev) + new(OpCodes.Dup), // Leave ShotEventArgs on the stack new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnShot))), + + // if (!ev.CanHurt) hitInfo.distance = maxDistance; + new(OpCodes.Callvirt, PropertyGetter(typeof(ShotEventArgs), nameof(ShotEventArgs.CanHurt))), + new(OpCodes.Brtrue, continueLabel), + + new(OpCodes.Ldloca_S, 1), // hitInfo address + new(OpCodes.Ldloc_0), // maxDistance + new(OpCodes.Call, PropertySetter(typeof(RaycastHit), nameof(RaycastHit.distance))), // hitInfo.distance = maxDistance + + new CodeInstruction(OpCodes.Nop).WithLabels(continueLabel), + }); + + /* + [] <= Here + IL_0067: ldarg.0 // this + IL_0068: call instance class InventorySystem.Items.Firearms.Firearm InventorySystem.Items.Firearms.FirearmSubcomponentBase::get_Firearm() + IL_006d: ldloca.s module + IL_006f: ldc.i4.1 + IL_0070: call bool InventorySystem.Items.Firearms.Modules.ModulesUtils::TryGetModule(class InventorySystem.Items.Firearms.Firearm, !!0/*class InventorySystem.Items.Firearms.Modules.ImpactEffectsModule* /&, bool) + IL_0075: brtrue.s IL_0079 + */ + int impactEffectsIndex = newInstructions.FindIndex(i => i.operand is MethodInfo { Name: nameof(ModulesUtils.TryGetModule) }) - 4; + List public void ClearAttachments() => Base.ApplyAttachmentsCode(BaseCode, true); - /// - /// Creates the that based on this . - /// - /// The location to spawn the item. - /// The rotation of the item. - /// Whether the should be initially spawned. - /// The created . - public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) - => base.CreatePickup(position, rotation, spawn); // TODO: Deleted this overide - /// /// Gets a of the specified . /// diff --git a/EXILED/Exiled.API/Features/Items/Item.cs b/EXILED/Exiled.API/Features/Items/Item.cs index 7cff7ab1e..8b88942a1 100644 --- a/EXILED/Exiled.API/Features/Items/Item.cs +++ b/EXILED/Exiled.API/Features/Items/Item.cs @@ -361,11 +361,11 @@ public static Item Create(ItemType type, Player owner = null) /// The rotation of the item. /// Whether the should be initially spawned. /// The created . - public virtual Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) + public virtual Pickup CreatePickup(Vector3 position, Quaternion? rotation = null, bool spawn = true) { PickupSyncInfo info = new(Type, Weight, Serial); - ItemPickupBase ipb = InventoryExtensions.ServerCreatePickup(Base, info, position, rotation); + ItemPickupBase ipb = InventoryExtensions.ServerCreatePickup(Base, info, position, rotation ?? Quaternion.identity); Base.OnRemoved(ipb); diff --git a/EXILED/Exiled.API/Features/Items/Scp244.cs b/EXILED/Exiled.API/Features/Items/Scp244.cs index 1ed62113c..0cfea6c3a 100644 --- a/EXILED/Exiled.API/Features/Items/Scp244.cs +++ b/EXILED/Exiled.API/Features/Items/Scp244.cs @@ -82,11 +82,11 @@ public bool Primed /// The rotation of the item. /// Whether the should be initially spawned. /// The created . - public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) + public override Pickup CreatePickup(Vector3 position, Quaternion? rotation = null, bool spawn = true) { PickupSyncInfo info = new(Type, Weight, Serial); - Scp244DeployablePickup ipb = (Scp244DeployablePickup)InventoryExtensions.ServerCreatePickup(Base, info, position, rotation); + Scp244DeployablePickup ipb = (Scp244DeployablePickup)InventoryExtensions.ServerCreatePickup(Base, info, position, rotation ?? Quaternion.identity); Base.OnRemoved(ipb); diff --git a/EXILED/Exiled.API/Features/Items/Scp330.cs b/EXILED/Exiled.API/Features/Items/Scp330.cs index f31bfcf25..38c9ded76 100644 --- a/EXILED/Exiled.API/Features/Items/Scp330.cs +++ b/EXILED/Exiled.API/Features/Items/Scp330.cs @@ -240,11 +240,11 @@ public IEnumerable DropCandy(CandyKindID type, bool dropAll = fals /// The rotation to give the item. /// Whether the should be initially spawned. /// The created . - public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) + public override Pickup CreatePickup(Vector3 position, Quaternion? rotation = null, bool spawn = true) { PickupSyncInfo info = new(Type, Weight, Serial); - InventorySystem.Items.Usables.Scp330.Scp330Pickup ipb = (InventorySystem.Items.Usables.Scp330.Scp330Pickup)InventoryExtensions.ServerCreatePickup(Base, info, position, rotation); + InventorySystem.Items.Usables.Scp330.Scp330Pickup ipb = (InventorySystem.Items.Usables.Scp330.Scp330Pickup)InventoryExtensions.ServerCreatePickup(Base, info, position, rotation ?? Quaternion.identity); Base.OnRemoved(ipb); diff --git a/EXILED/Exiled.API/Features/Items/Usable.cs b/EXILED/Exiled.API/Features/Items/Usable.cs index fe07f3c24..6ba68e2cb 100644 --- a/EXILED/Exiled.API/Features/Items/Usable.cs +++ b/EXILED/Exiled.API/Features/Items/Usable.cs @@ -109,11 +109,11 @@ public float RemainingCooldown /// The rotation of the item. /// Whether the should be initially spawned. /// The created . - public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) + public override Pickup CreatePickup(Vector3 position, Quaternion? rotation = null, bool spawn = true) { PickupSyncInfo info = new(Type, Weight, Serial); - ItemPickupBase ipb = InventoryExtensions.ServerCreatePickup(Base, info, position, rotation); + ItemPickupBase ipb = InventoryExtensions.ServerCreatePickup(Base, info, position, rotation ?? Quaternion.identity); Pickup pickup = Pickup.Get(ipb); diff --git a/EXILED/Exiled.API/Features/Pickups/Pickup.cs b/EXILED/Exiled.API/Features/Pickups/Pickup.cs index 2deb4f484..047958be7 100644 --- a/EXILED/Exiled.API/Features/Pickups/Pickup.cs +++ b/EXILED/Exiled.API/Features/Pickups/Pickup.cs @@ -237,7 +237,7 @@ public PickupSyncInfo Info /// /// Gets or sets the previous owner of this item. /// - /// + /// public Player PreviousOwner { get => Player.Get(Base.PreviousOwner.Hub); @@ -260,7 +260,7 @@ public bool InUse /// /// Gets or sets the pickup position. /// - /// + /// public Vector3 Position { get => Base.Position; @@ -279,7 +279,7 @@ public RelativePosition RelativePosition /// /// Gets or sets the pickup rotation. /// - /// + /// public Quaternion Rotation { get => Base.Rotation; @@ -532,8 +532,8 @@ public static Pickup Create(ItemType type) /// The rotation to spawn the . /// An optional previous owner of the item. /// The . See documentation of for more information on casting. - /// - public static Pickup CreateAndSpawn(ItemType type, Vector3 position, Quaternion rotation, Player previousOwner = null) => Create(type).Spawn(position, rotation, previousOwner); + /// + public static Pickup CreateAndSpawn(ItemType type, Vector3 position, Quaternion? rotation = null, Player previousOwner = null) => Create(type).Spawn(position, rotation, previousOwner); /// /// Creates and spawns a . @@ -544,8 +544,8 @@ public static Pickup Create(ItemType type) /// An optional previous owner of the item. /// The specified type. /// The . See documentation of for more information on casting. - /// - public static Pickup CreateAndSpawn(ItemType type, Vector3 position, Quaternion rotation, Player previousOwner = null) + /// + public static Pickup CreateAndSpawn(ItemType type, Vector3 position, Quaternion? rotation = null, Player previousOwner = null) where T : Pickup => CreateAndSpawn(type, position, rotation, previousOwner) as T; /// @@ -588,11 +588,11 @@ public void Spawn() /// The rotation to spawn the . /// An optional previous owner of the item. /// The spawned . - /// - public Pickup Spawn(Vector3 position, Quaternion rotation, Player previousOwner = null) + /// + public Pickup Spawn(Vector3 position, Quaternion? rotation = null, Player previousOwner = null) { Position = position; - Rotation = rotation; + Rotation = rotation ?? Quaternion.identity; PreviousOwner = previousOwner; Spawn(); diff --git a/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs b/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs index fa78c214e..17a0691b9 100644 --- a/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs +++ b/EXILED/Exiled.API/Features/Pickups/Projectiles/Projectile.cs @@ -123,7 +123,7 @@ public static Projectile Create(ProjectileType projectiletype) /// Whether the should be in active state after spawn. /// An optional previous owner of the item. /// The . See documentation of for more information on casting. - public static Projectile CreateAndSpawn(ProjectileType type, Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) => Create(type).Spawn(position, rotation, shouldBeActive, previousOwner); + public static Projectile CreateAndSpawn(ProjectileType type, Vector3 position, Quaternion? rotation = null, bool shouldBeActive = true, Player previousOwner = null) => Create(type).Spawn(position, rotation, shouldBeActive, previousOwner); /// /// Creates and spawns a . @@ -135,7 +135,7 @@ public static Projectile Create(ProjectileType projectiletype) /// An optional previous owner of the item. /// The specified type. /// The . See documentation of for more information on casting. - public static Projectile CreateAndSpawn(ProjectileType type, Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) + public static Projectile CreateAndSpawn(ProjectileType type, Vector3 position, Quaternion? rotation = null, bool shouldBeActive = true, Player previousOwner = null) where T : Projectile => CreateAndSpawn(type, position, rotation, shouldBeActive, previousOwner) as T; /// @@ -151,10 +151,10 @@ public static Projectile CreateAndSpawn(ProjectileType type, Vector3 position /// Whether the should be in active state after spawn. /// An optional previous owner of the item. /// The spawned . - public Projectile Spawn(Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) + public Projectile Spawn(Vector3 position, Quaternion? rotation = null, bool shouldBeActive = true, Player previousOwner = null) { Position = position; - Rotation = rotation; + Rotation = rotation ?? Quaternion.identity; PreviousOwner = previousOwner; Spawn(); diff --git a/EXILED/Exiled.API/Features/PrefabHelper.cs b/EXILED/Exiled.API/Features/PrefabHelper.cs index c80d2ab20..82180ac9a 100644 --- a/EXILED/Exiled.API/Features/PrefabHelper.cs +++ b/EXILED/Exiled.API/Features/PrefabHelper.cs @@ -89,12 +89,12 @@ public static T GetPrefab(PrefabType prefabType) /// The position where the will spawn. /// The rotation of the . /// Returns the instantied. - public static GameObject Spawn(PrefabType prefabType, Vector3 position = default, Quaternion rotation = default) + public static GameObject Spawn(PrefabType prefabType, Vector3 position = default, Quaternion? rotation = null) { if (!TryGetPrefab(prefabType, out GameObject gameObject)) return null; - GameObject newGameObject = UnityEngine.Object.Instantiate(gameObject, position, rotation); + GameObject newGameObject = UnityEngine.Object.Instantiate(gameObject, position, rotation ?? Quaternion.identity); NetworkServer.Spawn(newGameObject); return newGameObject; } @@ -107,7 +107,7 @@ public static GameObject Spawn(PrefabType prefabType, Vector3 position = default /// The rotation of the . /// The type. /// Returns the of the . - public static T Spawn(PrefabType prefabType, Vector3 position = default, Quaternion rotation = default) + public static T Spawn(PrefabType prefabType, Vector3 position = default, Quaternion? rotation = null) where T : Component { GameObject gameObject = Spawn(prefabType, position, rotation); diff --git a/EXILED/Exiled.API/Features/Ragdoll.cs b/EXILED/Exiled.API/Features/Ragdoll.cs index bb0a83f6d..8cde5d8cb 100644 --- a/EXILED/Exiled.API/Features/Ragdoll.cs +++ b/EXILED/Exiled.API/Features/Ragdoll.cs @@ -358,8 +358,8 @@ public static Ragdoll CreateAndSpawn(RagdollData networkInfo) /// The rotation of the ragdoll. /// The optional owner of the ragdoll. /// The ragdoll. - public static Ragdoll CreateAndSpawn(RoleTypeId roleType, string name, DamageHandlerBase damageHandler, Vector3 position, Quaternion rotation, Player owner = null) - => CreateAndSpawn(new(owner?.ReferenceHub ?? Server.Host.ReferenceHub, damageHandler, roleType, position, rotation, name, NetworkTime.time)); + public static Ragdoll CreateAndSpawn(RoleTypeId roleType, string name, DamageHandlerBase damageHandler, Vector3 position, Quaternion? rotation = null, Player owner = null) + => CreateAndSpawn(new(owner?.ReferenceHub ?? Server.Host.ReferenceHub, damageHandler, roleType, position, rotation ?? Quaternion.identity, name, NetworkTime.time)); /// /// Creates and spawns a new ragdoll. @@ -371,7 +371,7 @@ public static Ragdoll CreateAndSpawn(RoleTypeId roleType, string name, DamageHan /// The rotation of the ragdoll. /// The optional owner of the ragdoll. /// The ragdoll. - public static Ragdoll CreateAndSpawn(RoleTypeId roleType, string name, string deathReason, Vector3 position, Quaternion rotation, Player owner = null) + public static Ragdoll CreateAndSpawn(RoleTypeId roleType, string name, string deathReason, Vector3 position, Quaternion? rotation = null, Player owner = null) => CreateAndSpawn(roleType, name, new CustomReasonDamageHandler(deathReason), position, rotation, owner); /// From a986de6692d09d90a241bec32da2d7bdaf28f276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artem=20Ko=C5=A1ilinskis?= <46756889+ITeMbI4@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:02:20 +0100 Subject: [PATCH 064/102] Update project credits (#294) * Update files * Revert yaml changes --- EXILED/EXILED.props | 2 +- EXILED/Exiled.API/Exiled.API.csproj | 4 +--- EXILED/Exiled.Loader/Exiled.Loader.csproj | 2 +- EXILED/Exiled/Exiled.nuspec | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/EXILED/EXILED.props b/EXILED/EXILED.props index 2d1f11bec..895d1ea8b 100644 --- a/EXILED/EXILED.props +++ b/EXILED/EXILED.props @@ -2,7 +2,7 @@ - Exiled Official + ExMod Team diff --git a/EXILED/Exiled.API/Exiled.API.csproj b/EXILED/Exiled.API/Exiled.API.csproj index e0949b7ff..bb753ef98 100644 --- a/EXILED/Exiled.API/Exiled.API.csproj +++ b/EXILED/Exiled.API/Exiled.API.csproj @@ -34,9 +34,7 @@ - - $(EXILED_REFERENCES)\UnityEngine.ParticleSystemModule.dll - + diff --git a/EXILED/Exiled.Loader/Exiled.Loader.csproj b/EXILED/Exiled.Loader/Exiled.Loader.csproj index cb3a04e39..fc19e5aea 100644 --- a/EXILED/Exiled.Loader/Exiled.Loader.csproj +++ b/EXILED/Exiled.Loader/Exiled.Loader.csproj @@ -31,9 +31,9 @@ - + diff --git a/EXILED/Exiled/Exiled.nuspec b/EXILED/Exiled/Exiled.nuspec index abb547bd1..388d8ae0e 100644 --- a/EXILED/Exiled/Exiled.nuspec +++ b/EXILED/Exiled/Exiled.nuspec @@ -7,7 +7,7 @@ $version$ ExMod-Team ExMod-Team - Copyright © Exiled Official 2024 - $year$ + Copyright © ExMod Team 2024 - $year$ false https://github.com/ExMod-Team/EXILED/blob/master/LICENSE From 9fb56a91b1093aabf5208f8ef7ad70e99762c7b5 Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:26:30 +0100 Subject: [PATCH 065/102] Add docs to some RoomType & remove types no longer present (#293) * docs + fix: remove unused types * fix: missing servers * fix: missing ez straight column --- EXILED/Exiled.API/Enums/CameraType.cs | 3 - EXILED/Exiled.API/Enums/DoorType.cs | 5 -- EXILED/Exiled.API/Enums/RoomType.cs | 30 +++----- EXILED/Exiled.API/Enums/SpawnLocationType.cs | 5 -- .../Exiled.API/Extensions/SpawnExtensions.cs | 2 - EXILED/Exiled.API/Features/Camera.cs | 3 - EXILED/Exiled.API/Features/Doors/Door.cs | 1 - EXILED/Exiled.API/Features/Room.cs | 71 +++++++++---------- 8 files changed, 45 insertions(+), 75 deletions(-) diff --git a/EXILED/Exiled.API/Enums/CameraType.cs b/EXILED/Exiled.API/Enums/CameraType.cs index 3da1f461e..6248d2a24 100644 --- a/EXILED/Exiled.API/Enums/CameraType.cs +++ b/EXILED/Exiled.API/Enums/CameraType.cs @@ -68,9 +68,6 @@ public enum CameraType HczElevSysB, HczHallway, HczThreeWay, - HczServersBottom, - HczServersStairs, - HczServersTop, HczTeslaGate, HczTestroomBridge, HczTestroomMain, diff --git a/EXILED/Exiled.API/Enums/DoorType.cs b/EXILED/Exiled.API/Enums/DoorType.cs index 6b3498baa..36bb9b853 100644 --- a/EXILED/Exiled.API/Enums/DoorType.cs +++ b/EXILED/Exiled.API/Enums/DoorType.cs @@ -132,11 +132,6 @@ public enum DoorType /// EscapeSecondary, - /// - /// Represents the SERVERS_BOTTOM door. - /// - ServersBottom, - /// /// Represents the GATE_A door. /// diff --git a/EXILED/Exiled.API/Enums/RoomType.cs b/EXILED/Exiled.API/Enums/RoomType.cs index 4402ae7e3..c0d59291e 100644 --- a/EXILED/Exiled.API/Enums/RoomType.cs +++ b/EXILED/Exiled.API/Enums/RoomType.cs @@ -149,16 +149,6 @@ public enum RoomType /// HczTesla, - /// - /// Heavy Containment Zone's Servers room. - /// - HczServers, - - /// - /// Heavy Containment Zone's 3-way intersection. - /// - HczTCross, - /// /// Heavy Containment Zone's cruved hall. /// @@ -255,7 +245,7 @@ public enum RoomType Surface, /// - /// Heavy Containment Zone's straight hall. + /// Heavy Containment Zone's straight hall with ceiling fan. /// HczStraight, @@ -265,7 +255,7 @@ public enum RoomType EzTCross, /// - /// Light Containment ZOne's SCP-330 room. + /// Light Containment Zone's SCP-330 room. /// Lcz330, @@ -295,42 +285,42 @@ public enum RoomType HczElevatorB, /// - /// Lazy TODO. + /// Heavy Containment Zone's cross room with waterfall. /// HczCrossRoomWater, /// - /// Lazy TODO. + /// Heavy Containment Zone's corner. /// HczCornerDeep, /// - /// Lazy TODO. + /// Heavy Containment Zone's 3-way intersection with storage crates obstructing the passage. /// HczIntersectionJunk, /// - /// Lazy TODO. + /// Heavy Containment Zone's 3-way intersection. /// HczIntersection, /// - /// Lazy TODO. + /// Heavy Containment Zone's straight hall with pipelines and sanitary door. /// HczStraightC, /// - /// Lazy TODO. + /// Heavy Containment Zone's straight hall with pipelines obstructing the passage. /// HczStraightPipeRoom, /// - /// Lazy TODO. + /// Heavy Containment Zone's straight hall. /// HczStraightVariant, /// - /// Lazy TODO. + /// Entrance Zone's straight hall with Dr.L's and conference room 9b locked room. /// EzSmallrooms, } diff --git a/EXILED/Exiled.API/Enums/SpawnLocationType.cs b/EXILED/Exiled.API/Enums/SpawnLocationType.cs index 12d32ce2a..0cd2c6dde 100644 --- a/EXILED/Exiled.API/Enums/SpawnLocationType.cs +++ b/EXILED/Exiled.API/Enums/SpawnLocationType.cs @@ -142,10 +142,5 @@ public enum SpawnLocationType /// Just inside the LCZ WC door. /// InsideLczWc, - - /// - /// Just inside the door at the bottom of the server's room. - /// - InsideServersBottom, } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Extensions/SpawnExtensions.cs b/EXILED/Exiled.API/Extensions/SpawnExtensions.cs index 2eed0d7ea..5c1c31f89 100644 --- a/EXILED/Exiled.API/Extensions/SpawnExtensions.cs +++ b/EXILED/Exiled.API/Extensions/SpawnExtensions.cs @@ -23,7 +23,6 @@ public static class SpawnExtensions /// public static readonly SpawnLocationType[] ReversedLocations = { - SpawnLocationType.InsideServersBottom, SpawnLocationType.InsideHczArmory, SpawnLocationType.Inside079First, SpawnLocationType.InsideHidRight, @@ -103,7 +102,6 @@ public static Vector3 GetPosition(this SpawnLocationType location) SpawnLocationType.InsideSurfaceNuke => "SURFACE_NUKE", SpawnLocationType.Inside079Secondary => "079_SECOND", SpawnLocationType.Inside173Connector => "173_CONNECTOR", - SpawnLocationType.InsideServersBottom => "SERVERS_BOTTOM", SpawnLocationType.InsideEscapePrimary => "ESCAPE_PRIMARY", SpawnLocationType.InsideEscapeSecondary => "ESCAPE_SECONDARY", _ => default, diff --git a/EXILED/Exiled.API/Features/Camera.cs b/EXILED/Exiled.API/Features/Camera.cs index 0c90edf56..6c7248573 100644 --- a/EXILED/Exiled.API/Features/Camera.cs +++ b/EXILED/Exiled.API/Features/Camera.cs @@ -77,9 +77,6 @@ public class Camera : IWrapper, IWorldSpace ["HCZ ELEV SYS B"] = CameraType.HczElevSysB, ["HCZ HALLWAY"] = CameraType.HczHallway, ["HCZ THREE-WAY"] = CameraType.HczThreeWay, - ["SERVERS BOTTOM"] = CameraType.HczServersBottom, - ["SERVERS STAIRS"] = CameraType.HczServersStairs, - ["SERVERS TOP"] = CameraType.HczServersTop, ["TESLA GATE"] = CameraType.HczTeslaGate, ["TESTROOM BRIDGE"] = CameraType.HczTestroomBridge, ["TESTROOM MAIN"] = CameraType.HczTestroomMain, diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index c15e5c3b4..63b4f62ce 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -646,7 +646,6 @@ private DoorType GetDoorType() "079_FIRST" => DoorType.Scp079First, "GATE_B" => DoorType.GateB, "079_SECOND" => DoorType.Scp079Second, - "SERVERS_BOTTOM" => DoorType.ServersBottom, "173_CONNECTOR" => DoorType.Scp173Connector, "LCZ_WC" => DoorType.LczWc, "HID_CHAMBER" => DoorType.HIDChamber, diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index d1361ac07..2a7a39b4a 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -412,70 +412,69 @@ private static RoomType FindType(GameObject gameObject) // Try to remove brackets if they exist. return gameObject.name.RemoveBracketsOnEndOfName() switch { - "LCZ_Armory" => RoomType.LczArmory, - "LCZ_Curve" => RoomType.LczCurve, - "LCZ_Straight" => RoomType.LczStraight, - "LCZ_330" => RoomType.Lcz330, - "LCZ_914" => RoomType.Lcz914, - "LCZ_Crossing" => RoomType.LczCrossing, - "LCZ_TCross" => RoomType.LczTCross, + "PocketWorld" => RoomType.Pocket, + "Outside" => RoomType.Surface, "LCZ_Cafe" => RoomType.LczCafe, - "LCZ_Plants" => RoomType.LczPlants, "LCZ_Toilets" => RoomType.LczToilets, + "LCZ_TCross" => RoomType.LczTCross, "LCZ_Airlock" => RoomType.LczAirlock, - "LCZ_173" => RoomType.Lcz173, - "LCZ_ClassDSpawn" => RoomType.LczClassDSpawn, + "LCZ_ChkpA" => RoomType.LczCheckpointA, "LCZ_ChkpB" => RoomType.LczCheckpointB, + "LCZ_Plants" => RoomType.LczPlants, + "LCZ_Straight" => RoomType.LczStraight, + "LCZ_Armory" => RoomType.LczArmory, + "LCZ_Crossing" => RoomType.LczCrossing, + "LCZ_Curve" => RoomType.LczCurve, + "LCZ_173" => RoomType.Lcz173, + "LCZ_330" => RoomType.Lcz330, "LCZ_372" => RoomType.LczGlassBox, - "LCZ_ChkpA" => RoomType.LczCheckpointA, - "HCZ_079" => RoomType.Hcz079, + "LCZ_914" => RoomType.Lcz914, + "LCZ_ClassDSpawn" => RoomType.LczClassDSpawn, + "HCZ_Nuke" => RoomType.HczNuke, "HCZ_TArmory" => RoomType.HczArmory, - "HCZ_Testroom" => RoomType.HczTestRoom, "HCZ_MicroHID_New" => RoomType.HczHid, + "HCZ_Crossroom_Water" => RoomType.HczCrossRoomWater, + "HCZ_Testroom" => RoomType.HczTestRoom, "HCZ_049" => RoomType.Hcz049, - "HCZ_Crossing" => RoomType.HczCrossing, + "HCZ_079" => RoomType.Hcz079, + "HCZ_096" => RoomType.Hcz096, "HCZ_106_Rework" => RoomType.Hcz106, - "HCZ_Nuke" => RoomType.HczNuke, + "HCZ_939" => RoomType.Hcz939, "HCZ_Tesla_Rework" => RoomType.HczTesla, - "HCZ_Servers" => RoomType.HczServers, - "HCZ_Room3" => RoomType.HczTCross, - "HCZ_Intersection_Junk" => RoomType.HczIntersectionJunk, - "HCZ_Intersection" => RoomType.HczIntersectionJunk, - "HCZ_096" => RoomType.Hcz096, "HCZ_Curve" => RoomType.HczCurve, + "HCZ_Crossing" => RoomType.HczCrossing, + "HCZ_Intersection" => RoomType.HczIntersection, + "HCZ_Intersection_Junk" => RoomType.HczIntersectionJunk, "HCZ_Corner_Deep" => RoomType.HczCornerDeep, - "HCZ_Straight_C" => RoomType.HczStraightC, "HCZ_Straight" => RoomType.HczStraight, + "HCZ_Straight_C" => RoomType.HczStraightC, "HCZ_Straight_PipeRoom"=> RoomType.HczStraightPipeRoom, "HCZ_Straight Variant" => RoomType.HczStraightVariant, - "HCZ_Crossroom_Water" => RoomType.HczCrossRoomWater, - "EZ_Endoof" => RoomType.EzVent, - "EZ_Intercom" => RoomType.EzIntercom, + "HCZ_ChkpA" => RoomType.HczElevatorA, + "HCZ_ChkpB" => RoomType.HczElevatorB, "EZ_GateA" => RoomType.EzGateA, - "EZ_PCs_small" => RoomType.EzDownstairsPcs, + "EZ_GateB" => RoomType.EzGateB, + "EZ_ThreeWay" => RoomType.EzTCross, + "EZ_Crossing" => RoomType.EzCrossing, "EZ_Curve" => RoomType.EzCurve, "EZ_PCs" => RoomType.EzPcs, - "EZ_Crossing" => RoomType.EzCrossing, - "EZ_CollapsedTunnel" => RoomType.EzCollapsedTunnel, - "EZ_Smallrooms1" => RoomType.EzConference, + "EZ_upstairs" => RoomType.EzUpstairsPcs, + "EZ_Intercom" => RoomType.EzIntercom, "EZ_Smallrooms2" => RoomType.EzSmallrooms, + "EZ_PCs_small" => RoomType.EzDownstairsPcs, "EZ_Chef" => RoomType.EzChef, + "EZ_Endoof" => RoomType.EzVent, + "EZ_CollapsedTunnel" => RoomType.EzCollapsedTunnel, + "EZ_Smallrooms1" => RoomType.EzConference, "EZ_Straight" => RoomType.EzStraight, + "EZ_StraightColumn" => RoomType.EzStraight, "EZ_Cafeteria" => RoomType.EzCafeteria, - "EZ_upstairs" => RoomType.EzUpstairsPcs, - "EZ_GateB" => RoomType.EzGateB, "EZ_Shelter" => RoomType.EzShelter, - "EZ_ThreeWay" => RoomType.EzTCross, - "PocketWorld" => RoomType.Pocket, - "Outside" => RoomType.Surface, - "HCZ_939" => RoomType.Hcz939, "EZ_HCZ_Checkpoint Part" => gameObject.transform.position.z switch { > 80 => RoomType.EzCheckpointHallwayA, _ => RoomType.EzCheckpointHallwayB, }, - "HCZ_ChkpA" => RoomType.HczElevatorA, - "HCZ_ChkpB" => RoomType.HczElevatorB, "HCZ_EZ_Checkpoint Part" => gameObject.transform.position.z switch { > 80 => RoomType.HczEzCheckpointA, From ae88d5a87dd8828141328b6698f7036bc36ffc78 Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:46:17 +0100 Subject: [PATCH 066/102] docs: add EzStraightColumn type (#298) --- EXILED/Exiled.API/Enums/RoomType.cs | 7 ++++++- EXILED/Exiled.API/Features/Room.cs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.API/Enums/RoomType.cs b/EXILED/Exiled.API/Enums/RoomType.cs index c0d59291e..054029601 100644 --- a/EXILED/Exiled.API/Enums/RoomType.cs +++ b/EXILED/Exiled.API/Enums/RoomType.cs @@ -210,10 +210,15 @@ public enum RoomType EzChef, /// - /// Entrance Zone's straight hall + /// Entrance Zone's straight hall. /// EzStraight, + /// + /// Entrance Zone's straight hall with a different placement of seasonal objects. + /// + EzStraightColumn, + /// /// Entrance Zone's Cafeteria Room. /// diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index 2a7a39b4a..f0440ad64 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -467,7 +467,7 @@ private static RoomType FindType(GameObject gameObject) "EZ_CollapsedTunnel" => RoomType.EzCollapsedTunnel, "EZ_Smallrooms1" => RoomType.EzConference, "EZ_Straight" => RoomType.EzStraight, - "EZ_StraightColumn" => RoomType.EzStraight, + "EZ_StraightColumn" => RoomType.EzStraightColumn, "EZ_Cafeteria" => RoomType.EzCafeteria, "EZ_Shelter" => RoomType.EzShelter, "EZ_HCZ_Checkpoint Part" => gameObject.transform.position.z switch From a296894c5aaf17570a465bcb6b60aee451c39d16 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:40:12 +0100 Subject: [PATCH 067/102] little nw fix again (#297) --- EXILED/Exiled.API/Features/Round.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.API/Features/Round.cs b/EXILED/Exiled.API/Features/Round.cs index d998c06a3..b6ee2b35f 100644 --- a/EXILED/Exiled.API/Features/Round.cs +++ b/EXILED/Exiled.API/Features/Round.cs @@ -49,12 +49,12 @@ public static class Round /// /// Gets a value indicating whether the round in progress. /// - public static bool InProgress => ReferenceHub._localHubSet && RoundSummary.RoundInProgress(); + public static bool InProgress => !IsEnded && RoundSummary.RoundInProgress(); /// /// Gets a value indicating whether the round is ended. /// - public static bool IsEnded => RoundSummary.singleton._roundEnded; + public static bool IsEnded => RoundSummary._singletonSet && RoundSummary.singleton._roundEnded; /// /// Gets a value indicating whether the round is lobby. From d516b6a8165c812930d50a6f1848b523a68e3df2 Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:49:50 +0100 Subject: [PATCH 068/102] change var --- EXILED/Exiled.Events/Patches/Events/Player/Shot.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs b/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs index 07206dc3b..317a694ae 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Shot.cs @@ -37,7 +37,7 @@ private static void ProcessRaycastMiss(HitscanHitregModuleBase hitregModule, Ray normal = -ray.direction, }; - var ev = new ShotEventArgs(hitregModule, hit, hitregModule.Firearm, null); + ShotEventArgs ev = new(hitregModule, hit, hitregModule.Firearm, null); Handlers.Player.OnShot(ev); } From 0adcc603ec8209447b56e7aa21bdfb40505a4f0c Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Thu, 5 Dec 2024 09:40:39 +0100 Subject: [PATCH 069/102] fix: DroppingCandy event (#301) --- .../Scp330/DroppingScp330EventArgs.cs | 4 ++-- .../Patches/Events/Scp330/DroppingCandy.cs | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Scp330/DroppingScp330EventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp330/DroppingScp330EventArgs.cs index 1542d6aa0..0ead45776 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp330/DroppingScp330EventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp330/DroppingScp330EventArgs.cs @@ -39,9 +39,9 @@ public DroppingScp330EventArgs(Player player, Scp330Bag scp330, CandyKindID cand } /// - /// Gets or sets a value representing the being picked up. + /// Gets a value representing the being picked up. /// - public Scp330 Scp330 { get; set; } // Todo Remove set + public Scp330 Scp330 { get; } /// public Item Item => Scp330; diff --git a/EXILED/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs b/EXILED/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs index 21f4d40ed..36ea89bcc 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs @@ -56,15 +56,14 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } + + private static CandyKindID GetCandyID(Scp330Bag scp330Bag, int index) + { + if (index < 0 || index > scp330Bag.Candies.Count) + return CandyKindID.None; + return scp330Bag.Candies[index]; + } } } \ No newline at end of file From 9633893c9280aed7cda7ecb32cf3e8deeeb891e1 Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:23:17 +0100 Subject: [PATCH 070/102] fix: ending round event (#304) --- .../EventArgs/Server/EndingRoundEventArgs.cs | 50 +++++++++-------- .../Patches/Events/Server/RoundEnd.cs | 53 ++++++++++++------- 2 files changed, 63 insertions(+), 40 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs index 5c72d299b..bbdce5c08 100644 --- a/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Server { - using System; - using API.Enums; using Interfaces; @@ -23,21 +21,18 @@ public class EndingRoundEventArgs : IDeniableEvent /// /// /// - /// - /// - /// - /// - /// - /// /// /// /// - public EndingRoundEventArgs(RoundSummary.LeadingTeam leadingTeam, RoundSummary.SumInfo_ClassList classList, bool isAllowed, bool isForceEnded) + /// + /// + /// + public EndingRoundEventArgs(RoundSummary.SumInfo_ClassList classList, bool isForceEnded, bool isAllowed) { ClassList = classList; - LeadingTeam = (LeadingTeam)leadingTeam; - IsRoundEnded = isAllowed; + LeadingTeam = GetLeadingTeam(classList); IsForceEnded = isForceEnded; + IsAllowed = isAllowed; } /// @@ -51,22 +46,33 @@ public EndingRoundEventArgs(RoundSummary.LeadingTeam leadingTeam, RoundSummary.S public LeadingTeam LeadingTeam { get; set; } /// - /// Gets or sets a value indicating whether the round is going to finish. - /// - public bool IsRoundEnded { get; set; } // TODO: Obsolete this in Exiled 10 - - /// - /// Gets or Sets a value indicating whether the round is ended by API call. + /// Gets or sets a value indicating whether the round is ended by API call. /// public bool IsForceEnded { get; set; } /// - /// Gets or sets a value indicating whether the event can be executed. + /// Gets or sets a value indicating whether the round is going to finish or not. /// - public bool IsAllowed + public bool IsAllowed { get; set; } + + private LeadingTeam GetLeadingTeam(RoundSummary.SumInfo_ClassList classList) { - get => IsRoundEnded; - set => IsRoundEnded = value; + // NW logic + int facilityForces = classList.mtf_and_guards + classList.scientists; + int chaosInsurgency = classList.chaos_insurgents + classList.class_ds; + int anomalies = classList.scps_except_zombies + classList.zombies; + int num4 = facilityForces > 0 ? 1 : 0; + bool flag1 = chaosInsurgency > 0; + bool flag2 = anomalies > 0; + RoundSummary.LeadingTeam leadingTeam = RoundSummary.LeadingTeam.Draw; + if (num4 != 0) + leadingTeam = RoundSummary.EscapedScientists >= RoundSummary.EscapedClassD ? RoundSummary.LeadingTeam.FacilityForces : RoundSummary.LeadingTeam.Draw; + else if (flag2 || flag2 & flag1) + leadingTeam = RoundSummary.EscapedClassD > RoundSummary.SurvivingSCPs ? RoundSummary.LeadingTeam.ChaosInsurgency : (RoundSummary.SurvivingSCPs > RoundSummary.EscapedScientists ? RoundSummary.LeadingTeam.Anomalies : RoundSummary.LeadingTeam.Draw); + else if (flag1) + leadingTeam = RoundSummary.EscapedClassD >= RoundSummary.EscapedScientists ? RoundSummary.LeadingTeam.ChaosInsurgency : RoundSummary.LeadingTeam.Draw; + + return (LeadingTeam)leadingTeam; } -} + } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs index 9088c7ed3..489e015a1 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs @@ -78,29 +78,25 @@ private static IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Ldfld && x.operand == (object)Field(typeof(RoundSummary), nameof(RoundSummary._roundEnded))) + offset; + index = newInstructions.FindIndex(x => x.LoadsField(Field(typeof(RoundSummary), nameof(RoundSummary._roundEnded)))) + offset; LocalBuilder evEndingRound = generator.DeclareLocal(typeof(EndingRoundEventArgs)); newInstructions.InsertRange( index, - new CodeInstruction[] + new[] { - // this.leadingTeam - new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Ldfld, Field(PrivateType, LeadingTeam)), - // this.newList - new(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), new(OpCodes.Ldfld, Field(PrivateType, NewList)), - // shouldRoundEnd - new(OpCodes.Ldloc_S, 4), - // isForceEnd new(OpCodes.Ldloc_1), new(OpCodes.Ldfld, Field(typeof(RoundSummary), nameof(RoundSummary._roundEnded))), - // EndingRoundEventArgs evEndingRound = new(RoundSummary.LeadingTeam, RoundSummary.SumInfo_ClassList, bool, bool); + // baseGameConditionsSatisfied + new(OpCodes.Ldloc_S, 5), + + // EndingRoundEventArgs evEndingRound = new(RoundSummary.SumInfo_ClassList, bool, bool); new(OpCodes.Newobj, GetDeclaredConstructors(typeof(EndingRoundEventArgs))[0]), new(OpCodes.Dup), @@ -108,12 +104,6 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable x.LoadsField(Field(typeof(RoundSummary), nameof(RoundSummary._roundEnded)))) + offset; + int offset2 = 1; + int index2 = newInstructions.FindLastIndex(x => x.opcode == OpCodes.Stloc_S && x.operand is LocalBuilder { LocalIndex: 7 }) + offset2; + + newInstructions.RemoveRange(index, index2 - index); + + offset = -1; + index = newInstructions.FindIndex(x => x.StoresField(Field(PrivateType, LeadingTeam))) + offset; + + newInstructions.RemoveAt(index); + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + new(OpCodes.Ldloc_S, evEndingRound.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(EndingRoundEventArgs), nameof(EndingRoundEventArgs.LeadingTeam))), }); + offset = 1; + index = newInstructions.FindIndex(x => x.StoresField(Field(PrivateType, LeadingTeam))) + offset; + offset2 = 1; + index2 = newInstructions.FindLastIndex(x => x.StoresField(Field(PrivateType, LeadingTeam))) + offset2; + + newInstructions.RemoveRange(index, index2 - index); + // Round.LastClassList = this.newList; offset = 1; index = newInstructions.FindIndex(x => x.opcode == OpCodes.Stfld && x.operand == (object)Field(typeof(SumInfo_ClassList), nameof(SumInfo_ClassList.warhead_kills))) + offset; From 229c6c7784a0eaf07094156a387ca0eb03aa7085 Mon Sep 17 00:00:00 2001 From: Rysik5318 <72207886+Rysik5318@users.noreply.github.com> Date: Sat, 7 Dec 2024 19:43:20 +0400 Subject: [PATCH 071/102] Added Emotion Events and Player.Emotion (#257) * SigmoEmotionPatchAdd * Oops * Oops * Fucking Exiled Dev CI / build * Update Player.cs * Update EXILED/Exiled.Events/Handlers/Player.cs Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com> * Update EXILED/Exiled.Events/Handlers/Player.cs * Sigmoemotionadd (#11) * Say hi to transpilers * Update Emotion.cs * Allows setting emotion * missing dup --------- Co-authored-by: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com> Co-authored-by: VALERA771 <72030575+VALERA771@users.noreply.github.com> --- EXILED/Exiled.API/Features/Player.cs | 10 +++ .../Player/ChangedEmotionEventArgs.cs | 38 ++++++++ .../Player/ChangingEmotionEventArgs.cs | 50 +++++++++++ EXILED/Exiled.Events/Handlers/Player.cs | 22 +++++ .../Patches/Events/Player/Emotion.cs | 87 +++++++++++++++++++ 5 files changed, 207 insertions(+) create mode 100644 EXILED/Exiled.Events/EventArgs/Player/ChangedEmotionEventArgs.cs create mode 100644 EXILED/Exiled.Events/EventArgs/Player/ChangingEmotionEventArgs.cs create mode 100644 EXILED/Exiled.Events/Patches/Events/Player/Emotion.cs diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 788493ca9..3251d1b34 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -47,6 +47,7 @@ namespace Exiled.API.Features using Mirror.LiteNetLib4Mirror; using PlayerRoles; using PlayerRoles.FirstPersonControl; + using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; using PlayerRoles.RoleAssign; using PlayerRoles.Spectating; using PlayerRoles.Voice; @@ -732,6 +733,15 @@ public bool IsBypassModeEnabled set => ReferenceHub.serverRoles.BypassMode = value; } + /// + /// Gets or sets the player's emotion. + /// + public EmotionPresetType Emotion + { + get => EmotionSync.GetEmotionPreset(ReferenceHub); + set => EmotionSync.ServerSetEmotionPreset(ReferenceHub, value); + } + /// /// Gets or sets a value indicating whether the player is muted. /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/ChangedEmotionEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ChangedEmotionEventArgs.cs new file mode 100644 index 000000000..cd5e3447a --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Player/ChangedEmotionEventArgs.cs @@ -0,0 +1,38 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Player +{ + using Exiled.API.Features; + using Exiled.Events.EventArgs.Interfaces; + using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; + + /// + /// Contains all the information after the player's emotion. + /// + public class ChangedEmotionEventArgs : IPlayerEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + public ChangedEmotionEventArgs(ReferenceHub hub, EmotionPresetType emotionPresetType) + { + Player = Player.Get(hub); + EmotionPresetType = emotionPresetType; + } + + /// + /// Gets the player's emotion. + /// + public EmotionPresetType EmotionPresetType { get; } + + /// + public Player Player { get; } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Player/ChangingEmotionEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ChangingEmotionEventArgs.cs new file mode 100644 index 000000000..759f1fa9e --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Player/ChangingEmotionEventArgs.cs @@ -0,0 +1,50 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Player +{ + using Exiled.API.Features; + using Exiled.Events.EventArgs.Interfaces; + using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; + + /// + /// Contains all the information before the player's emotion changes. + /// + public class ChangingEmotionEventArgs : IDeniableEvent, IPlayerEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + public ChangingEmotionEventArgs(ReferenceHub hub, EmotionPresetType newEmotionPresetType, EmotionPresetType oldEmotionPresetType, bool isAllowed = true) + { + Player = Player.Get(hub); + NewEmotionPresetType = newEmotionPresetType; + OldEmotionPresetType = oldEmotionPresetType; + IsAllowed = isAllowed; + } + + /// + public bool IsAllowed { get; set; } + + /// + /// Gets the old player's emotion. + /// + public EmotionPresetType OldEmotionPresetType { get; } + + /// + /// Gets or sets the new player's emotion. + /// + public EmotionPresetType NewEmotionPresetType { get; set; } + + /// + public Player Player { get; } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Handlers/Player.cs b/EXILED/Exiled.Events/Handlers/Player.cs index 581b10014..af69cf807 100644 --- a/EXILED/Exiled.Events/Handlers/Player.cs +++ b/EXILED/Exiled.Events/Handlers/Player.cs @@ -549,6 +549,28 @@ public class Player /// public static Event ChangingNickname { get; set; } = new(); + /// + /// Invoked before a player's emotion changed. + /// + public static Event ChangingEmotion { get; set; } = new(); + + /// + /// Invoked after a player's emotion changed. + /// + public static Event ChangedEmotion { get; set; } = new(); + + /// + /// Called before a player's emotion changed. + /// + /// The instance. + public static void OnChangingEmotion(ChangingEmotionEventArgs ev) => ChangingEmotion.InvokeSafely(ev); + + /// + /// Called after a player's emotion changed. + /// + /// The instance. + public static void OnChangedEmotion(ChangedEmotionEventArgs ev) => ChangedEmotion.InvokeSafely(ev); + /// /// Called before reserved slot is resolved for a . /// diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Emotion.cs b/EXILED/Exiled.Events/Patches/Events/Player/Emotion.cs new file mode 100644 index 000000000..a7d447569 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Events/Player/Emotion.cs @@ -0,0 +1,87 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Events.Player +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using Exiled.API.Features.Pools; + using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Player; + using HarmonyLib; + using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; + + using static HarmonyLib.AccessTools; + + /// + /// Patches . + /// Adds the event and + /// event. + /// + [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.ChangingEmotion))] + [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.ChangedEmotion))] + [HarmonyPatch(typeof(EmotionSync), nameof(EmotionSync.ServerSetEmotionPreset))] + internal static class Emotion + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + Label ret = generator.DefineLabel(); + LocalBuilder ev = generator.DeclareLocal(typeof(ChangingEmotionEventArgs)); + + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ldsfld); + + newInstructions.InsertRange(index, new CodeInstruction[] + { + // ChangingEmotionEventArgs ev = new(hub, preset, EmotionSync.GetEmotionPreset(hub), true); + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Ldarg_1), + new(OpCodes.Ldarg_0), + new(OpCodes.Call, Method(typeof(EmotionSync), nameof(EmotionSync.GetEmotionPreset))), + new(OpCodes.Ldc_I4_1), + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ChangingEmotionEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev), + + // Handlers.Player.OnChangingEmotion(ev); + new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnChangingEmotion))), + + // if (!ev.IsAllowed) + // return; + new(OpCodes.Callvirt, PropertyGetter(typeof(ChangingEmotionEventArgs), nameof(ChangingEmotionEventArgs.IsAllowed))), + new(OpCodes.Brfalse, ret), + + // preset = ev.EmotionPresetTypeNew + new(OpCodes.Ldloc_S, ev), + new(OpCodes.Callvirt, PropertyGetter(typeof(ChangingEmotionEventArgs), nameof(ChangingEmotionEventArgs.NewEmotionPresetType))), + new(OpCodes.Starg_S, 1), + }); + + newInstructions.InsertRange(newInstructions.Count - 1, new CodeInstruction[] + { + // ChangedEmotionEventArgs ev = new(hub, EmotionSync.GetEmotionPreset(hub)); + new CodeInstruction(OpCodes.Ldarg_0), + new(OpCodes.Ldarg_0), + new(OpCodes.Call, Method(typeof(EmotionSync), nameof(EmotionSync.GetEmotionPreset))), + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ChangedEmotionEventArgs))[0]), + + // Handlers.Player.OnChangedEmotion(ev); + new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnChangedEmotion))), + }); + + newInstructions[newInstructions.Count - 1].labels.Add(ret); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} From 0d20b8bbeefccd5b435a7e2c36382ca10440d757 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Sat, 7 Dec 2024 16:44:36 +0100 Subject: [PATCH 072/102] Scp1344Item & move Prefabs (#235) * Cry * Update Speaker.cs * Update Speaker.cs * fix build * feat: spawn the speaker * Update Item.cs * Update Item.cs * fix build --------- Co-authored-by: Bolton <48883340+BoltonDev@users.noreply.github.com> Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com> Co-authored-by: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> --- .../Exiled.API/Features/Doors/ElevatorDoor.cs | 1 - EXILED/Exiled.API/Features/Items/Item.cs | 3 +- EXILED/Exiled.API/Features/Items/Scp1344.cs | 10 +- EXILED/Exiled.API/Features/Lift.cs | 1 - EXILED/Exiled.API/Features/Toys/Light.cs | 8 +- EXILED/Exiled.API/Features/Toys/Primitive.cs | 36 +++-- .../Features/Toys/ShootingTargetToy.cs | 23 ++- EXILED/Exiled.API/Features/Toys/Speaker.cs | 30 +++- EXILED/Exiled.API/Features/Toys/ToysHelper.cs | 142 ------------------ .../Handlers/Internal/MapGenerated.cs | 3 + 10 files changed, 86 insertions(+), 171 deletions(-) delete mode 100644 EXILED/Exiled.API/Features/Toys/ToysHelper.cs diff --git a/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs b/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs index dd597645c..797378312 100644 --- a/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs +++ b/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs @@ -12,7 +12,6 @@ namespace Exiled.API.Features.Doors using Exiled.API.Enums; using Interactables.Interobjects; - using Interactables.Interobjects.DoorUtils; using UnityEngine; /// diff --git a/EXILED/Exiled.API/Features/Items/Item.cs b/EXILED/Exiled.API/Features/Items/Item.cs index 8b88942a1..28acb9432 100644 --- a/EXILED/Exiled.API/Features/Items/Item.cs +++ b/EXILED/Exiled.API/Features/Items/Item.cs @@ -13,7 +13,6 @@ namespace Exiled.API.Features.Items using Exiled.API.Features.Core; using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; - using InventorySystem; using InventorySystem.Items; using InventorySystem.Items.Armor; @@ -224,7 +223,7 @@ public static Item Get(ItemBase itemBase) Scp018Projectile => new Scp018(throwable), _ => new Throwable(throwable), }, - _ => new Item(itemBase), + _ => new(itemBase), }; } diff --git a/EXILED/Exiled.API/Features/Items/Scp1344.cs b/EXILED/Exiled.API/Features/Items/Scp1344.cs index 805ff2d74..460aeb8c0 100644 --- a/EXILED/Exiled.API/Features/Items/Scp1344.cs +++ b/EXILED/Exiled.API/Features/Items/Scp1344.cs @@ -8,6 +8,7 @@ namespace Exiled.API.Features.Items { using Exiled.API.Interfaces; + using InventorySystem.Items.Usables; using InventorySystem.Items.Usables.Scp1344; using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; @@ -40,6 +41,11 @@ internal Scp1344() /// public new Scp1344Item Base { get; } + /// + /// Gets a value indicating whether the item is worn. + /// + public bool IsWorn => Base.IsWorn; + /// /// Gets a value indicating whether it can be started to use. /// @@ -55,9 +61,9 @@ public Scp1344Status Status } /// - /// Forcefully Deactivate SCP-1344. + /// Forcefully deactivate SCP-1344. /// - /// Drop or not the item. + /// Whether or not 1344 should be dropped. public void Deactivate(bool dropItem = false) { if (Status is not(Scp1344Status.Active or Scp1344Status.Stabbing or Scp1344Status.Dropping)) diff --git a/EXILED/Exiled.API/Features/Lift.cs b/EXILED/Exiled.API/Features/Lift.cs index 53160f9a6..c38e146a3 100644 --- a/EXILED/Exiled.API/Features/Lift.cs +++ b/EXILED/Exiled.API/Features/Lift.cs @@ -21,7 +21,6 @@ namespace Exiled.API.Features using UnityEngine; using static Interactables.Interobjects.ElevatorChamber; - using static Interactables.Interobjects.ElevatorManager; using Elevator = Interactables.Interobjects.ElevatorDoor; diff --git a/EXILED/Exiled.API/Features/Toys/Light.cs b/EXILED/Exiled.API/Features/Toys/Light.cs index 8e2a7642e..a831f4b6d 100644 --- a/EXILED/Exiled.API/Features/Toys/Light.cs +++ b/EXILED/Exiled.API/Features/Toys/Light.cs @@ -7,7 +7,6 @@ namespace Exiled.API.Features.Toys { - using System; using System.Linq; using AdminToys; @@ -32,6 +31,11 @@ internal Light(LightSourceToy lightSourceToy) Base = lightSourceToy; } + /// + /// Gets the prefab. + /// + public static LightSourceToy Prefab => PrefabHelper.GetPrefab(PrefabType.LightSourceToy); + /// /// Gets the base . /// @@ -131,7 +135,7 @@ public static Light Create(Vector3? position = null, Vector3? rotation = null, V /// The new . public static Light Create(Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { - Light light = new(UnityEngine.Object.Instantiate(ToysHelper.LightBaseObject)) + Light light = new(UnityEngine.Object.Instantiate(Prefab)) { Position = position ?? Vector3.zero, Rotation = Quaternion.Euler(rotation ?? Vector3.zero), diff --git a/EXILED/Exiled.API/Features/Toys/Primitive.cs b/EXILED/Exiled.API/Features/Toys/Primitive.cs index b90588d8f..1b7202fa7 100644 --- a/EXILED/Exiled.API/Features/Toys/Primitive.cs +++ b/EXILED/Exiled.API/Features/Toys/Primitive.cs @@ -31,6 +31,11 @@ public class Primitive : AdminToy, IWrapper internal Primitive(PrimitiveObjectToy toyAdminToyBase) : base(toyAdminToyBase, AdminToyType.PrimitiveObject) => Base = toyAdminToyBase; + /// + /// Gets the prefab. + /// + public static PrimitiveObjectToy Prefab => PrefabHelper.GetPrefab(PrefabType.PrimitiveObjectToy); + /// /// Gets the base . /// @@ -115,17 +120,16 @@ public static Primitive Create(PrimitiveType primitiveType = PrimitiveType.Spher /// The new . public static Primitive Create(Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { - Primitive primitive = new(Object.Instantiate(ToysHelper.PrimitiveBaseObject)); + Primitive primitive = new(Object.Instantiate(Prefab)); primitive.Position = position ?? Vector3.zero; primitive.Rotation = Quaternion.Euler(rotation ?? Vector3.zero); primitive.Scale = scale ?? Vector3.one; + primitive.Color = color ?? Color.gray; if (spawn) primitive.Spawn(); - primitive.Color = color ?? Color.gray; - return primitive; } @@ -141,18 +145,18 @@ public static Primitive Create(Vector3? position /*= null*/, Vector3? rotation / /// The new . public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sphere*/, Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { - Primitive primitive = new(Object.Instantiate(ToysHelper.PrimitiveBaseObject)); + Primitive primitive = new(Object.Instantiate(Prefab)); primitive.Position = position ?? Vector3.zero; primitive.Rotation = Quaternion.Euler(rotation ?? Vector3.zero); primitive.Scale = scale ?? Vector3.one; - if (spawn) - primitive.Spawn(); - primitive.Base.NetworkPrimitiveType = primitiveType; primitive.Color = color ?? Color.gray; + if (spawn) + primitive.Spawn(); + return primitive; } @@ -169,19 +173,19 @@ public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sph /// The new . public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sphere*/, PrimitiveFlags flags, Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { - Primitive primitive = new(Object.Instantiate(ToysHelper.PrimitiveBaseObject)); + Primitive primitive = new(Object.Instantiate(Prefab)); primitive.Position = position ?? Vector3.zero; primitive.Rotation = Quaternion.Euler(rotation ?? Vector3.zero); primitive.Scale = scale ?? Vector3.one; primitive.Flags = flags; - if (spawn) - primitive.Spawn(); - primitive.Base.NetworkPrimitiveType = primitiveType; primitive.Color = color ?? Color.gray; + if (spawn) + primitive.Spawn(); + return primitive; } @@ -192,20 +196,20 @@ public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sph /// The new . public static Primitive Create(PrimitiveSettings primitiveSettings) { - Primitive primitive = new(Object.Instantiate(ToysHelper.PrimitiveBaseObject)); + Primitive primitive = new(Object.Instantiate(Prefab)); primitive.Position = primitiveSettings.Position; primitive.Rotation = Quaternion.Euler(primitiveSettings.Rotation); primitive.Scale = primitiveSettings.Scale; primitive.Flags = primitiveSettings.Flags; - if (primitiveSettings.Spawn) - primitive.Spawn(); - primitive.Base.NetworkPrimitiveType = primitiveSettings.PrimitiveType; primitive.Color = primitiveSettings.Color; primitive.IsStatic = primitiveSettings.IsStatic; + if (primitiveSettings.Spawn) + primitive.Spawn(); + return primitive; } @@ -217,7 +221,7 @@ public static Primitive Create(PrimitiveSettings primitiveSettings) public static Primitive Get(PrimitiveObjectToy primitiveObjectToy) { AdminToy adminToy = Map.Toys.FirstOrDefault(x => x.AdminToyBase == primitiveObjectToy); - return adminToy is not null ? adminToy as Primitive : new Primitive(primitiveObjectToy); + return adminToy is not null ? adminToy as Primitive : new(primitiveObjectToy); } } } diff --git a/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs b/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs index 70bcf6f12..6723944a4 100644 --- a/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs +++ b/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs @@ -46,6 +46,21 @@ internal ShootingTargetToy(ShootingTarget target) Type = TypeLookup.TryGetValue(Base.gameObject.name.Substring(0, Base.gameObject.name.Length - 7), out ShootingTargetType type) ? type : ShootingTargetType.Unknown; } + /// + /// Gets the prefab for Sport Shooting Target. + /// + public static ShootingTarget SportShootingTargetPrefab => PrefabHelper.GetPrefab(PrefabType.SportTarget); + + /// + /// Gets the prefab for DBoy Shooting Target. + /// + public static ShootingTarget DboyShootingTargetPrefab => PrefabHelper.GetPrefab(PrefabType.DBoyTarget); + + /// + /// Gets the prefab for Binary Shooting Target. + /// + public static ShootingTarget BinaryShootingTargetPrefab => PrefabHelper.GetPrefab(PrefabType.BinaryTarget); + /// /// Gets the base-game for this target. /// @@ -165,19 +180,19 @@ public static ShootingTargetToy Create(ShootingTargetType type, Vector3? positio { case ShootingTargetType.ClassD: { - shootingTargetToy = new ShootingTargetToy(Object.Instantiate(ToysHelper.DboyShootingTargetObject)); + shootingTargetToy = new(Object.Instantiate(DboyShootingTargetPrefab)); break; } case ShootingTargetType.Binary: { - shootingTargetToy = new ShootingTargetToy(Object.Instantiate(ToysHelper.BinaryShootingTargetObject)); + shootingTargetToy = new(Object.Instantiate(BinaryShootingTargetPrefab)); break; } default: { - shootingTargetToy = new ShootingTargetToy(Object.Instantiate(ToysHelper.SportShootingTargetObject)); + shootingTargetToy = new(Object.Instantiate(SportShootingTargetPrefab)); break; } } @@ -200,7 +215,7 @@ public static ShootingTargetToy Create(ShootingTargetType type, Vector3? positio public static ShootingTargetToy Get(ShootingTarget shootingTarget) { AdminToy adminToy = Map.Toys.FirstOrDefault(x => x.AdminToyBase == shootingTarget); - return adminToy is not null ? adminToy as ShootingTargetToy : new ShootingTargetToy(shootingTarget); + return adminToy is not null ? adminToy as ShootingTargetToy : new(shootingTarget); } /// diff --git a/EXILED/Exiled.API/Features/Toys/Speaker.cs b/EXILED/Exiled.API/Features/Toys/Speaker.cs index dc03c3ff9..c51b8bcb7 100644 --- a/EXILED/Exiled.API/Features/Toys/Speaker.cs +++ b/EXILED/Exiled.API/Features/Toys/Speaker.cs @@ -8,9 +8,9 @@ namespace Exiled.API.Features.Toys { using AdminToys; - using Enums; using Exiled.API.Interfaces; + using UnityEngine; /// /// A wrapper class for . @@ -24,6 +24,11 @@ public class Speaker : AdminToy, IWrapper internal Speaker(SpeakerToy speakerToy) : base(speakerToy, AdminToyType.Speaker) => Base = speakerToy; + /// + /// Gets the prefab. + /// + public static SpeakerToy Prefab => PrefabHelper.GetPrefab(PrefabType.SpeakerToy); + /// /// Gets the base . /// @@ -80,5 +85,28 @@ public float MinDistance get => Base.NetworkMinDistance; set => Base.NetworkMinDistance = value; } + + /// + /// Creates a new . + /// + /// The position of the . + /// The rotation of the . + /// The scale of the . + /// Whether the should be initially spawned. + /// The new . + public static Speaker Create(Vector3? position, Vector3? rotation, Vector3? scale, bool spawn) + { + Speaker speaker = new(UnityEngine.Object.Instantiate(Prefab)) + { + Position = position ?? Vector3.zero, + Rotation = Quaternion.Euler(rotation ?? Vector3.zero), + Scale = scale ?? Vector3.one, + }; + + if (spawn) + speaker.Spawn(); + + return speaker; + } } } diff --git a/EXILED/Exiled.API/Features/Toys/ToysHelper.cs b/EXILED/Exiled.API/Features/Toys/ToysHelper.cs deleted file mode 100644 index 5ebcfc42f..000000000 --- a/EXILED/Exiled.API/Features/Toys/ToysHelper.cs +++ /dev/null @@ -1,142 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.API.Features.Toys -{ - using AdminToys; - - using Mirror; - - using UnityEngine; - - /// - /// A helper class for interacting with toys. - /// - public static class ToysHelper - { - private static PrimitiveObjectToy primitiveBaseObject; - private static LightSourceToy lightBaseObject; - private static ShootingTarget sportShootingTargetObject; - private static ShootingTarget dboyShootingTargetObject; - private static ShootingTarget binaryShootingTargetObject; - - /// - /// Gets the base to instantiate when creating a new primitive. - /// - public static PrimitiveObjectToy PrimitiveBaseObject - { - get - { - if (primitiveBaseObject is null) - { - foreach (GameObject gameObject in NetworkClient.prefabs.Values) - { - if (gameObject.TryGetComponent(out PrimitiveObjectToy component)) - { - primitiveBaseObject = component; - break; - } - } - } - - return primitiveBaseObject; - } - } - - /// - /// Gets the base to instantiate when creating a new light. - /// - public static LightSourceToy LightBaseObject - { - get - { - if (lightBaseObject is null) - { - foreach (GameObject gameObject in NetworkClient.prefabs.Values) - { - if (gameObject.TryGetComponent(out LightSourceToy component)) - { - lightBaseObject = component; - break; - } - } - } - - return lightBaseObject; - } - } - - /// - /// Gets the base to instantiate when creating a new sport shooting target. - /// - public static ShootingTarget SportShootingTargetObject - { - get - { - if (sportShootingTargetObject is null) - { - foreach (GameObject gameObject in NetworkClient.prefabs.Values) - { - if ((gameObject.name == "sportTargetPrefab") && gameObject.TryGetComponent(out ShootingTarget shootingTarget)) - { - sportShootingTargetObject = shootingTarget; - break; - } - } - } - - return sportShootingTargetObject; - } - } - - /// - /// Gets the base to instantiate when creating a new dboy shooting target. - /// - public static ShootingTarget DboyShootingTargetObject - { - get - { - if (dboyShootingTargetObject is null) - { - foreach (GameObject gameObject in NetworkClient.prefabs.Values) - { - if ((gameObject.name == "dboyTargetPrefab") && gameObject.TryGetComponent(out ShootingTarget shootingTarget)) - { - dboyShootingTargetObject = shootingTarget; - break; - } - } - } - - return dboyShootingTargetObject; - } - } - - /// - /// Gets the base to instantiate when creating a new binary shooting target. - /// - public static ShootingTarget BinaryShootingTargetObject - { - get - { - if (binaryShootingTargetObject is null) - { - foreach (GameObject gameObject in NetworkClient.prefabs.Values) - { - if ((gameObject.name == "binaryTargetPrefab") && gameObject.TryGetComponent(out ShootingTarget shootingTarget)) - { - binaryShootingTargetObject = shootingTarget; - break; - } - } - } - - return binaryShootingTargetObject; - } - } - } -} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs b/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs index 8014a45e9..1320ad76a 100644 --- a/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs +++ b/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs @@ -7,6 +7,9 @@ namespace Exiled.Events.Handlers.Internal { + using System.Collections.Generic; + using System.Linq; + using API.Features; using Exiled.API.Features.Lockers; From 0a66910f3c6fb40409685c4e615c063f1010259d Mon Sep 17 00:00:00 2001 From: Banalny-Banan <133122450+Banalny-Banan@users.noreply.github.com> Date: Sat, 7 Dec 2024 18:19:29 +0200 Subject: [PATCH 073/102] New Shooting patch (#249) * New Shooting patch (not tested) * formatting stuff * Tested & working * Added shootingEventArgs.Direction * Minor documentation improvements * remarks * Requested changes * Requested changes --- .../EventArgs/Player/ShootingEventArgs.cs | 88 ++++++------------- .../Patches/Events/Player/Shooting.cs | 75 ++++++++++------ 2 files changed, 76 insertions(+), 87 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs index c348e649b..3c2f9d12b 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs @@ -8,106 +8,72 @@ namespace Exiled.Events.EventArgs.Player { using API.Features; - using Exiled.API.Features.Items; - using Interfaces; - - using InventorySystem.Items.Firearms.BasicMessages; - - using RelativePositioning; - + using InventorySystem.Items.Firearms.Modules.Misc; using UnityEngine; using BaseFirearm = InventorySystem.Items.Firearms.Firearm; /// /// Contains all information before a player fires a weapon. + /// ClaimedTarget and Player transform values are modified by according to sent by the Player and do not match the actual values. /// public class ShootingEventArgs : IPlayerEvent, IDeniableEvent, IFirearmEvent { /// /// Initializes a new instance of the class. /// - /// - /// - /// /// - /// + /// The that is being fired. /// - public ShootingEventArgs(Player shooter, BaseFirearm firearm) + /// + /// sent by the client. + /// + public ShootingEventArgs(BaseFirearm firearm, ref ShotBacktrackData shotBacktrackData) { - Player = shooter; - Firearm = Item.Get(firearm).As(); - - // ShotMessage = msg; + Firearm = (Firearm)Item.Get(firearm); + Player = Firearm.Owner; + ShotBacktrackData = shotBacktrackData; } /// - /// Gets the player who's shooting. + /// Gets the player who is shooting. /// public Player Player { get; } /// - /// Gets the target . + /// Gets the target that client claims it hit. /// - public Firearm Firearm { get; } - - /// - public Item Item => Firearm; + /// This value is controlled by the shooting player and should not be trusted. Can be null. + public Player ClaimedTarget => ShotBacktrackData.HasPrimaryTarget ? Player.Get(ShotBacktrackData.PrimaryTargetHub) : null; - /* /// - /// Gets or sets the for the event. + /// Gets the . This object contains the data sent by the client to the server. /// - public ShotMessage ShotMessage { get; set; } + /// Values are controlled by the shooting player and should not be trusted. + public ShotBacktrackData ShotBacktrackData { get; } /// - /// Gets or sets the position of the shot. + /// Gets or sets the exact direction of the shot before the bullet spread is applied. /// - public Vector3 ShotPosition + public Vector3 Direction { - get => ShotMessage.TargetPosition.Position; - set - { - ShotMessage msg = ShotMessage; - ShotMessage = new ShotMessage - { - ShooterPosition = msg.ShooterPosition, - ShooterCameraRotation = msg.ShooterCameraRotation, - ShooterWeaponSerial = msg.ShooterWeaponSerial, - TargetPosition = new RelativePosition(value), - TargetRotation = msg.TargetRotation, - TargetNetId = msg.TargetNetId, - }; - } + get => Player.CameraTransform.forward; + set => Player.CameraTransform.forward = value; // It is going to be reset by FpcBacktracker the same frame, so why we can set it freely. } /// - /// Gets or sets the netId of the target of the shot. + /// Gets the firearm that is being fired. /// - public uint TargetNetId - { - get => ShotMessage.TargetNetId; - set - { - ShotMessage msg = ShotMessage; - ShotMessage = new ShotMessage - { - ShooterPosition = msg.ShooterPosition, - ShooterCameraRotation = msg.ShooterCameraRotation, - ShooterWeaponSerial = msg.ShooterWeaponSerial, - TargetPosition = msg.TargetPosition, - TargetRotation = msg.TargetRotation, - TargetNetId = value, - }; - } - } - */ + public Firearm Firearm { get; } + + /// + public Item Item => Firearm; /// /// Gets or sets a value indicating whether the shot can be fired. /// public bool IsAllowed { get; set; } = true; } -} +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs b/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs index fc1265b8e..501c1f812 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs @@ -8,19 +8,14 @@ namespace Exiled.Events.Patches.Events.Player { using System.Collections.Generic; + using System.Reflection; using System.Reflection.Emit; using API.Features; using API.Features.Pools; - using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Player; - using HarmonyLib; - - using InventorySystem.Items.Firearms; - using InventorySystem.Items.Firearms.BasicMessages; - using InventorySystem.Items.Firearms.Modules; using InventorySystem.Items.Firearms.Modules.Misc; using static HarmonyLib.AccessTools; @@ -39,34 +34,62 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); Label returnLabel = generator.DefineLabel(); - - int offset = 1; - int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Stloc_2) + offset; - - newInstructions.InsertRange( - index, + Label continueLabel1 = generator.DefineLabel(); + Label continueLabel2 = generator.DefineLabel(); + + /* + [] <= Here + IL_0078: ldarg.2 // processingMethod + IL_0079: ldarg.0 // this + IL_007a: ldfld class ReferenceHub InventorySystem.Items.Firearms.Modules.Misc.ShotBacktrackData::PrimaryTargetHub + IL_007f: callvirt instance void class [mscorlib]System.Action`1::Invoke(!0/*class ReferenceHub* /) + */ + int hasTargetIndex = newInstructions.FindIndex(instruction => instruction.IsLdarg(2)); + + /* + [] <= Here + IL_0092: ldarg.2 // processingMethod + IL_0093: ldnull // null + IL_0094: callvirt instance void class [mscorlib]System.Action`1::Invoke(!0/*class ReferenceHub* /) + */ + int noTargetIndex = newInstructions.FindIndex(hasTargetIndex + 1, instruction => instruction.IsLdarg(2)); + List public bool HasHint => CurrentHint != null; - /// - /// Gets the 's , can be null. - /// - [Obsolete("Use IVoiceRole::VoiceModule instead.")] - public VoiceModuleBase VoiceModule => Role is Roles.IVoiceRole voiceRole ? voiceRole.VoiceModule : null; - /// /// Gets the 's , can be null. /// @@ -680,11 +674,16 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences public bool IsDead => Role?.IsDead ?? false; /// - /// Gets a value indicating whether the player's is any NTF rank. + /// Gets a value indicating whether the player's is any Foundation Forces. + /// Equivalent to checking the player's . + /// + public bool IsFoundationForces => Role?.Team is Team.FoundationForces; + + /// + /// Gets a value indicating whether the player's is any NTF rank and not a Facility Guard. /// Equivalent to checking the player's . /// - // TODO: Change logic for FacilityGuard in next major update - public bool IsNTF => Role?.Team is Team.FoundationForces; + public bool IsNTF => Role?.Team is Team.FoundationForces && Role?.Type is not RoleTypeId.FacilityGuard; /// /// Gets a value indicating whether the player's is any Chaos rank. @@ -1479,16 +1478,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. /// @@ -1541,15 +1530,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. /// @@ -3234,13 +3214,6 @@ public void EnableEffect(EffectType type, float duration = 0f, bool addDurationI public bool EnableEffect(EffectType type, byte intensity, float duration = 0f, bool addDurationIfActive = false) => TryGetEffect(type, out StatusEffectBase statusEffect) && EnableEffect(statusEffect, intensity, duration, addDurationIfActive); - /// - /// Enables a status effect on the player. - /// - /// The to enable. - [Obsolete("Use SyncEffect(Effect) instead of this")] - public void EnableEffect(Effect effect) => SyncEffect(effect); - /// /// Syncs the status effect on the player. /// diff --git a/EXILED/Exiled.API/Features/Respawn.cs b/EXILED/Exiled.API/Features/Respawn.cs index 1aecd920c..fbbfd9ce5 100644 --- a/EXILED/Exiled.API/Features/Respawn.cs +++ b/EXILED/Exiled.API/Features/Respawn.cs @@ -68,27 +68,6 @@ public static Faction NextKnownFaction /// public static SpawnableTeamType NextKnownTeam => NextKnownFaction.GetSpawnableTeam(); - /* TODO: Possibly moved to TimedWave - /// - /// Gets or sets the amount of seconds before the next respawn phase will occur. - /// - public static float TimeUntilNextPhase - { - get => RespawnManager.Singleton._timeForNextSequence - (float)RespawnManager.Singleton._stopwatch.Elapsed.TotalSeconds - set => RespawnManager.Singleton._timeForNextSequence = (float)RespawnManager.Singleton._stopwatch.Elapsed.TotalSeconds + value; - } - - /// - /// Gets a indicating the amount of time before the next respawn wave will occur. - /// - public static TimeSpan TimeUntilSpawnWave => TimeSpan.FromSeconds(TimeUntilNextPhase); - - /// - /// Gets a indicating the moment in UTC time the next respawn wave will occur. - /// - public static DateTime NextTeamTime => DateTime.UtcNow.AddSeconds(TimeUntilSpawnWave.TotalSeconds); - */ - /// /// Gets the current state of the . /// diff --git a/EXILED/Exiled.API/Features/Toys/Light.cs b/EXILED/Exiled.API/Features/Toys/Light.cs index a831f4b6d..757480e90 100644 --- a/EXILED/Exiled.API/Features/Toys/Light.cs +++ b/EXILED/Exiled.API/Features/Toys/Light.cs @@ -157,8 +157,8 @@ public static Light Create(Vector3? position /*= null*/, Vector3? rotation /*= n /// The corresponding instance. public static Light Get(LightSourceToy lightSourceToy) { - AdminToy adminToy = Map.Toys.FirstOrDefault(x => x.AdminToyBase == lightSourceToy); - return adminToy is not null ? adminToy as Light : new Light(lightSourceToy); + AdminToy adminToy = List.FirstOrDefault(x => x.AdminToyBase == lightSourceToy); + return adminToy is not null ? adminToy as Light : new(lightSourceToy); } } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Toys/Primitive.cs b/EXILED/Exiled.API/Features/Toys/Primitive.cs index 1b7202fa7..9ca95036d 100644 --- a/EXILED/Exiled.API/Features/Toys/Primitive.cs +++ b/EXILED/Exiled.API/Features/Toys/Primitive.cs @@ -220,7 +220,7 @@ public static Primitive Create(PrimitiveSettings primitiveSettings) /// The corresponding instance. public static Primitive Get(PrimitiveObjectToy primitiveObjectToy) { - AdminToy adminToy = Map.Toys.FirstOrDefault(x => x.AdminToyBase == primitiveObjectToy); + AdminToy adminToy = List.FirstOrDefault(x => x.AdminToyBase == primitiveObjectToy); return adminToy is not null ? adminToy as Primitive : new(primitiveObjectToy); } } diff --git a/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs b/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs index 6723944a4..2951459bc 100644 --- a/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs +++ b/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs @@ -214,7 +214,7 @@ public static ShootingTargetToy Create(ShootingTargetType type, Vector3? positio /// The corresponding instance. public static ShootingTargetToy Get(ShootingTarget shootingTarget) { - AdminToy adminToy = Map.Toys.FirstOrDefault(x => x.AdminToyBase == shootingTarget); + AdminToy adminToy = List.FirstOrDefault(x => x.AdminToyBase == shootingTarget); return adminToy is not null ? adminToy as ShootingTargetToy : new(shootingTarget); } diff --git a/EXILED/Exiled.API/Features/Waves/TimedWave.cs b/EXILED/Exiled.API/Features/Waves/TimedWave.cs index e8e91583b..fe33d1418 100644 --- a/EXILED/Exiled.API/Features/Waves/TimedWave.cs +++ b/EXILED/Exiled.API/Features/Waves/TimedWave.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) ExMod Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -30,10 +30,7 @@ public class TimedWave /// /// The that this class should be based off of. /// - public TimedWave(TimeBasedWave wave) - { - timedWave = wave; - } + public TimedWave(TimeBasedWave wave) => timedWave = wave; /// /// Gets the name of the wave timer. @@ -166,10 +163,7 @@ public static List GetTimedWaves() /// /// Destroys this wave. /// - public void Destroy() - { - timedWave.Destroy(); - } + public void Destroy() => timedWave.Destroy(); /// /// Populates this wave with the specified amount of roles. @@ -180,9 +174,6 @@ public void Destroy() /// /// The amount of people to populate. /// - public void PopulateQueue(Queue queue, int amount) - { - timedWave.PopulateQueue(queue, amount); - } + public void PopulateQueue(Queue queue, int amount) => timedWave.PopulateQueue(queue, amount); } } \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Waves/WaveTimer.cs b/EXILED/Exiled.API/Features/Waves/WaveTimer.cs index 203f4a1cd..279eba75d 100644 --- a/EXILED/Exiled.API/Features/Waves/WaveTimer.cs +++ b/EXILED/Exiled.API/Features/Waves/WaveTimer.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) ExMod Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -33,10 +33,7 @@ public class WaveTimer /// Initializes a new instance of the class. /// /// The that this class should be based off of. - public WaveTimer(Respawning.Waves.WaveTimer wave) - { - waveTimer = wave; - } + public WaveTimer(Respawning.Waves.WaveTimer wave) => waveTimer = wave; /// /// Gets the name of the wave timer. @@ -141,10 +138,7 @@ public static List GetWaveTimers() /// /// Destroys this wave timer. /// - public void Destroy() - { - waveTimer.Destroy(); - } + public void Destroy() => waveTimer.Destroy(); /// /// Pauses this wave timer. @@ -152,18 +146,12 @@ public void Destroy() /// /// The amount of time to pause this wave timer for. /// - public void Pause(float seconds) - { - waveTimer.Pause(seconds); - } + public void Pause(float seconds) => waveTimer.Pause(seconds); /// /// Unpauses this wave timer. /// - public void Unpause() - { - waveTimer.Pause(0); - } + public void Unpause() => waveTimer.Pause(0); /// /// Resets this wave timer. @@ -171,18 +159,12 @@ public void Unpause() /// /// A value indicating whether the should be reset. /// - public void Reset(bool resetInterval = true) - { - waveTimer.Reset(resetInterval); - } + public void Reset(bool resetInterval = true) => waveTimer.Reset(resetInterval); /// /// Update the timer. /// - public void Update() - { - waveTimer.Update(); - } + public void Update() => waveTimer.Update(); /// /// Add time to the wave timer. @@ -190,10 +172,7 @@ public void Update() /// /// The amount of time to add in seconds. /// - public void AddTime(float seconds) - { - waveTimer.AddTime(seconds); - } + public void AddTime(float seconds) => waveTimer.AddTime(seconds); /// /// Set the amount of time before the wave spawns. @@ -209,9 +188,6 @@ public void AddTime(float seconds) /// /// The amount of time before the wave spawns, in seconds. /// - public void SetTime(float seconds) - { - waveTimer.SetTime(seconds); - } + public void SetTime(float seconds) => waveTimer.SetTime(seconds); } } \ No newline at end of file diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs index 1ad086c77..2789f2fd1 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs @@ -120,19 +120,6 @@ public virtual ItemType Type [YamlIgnore] public virtual bool ShouldMessageOnGban { get; } = false; - /// - /// Gets a with a specific ID. - /// - /// The ID. - /// The matching the search, if not registered. - [Obsolete("Use Get(uint) instead.", true)] - public static CustomItem? Get(int id) - { - if (!idLookupTable.ContainsKey((uint)id)) - idLookupTable.Add((uint)id, Registered.FirstOrDefault(i => i.Id == id)); - return idLookupTable[(uint)id]; - } - /// /// Gets a with a specific ID. /// diff --git a/EXILED/Exiled.CustomRoles/API/Features/ActiveAbility.cs b/EXILED/Exiled.CustomRoles/API/Features/ActiveAbility.cs index de4869800..cadc7c63f 100644 --- a/EXILED/Exiled.CustomRoles/API/Features/ActiveAbility.cs +++ b/EXILED/Exiled.CustomRoles/API/Features/ActiveAbility.cs @@ -227,14 +227,6 @@ protected virtual void AbilityEnded(Player player) { } - /// - /// Called when the ability is successfully used. - /// - /// The using the ability. - [Obsolete("The Keypress Activator will already do this, you do not need to call this unless you are overwriting the keypress activator.", true)] - protected virtual void ShowMessage(Player player) => - player.ShowHint(string.Format(CustomRoles.Instance!.Config.UsedAbilityHint.Content, Name, Description), CustomRoles.Instance.Config.UsedAbilityHint.Duration); - /// /// Called when the ability is selected. /// diff --git a/EXILED/Exiled.Events/EventArgs/Item/ChargingJailbirdEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Item/ChargingJailbirdEventArgs.cs index 7e4d21b1c..7e7a6e58b 100644 --- a/EXILED/Exiled.Events/EventArgs/Item/ChargingJailbirdEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Item/ChargingJailbirdEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Item { - using System; - using Exiled.API.Features; using Exiled.API.Features.Items; using Exiled.Events.EventArgs.Interfaces; @@ -16,7 +14,7 @@ namespace Exiled.Events.EventArgs.Item /// /// Contains all information before a player charges a . /// - public class ChargingJailbirdEventArgs : IPlayerEvent, IItemEvent, IDeniableEvent + public class ChargingJailbirdEventArgs : IPlayerEvent, IItemEvent { /// /// Initializes a new instance of the class. @@ -49,13 +47,8 @@ public ChargingJailbirdEventArgs(ReferenceHub player, InventorySystem.Items.Item public Item Item => Jailbird; /// - /// Gets or sets a value indicating whether the Jailbird can be charged. + /// Gets a value indicating whether the Jailbird can be charged. /// - public bool IsAllowed - { - get; - [Obsolete("This event cannot be denied as it will cause desync.")] - set; - } + public bool IsAllowed { get; } } } diff --git a/EXILED/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs index d1f4cd82a..94f5b93a3 100644 --- a/EXILED/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Map { - using System; - using Exiled.API.Features.Pickups; using Exiled.API.Features.Pickups.Projectiles; using Exiled.Events.EventArgs.Interfaces; @@ -26,8 +24,8 @@ public class ChangedIntoGrenadeEventArgs : IExiledEvent /// The . public ChangedIntoGrenadeEventArgs(TimedGrenadePickup pickup, ThrownProjectile projectile) { - Pickup = (GrenadePickup)API.Features.Pickups.Pickup.Get(pickup); - Projectile = (Projectile)API.Features.Pickups.Pickup.Get(projectile); + Pickup = API.Features.Pickups.Pickup.Get(pickup); + Projectile = API.Features.Pickups.Pickup.Get(projectile); } /// @@ -39,11 +37,5 @@ public ChangedIntoGrenadeEventArgs(TimedGrenadePickup pickup, ThrownProjectile p /// Gets a value indicating the projectile that spawned. /// public Projectile Projectile { get; } - - /// - /// Gets or sets a value indicating how long the fuse of the changed grenade will be. - /// - [Obsolete("Use Projectile.Is(Projectile, out TimeGrenadeProjectile timeGrenadeProjectile) ? timeGrenadeProjectile.FuseTime : 0 instead of this", true)] - public double FuseTime { get; set; } } } diff --git a/EXILED/Exiled.Events/EventArgs/Map/FillingLockerEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/FillingLockerEventArgs.cs index 794aae85f..66043379d 100644 --- a/EXILED/Exiled.Events/EventArgs/Map/FillingLockerEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Map/FillingLockerEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Map { - using System; - using Exiled.API.Features.Lockers; using Exiled.API.Features.Pickups; using Exiled.Events.EventArgs.Interfaces; @@ -40,12 +38,6 @@ public FillingLockerEventArgs(ItemPickupBase pickupBase, LockerChamber lockerCha /// public Pickup Pickup { get; } - /// - /// Gets a value indicating the target locker chamber. - /// - [Obsolete("Use Chamber instead.")] - public LockerChamber LockerChamber => Chamber.Base; - /// /// Gets a locker which is containing . /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/ChangedItemEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ChangedItemEventArgs.cs index 44f032779..5d99086af 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/ChangedItemEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/ChangedItemEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Player { - using System; - using API.Features; using API.Features.Items; @@ -42,12 +40,6 @@ public ChangedItemEventArgs(Player player, ItemBase oldItem) /// public Item OldItem { get; } - /// - /// Gets the new item. - /// - [Obsolete("Use ev.Item instead of this")] - public Item NewItem => Item; - /// /// Gets the new item. /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/ChangingMoveStateEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ChangingMoveStateEventArgs.cs index 3be8dd579..36d524015 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/ChangingMoveStateEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/ChangingMoveStateEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Player { - using System; - using API.Features; using Interfaces; @@ -18,7 +16,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 +30,11 @@ 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 +48,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/Exiled.Events/EventArgs/Player/DyingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/DyingEventArgs.cs index 2ac0a0695..9919ac089 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/DyingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/DyingEventArgs.cs @@ -7,7 +7,6 @@ namespace Exiled.Events.EventArgs.Player { - using System; using System.Collections.Generic; using System.Linq; @@ -45,14 +44,9 @@ public DyingEventArgs(Player target, DamageHandlerBase damageHandler) } /// - /// Gets or sets the list of items to be dropped. + /// Gets the list of items to be dropped. /// - public List ItemsToDrop - { - get; - [Obsolete("This setter has been deprecated")] - set; - } + public List ItemsToDrop { get; } /// /// Gets the dying player. diff --git a/EXILED/Exiled.Events/EventArgs/Player/EscapedEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/EscapedEventArgs.cs index 6b470210c..71df7a008 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/EscapedEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/EscapedEventArgs.cs @@ -8,14 +8,11 @@ namespace Exiled.Events.EventArgs.Player { using System; - using System.Collections.Generic; using Exiled.API.Enums; using Exiled.API.Features; using Exiled.API.Features.Roles; using Exiled.Events.EventArgs.Interfaces; - using PlayerRoles; - using Respawning; /// /// Contains all information after player has escaped. diff --git a/EXILED/Exiled.Events/EventArgs/Player/InteractingLockerEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/InteractingLockerEventArgs.cs index 2be075af6..b7cc7f3b5 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/InteractingLockerEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/InteractingLockerEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Player { - using System; - using API.Features; using Exiled.API.Features.Lockers; using Interfaces; @@ -36,23 +34,11 @@ public class InteractingLockerEventArgs : IPlayerEvent, IDeniableEvent public InteractingLockerEventArgs(Player player, MapGeneration.Distributors.Locker locker, byte colliderId, bool isAllowed) { Player = player; - InteractingLocker = API.Features.Lockers.Locker.Get(locker); - InteractingChamber = API.Features.Lockers.Chamber.Get(locker.Chambers[colliderId]); + InteractingLocker = Locker.Get(locker); + InteractingChamber = Chamber.Get(locker.Chambers[colliderId]); IsAllowed = isAllowed; } - /// - /// Gets the instance. - /// - [Obsolete("Use InteractingLocker instead.")] - public MapGeneration.Distributors.Locker Locker => InteractingLocker.Base; - - /// - /// Gets the interacting chamber. - /// - [Obsolete("Use InteractingChamber instead.")] - public MapGeneration.Distributors.LockerChamber Chamber => InteractingChamber.Base; - /// /// Gets the locker which is containing . /// @@ -63,12 +49,6 @@ public InteractingLockerEventArgs(Player player, MapGeneration.Distributors.Lock /// public Chamber InteractingChamber { get; } - /// - /// Gets the chamber id. - /// - [Obsolete("Use Chamber::Id instead.")] - public byte ChamberId => InteractingChamber.Id; - /// /// Gets or sets a value indicating whether the player can interact with the locker. /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/KickingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/KickingEventArgs.cs index 736a52e6c..036b2aa4c 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/KickingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/KickingEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Player { - using System; - using System.Linq; using System.Reflection; using API.Features; @@ -76,14 +74,9 @@ public Player Target public string Reason { get; set; } /// - /// Gets or sets the full kick message. + /// Gets the full kick message. /// - public string FullMessage - { - get => startkickmessage + Reason; - [Obsolete("this will be remove use Reason instead of FullMessage")] - set => Reason = value.StartsWith(startkickmessage) ? value.Remove(0, startkickmessage.Count()) : value; - } + public string FullMessage => startkickmessage + Reason; /// /// Gets or sets a value indicating whether action is taken against the target. diff --git a/EXILED/Exiled.Events/EventArgs/Player/KillingPlayerEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/KillingPlayerEventArgs.cs deleted file mode 100644 index d575cb310..000000000 --- a/EXILED/Exiled.Events/EventArgs/Player/KillingPlayerEventArgs.cs +++ /dev/null @@ -1,42 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.EventArgs.Player -{ - using System; - - using Interfaces; - using PlayerStatsSystem; - - /// - /// Contains all information before player data to kill player is sent. - /// - [Obsolete] - public class KillingPlayerEventArgs : IPlayerEvent - { - /// - /// Initializes a new instance of the class. - /// - /// Current player. - /// DamageHandler instance. - public KillingPlayerEventArgs(API.Features.Player player, ref DamageHandlerBase handler) - { - Player = player; - Handler = handler; - } - - /// - /// Gets or sets current player. - /// - public API.Features.Player Player { get; set; } - - /// - /// Gets or sets current Damage Handler. - /// - public DamageHandlerBase Handler { get; set; } - } -} \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Player/TransmittingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/TransmittingEventArgs.cs index f8e4419d0..96e1ffde4 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/TransmittingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/TransmittingEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Player { - using System; - using Exiled.API.Features; using Exiled.Events.EventArgs.Interfaces; @@ -48,12 +46,6 @@ public TransmittingEventArgs(Player player, VoiceModuleBase voiceModule, bool is /// public VoiceModuleBase VoiceModule { get; } - /// - /// Gets a value indicating whether the player is transmitting. - /// - [Obsolete("IsTransmitting is always true.")] - public bool IsTransmitting => true; - /// /// Gets or sets a value indicating whether the player can transmit. /// diff --git a/EXILED/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs index e350a746d..c8ae4fdae 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs @@ -7,10 +7,7 @@ namespace Exiled.Events.EventArgs.Scp049 { - using System; - using API.Features; - using Exiled.API.Features.Roles; using Exiled.Events.EventArgs.Interfaces; using Scp049Role = API.Features.Roles.Scp049Role; @@ -54,12 +51,6 @@ public ActivatingSenseEventArgs(Player player, Player target, bool isAllowed = t /// public float FailedCooldown { get; set; } - /// - /// Gets or sets the cooldown of the ability. - /// - [Obsolete("Use FailedCooldown instead of this")] - public float Cooldown { get => FailedCooldown; set => FailedCooldown = value; } - /// /// Gets or sets the duration of the Effect. /// diff --git a/EXILED/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs index e27675ed3..56aff95ac 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Scp0492 { - using System; - using API.Features; using Exiled.API.Features.Roles; using Interfaces; diff --git a/EXILED/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs index 0f86698bf..b501c112c 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs @@ -7,11 +7,8 @@ namespace Exiled.Events.EventArgs.Scp106 { - using System; - using API.Features; using Interfaces; - using PlayerRoles.PlayableScps.Scp106; using Scp106Role = API.Features.Roles.Scp106Role; diff --git a/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs index dcfac59af..b94a3db6f 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Scp106 { - using System; - using API.Features; using Interfaces; using PlayerRoles.PlayableScps.Scp106; @@ -32,23 +30,6 @@ public StalkingEventArgs(Player player) MinimumVigor = Scp106StalkAbility.MinVigorToSubmerge; } - /// - /// Gets the . - /// - [Obsolete("Use Scp106.StalkAbility instead of this")] - public Scp106StalkAbility Scp106StalkAbility => Scp106.StalkAbility; - - /// - /// Gets or sets the current vigor when SCP-106 starts to stalk. - /// - public float Vigor - { - [Obsolete("Use Scp106.Vigor instead of this")] - get => Scp106.Vigor; - [Obsolete("Use Scp106.Vigor instead of this")] - set => Scp106.Vigor = value; - } - /// /// Gets or sets the required minimum vigor to stalk. /// diff --git a/EXILED/Exiled.Events/EventArgs/Scp173/BlinkingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp173/BlinkingEventArgs.cs index ef697602d..95f3e2a08 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp173/BlinkingEventArgs.cs +++ b/EXILED/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 IReadOnlyCollection Targets { get; } /// /// Gets or sets a value indicating whether the player is allowed to blink. diff --git a/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingInventoryItemEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingInventoryItemEventArgs.cs index 18247e605..b4f27aa5f 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingInventoryItemEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingInventoryItemEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Scp914 { - using System; - using API.Features; using API.Features.Items; using global::Scp914; @@ -43,12 +41,6 @@ public UpgradingInventoryItemEventArgs(Player player, ItemBase item, Scp914KnobS IsAllowed = isAllowed; } - /// - /// Gets the instance. - /// - [Obsolete("Use Scp914::Scp914Controller instead.")] - public Scp914Controller Scp914 => API.Features.Scp914.Scp914Controller; - /// /// Gets or sets SCP-914 working knob setting. /// diff --git a/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingPickupEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingPickupEventArgs.cs index cf374690a..691db20a1 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingPickupEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp914/UpgradingPickupEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Scp914 { - using System; - using Exiled.API.Features.Pickups; using Exiled.Events.EventArgs.Interfaces; using global::Scp914; @@ -44,12 +42,6 @@ public UpgradingPickupEventArgs(ItemPickupBase item, Vector3 newPos, Scp914KnobS /// public Pickup Pickup { get; } - /// - /// Gets the instance. - /// - [Obsolete("Use Scp914::Scp914Controller instead.")] - public Scp914Controller Scp914 => API.Features.Scp914.Scp914Controller; - /// /// Gets or sets the position the item will be output to. /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/LocalReportingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/LocalReportingEventArgs.cs similarity index 95% rename from EXILED/Exiled.Events/EventArgs/Player/LocalReportingEventArgs.cs rename to EXILED/Exiled.Events/EventArgs/Server/LocalReportingEventArgs.cs index d937a5fef..02d1d6b98 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/LocalReportingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/LocalReportingEventArgs.cs @@ -5,7 +5,7 @@ // // ----------------------------------------------------------------------- -namespace Exiled.Events.EventArgs.Player // TODO: Wrong namespace should be Server +namespace Exiled.Events.EventArgs.Server { using API.Features; diff --git a/EXILED/Exiled.Events/EventArgs/Server/SelectingRespawnTeamEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/SelectingRespawnTeamEventArgs.cs index 63f27d345..e4c87e6b2 100644 --- a/EXILED/Exiled.Events/EventArgs/Server/SelectingRespawnTeamEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/SelectingRespawnTeamEventArgs.cs @@ -7,9 +7,6 @@ namespace Exiled.Events.EventArgs.Server { - using System; - - using Exiled.API.Features; using Exiled.Events.EventArgs.Interfaces; using Respawning; diff --git a/EXILED/Exiled.Events/Events.cs b/EXILED/Exiled.Events/Events.cs index fcdd47cf1..f68d6527f 100644 --- a/EXILED/Exiled.Events/Events.cs +++ b/EXILED/Exiled.Events/Events.cs @@ -14,7 +14,6 @@ namespace Exiled.Events using API.Features; using CentralAuth; using Exiled.Events.Features; - using HarmonyLib; using InventorySystem.Items.Pickups; using InventorySystem.Items.Usables; diff --git a/EXILED/Exiled.Events/Handlers/Player.cs b/EXILED/Exiled.Events/Handlers/Player.cs index d9c9900d6..deeaa5540 100644 --- a/EXILED/Exiled.Events/Handlers/Player.cs +++ b/EXILED/Exiled.Events/Handlers/Player.cs @@ -505,8 +505,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. @@ -523,12 +523,6 @@ public class Player /// public static Event ItemRemoved { get; set; } = new(); - /// - /// Invoked before KillPlayer is called. - /// - [Obsolete("Use DyingEventArgs")] - public static Event KillingPlayer { get; set; } = new(); - /// /// Invoked before a enters in an environmental hazard. /// @@ -702,8 +696,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. @@ -1011,13 +1004,6 @@ public class Player /// The instance. public static void OnSendingAdminChatMessage(SendingAdminChatMessageEventsArgs ev) => SendingAdminChatMessage.InvokeSafely(ev); - /// - /// Called before KillPlayer is called. - /// - /// The event handler. - [Obsolete("Use DyingEventArgs")] - public static void OnKillPlayer(KillingPlayerEventArgs ev) => KillingPlayer.InvokeSafely(ev); - /// /// Called after a has an item added to their inventory. /// @@ -1074,7 +1060,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 OnDamagingWindow(DamagingWindowEventArgs ev) => DamagingWindow.InvokeSafely(ev); /// /// Called before a damage a window. diff --git a/EXILED/Exiled.Events/Handlers/Server.cs b/EXILED/Exiled.Events/Handlers/Server.cs index a48d599a2..c86a8adee 100644 --- a/EXILED/Exiled.Events/Handlers/Server.cs +++ b/EXILED/Exiled.Events/Handlers/Server.cs @@ -14,7 +14,6 @@ namespace Exiled.Events.Handlers #pragma warning disable SA1623 // Property summary documentation should match accessors - using Exiled.Events.EventArgs.Player; using Exiled.Events.EventArgs.Server; using Exiled.Events.Features; diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ChangingMoveState.cs b/EXILED/Exiled.Events/Patches/Events/Player/ChangingMoveState.cs index b65d6e5c9..5c9879f7c 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/ChangingMoveState.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/ChangingMoveState.cs @@ -58,10 +58,7 @@ private static IEnumerable Transpiler(IEnumerable list = new List(); if (inventory.TryGetBodyArmor(out BodyArmor bodyArmor)) - { bodyArmor.DontRemoveExcessOnDrop = true; - } HashSet hashSet = HashSetPool.Pool.Get(); foreach (KeyValuePair item2 in inventory.UserInventory.Items) { if (item2.Value is Scp1344Item scp1344Item) - { scp1344Item.Status = Scp1344Status.Idle; - } else - { hashSet.Add(item2.Key); - } } - foreach (ushort item3 in hashSet) - { - list.Add(inventory.ServerDropItem(item3)); - } + foreach (ushort item in hashSet) + list.Add(inventory.ServerDropItem(item)); HashSetPool.Pool.Return(hashSet); InventoryItemProvider.PreviousInventoryPickups[ev.Player.ReferenceHub] = list; } - - if (!flag) + else { while (inventory.UserInventory.Items.Count > 0) - { inventory.ServerRemoveItem(inventory.UserInventory.Items.ElementAt(0).Key, null); - } inventory.UserInventory.ReserveAmmo.Clear(); inventory.SendAmmoNextFrame = true; } if (!StartingInventories.DefinedInventories.TryGetValue(ev.NewRole, out InventoryRoleInfo value)) - { return; - } foreach (KeyValuePair item in value.Ammo) - { inventory.ServerAddAmmo(item.Key, item.Value); - } for (int i = 0; i < value.Items.Length; i++) { diff --git a/EXILED/Exiled.Events/Patches/Events/Player/DamagingWindow.cs b/EXILED/Exiled.Events/Patches/Events/Player/DamagingWindow.cs index df26d055b..097127383 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/DamagingWindow.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/DamagingWindow.cs @@ -25,9 +25,9 @@ namespace Exiled.Events.Patches.Events.Player /// /// 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 { @@ -62,7 +62,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable // ----------------------------------------------------------------------- -namespace Exiled.Events.Patches.Events.Player +namespace Exiled.Events.Patches.Events.Scp079 { using System.Collections.Generic; using System.Reflection.Emit; diff --git a/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs b/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs index 3aa103763..c690f20e2 100755 --- a/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs @@ -7,7 +7,6 @@ namespace Exiled.Events.Patches.Events.Scp173 { - using System; using System.Collections.Generic; using System.Linq; using System.Reflection; diff --git a/EXILED/Exiled.Events/Patches/Events/Scp3114/Strangling.cs b/EXILED/Exiled.Events/Patches/Events/Scp3114/Strangling.cs index e1ea777e1..c0dbbe2ef 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp3114/Strangling.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp3114/Strangling.cs @@ -7,11 +7,9 @@ namespace Exiled.Events.Patches.Events.Scp3114 { - using System; using System.Collections.Generic; using System.Reflection.Emit; - using Exiled.API.Features; using Exiled.API.Features.Pools; using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Scp3114; diff --git a/EXILED/Exiled.Events/Patches/Events/Server/Reporting.cs b/EXILED/Exiled.Events/Patches/Events/Server/Reporting.cs index 8cfa11cbc..99ff8006d 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/Reporting.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/Reporting.cs @@ -12,7 +12,6 @@ namespace Exiled.Events.Patches.Events.Server using API.Features.Pools; using Exiled.Events.Attributes; - using Exiled.Events.EventArgs.Player; using Exiled.Events.EventArgs.Server; using Exiled.Events.Handlers; diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RespawningTeam.cs b/EXILED/Exiled.Events/Patches/Events/Server/RespawningTeam.cs index 50baf6384..d6829b8c6 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RespawningTeam.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RespawningTeam.cs @@ -10,19 +10,15 @@ namespace Exiled.Events.Patches.Events.Server using System; using System.Collections.Generic; using System.Linq; - using System.Reflection; using System.Reflection.Emit; using API.Features.Pools; - using Exiled.API.Extensions; using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Server; using Exiled.Events.Handlers; using HarmonyLib; using PlayerRoles; - using Respawning; - using Respawning.NamingRules; using Respawning.Waves; using static HarmonyLib.AccessTools; diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs index 489e015a1..4eee538b2 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs @@ -13,7 +13,6 @@ namespace Exiled.Events.Patches.Events.Server using System.Reflection; using System.Reflection.Emit; - using Exiled.API.Extensions; using Exiled.API.Features; using Exiled.API.Features.Pools; using Exiled.Events.EventArgs.Server; @@ -201,4 +200,4 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } } -} +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Fixes/HurtingFix.cs b/EXILED/Exiled.Events/Patches/Fixes/HurtingFix.cs index 67d4df70c..044914dca 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/HurtingFix.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/HurtingFix.cs @@ -5,7 +5,7 @@ // // ----------------------------------------------------------------------- -namespace Exiled.Events.Patches.Events.Player +namespace Exiled.Events.Patches.Fixes { using System.Collections.Generic; using System.Reflection.Emit; diff --git a/EXILED/Exiled.Events/Patches/Fixes/Jailbird914CoarseFix.cs b/EXILED/Exiled.Events/Patches/Fixes/Jailbird914CoarseFix.cs index f0ac77f7e..bd416ca01 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/Jailbird914CoarseFix.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/Jailbird914CoarseFix.cs @@ -5,7 +5,7 @@ // // ----------------------------------------------------------------------- -namespace Exiled.Events.Patches.Events.Player +namespace Exiled.Events.Patches.Fixes { #pragma warning disable IDE0060 diff --git a/EXILED/Exiled.Events/Patches/Fixes/KillPlayer.cs b/EXILED/Exiled.Events/Patches/Fixes/KillPlayer.cs index 13dd7a6b5..0f30d7d2d 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/KillPlayer.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/KillPlayer.cs @@ -8,14 +8,9 @@ namespace Exiled.Events.Patches.Fixes { #pragma warning disable SA1313 // Parameter names should begin with lower-case letter -#pragma warning disable CS0612 // Type or member is obsolete -#pragma warning disable CS0618 // Type or member is obsolete - using API.Features; using API.Features.DamageHandlers; - using EventArgs.Player; - using HarmonyLib; using Mirror; @@ -32,20 +27,8 @@ internal class KillPlayer { private static void Prefix(PlayerStats __instance, ref DamageHandlerBase handler) { - if (!DamageHandlers.IdsByTypeHash.ContainsKey(handler.GetType().FullName.GetStableHashCode())) - { - if (handler is GenericDamageHandler exiledHandler) - { - handler = exiledHandler.Base; - } - else - { - KillingPlayerEventArgs ev = new(Player.Get(__instance._hub), ref handler); - Handlers.Player.OnKillPlayer(ev); - - handler = ev.Handler; - } - } + if (!DamageHandlers.IdsByTypeHash.ContainsKey(handler.GetType().FullName.GetStableHashCode()) && handler is GenericDamageHandler exiledHandler) + handler = exiledHandler.Base; } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Generic/Scp079Recontain.cs b/EXILED/Exiled.Events/Patches/Generic/Scp079Recontain.cs index e1a8219dd..f92a59482 100644 --- a/EXILED/Exiled.Events/Patches/Generic/Scp079Recontain.cs +++ b/EXILED/Exiled.Events/Patches/Generic/Scp079Recontain.cs @@ -5,7 +5,7 @@ // // ----------------------------------------------------------------------- -namespace Exiled.Events.Patches.Generic.Scp079API +namespace Exiled.Events.Patches.Generic { using System.Collections.Generic; using System.Reflection.Emit; @@ -20,7 +20,7 @@ namespace Exiled.Events.Patches.Generic.Scp079API /// /// Patches . - /// Adds the support. + /// Adds the support. /// [HarmonyPatch(typeof(Scp079Recontainer), nameof(Scp079Recontainer.OnServerRoleChanged))] internal class Scp079Recontain @@ -39,7 +39,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Mon, 9 Dec 2024 13:22:33 +0100 Subject: [PATCH 077/102] Respawn API changes (#246) --- EXILED/Exiled.API/Enums/SpawnableFaction.cs | 5 + .../Exiled.API/Extensions/RoleExtensions.cs | 57 ++- EXILED/Exiled.API/Features/Respawn.cs | 362 +++++++++++++----- 3 files changed, 324 insertions(+), 100 deletions(-) diff --git a/EXILED/Exiled.API/Enums/SpawnableFaction.cs b/EXILED/Exiled.API/Enums/SpawnableFaction.cs index 131a7a4ff..0903253fc 100644 --- a/EXILED/Exiled.API/Enums/SpawnableFaction.cs +++ b/EXILED/Exiled.API/Enums/SpawnableFaction.cs @@ -12,6 +12,11 @@ namespace Exiled.API.Enums /// public enum SpawnableFaction { + /// + /// Represents no wave. + /// + None, + /// /// Normal NTF wave. /// diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index 407e26565..445edb88c 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -12,12 +12,13 @@ namespace Exiled.API.Extensions using System.Linq; using Enums; - using Exiled.API.Features.Spawn; + using Features.Spawn; using Footprinting; using InventorySystem; using InventorySystem.Configs; using PlayerRoles; using PlayerRoles.FirstPersonControl; + using Respawning; using Respawning.Waves; using UnityEngine; @@ -233,12 +234,62 @@ public static Dictionary GetStartingAmmo(this RoleTypeId roleT /// /// A instance. /// associated with the wave. - public static SpawnableFaction GetFaction(this SpawnableWaveBase waveBase) => waveBase switch + public static SpawnableFaction GetSpawnableFaction(this SpawnableWaveBase waveBase) => waveBase switch { NtfSpawnWave => SpawnableFaction.NtfWave, NtfMiniWave => SpawnableFaction.NtfMiniWave, ChaosSpawnWave => SpawnableFaction.ChaosWave, - _ => SpawnableFaction.ChaosMiniWave + ChaosMiniWave => SpawnableFaction.ChaosMiniWave, + _ => SpawnableFaction.None }; + + /// + /// Gets the associated with the provided . + /// + /// A member of the enum. + /// associated with the provided . + public static Faction GetFaction(this SpawnableFaction spawnableFaction) => spawnableFaction switch + { + SpawnableFaction.ChaosWave or SpawnableFaction.ChaosMiniWave => Faction.FoundationEnemy, + SpawnableFaction.NtfWave or SpawnableFaction.NtfMiniWave => Faction.FoundationStaff, + _ => Faction.Unclassified, + }; + + /// + /// Gets the associated with the provided . + /// + /// A member of the enum. + /// associated with the provided . + public static Faction GetFaction(this SpawnableTeamType spawnableTeamType) => spawnableTeamType switch + { + SpawnableTeamType.ChaosInsurgency => Faction.FoundationEnemy, + SpawnableTeamType.NineTailedFox => Faction.FoundationStaff, + _ => Faction.Unclassified, + }; + + /// + /// Tries to get the associated with the provided and . + /// + /// A member of the enum. + /// The to return. + /// A determining whether to get a normal spawn wave or a mini one. + /// associated with the provided influenced by . + public static bool TryGetSpawnableFaction(this Faction faction, out SpawnableFaction spawnableFaction, bool mini = false) + { + switch (faction) + { + case Faction.FoundationStaff: + spawnableFaction = mini ? SpawnableFaction.NtfMiniWave : SpawnableFaction.NtfWave; + break; + case Faction.FoundationEnemy: + spawnableFaction = mini ? SpawnableFaction.ChaosMiniWave : SpawnableFaction.ChaosWave; + break; + default: + spawnableFaction = SpawnableFaction.None; + return false; + } + + return true; + } } } diff --git a/EXILED/Exiled.API/Features/Respawn.cs b/EXILED/Exiled.API/Features/Respawn.cs index fbbfd9ce5..a7590dfd2 100644 --- a/EXILED/Exiled.API/Features/Respawn.cs +++ b/EXILED/Exiled.API/Features/Respawn.cs @@ -9,9 +9,11 @@ namespace Exiled.API.Features { using System; using System.Collections.Generic; + using System.Linq; using CustomPlayerEffects; using Enums; + using Extensions; using PlayerRoles; using Respawning; using Respawning.Waves; @@ -26,6 +28,16 @@ public static class Respawn private static GameObject ntfHelicopterGameObject; private static GameObject chaosCarGameObject; + /// + /// Gets the of paused 's. + /// + public static List PausedWaves { get; } = new(); + + /// + /// Gets the containing faction influence. + /// + public static Dictionary FactionInfluence => FactionInfluenceManager.Influence; + /// /// Gets the NTF Helicopter's . /// @@ -55,18 +67,16 @@ public static GameObject ChaosVan } /// - /// Gets or sets the next known that will spawn. + /// Gets the next known that will spawn. /// - public static Faction NextKnownFaction - { - get => WaveManager._nextWave.TargetFaction; - set => WaveManager._nextWave = WaveManager.Waves.Find(x => x.TargetFaction == value); - } + /// This returns SpawnableFaction.None unless a respawn has already started. + public static SpawnableFaction NextKnownSpawnableFaction => WaveManager._nextWave is not null ? WaveManager._nextWave.GetSpawnableFaction() : SpawnableFaction.None; /// /// Gets the next known that will spawn. /// - public static SpawnableTeamType NextKnownTeam => NextKnownFaction.GetSpawnableTeam(); + /// This returns SpawnableFaction.None unless a respawn has already started. + public static SpawnableTeamType NextKnownTeam => NextKnownSpawnableFaction.GetFaction().GetSpawnableTeam(); /// /// Gets the current state of the . @@ -74,7 +84,7 @@ public static Faction NextKnownFaction public static WaveManager.WaveQueueState CurrentState => WaveManager.State; /// - /// Gets a value indicating whether a team is currently being spawned or the animations are playing for a team. + /// Gets a value indicating whether the respawn process for a is currently in progress.. /// public static bool IsSpawning => WaveManager.State == WaveManager.WaveQueueState.WaveSpawning; @@ -106,177 +116,335 @@ public static bool ProtectedCanShoot } /// - /// Gets a of that have spawn protection. + /// Gets a of s that have spawn protection. /// public static List ProtectedTeams => SpawnProtected.ProtectedTeams; /// /// Tries to get a . /// - /// Found . + /// The found . /// Type of . - /// true if was successfully found. Otherwise, false. - public static bool TryGetWaveBase(out T spawnWave) - where T : SpawnableWaveBase => WaveManager.TryGet(out spawnWave); + /// true if was successfully found. Otherwise, false. + /// + public static bool TryGetWaveBase(out T spawnableWaveBase) + where T : SpawnableWaveBase => WaveManager.TryGet(out spawnableWaveBase); /// - /// Tries to get a from a . + /// Tries to get a . /// - /// Team's . - /// Found . - /// true if was successfully found. Otherwise, false. - public static bool TryGetWaveBase(Faction faction, out SpawnableWaveBase spawnWave) - => WaveManager.TryGet(faction, out spawnWave); + /// A determining which wave to search for. + /// The found . + /// true if was successfully found. Otherwise, false. + /// + public static bool TryGetWaveBase(SpawnableFaction spawnableFaction, out SpawnableWaveBase spawnableWaveBase) + { + spawnableWaveBase = WaveManager.Waves.Find(x => x.GetSpawnableFaction() == spawnableFaction); + return spawnableWaveBase is not null; + } /// - /// Tries to get a from a . + /// Tries to get an of . /// - /// Team's . - /// Found . - /// true if was successfully found. Otherwise, false. - public static bool TryGetWaveBase(SpawnableFaction faction, out SpawnableWaveBase spawnWave) + /// A determining which waves to search for. + /// The containing found 's if there are any, otherwise null. + /// true if was successfully found. Otherwise, false. + /// + public static bool TryGetWaveBases(Faction faction, out IEnumerable spawnableWaveBases) { - switch (faction) + List spawnableWaves = new(); + spawnableWaves.AddRange(WaveManager.Waves.Where(x => x.TargetFaction == faction)); + + if (spawnableWaves.IsEmpty()) { - case SpawnableFaction.NtfWave: - bool result = TryGetWaveBase(out NtfSpawnWave ntfSpawnWave); - spawnWave = ntfSpawnWave; - return result; - case SpawnableFaction.NtfMiniWave: - result = TryGetWaveBase(out NtfMiniWave ntfMiniWave); - spawnWave = ntfMiniWave; - return result; - case SpawnableFaction.ChaosWave: - result = TryGetWaveBase(out ChaosSpawnWave chaosSpawnWave); - spawnWave = chaosSpawnWave; - return result; - case SpawnableFaction.ChaosMiniWave: - result = TryGetWaveBase(out ChaosMiniWave chaosMiniWave); - spawnWave = chaosMiniWave; - return result; + spawnableWaveBases = null; + return false; } - spawnWave = null; - return false; + spawnableWaveBases = spawnableWaves; + return true; } /// - /// Docs. + /// Tries to get an of . + /// + /// A determining which waves to search for. + /// The containing found 's if there are any, otherwise null. + /// true if was successfully found. Otherwise, false. + /// + public static bool TryGetWaveBases(SpawnableTeamType spawnableTeamType, out IEnumerable spawnableWaveBases) + { + return TryGetWaveBases(spawnableTeamType.GetFaction(), out spawnableWaveBases); + } + + /// + /// Advances the respawn timer for s. + /// + /// The whose 's timers are to be advanced. + /// Number of seconds to advance the timers by. + /// This advances the timer for both the normal and mini wave. + public static void AdvanceTimer(Faction faction, float seconds) => WaveManager.AdvanceTimer(faction, seconds); + + /// + /// Advances the respawn timer for s. + /// + /// The whose 's timers are to be advanced. + /// A representing the amount of time to advance the timers by. + /// This advances the timer for both the normal and mini wave. + public static void AdvanceTimer(Faction faction, TimeSpan time) => AdvanceTimer(faction, (float)time.TotalSeconds); + + /// + /// Advances the respawn timer for s. /// - /// Docs1. - /// Docs2. - public static void AdvanceTime(Faction faction, float time) => WaveManager.AdvanceTimer(faction, time); + /// The whose 's timers are to be advanced. + /// Number of seconds to advance the timers by. + /// This advances the timer for both the normal and mini wave. + public static void AdvanceTimer(SpawnableTeamType spawnableTeamType, float seconds) => AdvanceTimer(spawnableTeamType.GetFaction(), seconds); /// - /// Docs. + /// Advances the respawn timer for s. /// - /// Docs1. - public static void SpawnWave(SpawnableWaveBase wave) => WaveManager.Spawn(wave); + /// The whose 's timers are to be advanced. + /// A representing the amount of time to advance the timers by. + /// This advances the timer for both the normal and mini wave. + public static void AdvanceTimer(SpawnableTeamType spawnableTeamType, TimeSpan time) => AdvanceTimer(spawnableTeamType.GetFaction(), time); /// - /// Docs. + /// Advances the respawn timer for s. /// - /// Docs1. - /// Docs2. - /// Docs3. - public static void SpawnWave(Faction faction, bool mini) - where T : SpawnableWaveBase + /// The whose 's timer is to be advanced. + /// Number of seconds to advance the timers by. + public static void AdvanceTimer(SpawnableFaction spawnableFaction, float seconds) { - if (TryGetWaveBase(out T wave)) - SpawnWave(wave); + foreach (SpawnableWaveBase spawnableWaveBase in WaveManager.Waves) + { + TimeBasedWave timeBasedWave = (TimeBasedWave)spawnableWaveBase; + if (timeBasedWave.GetSpawnableFaction() == spawnableFaction) + { + timeBasedWave.Timer.AddTime(Mathf.Abs(seconds)); + } + } } /// - /// Play effects when a certain class spawns. + /// Advances the respawn timer for s. /// - /// The for which effects should be played. + /// The whose 's timer is to be advanced. + /// A representing the amount of time to advance the timers by. + public static void AdvanceTimer(SpawnableFaction spawnableFaction, TimeSpan time) => AdvanceTimer(spawnableFaction, (float)time.TotalSeconds); + + /// + /// Play the spawn effect of a . + /// + /// The whose effect should be played. public static void PlayEffect(SpawnableWaveBase wave) { WaveUpdateMessage.ServerSendUpdate(wave, UpdateMessageFlags.Trigger); } /// - /// Summons the NTF chopper. + /// Summons the chopper. /// public static void SummonNtfChopper() { - if (TryGetWaveBase(Faction.FoundationStaff, out SpawnableWaveBase wave)) + if (TryGetWaveBase(SpawnableFaction.NtfWave, out SpawnableWaveBase wave)) PlayEffect(wave); } /// - /// Summons the van. + /// Summons the van. /// /// This will also trigger Music effect. + /// public static void SummonChaosInsurgencyVan() { - if (TryGetWaveBase(Faction.FoundationEnemy, out SpawnableWaveBase wave)) + if (TryGetWaveBase(SpawnableFaction.ChaosWave, out SpawnableWaveBase wave)) PlayEffect(wave); } /// - /// Grants tickets to a . + /// Grants tokens to a given 's s. + /// + /// The to whose s to grant tokens. + /// The amount of tokens to grant. + /// true if tokens were successfully granted to an , otherwise false. + public static bool GrantTokens(Faction faction, int amount) + { + if (TryGetWaveBases(faction, out IEnumerable waveBases)) + { + foreach (ILimitedWave limitedWave in waveBases.OfType()) + { + limitedWave.RespawnTokens += amount; + } + + return true; + } + + return false; + } + + /// + /// Removes tokens from a given 's s. + /// + /// The from whose s to remove tokens. + /// The amount of tokens to remove. + /// true if tokens were successfully removed from an , otherwise false. + public static bool RemoveTokens(Faction faction, int amount) + { + if (TryGetWaveBases(faction, out IEnumerable waveBases)) + { + foreach (ILimitedWave limitedWave in waveBases.OfType()) + { + limitedWave.RespawnTokens = Math.Max(0, limitedWave.RespawnTokens - amount); + } + + return true; + } + + return false; + } + + /// + /// Modifies tokens of a given 's s by a given amount. /// - /// The to grant tickets to. - /// The amount of tickets to grant. - public static void GrantTickets(Faction team, int amount) + /// The whose s' tokens are to be modified. + /// The amount of tokens to add/remove. + /// true if tokens were successfully modified for an , otherwise false. + public static bool ModifyTokens(Faction faction, int amount) { - if (TryGetWaveBase(team, out SpawnableWaveBase wave) && wave is ILimitedWave limitedWave) - limitedWave.RespawnTokens += amount; + if (TryGetWaveBases(faction, out IEnumerable waveBases)) + { + foreach (ILimitedWave limitedWave in waveBases.OfType()) + { + limitedWave.RespawnTokens = amount; + } + + return true; + } + + return false; } /// - /// Removes tickets from a . + /// Tries to get the tokens of a given 's . /// - /// The to remove tickets from. - /// The amount of tickets to remove. - public static void RemoveTickets(Faction team, int amount) + /// The from whose to get the tokens. + /// The amount of tokens an has, if one was found, otherwise 0. + /// true if an was successfully found, otherwise false. + public static bool TryGetTokens(SpawnableFaction spawnableFaction, out int tokens) { - if (TryGetWaveBase(team, out SpawnableWaveBase wave) && wave is ILimitedWave limitedWave) - limitedWave.RespawnTokens = Math.Max(0, limitedWave.RespawnTokens - amount); + if (TryGetWaveBase(spawnableFaction, out SpawnableWaveBase waveBase) && waveBase is ILimitedWave limitedWave) + { + tokens = limitedWave.RespawnTokens; + return true; + } + + tokens = 0; + return false; } /// - /// Modify tickets from a . + /// Sets the amount of tokens of an of the given . /// - /// The to modify tickets from. - /// The amount of tickets to modify. - public static void ModifyTickets(Faction team, int amount) + /// The whose 's tokens to set. + /// The amount of tokens to set. + /// true if tokens were successfully set for an , otherwise false. + public static bool SetTokens(SpawnableFaction spawnableFaction, int amount) { - if (TryGetWaveBase(team, out SpawnableWaveBase wave) && wave is ILimitedWave limitedWave) + if (TryGetWaveBase(spawnableFaction, out SpawnableWaveBase waveBase) && waveBase is ILimitedWave limitedWave) + { limitedWave.RespawnTokens = amount; + return true; + } + + return false; + } + + /// + /// Starts the spawn sequence of the given . + /// + /// The whose wave to spawn. + /// Whether the wave should be a mini wave or not. + public static void ForceWave(SpawnableTeamType spawnableTeamType, bool isMini = false) + { + ForceWave(spawnableTeamType.GetFaction(), isMini); + } + + /// + /// Starts the spawn sequence of the given . + /// + /// The whose wave to spawn. + /// Whether the wave should be a mini wave or not. + public static void ForceWave(Faction faction, bool isMini = false) + { + if (faction.TryGetSpawnableFaction(out SpawnableFaction spawnableFaction, isMini)) + { + ForceWave(spawnableFaction); + } + } + + /// + /// Starts the spawn sequence of the given . + /// + /// The whose wave to spawn. + public static void ForceWave(SpawnableFaction spawnableFaction) + { + if (TryGetWaveBase(spawnableFaction, out SpawnableWaveBase spawnableWaveBase)) + { + ForceWave(spawnableWaveBase); + } } /// - /// Gets the amount of tickets from a . + /// Starts the spawn sequence of the given . /// - /// 's faction. - /// Tickets of team or -1 if team doesn't depend on tickets. - public static int GetTickets(SpawnableFaction faction) + /// The to spawn. + public static void ForceWave(SpawnableWaveBase spawnableWaveBase) { - if (TryGetWaveBase(faction, out SpawnableWaveBase wave) && wave is ILimitedWave limitedWave) - return limitedWave.RespawnTokens; + WaveManager.Spawn(spawnableWaveBase); + } - return -1; + /// + /// Pauses respawn waves by removing them from WaveManager.Waves and storing them in . + /// + /// + public static void PauseWaves() + { + PausedWaves.Clear(); + PausedWaves.AddRange(WaveManager.Waves); + WaveManager.Waves.Clear(); } /// - /// Forces a spawn of the given . + /// Resumes respawn waves by filling WaveManager.Waves with values stored in . /// - /// The to spawn. - public static void ForceWave(Faction team) + /// + /// This also clears . + public static void ResumeWaves() { - if (TryGetWaveBase(team, out SpawnableWaveBase wave)) - ForceWave(wave); + WaveManager.Waves.Clear(); + WaveManager.Waves.AddRange(PausedWaves); + PausedWaves.Clear(); } /// - /// Docs. + /// Restarts respawn waves by clearing WaveManager.Waves and filling it with new values.. /// - /// Docs1. - public static void ForceWave(SpawnableWaveBase wave) + /// + /// This also clears . + public static void RestartWaves() { - WaveManager.Spawn(wave); + WaveManager.Waves.Clear(); + WaveManager.Waves.AddRange(new List { new ChaosMiniWave(), new ChaosSpawnWave(), new NtfMiniWave(), new NtfSpawnWave() }); + PausedWaves.Clear(); } + + /// + /// Tries to get the influence value of a given . + /// + /// The whose influence to get. + /// The amount of influence a faction has. + /// Whether an entry was successfully found. + public static bool TryGetFactionInfluence(Faction faction, out float influence) => FactionInfluence.TryGetValue(faction, out influence); } } \ No newline at end of file From d01185355d17ee55607461b3ee0232734a61b7b8 Mon Sep 17 00:00:00 2001 From: notzerotwo_ <63092138+NotZer0Two@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:24:23 +0100 Subject: [PATCH 078/102] New NPC Api (#241) --- EXILED/Exiled.API/Features/Npc.cs | 286 ++++++++++++++------------- EXILED/Exiled.API/Features/Player.cs | 6 +- 2 files changed, 148 insertions(+), 144 deletions(-) diff --git a/EXILED/Exiled.API/Features/Npc.cs b/EXILED/Exiled.API/Features/Npc.cs index d7d7d6d78..4055dfa6a 100644 --- a/EXILED/Exiled.API/Features/Npc.cs +++ b/EXILED/Exiled.API/Features/Npc.cs @@ -15,6 +15,7 @@ namespace Exiled.API.Features using CentralAuth; using CommandSystem; + using CommandSystem.Commands.RemoteAdmin.Dummies; using Exiled.API.Enums; using Exiled.API.Features.Components; using Exiled.API.Features.Roles; @@ -47,7 +48,7 @@ public Npc(GameObject gameObject) /// /// Gets a list of Npcs. /// - public static new List List => Player.List.OfType().ToList(); + public static new IReadOnlyCollection List => Dictionary.Values.OfType().ToList(); /// /// Gets or sets the player's position. @@ -63,6 +64,113 @@ public override Vector3 Position } } + /// + /// Gets or sets the player being followed. + /// + /// The npc must have . + public Player? FollowedPlayer + { + get => !GameObject.TryGetComponent(out PlayerFollower follower) ? null : Player.Get(follower._hubToFollow); + + set + { + if (!GameObject.TryGetComponent(out PlayerFollower follower)) + { + GameObject.AddComponent()._hubToFollow = value?.ReferenceHub; + return; + } + + follower._hubToFollow = value?.ReferenceHub; + } + } + + /// + /// Gets or sets the Max Distance of the npc. + /// + /// The npc must have . + public float? MaxDistance + { + get + { + if (!GameObject.TryGetComponent(out PlayerFollower follower)) + return null; + + return follower._maxDistance; + } + + set + { + if(!value.HasValue) + return; + + if (!GameObject.TryGetComponent(out PlayerFollower follower)) + { + GameObject.AddComponent()._maxDistance = value.Value; + return; + } + + follower._maxDistance = value.Value; + } + } + + /// + /// Gets or sets the Min Distance of the npc. + /// + /// The npc must have . + public float? MinDistance + { + get + { + if (!GameObject.TryGetComponent(out PlayerFollower follower)) + return null; + + return follower._minDistance; + } + + set + { + if(!value.HasValue) + return; + + if (!GameObject.TryGetComponent(out PlayerFollower follower)) + { + GameObject.AddComponent()._minDistance = value.Value; + return; + } + + follower._minDistance = value.Value; + } + } + + /// + /// Gets or sets the Speed of the npc. + /// + /// The npc must have . + public float? Speed + { + get + { + if (!GameObject.TryGetComponent(out PlayerFollower follower)) + return null; + + return follower._speed; + } + + set + { + if(!value.HasValue) + return; + + if (!GameObject.TryGetComponent(out PlayerFollower follower)) + { + GameObject.AddComponent()._speed = value.Value; + return; + } + + follower._speed = value.Value; + } + } + /// /// Retrieves the NPC associated with the specified ReferenceHub. /// @@ -133,100 +241,24 @@ public override Vector3 Position /// The NPC associated with the NetworkConnection, or null if not found. public static new Npc? Get(NetworkConnection conn) => Player.Get(conn) as Npc; - /// - /// Docs. - /// - /// Docs1. - /// Docs2. - /// Docs3. - /// Docs4. - public static Npc Create(string name, RoleTypeId role, Vector3 position) - { - // TODO: Test this. - Npc npc = new(DummyUtils.SpawnDummy(name)) - { - IsNPC = true, - }; - - npc.Role.Set(role); - npc.Position = position; - - return npc; - } - /// /// Spawns an NPC based on the given parameters. /// /// The name of the NPC. /// The RoleTypeId of the NPC. - /// The player ID of the NPC. - /// The userID of the NPC. - /// The position to spawn the NPC. - /// The spawned. - [Obsolete("This method is marked as obsolete due to a bug that make player have the same id. Use Npc.Spawn(string) instead", true)] - public static Npc Spawn(string name, RoleTypeId role, int id = 0, string userId = PlayerAuthenticationManager.DedicatedId, Vector3? position = null) + /// The position where the NPC should spawn. + /// Docs4. + public static Npc Spawn(string name, RoleTypeId role, Vector3 position) { - GameObject newObject = UnityEngine.Object.Instantiate(Mirror.NetworkManager.singleton.playerPrefab); - - Npc npc = new(newObject) - { - IsNPC = true, - }; - - if (!RecyclablePlayerId.FreeIds.Contains(id) && RecyclablePlayerId._autoIncrement >= id) - { - Log.Warn($"{Assembly.GetCallingAssembly().GetName().Name} tried to spawn an NPC with a duplicate PlayerID. Using auto-incremented ID instead to avoid an ID clash."); - id = new RecyclablePlayerId(true).Value; - } - - try - { - if (userId == PlayerAuthenticationManager.DedicatedId) - { - npc.ReferenceHub.authManager.SyncedUserId = userId; - try - { - npc.ReferenceHub.authManager.InstanceMode = ClientInstanceMode.DedicatedServer; - } - catch (Exception e) - { - Log.Debug($"Ignore: {e.Message}"); - } - } - else - { - npc.ReferenceHub.authManager.InstanceMode = ClientInstanceMode.Unverified; - npc.ReferenceHub.authManager._privUserId = userId == string.Empty ? $"Dummy@localhost" : userId; - } - } - catch (Exception e) - { - Log.Debug($"Ignore: {e.Message}"); - } - - try - { - npc.ReferenceHub.roleManager.InitializeNewRole(RoleTypeId.None, RoleChangeReason.None); - } - catch (Exception e) - { - Log.Debug($"Ignore: {e.Message}"); - } - - FakeConnection fakeConnection = new(id); - NetworkServer.AddPlayerForConnection(fakeConnection, newObject); - - npc.ReferenceHub.nicknameSync.Network_myNickSync = name; - Dictionary.Add(newObject, npc); + Npc npc = new(DummyUtils.SpawnDummy(name)); Timing.CallDelayed(0.5f, () => { - npc.Role.Set(role, SpawnReason.RoundStart, position is null ? RoleSpawnFlags.All : RoleSpawnFlags.AssignInventory); - - if (position is not null) - npc.Position = position.Value; + npc.Role.Set(role); + npc.Position = position; }); + Dictionary.Add(npc.GameObject, npc); return npc; } @@ -236,58 +268,11 @@ public static Npc Spawn(string name, RoleTypeId role, int id = 0, string userId /// The name of the NPC. /// The RoleTypeId of the NPC, defaulting to None. /// Whether the NPC should be ignored by round ending checks. - /// The userID of the NPC for authentication. Defaults to the Dedicated ID. /// The position where the NPC should spawn. If null, the default spawn location is used. /// The spawned. - public static Npc Spawn(string name, RoleTypeId role = RoleTypeId.None, bool ignored = false, string userId = PlayerAuthenticationManager.DedicatedId, Vector3? position = null) + public static Npc Spawn(string name, RoleTypeId role = RoleTypeId.None, bool ignored = false, Vector3? position = null) { - GameObject newObject = UnityEngine.Object.Instantiate(Mirror.NetworkManager.singleton.playerPrefab); - - Npc npc = new(newObject) - { - IsNPC = true, - }; - - FakeConnection fakeConnection = new(npc.Id); - - try - { - if (userId == PlayerAuthenticationManager.DedicatedId) - { - npc.ReferenceHub.authManager.SyncedUserId = userId; - try - { - npc.ReferenceHub.authManager.InstanceMode = ClientInstanceMode.DedicatedServer; - } - catch (Exception e) - { - Log.Debug($"Ignore: {e.Message}"); - } - } - else - { - npc.ReferenceHub.authManager.InstanceMode = ClientInstanceMode.Unverified; - npc.ReferenceHub.authManager._privUserId = userId == string.Empty ? $"Dummy-{npc.Id}@localhost" : userId; - } - } - catch (Exception e) - { - Log.Debug($"Ignore: {e.Message}"); - } - - try - { - npc.ReferenceHub.roleManager.InitializeNewRole(RoleTypeId.None, RoleChangeReason.None); - } - catch (Exception e) - { - Log.Debug($"Ignore: {e.Message}"); - } - - NetworkServer.AddPlayerForConnection(fakeConnection, newObject); - - npc.ReferenceHub.nicknameSync.Network_myNickSync = name; - Dictionary.Add(newObject, npc); + Npc npc = new(DummyUtils.SpawnDummy(name)); Timing.CallDelayed(0.5f, () => { @@ -300,16 +285,38 @@ public static Npc Spawn(string name, RoleTypeId role = RoleTypeId.None, bool ign if (ignored) Round.IgnoredPlayers.Add(npc.ReferenceHub); + Dictionary.Add(npc.GameObject, npc); return npc; } /// /// Destroys all NPCs currently spawned. /// - public static void DestroyAll() + public static void DestroyAll() => DummyUtils.DestroyAllDummies(); + + /// + /// Follow a specific player. + /// + /// the Player to follow. + public void Follow(Player player) + { + PlayerFollower follow = !GameObject.TryGetComponent(out PlayerFollower follower) ? GameObject.AddComponent() : follower; + + follow.Init(player.ReferenceHub); + } + + /// + /// Follow a specific player. + /// + /// the Player to follow. + /// the max distance the npc will go. + /// the min distance the npc will go. + /// the speed the npc will go. + public void Follow(Player player, float maxDistance, float minDistance, float speed = 30f) { - foreach (Npc npc in List) - npc.Destroy(); + PlayerFollower follow = !GameObject.TryGetComponent(out PlayerFollower follower) ? GameObject.AddComponent() : follower; + + follow.Init(player.ReferenceHub, maxDistance, minDistance, speed); } /// @@ -320,11 +327,8 @@ public void Destroy() try { Round.IgnoredPlayers.Remove(ReferenceHub); - NetworkConnectionToClient conn = ReferenceHub.connectionToClient; - ReferenceHub.OnDestroy(); - CustomNetworkManager.TypedSingleton.OnServerDisconnect(conn); - Dictionary.Remove(GameObject); - Object.Destroy(GameObject); + Dictionary.Remove(ReferenceHub.gameObject); + NetworkServer.Destroy(ReferenceHub.gameObject); } catch (Exception e) { diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index f67fc2fc1..6df9948db 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -136,7 +136,7 @@ public Player(GameObject gameObject) /// /// Gets a list of all 's on the server. /// - public static IReadOnlyCollection List => Dictionary.Values; + public static IReadOnlyCollection List => Dictionary.Values.Where(x => !x.IsNPC).ToList(); /// /// Gets a containing cached and their user ids. @@ -296,9 +296,9 @@ public AuthenticationType AuthenticationType public bool IsVerified { get; internal set; } /// - /// Gets or sets a value indicating whether the player is a NPC. + /// Gets a value indicating whether the player is a NPC. /// - public bool IsNPC { get; set; } + public bool IsNPC => ReferenceHub.IsDummy; /// /// Gets a value indicating whether the player has an active CustomName. From 6355a32ba68bbc752661e4dabde84c727c0ead0c Mon Sep 17 00:00:00 2001 From: TheLongQuite <166433804+TheLongQuite@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:25:18 +0300 Subject: [PATCH 079/102] Making TargetsToAffect a Hashset (#123) --- .../EventArgs/Map/ExplodingGrenadeEventArgs.cs | 16 +++++++--------- .../Patches/Events/Map/BreakingScp2176.cs | 4 ++-- .../Patches/Events/Map/ExplodingFlashGrenade.cs | 4 ++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs index 6bd4343a1..27b0bc165 100644 --- a/EXILED/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs @@ -39,7 +39,7 @@ public ExplodingGrenadeEventArgs(Footprint thrower, Vector3 position, ExplosionG Player = Player.Get(thrower.Hub); Projectile = Pickup.Get(grenade); Position = position; - TargetsToAffect = ListPool.Pool.Get(); + TargetsToAffect = HashSetPool.Pool.Get(); if (Projectile.Base is not ExplosionGrenade) return; @@ -59,8 +59,7 @@ public ExplodingGrenadeEventArgs(Footprint thrower, Vector3 position, ExplosionG { if (Server.FriendlyFire || IndividualFriendlyFire.CheckFriendlyFirePlayer(thrower, hub)) { - if (!TargetsToAffect.Contains(player)) - TargetsToAffect.Add(player); + TargetsToAffect.Add(player); } } @@ -69,8 +68,7 @@ public ExplodingGrenadeEventArgs(Footprint thrower, Vector3 position, ExplosionG { if (Server.FriendlyFire || thrower.Hub == Server.Host.ReferenceHub || HitboxIdentity.IsEnemy(thrower.Role, hub.roleManager.CurrentRole.RoleTypeId)) { - if (!TargetsToAffect.Contains(player)) - TargetsToAffect.Add(player); + TargetsToAffect.Add(player); } } @@ -94,12 +92,12 @@ public ExplodingGrenadeEventArgs(Footprint thrower, Vector3 position, ExplosionG /// /// /// - public ExplodingGrenadeEventArgs(Player thrower, EffectGrenade grenade, List targetsToAffect, bool isAllowed = true) + public ExplodingGrenadeEventArgs(Player thrower, EffectGrenade grenade, HashSet targetsToAffect, bool isAllowed = true) { Player = thrower ?? Server.Host; Projectile = Pickup.Get(grenade); Position = Projectile.Position; - TargetsToAffect = ListPool.Pool.Get(targetsToAffect ?? new()); + TargetsToAffect = HashSetPool.Pool.Get(targetsToAffect ?? new HashSet()); IsAllowed = isAllowed; } @@ -108,7 +106,7 @@ public ExplodingGrenadeEventArgs(Player thrower, EffectGrenade grenade, List ~ExplodingGrenadeEventArgs() { - ListPool.Pool.Return(TargetsToAffect); + HashSetPool.Pool.Return(TargetsToAffect); } /// @@ -119,7 +117,7 @@ public ExplodingGrenadeEventArgs(Player thrower, EffectGrenade grenade, List /// Gets the players who could be affected by the grenade, if any, and the damage that be dealt. /// - public List TargetsToAffect { get; } + public HashSet TargetsToAffect { get; } /// /// Gets the grenade that is exploding. diff --git a/EXILED/Exiled.Events/Patches/Events/Map/BreakingScp2176.cs b/EXILED/Exiled.Events/Patches/Events/Map/BreakingScp2176.cs index 6707f5b82..8236e2c48 100644 --- a/EXILED/Exiled.Events/Patches/Events/Map/BreakingScp2176.cs +++ b/EXILED/Exiled.Events/Patches/Events/Map/BreakingScp2176.cs @@ -56,8 +56,8 @@ private static IEnumerable Transpiler(IEnumerable, bool) - new(OpCodes.Newobj, DeclaredConstructor(typeof(ExplodingGrenadeEventArgs), new[] { typeof(Player), typeof(EffectGrenade), typeof(List), typeof(bool) })), + // new ExplodingGrenadeEventArgs(Player, EffectGrenade, HashSet, bool) + new(OpCodes.Newobj, DeclaredConstructor(typeof(ExplodingGrenadeEventArgs), new[] { typeof(Player), typeof(EffectGrenade), typeof(HashSet), typeof(bool) })), new(OpCodes.Dup), // Handlers.Map.OnExplodingGrenade(ev); diff --git a/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs b/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs index bfb61c181..4413d1829 100644 --- a/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs +++ b/EXILED/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs @@ -63,7 +63,7 @@ private static IEnumerable Transpiler(IEnumerable targetToAffect = ListPool.Pool.Get(); + HashSet targetToAffect = HashSetPool.Pool.Get(); foreach (Player player in Player.List) { if ((instance.transform.position - player.Position).sqrMagnitude >= distance) @@ -80,7 +80,7 @@ private static void ProcessEvent(FlashbangGrenade instance, float distance) ExplodingGrenadeEventArgs explodingGrenadeEvent = new(Player.Get(instance.PreviousOwner.Hub), instance, targetToAffect); - ListPool.Pool.Return(targetToAffect); + HashSetPool.Pool.Return(targetToAffect); Handlers.Map.OnExplodingGrenade(explodingGrenadeEvent); From a37c26a361c1a3b18b70184e8cf0e02bd977f862 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:07:57 +0100 Subject: [PATCH 080/102] Fix BeginOvercharge (#308) * Fix BeginOvercharge * . --- EXILED/Exiled.API/Features/Recontainer.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Features/Recontainer.cs b/EXILED/Exiled.API/Features/Recontainer.cs index 6ebf128c3..17f59c97d 100644 --- a/EXILED/Exiled.API/Features/Recontainer.cs +++ b/EXILED/Exiled.API/Features/Recontainer.cs @@ -193,7 +193,16 @@ public static bool IsContainmentSequenceSuccessful /// /// Begins the overcharge procedure. /// - public static void BeginOvercharge() => Base.BeginOvercharge(); + /// Make than is call after the . + public static void BeginOvercharge(bool endOvercharge = true) + { + Base.BeginOvercharge(); + if (endOvercharge) + { + Base._delayStopwatch.Stop(); + Base._unlockStopwatch.Start(); + } + } /// /// Ends the overcharge procedure. From 941aacde549670a45aed46f54101e26c7e0228e7 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Wed, 11 Dec 2024 21:17:05 +0100 Subject: [PATCH 081/102] Server RoundEnding small change (#306) * IDK why don't work * fix offset * RemoveDebug * little change * Oups * fix --- .../EventArgs/Server/EndingRoundEventArgs.cs | 27 ++-------- .../Patches/Events/Server/RoundEnd.cs | 50 +++++++++---------- 2 files changed, 29 insertions(+), 48 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs index bbdce5c08..216676772 100644 --- a/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs @@ -18,6 +18,9 @@ public class EndingRoundEventArgs : IDeniableEvent /// /// Initializes a new instance of the class. /// + /// + /// + /// /// /// /// @@ -27,10 +30,10 @@ public class EndingRoundEventArgs : IDeniableEvent /// /// /// - public EndingRoundEventArgs(RoundSummary.SumInfo_ClassList classList, bool isForceEnded, bool isAllowed) + public EndingRoundEventArgs(LeadingTeam leadingTeam, RoundSummary.SumInfo_ClassList classList, bool isForceEnded, bool isAllowed) { + LeadingTeam = leadingTeam; ClassList = classList; - LeadingTeam = GetLeadingTeam(classList); IsForceEnded = isForceEnded; IsAllowed = isAllowed; } @@ -54,25 +57,5 @@ public EndingRoundEventArgs(RoundSummary.SumInfo_ClassList classList, bool isFor /// Gets or sets a value indicating whether the round is going to finish or not. /// public bool IsAllowed { get; set; } - - private LeadingTeam GetLeadingTeam(RoundSummary.SumInfo_ClassList classList) - { - // NW logic - int facilityForces = classList.mtf_and_guards + classList.scientists; - int chaosInsurgency = classList.chaos_insurgents + classList.class_ds; - int anomalies = classList.scps_except_zombies + classList.zombies; - int num4 = facilityForces > 0 ? 1 : 0; - bool flag1 = chaosInsurgency > 0; - bool flag2 = anomalies > 0; - RoundSummary.LeadingTeam leadingTeam = RoundSummary.LeadingTeam.Draw; - if (num4 != 0) - leadingTeam = RoundSummary.EscapedScientists >= RoundSummary.EscapedClassD ? RoundSummary.LeadingTeam.FacilityForces : RoundSummary.LeadingTeam.Draw; - else if (flag2 || flag2 & flag1) - leadingTeam = RoundSummary.EscapedClassD > RoundSummary.SurvivingSCPs ? RoundSummary.LeadingTeam.ChaosInsurgency : (RoundSummary.SurvivingSCPs > RoundSummary.EscapedScientists ? RoundSummary.LeadingTeam.Anomalies : RoundSummary.LeadingTeam.Draw); - else if (flag1) - leadingTeam = RoundSummary.EscapedClassD >= RoundSummary.EscapedScientists ? RoundSummary.LeadingTeam.ChaosInsurgency : RoundSummary.LeadingTeam.Draw; - - return (LeadingTeam)leadingTeam; - } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs index 4eee538b2..e890ef80d 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs @@ -76,16 +76,35 @@ private static IEnumerable Transpiler(IEnumerable x.StoresField(Field(PrivateType, LeadingTeam))) + offset; + int offset2 = 1; + int index2 = newInstructions.FindLastIndex(x => x.StoresField(Field(PrivateType, LeadingTeam))) + offset2; + List leadingTeamLogic = newInstructions.GetRange(index, index2 - index); + List