From 6907a0179c83be11b423559cafd619ffc487dff5 Mon Sep 17 00:00:00 2001 From: TeMbI4 Date: Sun, 21 Jul 2024 13:53:08 +0200 Subject: [PATCH 1/2] Small fixes --- Exiled.API/Features/Doors/Door.cs | 2 +- Exiled.API/Features/Items/Firearm.cs | 2 +- Exiled.API/Features/Items/Item.cs | 4 ++-- Exiled.API/Features/Player.cs | 2 ++ Exiled.API/Features/Round.cs | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Exiled.API/Features/Doors/Door.cs b/Exiled.API/Features/Doors/Door.cs index 244f176b0a..a411925ff4 100644 --- a/Exiled.API/Features/Doors/Door.cs +++ b/Exiled.API/Features/Doors/Door.cs @@ -166,7 +166,7 @@ public bool IsClosed /// /// Gets the checkpoint door the door is belonging to, or null if the door doesn't belong to a checkpoint. /// - public Door ParentCheckpointDoor { get; } + public Door ParentCheckpointDoor { get; internal set; } /// /// Gets a value indicating whether or not this door requires a keycard to open. diff --git a/Exiled.API/Features/Items/Firearm.cs b/Exiled.API/Features/Items/Firearm.cs index af0427420e..a9fff41820 100644 --- a/Exiled.API/Features/Items/Firearm.cs +++ b/Exiled.API/Features/Items/Firearm.cs @@ -63,7 +63,7 @@ internal Firearm(ItemType type) if (Base.HasAdvantageFlag(AttachmentDescriptiveAdvantages.Flashlight)) firearmStatusFlags.AddFlags(FirearmStatusFlags.FlashlightEnabled); - Base.Status = new(Base.AmmoManagerModule.MaxAmmo, firearmStatusFlags, Base.GetCurrentAttachmentsCode()); + Base.Status = new(MaxAmmo, firearmStatusFlags, Base.GetCurrentAttachmentsCode()); } /// . diff --git a/Exiled.API/Features/Items/Item.cs b/Exiled.API/Features/Items/Item.cs index ed28750f1c..a07780a99a 100644 --- a/Exiled.API/Features/Items/Item.cs +++ b/Exiled.API/Features/Items/Item.cs @@ -53,8 +53,8 @@ public Item(ItemBase itemBase) : base(itemBase.gameObject) { Base = itemBase; - BaseToItem.Add(itemBase, this); weight = itemBase.Weight; + BaseToItem.Add(itemBase, this); if (Base.ItemSerial is 0 && itemBase.Owner != null) { @@ -294,7 +294,7 @@ public static Item Get(ItemBase itemBase) public static Item Create(ItemType type, Player owner = null) => type switch { ItemType.SCP268 => new Usable(type), - ItemType.Adrenaline or ItemType.Medkit or ItemType.Painkillers or ItemType.SCP500 or ItemType.SCP207 or ItemType.SCP1853 => new Consumable(type), + ItemType.Adrenaline or ItemType.Medkit or ItemType.Painkillers or ItemType.SCP500 or ItemType.SCP207 or ItemType.AntiSCP207 or ItemType.SCP1853 => new Consumable(type), ItemType.SCP244a or ItemType.SCP244b => new Scp244(type), ItemType.Ammo9x19 or ItemType.Ammo12gauge or ItemType.Ammo44cal or ItemType.Ammo556x45 or ItemType.Ammo762x39 => new Ammo(type), ItemType.Flashlight or ItemType.Lantern => new Flashlight(type), diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index f194c827da..aeed751c80 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2461,6 +2461,8 @@ public bool UseItem(Item item) usableItem.Base.Owner = referenceHub; usableItem.Base.ServerOnUsingCompleted(); + typeof(UsableItemsController).InvokeStaticEvent(nameof(UsableItemsController.ServerOnUsingCompleted), new object[] { referenceHub, usableItem.Base }); + if (usableItem.Base is not null) usableItem.Destroy(); diff --git a/Exiled.API/Features/Round.cs b/Exiled.API/Features/Round.cs index c32b863e38..071625019b 100644 --- a/Exiled.API/Features/Round.cs +++ b/Exiled.API/Features/Round.cs @@ -51,7 +51,7 @@ public static class Round /// /// Gets a value indicating whether the round in progress or not. /// - public static bool InProgress => ReferenceHub.LocalHub is not null && RoundSummary.RoundInProgress(); + public static bool InProgress => ReferenceHub.LocalHub != null && RoundSummary.RoundInProgress(); /// /// Gets a value indicating whether the round is ended or not. From 790a65ae87bace59c8268742bd8892eb613bcb88 Mon Sep 17 00:00:00 2001 From: TeMbI4 Date: Sun, 21 Jul 2024 17:38:55 +0200 Subject: [PATCH 2/2] Fix items weight --- Exiled.API/Features/Items/Armor.cs | 2 +- Exiled.API/Features/Items/Item.cs | 13 ++----------- Exiled.API/Features/Items/Usable.cs | 2 +- Exiled.API/Features/Pickups/Pickup.cs | 7 ++----- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/Exiled.API/Features/Items/Armor.cs b/Exiled.API/Features/Items/Armor.cs index 7f6dcbe9f0..1adfee860e 100644 --- a/Exiled.API/Features/Items/Armor.cs +++ b/Exiled.API/Features/Items/Armor.cs @@ -68,7 +68,7 @@ internal Armor(ItemType type) /// Gets or sets the Weight of the armor. /// [EProperty(category: nameof(Armor))] - public override float Weight + public new float Weight { get => Base.Weight; set => Base._weight = value; diff --git a/Exiled.API/Features/Items/Item.cs b/Exiled.API/Features/Items/Item.cs index a07780a99a..3896bd2080 100644 --- a/Exiled.API/Features/Items/Item.cs +++ b/Exiled.API/Features/Items/Item.cs @@ -43,7 +43,6 @@ public class Item : GameEntity, IWrapper /// A dictionary of all 's that have been converted into . /// internal static readonly Dictionary BaseToItem = new(new ComponentsEqualityComparer()); - private float weight; /// /// Initializes a new instance of the class. @@ -53,7 +52,6 @@ public Item(ItemBase itemBase) : base(itemBase.gameObject) { Base = itemBase; - weight = itemBase.Weight; BaseToItem.Add(itemBase, this); if (Base.ItemSerial is 0 && itemBase.Owner != null) @@ -130,14 +128,10 @@ public ushort Serial public ItemTierFlags TierFlags => Base.TierFlags; /// - /// Gets or sets the Weight of the item. + /// Gets the Weight of the item. /// [EProperty(category: nameof(Item))] - public virtual float Weight - { - get => weight; - set => weight = value; - } + public float Weight => Base.Weight; /// /// Gets a value indicating whether or not this item is ammunition. @@ -394,10 +388,7 @@ internal virtual void ChangeOwner(Player oldOwner, Player newOwner) internal virtual void ReadPickupInfo(Pickup pickup) { if (pickup is not null) - { Scale = pickup.Scale; - Weight = pickup.Weight; - } } } } diff --git a/Exiled.API/Features/Items/Usable.cs b/Exiled.API/Features/Items/Usable.cs index 09b2613df1..ec62d4ac0e 100644 --- a/Exiled.API/Features/Items/Usable.cs +++ b/Exiled.API/Features/Items/Usable.cs @@ -60,7 +60,7 @@ internal Usable(ItemType type) /// Gets or sets the weight of the item. /// [EProperty(category: nameof(Usable))] - public override float Weight + public new float Weight { get => Base._weight; set => Base._weight = value; diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index a1cff948fc..da388823db 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -47,8 +47,8 @@ public class Pickup : GameEntity, IWrapper /// internal static readonly Dictionary BaseToPickup = new(new ComponentsEqualityComparer()); - private readonly ConstProperty minPickupTime = new(0.24500000476837158, new[] { typeof(ItemPickupBase) }); - private readonly ConstProperty weightToTime = new(0.17499999701976776, new[] { typeof(ItemPickupBase) }); + private readonly ConstProperty minPickupTime = new(0.245d, new[] { typeof(ItemPickupBase) }); + private readonly ConstProperty weightToTime = new(0.175d, new[] { typeof(ItemPickupBase) }); /// /// Initializes a new instance of the class. @@ -611,10 +611,7 @@ public void UnSpawn() internal virtual void ReadItemInfo(Items.Item item) { if (item is not null) - { Scale = item.Scale; - Weight = item.Weight; - } } ///