diff --git a/.github/workflows/labapi.yml b/.github/workflows/labapi.yml new file mode 100644 index 0000000000..889c33f8d6 --- /dev/null +++ b/.github/workflows/labapi.yml @@ -0,0 +1,74 @@ +name: Exiled Dev CI + +on: + push: + branches: + - LabAPI + pull_request: + branches: + - LabAPI + workflow_dispatch: + +defaults: + run: + working-directory: ./EXILED + +env: + EXILED_REFERENCES_URL: https://exmod-team.github.io/SL-References/LabAPI.zip + EXILED_REFERENCES_PATH: ${{ github.workspace }}/EXILED/References + EXILED_DLL_ARCHIVER_URL: https://github.com/ExMod-Team/EXILED-DLL-Archiver/releases/latest/download/EXILED-DLL-Archiver.exe + +jobs: + + build: + + runs-on: windows-latest + # Prevent double running for push & pull_request events from the main repo + if: github.event_name != 'push' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + + steps: + + - name: Setup .NET Core SDK + uses: actions/setup-dotnet@v4.0.1 + + - name: Setup Nuget + uses: nuget/setup-nuget@v2 + + - uses: actions/checkout@v4.1.7 + + - name: Get references + shell: pwsh + run: | + Invoke-WebRequest -Uri ${{ env.EXILED_REFERENCES_URL }} -OutFile ${{ github.workspace }}/EXILED/References.zip + Expand-Archive -Path References.zip -DestinationPath ${{ env.EXILED_REFERENCES_PATH }} + + - name: Build + env: + EXILED_REFERENCES: ${{ env.EXILED_REFERENCES_PATH }} + shell: pwsh + run: | + ./build.ps1 -BuildNuGet + $File = (Get-ChildItem -Path . -Include 'ExMod.Exiled.*.nupkg' -Recurse).Name + Out-File -FilePath ${{ github.env }} -InputObject "PackageFile=$File" -Encoding utf-8 -Append + + - name: Upload nuget package + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PackageFile }} + path: EXILED/${{ env.PackageFile }} + + - name: Get references + shell: pwsh + run: | + Invoke-WebRequest -Uri ${{ env.EXILED_DLL_ARCHIVER_URL }} -OutFile ${{ github.workspace }}/EXILED/EXILED-DLL-Archiver.exe + + - name: Packaging results as tar.gz + shell: pwsh + run: ./packaging.ps1 + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: Build Result + path: EXILED/bin/Release/Exiled.tar.gz + diff --git a/EXILED/Exiled.API/Exiled.API.csproj b/EXILED/Exiled.API/Exiled.API.csproj index 961b44e98d..c8737a790c 100644 --- a/EXILED/Exiled.API/Exiled.API.csproj +++ b/EXILED/Exiled.API/Exiled.API.csproj @@ -27,10 +27,10 @@ + - diff --git a/EXILED/Exiled.API/Extensions/UserGroupExtensions.cs b/EXILED/Exiled.API/Extensions/UserGroupExtensions.cs index 7b9138618c..41b8523433 100644 --- a/EXILED/Exiled.API/Extensions/UserGroupExtensions.cs +++ b/EXILED/Exiled.API/Extensions/UserGroupExtensions.cs @@ -37,7 +37,7 @@ public static bool EqualsTo(this UserGroup @this, UserGroup other) /// /// The . /// The key of that group, or if not found. - public static string GetKey(this UserGroup @this) => Server.PermissionsHandler._groups + public static string GetKey(this UserGroup @this) => Server.PermissionsHandler.Groups .FirstOrDefault(pair => pair.Value.EqualsTo(@this)).Key; /// @@ -47,7 +47,7 @@ public static string GetKey(this UserGroup @this) => Server.PermissionsHandler._ /// The value of that group, or if not found. public static UserGroup GetValue(string groupName) { - ServerStatic.GetPermissionsHandler().GetAllGroups().TryGetValue(groupName, out UserGroup userGroup); + ServerStatic.PermissionsHandler.GetAllGroups().TryGetValue(groupName, out UserGroup userGroup); return userGroup; } } diff --git a/EXILED/Exiled.API/Features/Camera.cs b/EXILED/Exiled.API/Features/Camera.cs index 6c72485739..d852933ddc 100644 --- a/EXILED/Exiled.API/Features/Camera.cs +++ b/EXILED/Exiled.API/Features/Camera.cs @@ -216,8 +216,8 @@ internal Camera(Scp079Camera camera079) /// public Quaternion Rotation { - get => Base._cameraAnchor.rotation; - set => Base._cameraAnchor.rotation = value; + get => Base.CameraAnchor.rotation; + set => Base.CameraAnchor.rotation = value; } /// diff --git a/EXILED/Exiled.API/Features/CustomHealthStat.cs b/EXILED/Exiled.API/Features/CustomHealthStat.cs deleted file mode 100644 index 57f6d31c20..0000000000 --- a/EXILED/Exiled.API/Features/CustomHealthStat.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.API.Features -{ - using PlayerStatsSystem; - - /// - /// A custom version of which allows the player's max amount of health to be changed. - /// TODO: Move to Features.CustomStats. - /// - public class CustomHealthStat : HealthStat - { - /// - public override float MaxValue => CustomMaxValue == default ? base.MaxValue : CustomMaxValue; - - /// - /// Gets or sets the maximum amount of health the player will have. - /// - public float CustomMaxValue { get; set; } - } -} \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs b/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs index 78c4cd807d..b4c4d8d739 100644 --- a/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs +++ b/EXILED/Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) ExMod Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -18,25 +18,17 @@ namespace Exiled.API.Features.CustomStats /// public class CustomHumeShieldStat : HumeShieldStat { - /// - public override float MaxValue => CustomMaxValue == -1 ? base.MaxValue : CustomMaxValue; - /// /// Gets or sets the multiplier for gaining HumeShield. /// public float ShieldRegenerationMultiplier { get; set; } = 1; - /// - /// Gets or sets the maximum amount of HumeShield the player can have. - /// - public float CustomMaxValue { get; set; } = -1; - private float ShieldRegeneration => TryGetHsModule(out HumeShieldModuleBase controller) ? controller.HsRegeneration * ShieldRegenerationMultiplier : 0; /// public override void Update() { - if (MaxValue == -1 && ShieldRegenerationMultiplier is 1) + if (ShieldRegenerationMultiplier is 1) { base.Update(); return; @@ -45,7 +37,7 @@ public override void Update() if (!NetworkServer.active) return; - if (_valueDirty) + if (ValueDirty) { new SyncedStatMessages.StatMessage() { @@ -53,7 +45,7 @@ public override void Update() SyncedValue = CurValue, }.SendToHubsConditionally(CanReceive); _lastSent = CurValue; - _valueDirty = false; + ValueDirty = false; } if (ShieldRegeneration == 0) diff --git a/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs b/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs index 837bd5ff72..06c4f756db 100644 --- a/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs +++ b/EXILED/Exiled.API/Features/Doors/CheckpointDoor.cs @@ -44,8 +44,8 @@ internal CheckpointDoor(Interactables.Interobjects.CheckpointDoor door, List public Interactables.Interobjects.CheckpointDoor.CheckpointSequenceStage CurrentStage { - get => Base._currentSequence; - set => Base._currentSequence = value; + get => Base.CurrentSequence; + set => Base.CurrentSequence = value; } /// @@ -53,8 +53,8 @@ public Interactables.Interobjects.CheckpointDoor.CheckpointSequenceStage Current /// public float MainTimer { - get => Base._mainTimer; - set => Base._mainTimer = value; + get => Base.MainTimer; + set => Base.MainTimer = value; } /// @@ -62,8 +62,8 @@ public float MainTimer /// public float WaitTime { - get => Base._waitTime; - set => Base._waitTime = value; + get => Base.WaitTime; + set => Base.WaitTime = value; } /// @@ -71,8 +71,8 @@ public float WaitTime /// public float WarningTime { - get => Base._warningTime; - set => Base._warningTime = value; + get => Base.WarningTime; + set => Base.WarningTime = value; } /// diff --git a/EXILED/Exiled.API/Features/Hazards/TemporaryHazard.cs b/EXILED/Exiled.API/Features/Hazards/TemporaryHazard.cs index 0e701a8093..c9dfecb650 100644 --- a/EXILED/Exiled.API/Features/Hazards/TemporaryHazard.cs +++ b/EXILED/Exiled.API/Features/Hazards/TemporaryHazard.cs @@ -56,8 +56,8 @@ public bool IsDestroyed /// public float Duration { - get => Base._elapsed; - set => Base._elapsed = value; + get => Base.Elapsed; + set => Base.Elapsed = value; } /// diff --git a/EXILED/Exiled.API/Features/Paths.cs b/EXILED/Exiled.API/Features/Paths.cs index 153d8e0bf6..8d99b1a996 100644 --- a/EXILED/Exiled.API/Features/Paths.cs +++ b/EXILED/Exiled.API/Features/Paths.cs @@ -11,6 +11,8 @@ namespace Exiled.API.Features using System.IO; using System.Linq; + using LabApi.Loader; + /// /// A set of useful paths. /// @@ -106,7 +108,7 @@ public static void Reload(string rootDirectory = null) Dependencies = Path.Combine(Plugins, "dependencies"); Configs = Path.Combine(Exiled, "Configs"); IndividualConfigs = Path.Combine(Configs, "Plugins"); - LoaderConfig = PluginAPI.Loader.AssemblyLoader.InstalledPlugins.FirstOrDefault(x => x.PluginName == "Exiled Loader")?.MainConfigPath; + LoaderConfig = LabApi.Loader.PluginLoader.EnabledPlugins.FirstOrDefault(x => x.Name == "Exiled Loader")?.GetConfigPath("Exiled Loader"); Config = Path.Combine(Configs, $"{Server.Port}-config.yml"); BackupConfig = Path.Combine(Configs, $"{Server.Port}-config.yml.old"); IndividualTranslations = Path.Combine(Configs, "Translations"); diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index ada3c952af..df2ab96604 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -53,7 +53,6 @@ namespace Exiled.API.Features using PlayerRoles.Spectating; using PlayerRoles.Voice; using PlayerStatsSystem; - using PluginAPI.Core; using RelativePositioning; using RemoteAdmin; using Respawning.NamingRules; @@ -96,7 +95,7 @@ public class Player : TypeCastObject, IEntity, IWorldSpace private readonly HashSet componentsInChildren = new(); private ReferenceHub referenceHub; - private CustomHealthStat healthStat; + private HealthStat healthStat; private CustomHumeShieldStat humeShieldStat; private Role role; @@ -178,7 +177,7 @@ private set Inventory = value.inventory; CameraTransform = value.PlayerCameraReference; - value.playerStats._dictionarizedTypes[typeof(HealthStat)] = value.playerStats.StatModules[Array.IndexOf(PlayerStats.DefinedModules, typeof(HealthStat))] = healthStat = new CustomHealthStat { Hub = value }; + healthStat = value.playerStats.StatModules[Array.IndexOf(PlayerStats.DefinedModules, typeof(HealthStat))] as HealthStat; value.playerStats._dictionarizedTypes[typeof(HumeShieldStat)] = value.playerStats.StatModules[Array.IndexOf(PlayerStats.DefinedModules, typeof(HumeShieldStat))] = humeShieldStat = new CustomHumeShieldStat { Hub = value }; } } @@ -422,7 +421,7 @@ public float InfoViewRange /// /// /// - public bool HasReservedSlot => ReservedSlot.HasReservedSlot(UserId, out _); + public bool HasReservedSlot => ReservedSlot.HasReservedSlot(UserId); /// /// Gets a value indicating whether the player is in whitelist. @@ -509,7 +508,7 @@ public Player Cuffer public virtual Vector3 Position { get => Transform.position; - set => ReferenceHub.TryOverridePosition(value, Vector3.zero); + set => ReferenceHub.TryOverridePosition(value); } /// @@ -529,7 +528,7 @@ public RelativePosition RelativePosition public Quaternion Rotation { get => Transform.rotation; - set => ReferenceHub.TryOverridePosition(Position, value.eulerAngles); + set => ReferenceHub.TryOverrideRotation(value.eulerAngles); } /// @@ -883,7 +882,7 @@ public float Health public float MaxHealth { get => healthStat.MaxValue; - set => healthStat.CustomMaxValue = value; + set => healthStat.MaxValue = value; } /// @@ -939,7 +938,7 @@ public float HumeShield public float MaxHumeShield { get => humeShieldStat.MaxValue; - set => humeShieldStat.CustomMaxValue = value; + set => humeShieldStat.MaxValue = value; } /// @@ -1014,8 +1013,8 @@ public float Stamina /// public string GroupName { - get => ServerStatic.PermissionsHandler._members.TryGetValue(UserId, out string groupName) ? groupName : null; - set => ServerStatic.PermissionsHandler._members[UserId] = value; + get => ServerStatic.PermissionsHandler.Members.TryGetValue(UserId, out string groupName) ? groupName : null; + set => ServerStatic.PermissionsHandler.Members[UserId] = value; } /// @@ -1182,11 +1181,18 @@ public bool IsSpawnProtected internal static ConditionalWeakTable UnverifiedPlayers { get; } = new(); /// - /// Converts NwPluginAPI player to EXILED player. + /// Converts LabApi player to EXILED player. /// - /// The NwPluginAPI player. + /// The LabApi player. /// EXILED player. - public static implicit operator Player(PluginAPI.Core.Player player) => Get(player); + public static implicit operator Player(LabApi.Features.Wrappers.Player player) => Get(player); + + /// + /// Converts LabApi player to EXILED player. + /// + /// The LabApi player. + /// EXILED player. + public static implicit operator LabApi.Features.Wrappers.Player(Player player) => LabApi.Features.Wrappers.Player.Get(player.ReferenceHub); /// /// Gets a filtered by side. Can be empty. @@ -1377,11 +1383,11 @@ public static Player Get(string args) } /// - /// Gets the from NwPluginAPI class. + /// Gets the from LabApi class. /// - /// The class. + /// The class. /// A or if not found. - public static Player Get(PluginAPI.Core.Player apiPlayer) => Get(apiPlayer.ReferenceHub); + public static Player Get(LabApi.Features.Wrappers.Player apiPlayer) => Get(apiPlayer.ReferenceHub); /// /// Try-get a player given a . @@ -1464,12 +1470,12 @@ public static Player Get(string args) public static bool TryGet(string args, out Player player) => (player = Get(args)) is not null; /// - /// Try-get the from NwPluginAPI class. + /// Try-get the from LabApi class. /// - /// The class. + /// The class. /// The player found or if not found. /// A boolean indicating whether a player was found. - public static bool TryGet(PluginAPI.Core.Player apiPlayer, out Player player) => (player = Get(apiPlayer)) is not null; + public static bool TryGet(LabApi.Features.Wrappers.Player apiPlayer, out Player player) => (player = Get(apiPlayer)) is not null; /// /// Try-get player by . @@ -1508,10 +1514,10 @@ public static bool AddReservedSlot(string userId, bool isPermanent) { if (isPermanent) { - if (ReservedSlots.HasReservedSlot(userId)) + if (LabApi.Features.Wrappers.ReservedSlots.HasReservedSlot(userId)) return false; - ReservedSlots.Add(userId); + LabApi.Features.Wrappers.ReservedSlots.Add(userId); return true; } @@ -1532,7 +1538,7 @@ public static bool AddToWhitelist(string userId, bool isPermanent) if (WhiteList.IsOnWhitelist(userId)) return false; - Whitelist.Add(userId); + LabApi.Features.Wrappers.Whitelist.Add(userId); return true; } @@ -1824,7 +1830,7 @@ public bool TryGetItem(ushort serial, out Item item) /// The group to be set. public void SetRank(string name, UserGroup group) { - if (ServerStatic.GetPermissionsHandler()._groups.TryGetValue(name, out UserGroup userGroup)) + if (ServerStatic.PermissionsHandler.Groups.TryGetValue(name, out UserGroup userGroup)) { userGroup.BadgeColor = group.BadgeColor; userGroup.BadgeText = name; @@ -1835,15 +1841,15 @@ public void SetRank(string name, UserGroup group) } else { - ServerStatic.GetPermissionsHandler()._groups.Add(name, group); + ServerStatic.PermissionsHandler.Groups.Add(name, group); ReferenceHub.serverRoles.SetGroup(group, false, false); } - if (ServerStatic.GetPermissionsHandler()._members.ContainsKey(UserId)) - ServerStatic.GetPermissionsHandler()._members[UserId] = name; + if (ServerStatic.PermissionsHandler.Members.ContainsKey(UserId)) + ServerStatic.PermissionsHandler.Members[UserId] = name; else - ServerStatic.GetPermissionsHandler()._members.Add(UserId, name); + ServerStatic.PermissionsHandler.Members.Add(UserId, name); } /// diff --git a/EXILED/Exiled.API/Features/Roles/FpcRole.cs b/EXILED/Exiled.API/Features/Roles/FpcRole.cs index ecc946c9b7..fc041ff513 100644 --- a/EXILED/Exiled.API/Features/Roles/FpcRole.cs +++ b/EXILED/Exiled.API/Features/Roles/FpcRole.cs @@ -68,6 +68,15 @@ public RelativePosition ClientRelativePosition set => FirstPersonController.FpcModule.Motor.ReceivedPosition = value; } + /// + /// Gets or sets the player's gravity. + /// + public Vector3 Gravity + { + get => FirstPersonController.FpcModule.Motor.GravityController.Gravity; + set => FirstPersonController.FpcModule.Motor.GravityController.Gravity = value; + } + /// /// Gets or sets a value indicating whether if the player should get damage. /// diff --git a/EXILED/Exiled.API/Features/Roles/HumanRole.cs b/EXILED/Exiled.API/Features/Roles/HumanRole.cs index 8a238a3e7d..767a010d45 100644 --- a/EXILED/Exiled.API/Features/Roles/HumanRole.cs +++ b/EXILED/Exiled.API/Features/Roles/HumanRole.cs @@ -8,7 +8,7 @@ namespace Exiled.API.Features.Roles { using PlayerRoles; - + using PlayerRoles.PlayableScps.HumeShield; using Respawning; using Respawning.NamingRules; @@ -17,7 +17,7 @@ namespace Exiled.API.Features.Roles /// /// Defines a role that represents a human class. /// - public class HumanRole : FpcRole + public class HumanRole : FpcRole, IHumeShieldRole { /// /// Initializes a new instance of the class. @@ -27,6 +27,7 @@ internal HumanRole(HumanGameRole baseRole) : base(baseRole) { Base = baseRole; + HumeShieldModule = baseRole.HumeShieldModule; } /// @@ -56,6 +57,9 @@ public byte UnitNameId /// public new HumanGameRole Base { get; } + /// + public HumeShieldModuleBase HumeShieldModule { get; } + /// /// Gets the armor efficacy based on a specific and the armor the is wearing. /// diff --git a/EXILED/Exiled.API/Features/Scp914.cs b/EXILED/Exiled.API/Features/Scp914.cs index 57ee9d366c..7d9ea65818 100644 --- a/EXILED/Exiled.API/Features/Scp914.cs +++ b/EXILED/Exiled.API/Features/Scp914.cs @@ -40,8 +40,8 @@ public static Scp914KnobSetting KnobStatus /// public static Scp914Mode ConfigMode { - get => Scp914Controller._configMode.Value; - set => Scp914Controller._configMode.Value = value; + get => Scp914Controller.ConfigMode.Value; + set => Scp914Controller.ConfigMode.Value = value; } /// @@ -72,7 +72,7 @@ public static Scp914Mode ConfigMode /// /// Gets a value indicating whether SCP-914 is active and currently processing items. /// - public static bool IsWorking => Scp914Controller._isUpgrading; + public static bool IsWorking => Scp914Controller.IsUpgrading; /// /// Gets a value indicating all of the GameObjects currently present inside SCP-914's intake chamber. @@ -92,7 +92,7 @@ public static Scp914Mode ConfigMode /// /// Gets the list with which SCP-914 has. /// - public static IReadOnlyCollection Doors => Scp914Controller._doors.Select(Door.Get).ToList(); + public static IReadOnlyCollection Doors => Scp914Controller.Doors.Select(Door.Get).ToList(); /// /// Filters all GameObjects inside SCP-914's intake chamber into players and items. diff --git a/EXILED/Exiled.API/Features/Server.cs b/EXILED/Exiled.API/Features/Server.cs index c79d0c4c1d..c9a7e40212 100644 --- a/EXILED/Exiled.API/Features/Server.cs +++ b/EXILED/Exiled.API/Features/Server.cs @@ -60,11 +60,11 @@ public static class Server /// public static string Name { - get => ServerConsole._serverName; + get => ServerConsole.ServerName; set { - ServerConsole._serverName = value; - ServerConsole.singleton.RefreshServerName(); + ServerConsole.ServerName = value; + ServerConsole.Singleton.RefreshServerName(); } } diff --git a/EXILED/Exiled.API/Features/Warhead.cs b/EXILED/Exiled.API/Features/Warhead.cs index 687b4fb035..2857cd61c9 100644 --- a/EXILED/Exiled.API/Features/Warhead.cs +++ b/EXILED/Exiled.API/Features/Warhead.cs @@ -168,7 +168,16 @@ public static int Kills public static void CloseBlastDoors() { foreach (BlastDoor door in BlastDoors) - door.SetClosed(false, true); + door.SetDoorState(true, false); + } + + /// + /// Open the surface blast doors. + /// + public static void OpenBlastDoors() + { + foreach (BlastDoor door in BlastDoors) + door.SetDoorState(false, true); } /// diff --git a/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj b/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj index 9382489fb3..a169d69155 100644 --- a/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj +++ b/EXILED/Exiled.CreditTags/Exiled.CreditTags.csproj @@ -27,13 +27,13 @@ + - - + diff --git a/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs b/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs index 2fc89ef333..54f478d7ce 100644 --- a/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs +++ b/EXILED/Exiled.CustomItems/API/EventArgs/OwnerEscapingEventArgs.cs @@ -30,7 +30,7 @@ public class OwnerEscapingEventArgs : EscapingEventArgs /// /// The instance. public OwnerEscapingEventArgs(Item item, EscapingEventArgs ev) - : base(ev.Player, ev.NewRole, ev.EscapeScenario) + : base(ev.Player.ReferenceHub, ev.NewRole, ev.EscapeScenario) { Item = item; } diff --git a/EXILED/Exiled.CustomItems/Exiled.CustomItems.csproj b/EXILED/Exiled.CustomItems/Exiled.CustomItems.csproj index 703a8a7c77..6d45708c17 100644 --- a/EXILED/Exiled.CustomItems/Exiled.CustomItems.csproj +++ b/EXILED/Exiled.CustomItems/Exiled.CustomItems.csproj @@ -28,9 +28,9 @@ + - diff --git a/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj b/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj index d569aacb2c..78b2030580 100644 --- a/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj +++ b/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj @@ -29,9 +29,9 @@ + - diff --git a/EXILED/Exiled.Events/Commands/Config/Merge.cs b/EXILED/Exiled.Events/Commands/Config/Merge.cs index b9916ede64..c6cf79042d 100644 --- a/EXILED/Exiled.Events/Commands/Config/Merge.cs +++ b/EXILED/Exiled.Events/Commands/Config/Merge.cs @@ -49,8 +49,8 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s SortedDictionary configs = ConfigManager.LoadSorted(ConfigManager.Read()); LoaderPlugin.Config.ConfigType = ConfigType.Default; bool haveBeenSaved = ConfigManager.Save(configs); - PluginAPI.Loader.AssemblyLoader.InstalledPlugins.FirstOrDefault(x => x.PluginName == "Exiled Loader")?.SaveConfig(new LoaderPlugin(), nameof(LoaderPlugin.Config)); + LoaderPlugin.Instance.SaveConfig(); response = $"Configs have been merged successfully! Feel free to remove the directory in the following path:\n\"{Paths.IndividualConfigs}\""; return haveBeenSaved; } diff --git a/EXILED/Exiled.Events/Commands/Config/Split.cs b/EXILED/Exiled.Events/Commands/Config/Split.cs index 9fad9c3e16..34816af579 100644 --- a/EXILED/Exiled.Events/Commands/Config/Split.cs +++ b/EXILED/Exiled.Events/Commands/Config/Split.cs @@ -49,8 +49,8 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s SortedDictionary configs = ConfigManager.LoadSorted(ConfigManager.Read()); LoaderPlugin.Config.ConfigType = ConfigType.Separated; bool haveBeenSaved = ConfigManager.Save(configs); - PluginAPI.Loader.AssemblyLoader.InstalledPlugins.FirstOrDefault(x => x.PluginName == "Exiled Loader")?.SaveConfig(new LoaderPlugin(), nameof(LoaderPlugin.Config)); + LoaderPlugin.Instance.SaveConfig(); response = $"Configs have been merged successfully! Feel free to remove the file in the following path:\n\"{Paths.Config}\""; return haveBeenSaved; } diff --git a/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs index e39a463c23..a8b986c171 100644 --- a/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Cassie/SendingCassieMessageEventArgs.cs @@ -26,12 +26,20 @@ public class SendingCassieMessageEventArgs : IDeniableEvent /// /// /// + /// + /// + /// + /// + /// + /// /// Indicates whether the event can be executed. - public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise, bool isAllowed = true) + public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise, bool customAnnouncement, string customSubtitles, bool isAllowed = true) { Words = words; + CustomSubtitles = customSubtitles; MakeHold = makeHold; MakeNoise = makeNoise; + IsCustomAnnouncement = customAnnouncement; IsAllowed = isAllowed; } @@ -40,6 +48,11 @@ public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise /// public string Words { get; set; } + /// + /// Gets or sets the message subtitles. + /// + public string CustomSubtitles { get; set; } + /// /// Gets or sets a value indicating whether the message should be held. /// @@ -54,5 +67,10 @@ public SendingCassieMessageEventArgs(string words, bool makeHold, bool makeNoise /// Gets or sets a value indicating whether the message can be sent. /// public bool IsAllowed { get; set; } + + /// + /// Gets or sets a value indicating whether the message can be sent. + /// + public bool IsCustomAnnouncement { get; set; } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Player/DeactivatingWorkstationEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/DeactivatingWorkstationEventArgs.cs index 48b7164d83..20ce6f84d0 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/DeactivatingWorkstationEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/DeactivatingWorkstationEventArgs.cs @@ -31,7 +31,7 @@ public class DeactivatingWorkstationEventArgs : IPlayerEvent, IDeniableEvent /// public DeactivatingWorkstationEventArgs(WorkstationController controller, bool isAllowed = true) { - Player = Player.Get(controller._knownUser); + Player = Player.Get(controller.KnownUser); WorkstationController = controller; IsAllowed = isAllowed; } diff --git a/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs index a10eea6922..756873bc56 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/EscapingEventArgs.cs @@ -25,7 +25,7 @@ public class EscapingEventArgs : IPlayerEvent, IDeniableEvent /// /// Initializes a new instance of the class. /// - /// + /// /// /// /// @@ -34,9 +34,9 @@ public class EscapingEventArgs : IPlayerEvent, IDeniableEvent /// /// /// - public EscapingEventArgs(Player player, RoleTypeId newRole, EscapeScenario escapeScenario) + public EscapingEventArgs(ReferenceHub referenceHub, RoleTypeId newRole, EscapeScenario escapeScenario) { - Player = player; + Player = Player.Get(referenceHub); NewRole = newRole; EscapeScenario = escapeScenario; IsAllowed = escapeScenario is not EscapeScenario.CustomEscape; diff --git a/EXILED/Exiled.Events/EventArgs/Player/FailingEscapePocketDimensionEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/FailingEscapePocketDimensionEventArgs.cs index 247e62cbe7..9d398abdda 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/FailingEscapePocketDimensionEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/FailingEscapePocketDimensionEventArgs.cs @@ -7,6 +7,8 @@ namespace Exiled.Events.EventArgs.Player { + using System; + using API.Features; using Interfaces; @@ -22,22 +24,19 @@ public class FailingEscapePocketDimensionEventArgs : IPlayerEvent, IDeniableEven /// /// /// - /// - /// - /// /// /// /// - public FailingEscapePocketDimensionEventArgs(Player player, PocketDimensionTeleport teleporter, bool isAllowed = true) + public FailingEscapePocketDimensionEventArgs(Player player, bool isAllowed = true) { Player = player; - Teleporter = teleporter; IsAllowed = isAllowed; } /// /// Gets the PocketDimensionTeleport the player walked into. /// + [Obsolete("can't be used")] public PocketDimensionTeleport Teleporter { get; } /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/FlippingCoinEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/FlippingCoinEventArgs.cs index 369a443868..954d2f39e8 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/FlippingCoinEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/FlippingCoinEventArgs.cs @@ -20,7 +20,7 @@ public class FlippingCoinEventArgs : IPlayerEvent, IDeniableEvent, IItemEvent /// /// Initializes a new instance of the class. /// - /// + /// /// /// /// @@ -29,9 +29,9 @@ public class FlippingCoinEventArgs : IPlayerEvent, IDeniableEvent, IItemEvent /// /// /// - public FlippingCoinEventArgs(Player player, Coin coin, bool isTails) + public FlippingCoinEventArgs(ReferenceHub referenceHub, Coin coin, bool isTails) { - Player = player; + Player = Player.Get(referenceHub); Item = Item.Get(coin); IsTails = isTails; } diff --git a/EXILED/Exiled.Events/EventArgs/Player/HurtEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/HurtEventArgs.cs index 1b97b4a946..8fd0eab99b 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/HurtEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/HurtEventArgs.cs @@ -23,7 +23,7 @@ public class HurtEventArgs : IAttackerEvent /// /// Initializes a new instance of the class. /// - /// + /// /// /// /// @@ -32,11 +32,11 @@ public class HurtEventArgs : IAttackerEvent /// /// /// - public HurtEventArgs(Player target, DamageHandlerBase damageHandler, DamageHandlerBase.HandlerOutput handlerOutput) + public HurtEventArgs(ReferenceHub referenceHub, DamageHandlerBase damageHandler, DamageHandlerBase.HandlerOutput handlerOutput) { - DamageHandler = new CustomDamageHandler(target, damageHandler); + Player = Player.Get(referenceHub); + DamageHandler = new CustomDamageHandler(Player, damageHandler); Attacker = DamageHandler.BaseIs(out CustomAttackerHandler attackerDamageHandler) ? attackerDamageHandler.Attacker : null; - Player = target; HandlerOutput = handlerOutput; } diff --git a/EXILED/Exiled.Events/EventArgs/Player/PickingUpItemEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/PickingUpItemEventArgs.cs index 90493c03c5..f71781e3b7 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/PickingUpItemEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/PickingUpItemEventArgs.cs @@ -21,7 +21,7 @@ public class PickingUpItemEventArgs : IPlayerEvent, IPickupEvent, IDeniableEvent /// /// Initializes a new instance of the class. /// - /// + /// /// /// /// @@ -30,10 +30,10 @@ public class PickingUpItemEventArgs : IPlayerEvent, IPickupEvent, IDeniableEvent /// /// /// - public PickingUpItemEventArgs(Player player, ItemPickupBase pickup, bool isAllowed = true) + public PickingUpItemEventArgs(ReferenceHub referenceHub, ItemPickupBase pickup, bool isAllowed = true) { IsAllowed = isAllowed; - Player = player; + Player = Player.Get(referenceHub); Pickup = Pickup.Get(pickup); } diff --git a/EXILED/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs index f2af6a8300..3c127ca02e 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/PreAuthenticatingEventArgs.cs @@ -13,7 +13,6 @@ namespace Exiled.Events.EventArgs.Player using LiteNetLib; using LiteNetLib.Utils; - using PluginAPI.Events; #pragma warning disable SA1600 //TODO: #pragma warning disable SA1309 diff --git a/EXILED/Exiled.Events/EventArgs/Player/ReservedSlotsCheckEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ReservedSlotsCheckEventArgs.cs index 47861a038c..d571f1e451 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/ReservedSlotsCheckEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/ReservedSlotsCheckEventArgs.cs @@ -13,21 +13,24 @@ namespace Exiled.Events.EventArgs.Player /// /// Contains all information when checking if a player has a reserved slot. /// - public class ReservedSlotsCheckEventArgs : IExiledEvent + public class ReservedSlotsCheckEventArgs : IExiledEvent, IDeniableEvent { + private ReservedSlotEventResult reservedSlotEventResult = ReservedSlotEventResult.UseBaseGameSystem; + /// /// Initializes a new instance of the class. /// - /// - /// - /// /// /// /// - public ReservedSlotsCheckEventArgs(string userId, bool hasReservedSlot) + /// + /// + /// + public ReservedSlotsCheckEventArgs(bool hasReservedSlot, string userId) { UserId = userId; HasReservedSlot = hasReservedSlot; + IsAllowed = hasReservedSlot; } /// @@ -40,9 +43,36 @@ public ReservedSlotsCheckEventArgs(string userId, bool hasReservedSlot) /// public bool HasReservedSlot { get; } + /// + /// Gets or sets a value indicating whether the player is allowed to connect. + /// + public bool IsAllowed { get; set; } + /// /// Gets or sets the event result. /// - public ReservedSlotEventResult Result { get; set; } = ReservedSlotEventResult.UseBaseGameSystem; + public ReservedSlotEventResult Result + { + get => reservedSlotEventResult; + set + { + switch (reservedSlotEventResult) + { + case ReservedSlotEventResult.CanUseReservedSlots or ReservedSlotEventResult.UseBaseGameSystem: + IsAllowed = HasReservedSlot; + break; + case ReservedSlotEventResult.AllowConnectionUnconditionally: + IsAllowed = true; + break; + case ReservedSlotEventResult.CannotUseReservedSlots: + IsAllowed = false; + break; + default: + return; + } + + reservedSlotEventResult = value; + } + } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Player/SendingValidCommandEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/SendingValidCommandEventArgs.cs index a3fa2d5310..1ea8a6df71 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/SendingValidCommandEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/SendingValidCommandEventArgs.cs @@ -11,7 +11,7 @@ namespace Exiled.Events.EventArgs.Player using Exiled.API.Features; using Exiled.API.Features.Pickups; using Exiled.Events.EventArgs.Interfaces; - using PluginAPI.Enums; + using LabApi.Features.Enums; using RemoteAdmin; /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/SentValidCommandEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/SentValidCommandEventArgs.cs index 0fb7778a16..1c96ff88f9 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/SentValidCommandEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/SentValidCommandEventArgs.cs @@ -11,7 +11,7 @@ namespace Exiled.Events.EventArgs.Player using Exiled.API.Features; using Exiled.API.Features.Pickups; using Exiled.Events.EventArgs.Interfaces; - using PluginAPI.Enums; + using LabApi.Features.Enums; using RemoteAdmin; /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs index e12dc914a1..a925a3b8bf 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs @@ -8,7 +8,6 @@ namespace Exiled.Events.EventArgs.Player { using API.Features; - using Interfaces; using PlayerRoles; @@ -16,6 +15,7 @@ namespace Exiled.Events.EventArgs.Player using PlayerStatsSystem; using UnityEngine; + using YamlDotNet.Core.Tokens; /// /// Contains all information before spawning a player ragdoll. @@ -45,7 +45,7 @@ public SpawningRagdollEventArgs(RagdollData info, bool isAllowed = true) public Vector3 Position { get => Info.StartPosition; - set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, value, Rotation); + set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, value, Rotation, Scale, Nickname, CreationTime); } /// @@ -54,13 +54,22 @@ public Vector3 Position public Quaternion Rotation { get => Info.StartRotation; - set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Position, value); + set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, Position, value, Scale, Nickname, CreationTime); + } + + /// + /// Gets or sets the ragdoll's scale with RagdollData. + /// + public Vector3 Scale + { + get => Info.Scale; + set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, Position, Rotation, value, Nickname, CreationTime); } /// - /// Gets or sets the ragdoll's scale. + /// Gets or sets the ragdoll's scale with GameObject. /// - public Vector3 Scale { get; set; } + public Vector3 RagdollScale { get; set; } /// /// Gets or sets the ragdoll's . @@ -68,7 +77,7 @@ public Quaternion Rotation public RoleTypeId Role { get => Info.RoleType; - set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, value, Position, Rotation, Nickname, CreationTime); + set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, value, Position, Rotation, Scale, Nickname, CreationTime); } /// @@ -82,7 +91,7 @@ public RoleTypeId Role public string Nickname { get => Info.Nickname; - set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, Position, Rotation, value, CreationTime); + set => Info = new RagdollData(Player.ReferenceHub, DamageHandlerBase, Role, Position, Rotation, Scale, value, CreationTime); } /// @@ -96,7 +105,7 @@ public string Nickname public DamageHandlerBase DamageHandlerBase { get => Info.Handler; - set => Info = new RagdollData(Player.ReferenceHub, value, Role, Position, Rotation, Nickname, CreationTime); + set => Info = new RagdollData(Player.ReferenceHub, value, Role, Position, Rotation, Scale, Nickname, CreationTime); } /// diff --git a/EXILED/Exiled.Events/EventArgs/Player/TogglingNoClipEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/TogglingNoClipEventArgs.cs index 78144567ec..65ea273731 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/TogglingNoClipEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/TogglingNoClipEventArgs.cs @@ -19,7 +19,7 @@ public class TogglingNoClipEventArgs : IPlayerEvent, IDeniableEvent /// /// Initializes a new instance of the class. /// - /// + /// /// /// /// @@ -28,9 +28,9 @@ public class TogglingNoClipEventArgs : IPlayerEvent, IDeniableEvent /// /// /// - public TogglingNoClipEventArgs(Player player, bool newValue, bool isAllowed = true) + public TogglingNoClipEventArgs(ReferenceHub referenceHub, bool newValue, bool isAllowed = true) { - Player = player; + Player = Player.Get(referenceHub); IsEnabled = newValue; IsAllowed = isAllowed; } @@ -41,9 +41,9 @@ public TogglingNoClipEventArgs(Player player, bool newValue, bool isAllowed = tr public Player Player { get; } /// - /// Gets or sets a value indicating whether the noclip mode will be enabled. + /// Gets a value indicating whether the noclip mode will be enabled. /// - public bool IsEnabled { get; set; } + public bool IsEnabled { get; } /// /// Gets or sets a value indicating whether the player can toggle noclip. diff --git a/EXILED/Exiled.Events/EventArgs/Player/UsingRadioBatteryEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/UsingRadioBatteryEventArgs.cs index ae1995da47..3b3af1c73f 100644 --- a/EXILED/Exiled.Events/EventArgs/Player/UsingRadioBatteryEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Player/UsingRadioBatteryEventArgs.cs @@ -25,19 +25,16 @@ public class UsingRadioBatteryEventArgs : IPlayerEvent, IDeniableEvent, IItemEve /// /// /// - /// - /// - /// /// /// /// /// /// /// - public UsingRadioBatteryEventArgs(RadioItem radio, Player player, float drain, bool isAllowed = true) + public UsingRadioBatteryEventArgs(RadioItem radio, float drain, bool isAllowed = true) { Radio = Item.Get(radio); - Player = player; + Player = Radio.Owner; Drain = drain; IsAllowed = isAllowed; } diff --git a/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs index 216676772b..7ed1dcbb58 100644 --- a/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs @@ -24,17 +24,13 @@ public class EndingRoundEventArgs : IDeniableEvent /// /// /// - /// - /// - /// /// /// /// - public EndingRoundEventArgs(LeadingTeam leadingTeam, RoundSummary.SumInfo_ClassList classList, bool isForceEnded, bool isAllowed) + public EndingRoundEventArgs(LeadingTeam leadingTeam, RoundSummary.SumInfo_ClassList classList, bool isAllowed) { LeadingTeam = leadingTeam; ClassList = classList; - IsForceEnded = isForceEnded; IsAllowed = isAllowed; } @@ -51,7 +47,11 @@ public EndingRoundEventArgs(LeadingTeam leadingTeam, RoundSummary.SumInfo_ClassL /// /// Gets or sets a value indicating whether the round is ended by API call. /// - public bool IsForceEnded { get; set; } + public bool IsForceEnded + { + get => RoundSummary.singleton._roundEnded; + set => RoundSummary.singleton._roundEnded = value; + } /// /// Gets or sets a value indicating whether the round is going to finish or not. diff --git a/EXILED/Exiled.Events/Events.cs b/EXILED/Exiled.Events/Events.cs index ac37f5528a..4815c2492c 100644 --- a/EXILED/Exiled.Events/Events.cs +++ b/EXILED/Exiled.Events/Events.cs @@ -20,7 +20,7 @@ namespace Exiled.Events using InventorySystem.Items.Usables; using PlayerRoles.Ragdolls; using PlayerRoles.RoleAssign; - using PluginAPI.Events; + using Respawning; using UnityEngine.SceneManagement; using UserSettings.ServerSpecific; @@ -84,8 +84,6 @@ public override void OnEnabled() ServerConsole.ReloadServerName(); ServerSpecificSettingsSync.ServerOnSettingValueReceived += SettingBase.OnSettingUpdated; - - EventManager.RegisterEvents(this); } /// @@ -118,8 +116,6 @@ public override void OnDisabled() ItemPickupBase.OnPickupDestroyed -= Handlers.Internal.PickupEvent.OnRemovedPickup; ServerSpecificSettingsSync.ServerOnSettingValueReceived -= SettingBase.OnSettingUpdated; - - EventManager.UnregisterEvents(this); } /// diff --git a/EXILED/Exiled.Events/Exiled.Events.csproj b/EXILED/Exiled.Events/Exiled.Events.csproj index aa7f9ff4bf..620625057d 100644 --- a/EXILED/Exiled.Events/Exiled.Events.csproj +++ b/EXILED/Exiled.Events/Exiled.Events.csproj @@ -26,10 +26,10 @@ + - diff --git a/EXILED/Exiled.Events/Handlers/Player.cs b/EXILED/Exiled.Events/Handlers/Player.cs index ac58bb3085..62df1b459b 100644 --- a/EXILED/Exiled.Events/Handlers/Player.cs +++ b/EXILED/Exiled.Events/Handlers/Player.cs @@ -17,10 +17,6 @@ namespace Exiled.Events.Handlers using Exiled.Events.Features; - using PluginAPI.Core.Attributes; - using PluginAPI.Enums; - using PluginAPI.Events; - /// /// Player related events. /// diff --git a/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs b/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs index 1bdacfd8f2..2c138e305e 100644 --- a/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs +++ b/EXILED/Exiled.Events/Patches/Events/Cassie/SendingCassieMessage.cs @@ -22,7 +22,7 @@ namespace Exiled.Events.Patches.Events.Cassie using static HarmonyLib.AccessTools; /// - /// Patches . + /// Patches . /// Adds the event. /// [EventPatch(typeof(Cassie), nameof(Cassie.SendingCassieMessage))] @@ -35,13 +35,13 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj) + offset; newInstructions.InsertRange( index, new[] { - // Player.Get(hub) + // hub new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // roleTypeId - new(OpCodes.Ldloc_0), + new(OpCodes.Ldloc_1), // escapeScenario - new(OpCodes.Ldloc_1), + new(OpCodes.Ldloc_2), - // EscapingEventArgs ev = new(Player, RoleTypeId, EscapeScenario, SpawnableTeamType, float) + // EscapingEventArgs ev = new(Player, RoleTypeId, EscapeScenario) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(EscapingEventArgs))[0]), new(OpCodes.Dup), new(OpCodes.Dup), @@ -75,7 +74,12 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } } - - /// - /// Patches for . - /// Replaces last returned to . - /// - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Escaping))] - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Escaped))] - [HarmonyPatch(typeof(Escape), nameof(Escape.ServerGetScenario))] - internal static class GetScenario - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - LocalBuilder fpcRole = generator.DeclareLocal(typeof(FpcStandardRoleBase)); - - // replace HumanRole to FpcStandardRoleBase - newInstructions.Find(x => x.opcode == OpCodes.Isinst).operand = typeof(FpcStandardRoleBase); - - // after this index all invalid exit are considered Custom - int customExit = newInstructions.FindLastIndex(x => x.opcode == OpCodes.Ldarg_0); - for (int i = 0; i < newInstructions.Count; i++) - { - OpCode opcode = newInstructions[i].opcode; - if (opcode == OpCodes.Stloc_0) - newInstructions[i] = new CodeInstruction(OpCodes.Stloc_S, fpcRole.LocalIndex).WithLabels(newInstructions[i].labels); - else if (opcode == OpCodes.Ldloc_0) - newInstructions[i] = new CodeInstruction(OpCodes.Ldloc_S, fpcRole.LocalIndex).WithLabels(newInstructions[i].labels); - else if (opcode == OpCodes.Ldc_I4_0 && i > customExit) - newInstructions[i].opcode = OpCodes.Ldc_I4_5; - } - - 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/Player/EscapingPocketDimension.cs b/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.cs index e69b577385..6c6408b36f 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/EscapingPocketDimension.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; @@ -25,11 +26,11 @@ namespace Exiled.Events.Patches.Events.Player using static HarmonyLib.AccessTools; /// - /// Patches the method. + /// Patches the method. /// Adds the event. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.EscapingPocketDimension))] - [HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.OnTriggerEnter))] + [HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.Exit))] internal static class EscapingPocketDimension { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) @@ -40,24 +41,17 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(FirstPersonMovementModule), nameof(FirstPersonMovementModule.ServerOverridePosition)))) + offset; - - // Replaces "ServerOverridePosition" with our logic - newInstructions.RemoveRange(index, 6); - + int offset = 1; + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ret) + offset; newInstructions.InsertRange( index, new[] { - // Player.Get(referenceHub) - new CodeInstruction(OpCodes.Ldloc_1).WithLabels((Label)newInstructions[index + labelOffset].operand), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + // referenceHub + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), // Scp106PocketExitFinder.GetBestExitPosition(fpcRole) - new(OpCodes.Ldloc_2), + new(OpCodes.Ldloc_0), new(OpCodes.Call, Method(typeof(Scp106PocketExitFinder), nameof(Scp106PocketExitFinder.GetBestExitPosition), new[] { typeof(IFpcRole) })), // EscapingPocketDimensionEventArgs ev = new(Player, Vector3) @@ -73,15 +67,20 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(FirstPersonMovementModule), nameof(FirstPersonMovementModule.ServerOverridePosition)))) + offset; + + // Replaces "fpcRole.FpcModule.ServerOverridePosition(Scp106PocketExitFinder.GetBestExitPosition(fpcRole))" + // with "fpcRole.FpcModule.ServerOverridePosition(ev.TeleportPosition)" + newInstructions.RemoveRange(index, 2); + newInstructions.InsertRange(index, new CodeInstruction[] + { + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(EscapingPocketDimensionEventArgs), nameof(EscapingPocketDimensionEventArgs.TeleportPosition))), + }); newInstructions[newInstructions.Count - 1].WithLabels(ret); for (int z = 0; z < newInstructions.Count; z++) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/FailingEscapePocketDimension.cs b/EXILED/Exiled.Events/Patches/Events/Player/FailingEscapePocketDimension.cs index d64fe8c8cf..875c26611a 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/FailingEscapePocketDimension.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/FailingEscapePocketDimension.cs @@ -22,11 +22,11 @@ namespace Exiled.Events.Patches.Events.Player using static HarmonyLib.AccessTools; /// - /// Patches . + /// Patches . /// Adds the event. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.FailingEscapePocketDimension))] - [HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.OnTriggerEnter))] + [HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.Kill))] internal static class FailingEscapePocketDimension { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) @@ -35,34 +35,17 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj) + offset; - newInstructions.InsertRange( - index, + 0, new[] { - new CodeInstruction(OpCodes.Ldloc_1).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - new(OpCodes.Dup), - new(OpCodes.Stloc_S, player.LocalIndex), - new(OpCodes.Brfalse, returnLabel), - - // player - new CodeInstruction(OpCodes.Ldloc_S, player.LocalIndex), - - // this - new(OpCodes.Ldarg_0), + // referenceHub + new CodeInstruction(OpCodes.Ldarg_0), // true new(OpCodes.Ldc_I4_1), - // FailingEscapePocketDimensionEventArgs ev = new(Player, PocketDimensionTeleport, bool) + // FailingEscapePocketDimensionEventArgs ev = new(ReferenceHub, bool) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(FailingEscapePocketDimensionEventArgs))[0]), new(OpCodes.Dup), diff --git a/EXILED/Exiled.Events/Patches/Events/Player/FlippingCoin.cs b/EXILED/Exiled.Events/Patches/Events/Player/FlippingCoin.cs index 71e9711a7f..4ec1ce8c9f 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/FlippingCoin.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/FlippingCoin.cs @@ -38,25 +38,24 @@ private static IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Brtrue_S) + offset; + int offset = 1; + int index = newInstructions.FindLastIndex(x => x.opcode == OpCodes.Stloc_0) + offset; newInstructions.InsertRange( index, new[] { - // Player.Get(ReferenceHub) + // this.Owner new CodeInstruction(OpCodes.Ldarg_0), new(OpCodes.Callvirt, PropertyGetter(typeof(ItemBase), nameof(ItemBase.Owner))), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // this new CodeInstruction(OpCodes.Ldarg_0), // isTails - new(OpCodes.Ldloc_1), + new(OpCodes.Ldloc_0), - // FlippingCoinEventArgs ev = new(Player, bool) + // FlippingCoinEventArgs ev = new(ReferenceHub, bool) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(FlippingCoinEventArgs))[0]), new(OpCodes.Dup), new(OpCodes.Dup), diff --git a/EXILED/Exiled.Events/Patches/Events/Player/Hurting.cs b/EXILED/Exiled.Events/Patches/Events/Player/Hurting.cs index 11e3e2a96c..1a5e4093f6 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/Hurting.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/Hurting.cs @@ -38,8 +38,6 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - LocalBuilder player = generator.DeclareLocal(typeof(Player)); - Label jump = generator.DefineLabel(); int offset = 1; int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ret) + offset; @@ -48,15 +46,14 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); + Label retLabel = generator.DefineLabel(); LocalBuilder ev = generator.DeclareLocal(typeof(InteractingDoorEventArgs)); - List