From 0f03880dda2b618c72872e558b147e8a202f8349 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Sat, 6 Jul 2024 14:54:49 +0200 Subject: [PATCH 01/13] Fixes --- Exiled.API/Features/Pickups/AmmoPickup.cs | 1 + Exiled.API/Features/Pickups/FirearmPickup.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Exiled.API/Features/Pickups/AmmoPickup.cs b/Exiled.API/Features/Pickups/AmmoPickup.cs index 0ff7bbae0d..fc173a813c 100644 --- a/Exiled.API/Features/Pickups/AmmoPickup.cs +++ b/Exiled.API/Features/Pickups/AmmoPickup.cs @@ -36,6 +36,7 @@ internal AmmoPickup(BaseAmmo pickupBase) internal AmmoPickup(ItemType type) : base(type) { + Base = (BaseAmmo)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/FirearmPickup.cs b/Exiled.API/Features/Pickups/FirearmPickup.cs index 540096595a..485336f9e2 100644 --- a/Exiled.API/Features/Pickups/FirearmPickup.cs +++ b/Exiled.API/Features/Pickups/FirearmPickup.cs @@ -40,6 +40,7 @@ internal FirearmPickup(BaseFirearm pickupBase) internal FirearmPickup(ItemType type) : base(type) { + Base = (BaseFirearm)((Pickup)this).Base; IsDistributed = true; } From b90778ea5a344e24f1b20a4e8e97b49ee5e40ab7 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Sat, 6 Jul 2024 18:34:55 +0200 Subject: [PATCH 02/13] Change order --- Exiled.API/Features/Toys/Primitive.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Toys/Primitive.cs b/Exiled.API/Features/Toys/Primitive.cs index 12e6326212..c80ec34b36 100644 --- a/Exiled.API/Features/Toys/Primitive.cs +++ b/Exiled.API/Features/Toys/Primitive.cs @@ -99,10 +99,10 @@ public PrimitiveFlags Flags /// The position. /// The rotation. /// The size of the primitive. - /// Whether or not the primitive should be spawned. /// Whether or not the primitive is static. + /// Whether or not the primitive should be spawned. /// The newly created . - public static Primitive Create(PrimitiveType primitiveType, PrimitiveFlags flags = default, Color? color = null, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, bool spawn = true, bool isStatic = false) + public static Primitive Create(PrimitiveType primitiveType, PrimitiveFlags flags = default, Color? color = null, Vector3? position = null, Quaternion? rotation = null, Vector3? scale = null, bool isStatic = false, bool spawn = true) => Create(new(primitiveType, color, position, flags, rotation, scale, isStatic, spawn)); /// From db1d53c4be81bf0388f452530967f83dedfa775f Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Sat, 6 Jul 2024 18:42:48 +0200 Subject: [PATCH 03/13] Pickup fixes --- .../Features/Pickups/BodyArmorPickup.cs | 1 + Exiled.API/Features/Pickups/JailbirdPickup.cs | 1 + Exiled.API/Features/Pickups/KeycardPickup.cs | 19 +++++++++++-------- Exiled.API/Features/Pickups/MicroHIDPickup.cs | 1 + Exiled.API/Features/Pickups/Pickup.cs | 2 +- .../Projectiles/EffectGrenadeProjectile.cs | 3 ++- .../Projectiles/ExplosionGrenadeProjectile.cs | 3 ++- .../Projectiles/FlashbangProjectile.cs | 3 ++- .../Pickups/Projectiles/Projectile.cs | 3 ++- .../Pickups/Projectiles/Scp018Projectile.cs | 3 ++- .../Pickups/Projectiles/Scp2176Projectile.cs | 3 ++- .../Projectiles/TimeGrenadeProjectile.cs | 3 ++- Exiled.API/Features/Pickups/RadioPickup.cs | 1 + Exiled.API/Features/Pickups/Scp1576Pickup.cs | 1 + Exiled.API/Features/Pickups/Scp244Pickup.cs | 1 + 15 files changed, 32 insertions(+), 16 deletions(-) diff --git a/Exiled.API/Features/Pickups/BodyArmorPickup.cs b/Exiled.API/Features/Pickups/BodyArmorPickup.cs index fb87b7cff2..deea9290c9 100644 --- a/Exiled.API/Features/Pickups/BodyArmorPickup.cs +++ b/Exiled.API/Features/Pickups/BodyArmorPickup.cs @@ -45,6 +45,7 @@ internal BodyArmorPickup(BaseBodyArmor pickupBase) internal BodyArmorPickup(ItemType type) : base(type) { + Base = (BaseBodyArmor)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/JailbirdPickup.cs b/Exiled.API/Features/Pickups/JailbirdPickup.cs index a018de9755..f74be2f7d2 100644 --- a/Exiled.API/Features/Pickups/JailbirdPickup.cs +++ b/Exiled.API/Features/Pickups/JailbirdPickup.cs @@ -37,6 +37,7 @@ internal JailbirdPickup(BaseJailbirdPickup pickupBase) internal JailbirdPickup() : base(ItemType.Jailbird) { + Base = (BaseJailbirdPickup)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/KeycardPickup.cs b/Exiled.API/Features/Pickups/KeycardPickup.cs index 6accc9b336..f7435c78e8 100644 --- a/Exiled.API/Features/Pickups/KeycardPickup.cs +++ b/Exiled.API/Features/Pickups/KeycardPickup.cs @@ -39,6 +39,7 @@ internal KeycardPickup(BaseKeycard pickupBase) internal KeycardPickup(ItemType type) : base(type) { + Base = (BaseKeycard)((Pickup)this).Base; } /// @@ -56,20 +57,22 @@ internal KeycardPickup(ItemType type) internal override void ReadItemInfo(Item item) { base.ReadItemInfo(item); - if (item is Keycard keycarditem) - { - Permissions = keycarditem.Permissions; - } + + if (item is not Keycard keycarditem) + return; + + Permissions = keycarditem.Permissions; } /// protected override void InitializeProperties(ItemBase itemBase) { base.InitializeProperties(itemBase); - if (itemBase is KeycardItem keycardItem) - { - Permissions = (KeycardPermissions)keycardItem.Permissions; - } + + if (itemBase is not KeycardItem keycardItem) + return; + + Permissions = (KeycardPermissions)keycardItem.Permissions; } } } diff --git a/Exiled.API/Features/Pickups/MicroHIDPickup.cs b/Exiled.API/Features/Pickups/MicroHIDPickup.cs index eeb51e1727..3ba9bb3946 100644 --- a/Exiled.API/Features/Pickups/MicroHIDPickup.cs +++ b/Exiled.API/Features/Pickups/MicroHIDPickup.cs @@ -34,6 +34,7 @@ internal MicroHIDPickup(BaseMicroHID pickupBase) internal MicroHIDPickup() : base(ItemType.MicroHID) { + Base = (BaseMicroHID)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index 7b4ceeefd4..3e23b5fbb6 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -40,7 +40,7 @@ namespace Exiled.API.Features.Pickups /// A wrapper class for . /// [EClass(category: nameof(Pickup))] - public class Pickup : GameEntity, IWrapper, IWorldSpace + public class Pickup : GameEntity, IWrapper { /// /// A dictionary of all 's that have been converted into . diff --git a/Exiled.API/Features/Pickups/Projectiles/EffectGrenadeProjectile.cs b/Exiled.API/Features/Pickups/Projectiles/EffectGrenadeProjectile.cs index 1ac2faf184..4f12c8c76d 100644 --- a/Exiled.API/Features/Pickups/Projectiles/EffectGrenadeProjectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/EffectGrenadeProjectile.cs @@ -31,8 +31,9 @@ public EffectGrenadeProjectile(EffectGrenade pickupBase) /// /// The of the pickup. internal EffectGrenadeProjectile(ItemType type) - : this((EffectGrenade)type.GetItemBase().ServerDropItem()) + : base(type) { + Base = (EffectGrenade)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/Projectiles/ExplosionGrenadeProjectile.cs b/Exiled.API/Features/Pickups/Projectiles/ExplosionGrenadeProjectile.cs index 5fe2fba552..d593bbf9c5 100644 --- a/Exiled.API/Features/Pickups/Projectiles/ExplosionGrenadeProjectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/ExplosionGrenadeProjectile.cs @@ -35,8 +35,9 @@ public ExplosionGrenadeProjectile(ExplosionGrenade pickupBase) /// Initializes a new instance of the class. /// internal ExplosionGrenadeProjectile() - : this((ExplosionGrenade)Object.Instantiate(InventoryItemLoader.AvailableItems[ItemType.GrenadeHE] as ThrowableItem).Projectile) + : base(ItemType.GrenadeHE) { + Base = (ExplosionGrenade)((Pickup)this).Base; Info = new(ItemType.GrenadeHE, InventoryItemLoader.AvailableItems[ItemType.GrenadeHE].Weight, ItemSerialGenerator.GenerateNext()); } diff --git a/Exiled.API/Features/Pickups/Projectiles/FlashbangProjectile.cs b/Exiled.API/Features/Pickups/Projectiles/FlashbangProjectile.cs index df9b9881aa..4d665ad32f 100644 --- a/Exiled.API/Features/Pickups/Projectiles/FlashbangProjectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/FlashbangProjectile.cs @@ -34,8 +34,9 @@ public FlashbangProjectile(FlashbangGrenade pickupBase) /// Initializes a new instance of the class. /// internal FlashbangProjectile() - : this((FlashbangGrenade)Object.Instantiate(InventoryItemLoader.AvailableItems[ItemType.GrenadeFlash] as ThrowableItem).Projectile) + : base(ItemType.GrenadeFlash) { + Base = (FlashbangGrenade)((Pickup)this).Base; Info = new(ItemType.GrenadeFlash, InventoryItemLoader.AvailableItems[ItemType.GrenadeFlash].Weight, ItemSerialGenerator.GenerateNext()); } diff --git a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs index b06c00ff64..1966d450d9 100644 --- a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs @@ -34,8 +34,9 @@ internal Projectile(ThrownProjectile pickupBase) /// /// The of the pickup. internal Projectile(ItemType type) - : this((ThrownProjectile)type.GetItemBase().ServerDropItem()) + : base(type) { + Base = (ThrownProjectile)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs b/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs index 0f12265509..cc69e83bc2 100644 --- a/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/Scp018Projectile.cs @@ -33,8 +33,9 @@ public Scp018Projectile(BaseScp018Projectile pickupBase) /// Initializes a new instance of the class. /// internal Scp018Projectile() - : this((BaseScp018Projectile)ItemType.SCP018.GetItemBase().ServerDropItem()) + : base(ItemType.SCP018) { + Base = (BaseScp018Projectile)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/Projectiles/Scp2176Projectile.cs b/Exiled.API/Features/Pickups/Projectiles/Scp2176Projectile.cs index 95c5469fbb..195c94276b 100644 --- a/Exiled.API/Features/Pickups/Projectiles/Scp2176Projectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/Scp2176Projectile.cs @@ -33,8 +33,9 @@ public Scp2176Projectile(BaseScp2176Projectile pickupBase) /// Initializes a new instance of the class. /// internal Scp2176Projectile() - : this((BaseScp2176Projectile)ItemType.SCP2176.GetItemBase().ServerDropItem()) + : base(ItemType.SCP2176) { + Base = (BaseScp2176Projectile)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/Projectiles/TimeGrenadeProjectile.cs b/Exiled.API/Features/Pickups/Projectiles/TimeGrenadeProjectile.cs index 0db3479cfd..4e2849821d 100644 --- a/Exiled.API/Features/Pickups/Projectiles/TimeGrenadeProjectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/TimeGrenadeProjectile.cs @@ -33,8 +33,9 @@ internal TimeGrenadeProjectile(TimeGrenade pickupBase) /// /// The of the pickup. internal TimeGrenadeProjectile(ItemType type) - : this((TimeGrenade)type.GetItemBase().ServerDropItem()) + : base(type) { + Base = (TimeGrenade)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/RadioPickup.cs b/Exiled.API/Features/Pickups/RadioPickup.cs index 790a4d46bc..ca3247959f 100644 --- a/Exiled.API/Features/Pickups/RadioPickup.cs +++ b/Exiled.API/Features/Pickups/RadioPickup.cs @@ -35,6 +35,7 @@ internal RadioPickup(BaseRadio pickupBase) internal RadioPickup() : base(ItemType.Radio) { + Base = (BaseRadio)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/Scp1576Pickup.cs b/Exiled.API/Features/Pickups/Scp1576Pickup.cs index 33d4332b69..6d02cc4f4e 100644 --- a/Exiled.API/Features/Pickups/Scp1576Pickup.cs +++ b/Exiled.API/Features/Pickups/Scp1576Pickup.cs @@ -33,6 +33,7 @@ internal Scp1576Pickup(BaseScp1576 pickupBase) internal Scp1576Pickup() : base(ItemType.SCP1576) { + Base = (BaseScp1576)((Pickup)this).Base; } /// diff --git a/Exiled.API/Features/Pickups/Scp244Pickup.cs b/Exiled.API/Features/Pickups/Scp244Pickup.cs index cfb07ba6b2..21ad5f88a1 100644 --- a/Exiled.API/Features/Pickups/Scp244Pickup.cs +++ b/Exiled.API/Features/Pickups/Scp244Pickup.cs @@ -39,6 +39,7 @@ internal Scp244Pickup(Scp244DeployablePickup pickupBase) internal Scp244Pickup(ItemType type) : base(type) { + Base = (Scp244DeployablePickup)((Pickup)this).Base; } /// From 8e2f2e559b71d25bea88973083c8e419482d7b1a Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Sun, 7 Jul 2024 13:12:23 +0200 Subject: [PATCH 04/13] FpcRole & Fix pickup --- Exiled.API/Features/Pickups/Pickup.cs | 1 + Exiled.API/Features/Roles/FpcRole.cs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index 3e23b5fbb6..a1cff948fc 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -78,6 +78,7 @@ internal Pickup(ItemType type) ItemBase itemBase = type.GetItemBase(); Base = Object.Instantiate(itemBase.PickupDropModel); + GameObject = Base.gameObject; PickupSyncInfo psi = new() { diff --git a/Exiled.API/Features/Roles/FpcRole.cs b/Exiled.API/Features/Roles/FpcRole.cs index 5612038981..020efd254d 100644 --- a/Exiled.API/Features/Roles/FpcRole.cs +++ b/Exiled.API/Features/Roles/FpcRole.cs @@ -69,10 +69,20 @@ protected FpcRole(FpcStandardRoleBase baseRole) public CharacterController CharacterController => FirstPersonController.FpcModule.CharController; /// - /// Gets or sets the player's relative position. + /// Gets or sets the player's relative position as perceived by the server. /// [EProperty(category: nameof(FpcRole))] public RelativePosition RelativePosition + { + get => new(Position); + set => Position = value.Position; + } + + /// + /// Gets or sets the player's relative position as perceived by the client. + /// + [EProperty(category: nameof(FpcRole))] + public RelativePosition ClientRelativePosition { get => FirstPersonController.FpcModule.Motor.ReceivedPosition; set => FirstPersonController.FpcModule.Motor.ReceivedPosition = value; From cfa52625b6a4553d53f86780897f7805c20daada Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:36:17 +0200 Subject: [PATCH 05/13] Fixes --- Exiled.API/Extensions/EffectTypeExtension.cs | 4 ++-- Exiled.API/Features/Doors/Door.cs | 10 +++++----- Exiled.API/Features/Player.cs | 16 +++++++++++++--- .../Server/PreAssigningHumanRolesEventArgs.cs | 4 +--- .../Server/PreAssigningScpRolesEventArgs.cs | 6 +----- Exiled.Example/EventHandler.cs | 19 +++++++++++++++++++ 6 files changed, 41 insertions(+), 18 deletions(-) diff --git a/Exiled.API/Extensions/EffectTypeExtension.cs b/Exiled.API/Extensions/EffectTypeExtension.cs index 2772beb315..0c39f1cf28 100644 --- a/Exiled.API/Extensions/EffectTypeExtension.cs +++ b/Exiled.API/Extensions/EffectTypeExtension.cs @@ -155,7 +155,7 @@ or EffectType.Corroding or EffectType.Decontaminating or EffectType.Hemorrhage o /// The . /// Whether or not the effect is a negative effect. /// - public static bool IsNegative(this EffectType effect) => IsHarmful(effect) || GetEffectBase(effect).Classification is StatusEffectBase.EffectClassification.Negative; + public static bool IsNegative(this EffectType effect) => IsHarmful(effect) || GetEffectBase(effect)?.Classification is StatusEffectBase.EffectClassification.Negative; /// /// Returns whether or not the provided is a positive effect. @@ -163,7 +163,7 @@ or EffectType.Corroding or EffectType.Decontaminating or EffectType.Hemorrhage o /// The . /// Whether or not the effect is a positive effect. /// - public static bool IsPositive(this EffectType effect) => GetEffectBase(effect).Classification == StatusEffectBase.EffectClassification.Positive; + public static bool IsPositive(this EffectType effect) => GetEffectBase(effect)?.Classification == StatusEffectBase.EffectClassification.Positive; /// /// Returns whether or not the provided affects the player's movement speed. diff --git a/Exiled.API/Features/Doors/Door.cs b/Exiled.API/Features/Doors/Door.cs index 84faa12b69..8849926926 100644 --- a/Exiled.API/Features/Doors/Door.cs +++ b/Exiled.API/Features/Doors/Door.cs @@ -293,7 +293,7 @@ public Vector3 Scale /// /// Gets a containing all 's that are connected with . /// - internal List RoomsValue { get; } = new List(); + internal List RoomsValue { get; } = new(); /// /// Gets the door object associated with a specific , or creates a new one if there isn't one. @@ -604,11 +604,11 @@ public void PlaySound(DoorBeepType beep) /// /// The of the lockdown. /// A value indicating whether the door state should be modified. - public void Lock(DoorLockType lockType = DoorLockType.AdminCommand, bool updateTheDoorState = true) + public void Lock(DoorLockType lockType = DoorLockType.AdminCommand, bool updateTheDoorState = false) { ChangeLock(lockType); - if (updateTheDoorState) + if (!updateTheDoorState) return; DoorLockMode mode = DoorLockUtils.GetMode((DoorLockReason)LockType); @@ -624,7 +624,7 @@ public void Lock(DoorLockType lockType = DoorLockType.AdminCommand, bool updateT /// The amount of time that must pass before unlocking the door. /// The of the lockdown. /// A value indicating whether the door state should be modified. - public void Lock(float time, DoorLockType lockType = DoorLockType.AdminCommand, bool updateTheDoorState = true) + public void Lock(float time, DoorLockType lockType = DoorLockType.AdminCommand, bool updateTheDoorState = false) { Lock(lockType, updateTheDoorState); Unlock(time, lockType); @@ -633,7 +633,7 @@ public void Lock(float time, DoorLockType lockType = DoorLockType.AdminCommand, /// /// Unlocks and clears all active locks on the door. /// - public void Unlock() => ChangeLock(DoorLockType.None); + public void Unlock() => Base.NetworkActiveLocks = (ushort)DoorLockReason.None; /// /// Unlocks and clears all active locks on the door after a specified length of time. diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index b3a1b052e3..765c73ce34 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -967,7 +967,13 @@ public float MaxHealth public float ArtificialHealth { get => AhpStat.CurValue; - set => AhpStat.CurValue = value; + set + { + AhpStat.AhpProcess ahp = ActiveArtificialHealthProcesses.FirstOrDefault(); + + if (ahp is not null) + ahp.CurrentAmount = value; + } } /// @@ -1114,6 +1120,11 @@ public string GroupName /// public Lift Lift => Lift.Get(Position); + /// + /// Gets all effects from the player, including non active ones. + /// + public IEnumerable AllEffects => referenceHub.playerEffectsController.AllEffects; + /// /// Gets all currently active effects. /// @@ -3684,8 +3695,7 @@ public void ChangeEffectIntensity(string effectName, byte intensity, float durat /// Whether or not the process is removed when the value hits 0. public void AddAhp(float amount, float limit = 75f, float decay = 1.2f, float efficacy = 0.7f, float sustain = 0f, bool persistant = false) { - ReferenceHub.playerStats.GetModule() - .ServerAddProcess(amount, limit, decay, efficacy, sustain, persistant); + AhpStat.ServerAddProcess(amount, limit, decay, efficacy, sustain, persistant); } /// diff --git a/Exiled.Events/EventArgs/Server/PreAssigningHumanRolesEventArgs.cs b/Exiled.Events/EventArgs/Server/PreAssigningHumanRolesEventArgs.cs index a2a5b706c0..cc8e6ce214 100644 --- a/Exiled.Events/EventArgs/Server/PreAssigningHumanRolesEventArgs.cs +++ b/Exiled.Events/EventArgs/Server/PreAssigningHumanRolesEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Server { - using API.Enums; - using Interfaces; using PlayerRoles; @@ -16,7 +14,7 @@ namespace Exiled.Events.EventArgs.Server /// /// Contains all information before setting up the environment for the assignment of human roles. /// - public class PreAssigningHumanRolesEventArgs : IExiledEvent, IDeniableEvent + public class PreAssigningHumanRolesEventArgs : IDeniableEvent { /// /// Initializes a new instance of the class. diff --git a/Exiled.Events/EventArgs/Server/PreAssigningScpRolesEventArgs.cs b/Exiled.Events/EventArgs/Server/PreAssigningScpRolesEventArgs.cs index eb5dbccf29..5c52f8a3c6 100644 --- a/Exiled.Events/EventArgs/Server/PreAssigningScpRolesEventArgs.cs +++ b/Exiled.Events/EventArgs/Server/PreAssigningScpRolesEventArgs.cs @@ -7,16 +7,12 @@ namespace Exiled.Events.EventArgs.Server { - using API.Enums; - using Interfaces; - using PlayerRoles; - /// /// Contains all information before setting up the environment for the assignment of SCP roles. /// - public class PreAssigningScpRolesEventArgs : IExiledEvent, IDeniableEvent + public class PreAssigningScpRolesEventArgs : IDeniableEvent { /// /// Initializes a new instance of the class. diff --git a/Exiled.Example/EventHandler.cs b/Exiled.Example/EventHandler.cs index 8c963915fd..37530b3b04 100644 --- a/Exiled.Example/EventHandler.cs +++ b/Exiled.Example/EventHandler.cs @@ -7,6 +7,9 @@ namespace Exiled.Example { + using CustomPlayerEffects; + using Exiled.API.Enums; + using Exiled.API.Extensions; using Exiled.API.Features; using Exiled.Events.EventArgs.Player; @@ -21,6 +24,7 @@ public class EventHandler public EventHandler() { Exiled.Events.Handlers.Player.Verified += OnVerified; + Exiled.Events.Handlers.Server.WaitingForPlayers += OnWaiting; } /// @@ -31,6 +35,21 @@ public EventHandler() Exiled.Events.Handlers.Player.Verified -= OnVerified; } + private void OnWaiting() + { + foreach (EffectType type in EnumExtensions.QueryValues()) + { + if (type.TryGetEffectBase(out StatusEffectBase effect)) + { + Log.Info(effect); + } + else + { + Log.Error(type); + } + } + } + private void OnVerified(VerifiedEventArgs ev) => Log.Info($"{ev.Player} has joined the server!"); } } \ No newline at end of file From 1b263974b049fff97445dde93fd1356f63fbc8bc Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:37:48 +0200 Subject: [PATCH 06/13] Update --- Exiled.Example/EventHandler.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/Exiled.Example/EventHandler.cs b/Exiled.Example/EventHandler.cs index 37530b3b04..8c963915fd 100644 --- a/Exiled.Example/EventHandler.cs +++ b/Exiled.Example/EventHandler.cs @@ -7,9 +7,6 @@ namespace Exiled.Example { - using CustomPlayerEffects; - using Exiled.API.Enums; - using Exiled.API.Extensions; using Exiled.API.Features; using Exiled.Events.EventArgs.Player; @@ -24,7 +21,6 @@ public class EventHandler public EventHandler() { Exiled.Events.Handlers.Player.Verified += OnVerified; - Exiled.Events.Handlers.Server.WaitingForPlayers += OnWaiting; } /// @@ -35,21 +31,6 @@ public EventHandler() Exiled.Events.Handlers.Player.Verified -= OnVerified; } - private void OnWaiting() - { - foreach (EffectType type in EnumExtensions.QueryValues()) - { - if (type.TryGetEffectBase(out StatusEffectBase effect)) - { - Log.Info(effect); - } - else - { - Log.Error(type); - } - } - } - private void OnVerified(VerifiedEventArgs ev) => Log.Info($"{ev.Player} has joined the server!"); } } \ No newline at end of file From 07369dd036816069a9e053e4f8bebe4e89208001 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Mon, 8 Jul 2024 19:49:21 +0200 Subject: [PATCH 07/13] Fix --- Exiled.API/Features/Map.cs | 2 +- Exiled.API/Features/Room.cs | 2 +- Exiled.Events/Features/Event{T}.cs | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 6b81bcc053..791dc9a6ad 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -155,7 +155,7 @@ public static void TurnOffAllLights(float duration, ZoneType zoneTypes = ZoneTyp { foreach (RoomLightController controller in RoomLightController.Instances) { - Room room = controller.GetComponentInParent(); + Room room = Room.Get(controller); if (room == null) continue; diff --git a/Exiled.API/Features/Room.cs b/Exiled.API/Features/Room.cs index ad5757dd86..3b8df77fab 100644 --- a/Exiled.API/Features/Room.cs +++ b/Exiled.API/Features/Room.cs @@ -246,7 +246,7 @@ public static Room Get(RoomIdentifier roomIdentifier) => roomIdentifier == null /// /// The to search with. /// The of the given identified, if any. Can be . - public static Room Get(RoomLightController flickerableLightController) => flickerableLightController.GetComponentInParent(); + public static Room Get(RoomLightController flickerableLightController) => List.FirstOrDefault(r => r.RoomLightControllers.Contains(flickerableLightController)); /// /// Gets a given the specified . diff --git a/Exiled.Events/Features/Event{T}.cs b/Exiled.Events/Features/Event{T}.cs index 0a38b0217e..4e2aea78bb 100644 --- a/Exiled.Events/Features/Event{T}.cs +++ b/Exiled.Events/Features/Event{T}.cs @@ -10,7 +10,6 @@ namespace Exiled.Events.Features using System; using System.Collections.Generic; using System.Linq; - using System.Reflection; using Exiled.API.Features; using Exiled.Events.EventArgs.Interfaces; From 76a565380a9ee769b18f325e2a8f6b063e932be5 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Mon, 8 Jul 2024 20:52:25 +0200 Subject: [PATCH 08/13] Change --- Exiled.API/Features/Doors/Door.cs | 13 +++++++++++-- Exiled.API/Features/Player.cs | 7 +++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Exiled.API/Features/Doors/Door.cs b/Exiled.API/Features/Doors/Door.cs index 8849926926..244f176b0a 100644 --- a/Exiled.API/Features/Doors/Door.cs +++ b/Exiled.API/Features/Doors/Door.cs @@ -597,7 +597,16 @@ public void PlaySound(DoorBeepType beep) /// Change the door lock with the given lock type. /// /// The to use. - public void ChangeLock(DoorLockType lockType) => Base.ServerChangeLock((DoorLockReason)lockType, !LockType.HasFlag(lockType)); + public void ChangeLock(DoorLockType lockType) + { + if (lockType == DoorLockType.None) + { + Base.NetworkActiveLocks = (ushort)DoorLockReason.None; + return; + } + + Base.ServerChangeLock((DoorLockReason)lockType, !LockType.HasFlag(lockType)); + } /// /// Permanently locks all active locks on the door, and then reverts back any changes after a specified length of time. @@ -633,7 +642,7 @@ public void Lock(float time, DoorLockType lockType = DoorLockType.AdminCommand, /// /// Unlocks and clears all active locks on the door. /// - public void Unlock() => Base.NetworkActiveLocks = (ushort)DoorLockReason.None; + public void Unlock() => ChangeLock(DoorLockType.None); /// /// Unlocks and clears all active locks on the door after a specified length of time. diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 765c73ce34..ff64771a4b 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -3693,10 +3693,9 @@ public void ChangeEffectIntensity(string effectName, byte intensity, float durat /// Percent of incoming damage absorbed by this stat. /// The number of seconds to delay the start of the decay. /// Whether or not the process is removed when the value hits 0. - public void AddAhp(float amount, float limit = 75f, float decay = 1.2f, float efficacy = 0.7f, float sustain = 0f, bool persistant = false) - { - AhpStat.ServerAddProcess(amount, limit, decay, efficacy, sustain, persistant); - } + /// The that was added. + public AhpStat.AhpProcess AddAhp(float amount, float limit = 75f, float decay = 1.2f, float efficacy = 0.7f, float sustain = 0f, bool persistant = false) + => AhpStat.ServerAddProcess(amount, limit, decay, efficacy, sustain, persistant); /// /// Reconnects the player to the server. Can be used to redirect them to another server on a different port but same IP. From 3d5930a67d472ffd083a839fdc5163169d7f20dd Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Tue, 9 Jul 2024 17:28:41 +0200 Subject: [PATCH 09/13] Fix ahp --- Exiled.API/Features/Player.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index ff64771a4b..e8307bda83 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -973,6 +973,8 @@ public float ArtificialHealth if (ahp is not null) ahp.CurrentAmount = value; + else + AddAhp(value); } } From c4d8672d162903d21f78d10cf8a48add0bd83040 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:46:00 +0200 Subject: [PATCH 10/13] Fix --- Exiled.API/Features/Core/EObject.cs | 7 +++++-- .../API/Features/CustomRoles/CustomRole.cs | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Exiled.API/Features/Core/EObject.cs b/Exiled.API/Features/Core/EObject.cs index 61277c552f..85fa0ad639 100644 --- a/Exiled.API/Features/Core/EObject.cs +++ b/Exiled.API/Features/Core/EObject.cs @@ -171,14 +171,17 @@ public static Type RegisterObjectType(string name) /// /// The type to register. /// The name of the registered type. + /// The assembly to register object types in. /// The registered . - public static Type RegisterObjectType(Type type, string name) + public static Type RegisterObjectType(Type type, string name, Assembly assembly = null) { + assembly ??= Assembly.GetCallingAssembly(); + Type matching = GetObjectTypeFromRegisteredTypes(type, name); if (matching is not null) return matching; - foreach (Type t in Assembly.GetCallingAssembly().GetTypes() + foreach (Type t in assembly.GetTypes() .Where(item => item.BaseType == typeof(EObject) || item.IsSubclassOf(typeof(EObject)))) { if (t.Name != type.Name) diff --git a/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs b/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs index 7346ae63f7..ccd613de00 100644 --- a/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs +++ b/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs @@ -632,7 +632,7 @@ public static List EnableAll(Assembly assembly) if (!customRole.IsEnabled) continue; - if (customRole.TryRegister(attribute)) + if (customRole.TryRegister(assembly, attribute)) customRoles.Add(customRole); } @@ -905,9 +905,10 @@ public bool Eject(Pawn player) /// /// Tries to register a . /// + /// The assembly to try and register from. /// The specified . /// if the was registered; otherwise, . - internal bool TryRegister(CustomRoleAttribute attribute = null) + internal bool TryRegister(Assembly assembly, CustomRoleAttribute attribute = null) { if (!Registered.Contains(this)) { @@ -927,7 +928,7 @@ internal bool TryRegister(CustomRoleAttribute attribute = null) return false; } - EObject.RegisterObjectType(BehaviourComponent, Name); + EObject.RegisterObjectType(BehaviourComponent, Name, assembly); Registered.Add(this); TypeLookupTable.TryAdd(GetType(), this); From dde0202dc678cc81e53f730a1c2b87bcc3450574 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:53:30 +0200 Subject: [PATCH 11/13] Fix CustomItem --- .../API/Features/CustomItems/CustomItem.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Exiled.CustomModules/API/Features/CustomItems/CustomItem.cs b/Exiled.CustomModules/API/Features/CustomItems/CustomItem.cs index 57bc64e885..8039e4c441 100644 --- a/Exiled.CustomModules/API/Features/CustomItems/CustomItem.cs +++ b/Exiled.CustomModules/API/Features/CustomItems/CustomItem.cs @@ -394,7 +394,7 @@ public static List EnableAll(Assembly assembly) if (!customItem.IsEnabled) continue; - if (customItem.TryRegister(attribute)) + if (customItem.TryRegister(assembly, attribute)) customItems.Add(customItem); } @@ -614,9 +614,10 @@ public virtual void Give(Player player, Item item, bool displayMessage = true) /// /// Tries to register a . /// + /// The assembly to register items from. /// The specified . /// if the was registered; otherwise, . - internal bool TryRegister(CustomItemAttribute attribute = null) + internal bool TryRegister(Assembly assembly, CustomItemAttribute attribute = null) { if (!Registered.Contains(this)) { @@ -636,7 +637,7 @@ internal bool TryRegister(CustomItemAttribute attribute = null) return false; } - EObject.RegisterObjectType(BehaviourComponent, Name); + EObject.RegisterObjectType(BehaviourComponent, Name, assembly); Registered.Add(this); TypeLookupTable.TryAdd(GetType(), this); From bc2e681025fcd788126f4a22eed6fda8f9a7bdb6 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:57:05 +0200 Subject: [PATCH 12/13] Fix all --- .../API/Features/CustomAbilities/CustomAbility.cs | 7 ++++--- .../API/Features/CustomEscapes/CustomEscape.cs | 7 ++++--- .../API/Features/CustomGamemodes/CustomGameMode.cs | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Exiled.CustomModules/API/Features/CustomAbilities/CustomAbility.cs b/Exiled.CustomModules/API/Features/CustomAbilities/CustomAbility.cs index 849b892583..6930618c1b 100644 --- a/Exiled.CustomModules/API/Features/CustomAbilities/CustomAbility.cs +++ b/Exiled.CustomModules/API/Features/CustomAbilities/CustomAbility.cs @@ -496,7 +496,7 @@ public static IEnumerable> EnableAll(Assembly assembly) if (!customAbility.IsEnabled) continue; - if (customAbility.TryRegister(attribute)) + if (customAbility.TryRegister(assembly, attribute)) customAbilities.Add(customAbility); } @@ -587,9 +587,10 @@ public bool Remove(T entity) /// /// Tries to register a . /// + /// The assembly to register from. /// The specified . /// if the was registered; otherwise, . - internal bool TryRegister(CustomAbilityAttribute attribute = null) + internal bool TryRegister(Assembly assembly, CustomAbilityAttribute attribute = null) { if (!UnorderedRegistered.Contains(this)) { @@ -604,7 +605,7 @@ internal bool TryRegister(CustomAbilityAttribute attribute = null) return false; } - EObject.RegisterObjectType(BehaviourComponent, Name); + EObject.RegisterObjectType(BehaviourComponent, Name, assembly); UnorderedRegistered.Add(this); TypeLookupTable.TryAdd(GetType(), this); diff --git a/Exiled.CustomModules/API/Features/CustomEscapes/CustomEscape.cs b/Exiled.CustomModules/API/Features/CustomEscapes/CustomEscape.cs index bc5af2ae3a..24d3467477 100644 --- a/Exiled.CustomModules/API/Features/CustomEscapes/CustomEscape.cs +++ b/Exiled.CustomModules/API/Features/CustomEscapes/CustomEscape.cs @@ -197,7 +197,7 @@ public static List EnableAll(Assembly assembly) if (!customEscape.IsEnabled) continue; - if (customEscape.TryRegister(attribute)) + if (customEscape.TryRegister(assembly, attribute)) customEscapes.Add(customEscape); } @@ -353,9 +353,10 @@ public void Detach(Player player) /// /// Tries to register a . /// + /// The assembly to register from.. /// The specified . /// if the was registered; otherwise, . - internal bool TryRegister(CustomEscapeAttribute attribute = null) + internal bool TryRegister(Assembly assembly, CustomEscapeAttribute attribute = null) { if (!Registered.Contains(this)) { @@ -377,7 +378,7 @@ internal bool TryRegister(CustomEscapeAttribute attribute = null) AllScenariosInternal.AddRange(Scenarios); - EObject.RegisterObjectType(BehaviourComponent, Name); + EObject.RegisterObjectType(BehaviourComponent, Name, assembly); Registered.Add(this); TypeLookupTable.TryAdd(GetType(), this); diff --git a/Exiled.CustomModules/API/Features/CustomGamemodes/CustomGameMode.cs b/Exiled.CustomModules/API/Features/CustomGamemodes/CustomGameMode.cs index 262ccc61bc..da26a3062f 100644 --- a/Exiled.CustomModules/API/Features/CustomGamemodes/CustomGameMode.cs +++ b/Exiled.CustomModules/API/Features/CustomGamemodes/CustomGameMode.cs @@ -225,7 +225,7 @@ public static List EnableAll(Assembly assembly) continue; } - if (customGameMode.TryRegister(attribute)) + if (customGameMode.TryRegister(assembly, attribute)) customGameModes.Add(customGameMode); } @@ -252,9 +252,10 @@ public static List DisableAll() /// /// Tries to register a . /// + /// The assembly to register from. /// The specified . /// if the was registered; otherwise, . - internal bool TryRegister(CustomGameModeAttribute attribute = null) + internal bool TryRegister(Assembly assembly, CustomGameModeAttribute attribute = null) { if (!Registered.Contains(this)) { @@ -275,7 +276,7 @@ internal bool TryRegister(CustomGameModeAttribute attribute = null) } foreach (Type t in BehaviourComponents) - EObject.RegisterObjectType(t, typeof(GameState).IsAssignableFrom(t) ? $"GameState-{Name}" : typeof(PlayerState).IsAssignableFrom(t) ? $"PlayerState-{Name}" : Name); + EObject.RegisterObjectType(t, typeof(GameState).IsAssignableFrom(t) ? $"GameState-{Name}" : typeof(PlayerState).IsAssignableFrom(t) ? $"PlayerState-{Name}" : Name, assembly); Registered.Add(this); From 59b8377f26d50a1f95dbc4fb181a4b1f2adc5b9d Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:29:44 +0200 Subject: [PATCH 13/13] Change --- .../API/Features/CustomRoles/CustomRole.cs | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs b/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs index ccd613de00..ebff580130 100644 --- a/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs +++ b/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs @@ -910,38 +910,36 @@ public bool Eject(Pawn player) /// if the was registered; otherwise, . internal bool TryRegister(Assembly assembly, CustomRoleAttribute attribute = null) { - if (!Registered.Contains(this)) + if (Registered.Contains(this)) { - if (attribute is not null && Id == 0) - { - if (attribute.Id != 0) - Id = attribute.Id; - else - throw new ArgumentException($"Unable to register {Name}. The ID 0 is reserved for special use."); - } - - CustomRole duplicate = Registered.FirstOrDefault(x => x.Id == Id || x.Name == Name || x.BehaviourComponent == BehaviourComponent); - if (duplicate) - { - Log.Warn($"Unable to register {Name}. Another role with the same ID, Name or Behaviour Component already exists: {duplicate.Name}"); - - return false; - } - - EObject.RegisterObjectType(BehaviourComponent, Name, assembly); - Registered.Add(this); + Log.Warn($"Unable to register {Name}. Role already exists."); + return false; + } - TypeLookupTable.TryAdd(GetType(), this); - BehaviourLookupTable.TryAdd(BehaviourComponent, this); - IdLookupTable.TryAdd(Id, this); - NameLookupTable.TryAdd(Name, this); + if (attribute is not null && Id == 0) + { + if (attribute.Id != 0) + Id = attribute.Id; + else + throw new ArgumentException($"Unable to register {Name}. The ID 0 is reserved for special use."); + } - return true; + CustomRole duplicate = Registered.FirstOrDefault(x => x.Id == Id || x.Name == Name || x.BehaviourComponent == BehaviourComponent); + if (duplicate) + { + Log.Warn($"Unable to register {Name}. Another role with the same ID, Name or Behaviour Component already exists: {duplicate.Name}"); + return false; } - Log.Warn($"Unable to register {Name}. Role already exists."); + EObject.RegisterObjectType(BehaviourComponent, Name, assembly); + Registered.Add(this); - return false; + TypeLookupTable.TryAdd(GetType(), this); + BehaviourLookupTable.TryAdd(BehaviourComponent, this); + IdLookupTable.TryAdd(Id, this); + NameLookupTable.TryAdd(Name, this); + + return true; } ///