diff --git a/EXILED/Exiled.API/Features/Items/FirearmModules/Magazine.cs b/EXILED/Exiled.API/Features/Items/FirearmModules/Magazine.cs index 50a2538c64..8fb2688bb7 100644 --- a/EXILED/Exiled.API/Features/Items/FirearmModules/Magazine.cs +++ b/EXILED/Exiled.API/Features/Items/FirearmModules/Magazine.cs @@ -11,9 +11,8 @@ namespace Exiled.API.Features.Items.FirearmModules using Exiled.API.Features.Items.FirearmModules.Barrel; using Exiled.API.Features.Items.FirearmModules.Primary; - using InventorySystem.Items.Firearms.Modules; - + using InventorySystem.Items.Firearms.Modules.Scp127; using UnityEngine; /// @@ -66,8 +65,12 @@ public static Magazine Get(IAmmoContainerModule module) PumpActionModule pump => new PumpBarrelMagazine(pump), IPrimaryAmmoContainerModule primary => primary switch { - MagazineModule magazine => new NormalMagazine(magazine), CylinderAmmoModule cylinder => new CylinderMagazine(cylinder), + MagazineModule magazine => magazine switch + { + Scp127MagazineModule scp127MagazineModule => new Scp127Magazine(scp127MagazineModule), + _ => new NormalMagazine(magazine) + }, _ => null, }, _ => null, diff --git a/EXILED/Exiled.API/Features/Items/FirearmModules/Primary/Scp127Magazine.cs b/EXILED/Exiled.API/Features/Items/FirearmModules/Primary/Scp127Magazine.cs new file mode 100644 index 0000000000..c3226169ea --- /dev/null +++ b/EXILED/Exiled.API/Features/Items/FirearmModules/Primary/Scp127Magazine.cs @@ -0,0 +1,80 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Items.FirearmModules.Primary +{ + using InventorySystem.Items.Firearms.Modules.Scp127; + + /// + /// Represents a normal magazine for SCP-127. + /// + public class Scp127Magazine : NormalMagazine + { + /// + /// Initializes a new instance of the class. + /// + /// + public Scp127Magazine(Scp127MagazineModule magazine) + : base(magazine) + { + MagazineModule = magazine; + } + + /// + public new Scp127MagazineModule MagazineModule { get; } + + /// + /// Gets or sets the kill bonus. + /// + public int KillBonus + { + get => MagazineModule.KillBonus; + set => MagazineModule.KillBonus = value; + } + + /// + /// Gets or sets the rank up bonus. + /// + public int RankUpBonus + { + get => MagazineModule.RankUpBonus; + set => MagazineModule.RankUpBonus = value; + } + + /// + /// Gets or sets all settings. + /// + public Scp127MagazineModule.RegenerationSettings[] RegenerationPerTier + { + get => MagazineModule._regenerationPerTier; + set => MagazineModule._regenerationPerTier = value; + } + + /// + /// Gets the current setting. + /// + public Scp127MagazineModule.RegenerationSettings ActiveSetting => MagazineModule.ActiveSettings; + + /// + /// Gets or sets a pause in bullets regeneration process. + /// + public float RemainingRegenPause + { + get => MagazineModule._remainingRegenPause; + set => MagazineModule._remainingRegenPause = value; + } + + /// + /// Gets or sets the amount of bullets that should be regenerated. + /// + public float RegenProgress + { + get => MagazineModule._regenProgress; + set => MagazineModule._regenProgress = value; + } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Items/Item.cs b/EXILED/Exiled.API/Features/Items/Item.cs index f9d8a74a0d..04d4b72535 100644 --- a/EXILED/Exiled.API/Features/Items/Item.cs +++ b/EXILED/Exiled.API/Features/Items/Item.cs @@ -218,7 +218,11 @@ public static Item Get(ItemBase itemBase) return itemBase switch { - InventorySystem.Items.Firearms.Firearm firearm => new Firearm(firearm), + InventorySystem.Items.Firearms.Firearm firearm => firearm.ItemTypeId switch + { + ItemType.GunSCP127 => new Scp127(firearm), + _ => new Firearm(firearm), + }, KeycardItem keycard => keycard switch { ChaosKeycardItem chaosKeycardItem => new ChaosKeycard(chaosKeycardItem), @@ -318,7 +322,11 @@ public static T Get(ushort serial) /// The created. This can be cast as a subclass. public static Item Create(ItemType type, Player owner = null) => type.GetTemplate() switch { - InventorySystem.Items.Firearms.Firearm => new Firearm(type), + InventorySystem.Items.Firearms.Firearm => type switch + { + ItemType.GunSCP127 => new Scp127(), + _ => new Firearm(type), + }, KeycardItem keycard => keycard switch { ChaosKeycardItem => new ChaosKeycard(type), diff --git a/EXILED/Exiled.API/Features/Items/Scp127.cs b/EXILED/Exiled.API/Features/Items/Scp127.cs new file mode 100644 index 0000000000..2c71fbe4bb --- /dev/null +++ b/EXILED/Exiled.API/Features/Items/Scp127.cs @@ -0,0 +1,274 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Items +{ + using System.Collections.Generic; + using System.Linq; + + using InventorySystem.Items.Firearms.Modules; + using InventorySystem.Items.Firearms.Modules.Scp127; + using UnityEngine; + + /// + /// Represents SCP-127. + /// + public class Scp127 : Firearm + { + #pragma warning disable SA1401 + /// + /// Custom amount of max HS. + /// + internal float? CustomHsMax; + #pragma warning restore SA1401 + + /// + /// Initializes a new instance of the class. + /// + /// + public Scp127(InventorySystem.Items.Firearms.Firearm itemBase) + : base(itemBase) + { + foreach (ModuleBase module in Base.Modules) + { + switch (module) + { + case Scp127HumeModule humeModule: + HumeModule = humeModule; + break; + case Scp127TierManagerModule tierManagerModule: + TierManagerModule = tierManagerModule; + break; + case Scp127VoiceLineManagerModule voiceLineManagerModule: + VoiceLineManagerModule = voiceLineManagerModule; + break; + } + } + } + + /// + /// Initializes a new instance of the class. + /// + internal Scp127() + : this((InventorySystem.Items.Firearms.Firearm)Server.Host.Inventory.CreateItemInstance(new(ItemType.GunSCP127, 0), false)) + { + } + + /// + /// Gets a collection of all active HS sessions. + /// + public static List ActiveHumeShieldSessions => Scp127HumeModule.ServerActiveSessions; + + /// + /// Gets the instance. + /// + public Scp127HumeModule HumeModule { get; } + + /// + /// Gets the instance. + /// + public Scp127TierManagerModule TierManagerModule { get; } + + /// + /// Gets the instance. + /// + public Scp127VoiceLineManagerModule VoiceLineManagerModule { get; } + + /// + /// Gets or sets the maximum amount of HS. + /// + /// If setter is used, after tier chance this value won't be edited automatically. + public float HsMax + { + get => CustomHsMax ?? HumeModule.HsMax; + set => CustomHsMax = value; + } + + /// + /// Gets or sets a shield regeneration rate. + /// + public float ShieldRegenRate + { + get => HumeModule.ShieldRegenRate; + set => HumeModule.ShieldRegenRate = value; + } + + /// + /// Gets or sets a shield decay time. + /// + public float ShieldDecayRate + { + get => HumeModule.ShieldDecayRate; + set => HumeModule.ShieldDecayRate = value; + } + + /// + /// Gets or sets a pause before HS starts regeneration after damage being taken. + /// + public float ShieldOnDamagePause + { + get => HumeModule.ShieldOnDamagePause; + set => HumeModule.ShieldOnDamagePause = value; + } + + /// + /// Gets or sets a delay before HS starts dropping after unequipment. + /// + public float UnequipDecayDelay + { + get => HumeModule.UnequipDecayDelay; + set => HumeModule.UnequipDecayDelay = value; + } + + /// + /// Gets or sets a HumeShield regeneration. + /// + public float HsRegeneration + { + get => HumeModule.HsRegeneration; + set => HumeModule.HsRegeneration = value; + } + + /// + /// Gets or sets an experience bonus for kill. + /// + public float KillBonus + { + get => TierManagerModule.KillBonus; + set => TierManagerModule.KillBonus = value; + } + + /// + /// Gets or sets an amount of passive experience increase. + /// + public float PassiveExpAmount + { + get => TierManagerModule.PassiveExpAmount; + set => TierManagerModule.PassiveExpAmount = value; + } + + /// + /// Gets or sets an interval of passive experience increase. + /// + public float PassiveExpInterval + { + get => TierManagerModule.PassiveExpInterval; + set => TierManagerModule.PassiveExpInterval = value; + } + + /// + /// Gets or sets a collection of all tier thresholds. + /// + public Scp127TierManagerModule.TierThreshold[] TierThresholds + { + get => TierManagerModule.Thresholds; + set => TierManagerModule.Thresholds = value; + } + + /// + /// Gets or sets current tier. + /// + public Scp127Tier CurrentTier + { + get => TierManagerModule.CurTier; + set => TierManagerModule.CurTier = value; + } + + /// + /// Gets or sets the current experience amount. + /// + public float Experience + { + get => TierManagerModule.ServerExp; + set => TierManagerModule.ServerExp = value; + } + + /// + /// Gets the instance record. + /// + public Scp127TierManagerModule.InstanceRecord InstanceRecord => Scp127TierManagerModule.GetRecord(Serial); + + /// + /// Gets the Owner stats. + /// + public Scp127TierManagerModule.OwnerStats OwnerStats => Scp127TierManagerModule.GetStats(Base); + + /// + /// Gets or sets all Voice Triggers. + /// + public Scp127VoiceTriggerBase[] VoiceTriggers + { + get => VoiceLineManagerModule._foundTriggers; + set => VoiceLineManagerModule._foundTriggers = value; + } + + /// + /// Gets a collection of players that are friends with this SCP-127. + /// + public IEnumerable Friends + { + get + { + if (!Scp127VoiceLineManagerModule.FriendshipMemory.TryGetValue(Serial, out HashSet uintSet)) + return null; + + return uintSet.Select(Player.Get); + } + } + + /// + /// Increases experience. + /// + /// Amount to add. + public void IncreaseExperience(float amount) => TierManagerModule.ServerIncreaseExp(Base, amount); + + /// + /// Sets owner stats. + /// + /// New experience amount. + public void SetOwnerStats(float exp) => TierManagerModule.ServerSetStats(exp); + + /// + /// Sends tier stats. + /// + /// New tier. + /// New progress. + public void SendTierStats(Scp127Tier tier, byte progress) => TierManagerModule.ServerSendStats(Serial, Owner.ReferenceHub, tier, progress); + + /// + /// Tries to play voice line. + /// + /// Voice line to play. + /// Priority of the play. + /// true if voice line has been played successfully. Otherwise, false. + public bool TryPlayVoiceLine(Scp127VoiceLinesTranslation voiceLine, Scp127VoiceTriggerBase.VoiceLinePriority priority = Scp127VoiceTriggerBase.VoiceLinePriority.Normal) + { + if (!VoiceLineManagerModule.TryFindVoiceLine(voiceLine, out Scp127VoiceTriggerBase triggerBase, out AudioClip audioClip)) + return false; + + VoiceLineManagerModule.ServerSendVoiceLine(triggerBase, null, audioClip, (byte)priority); + return true; + } + + /// + /// Checks if this instance of SCP-127 and have friendship. + /// + /// Target to check. + /// true if this instance of SCP-127 and have friendship. Otherwise, false. + public bool HasFriendship(Player player) => Scp127VoiceLineManagerModule.HasFriendship(Serial, player.ReferenceHub); + + /// + /// Adds player as a friend. + /// + /// Target to be added. + public void AddFriend(Player player) + { + HashSet uints = Scp127VoiceLineManagerModule.FriendshipMemory.GetOrAddNew(Serial); + uints.Add(player.NetId); + } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Interfaces/IScp127Event.cs b/EXILED/Exiled.Events/EventArgs/Interfaces/IScp127Event.cs new file mode 100644 index 0000000000..616ad8f3e5 --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Interfaces/IScp127Event.cs @@ -0,0 +1,20 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Interfaces +{ + /// + /// Represents all events related to SCP-127. + /// + public interface IScp127Event : IItemEvent + { + /// + /// Gets the SCP-127 instance, related to this event. + /// + public API.Features.Items.Scp127 Scp127 { get; } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Scp127/GainedExperienceEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp127/GainedExperienceEventArgs.cs new file mode 100644 index 0000000000..533ccbb5ce --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Scp127/GainedExperienceEventArgs.cs @@ -0,0 +1,51 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp127 +{ + using Exiled.API.Features; + using Exiled.API.Features.Items; + using Exiled.Events.EventArgs.Interfaces; + using InventorySystem.Items.Firearms.Modules.Scp127; + + /// + /// Contains all information before SCP-127 gains experience. + /// + public class GainedExperienceEventArgs : IScp127Event + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + public GainedExperienceEventArgs(Scp127 scp127, float experience) + { + Scp127 = scp127; + Experience = experience; + Tier = Scp127.TierManagerModule.GetTierForExp(Experience + Scp127.Experience); + } + + /// + public Player Player => Scp127.Owner; + + /// + public Item Item => Scp127; + + /// + public Scp127 Scp127 { get; } + + /// + /// Gets the experience that SCP-127 has gained. + /// + public float Experience { get; } + + /// + /// Gets the tier. + /// + public Scp127Tier Tier { get; } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Scp127/GainingExperienceEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp127/GainingExperienceEventArgs.cs new file mode 100644 index 0000000000..6a1d7b738b --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Scp127/GainingExperienceEventArgs.cs @@ -0,0 +1,59 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp127 +{ + using Exiled.API.Features; + using Exiled.API.Features.Items; + using Exiled.Events.EventArgs.Interfaces; + using InventorySystem.Items.Firearms.Modules.Scp127; + + /// + /// Contains all information before SCP-127 gains experience. + /// + public class GainingExperienceEventArgs : IScp127Event, IDeniableEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + public GainingExperienceEventArgs(Scp127 scp127, float experience, bool isAllowed = true) + { + Scp127 = scp127; + Experience = experience; + IsAllowed = isAllowed; + } + + /// + public Player Player => Scp127.Owner; + + /// + public Item Item => Scp127; + + /// + public Scp127 Scp127 { get; } + + /// + public bool IsAllowed { get; set; } + + /// + /// Gets or sets the gaining experience. + /// + public float Experience { get; set; } + + /// + /// Gets or sets the new tier. + /// + public Scp127Tier Tier + { + get => Scp127.TierManagerModule.GetTierForExp(Experience + Scp127.Experience); + set => Experience = Scp127.TierManagerModule.GetExpForTier(value) - Scp127.Experience; + } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Scp127/TalkedEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp127/TalkedEventArgs.cs new file mode 100644 index 0000000000..10810403d5 --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Scp127/TalkedEventArgs.cs @@ -0,0 +1,52 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp127 +{ + using Exiled.API.Features; + using Exiled.API.Features.Items; + using Exiled.Events.EventArgs.Interfaces; + using InventorySystem.Items.Firearms.Modules.Scp127; + + /// + /// Contains all information after SCP-127 voice line is played. + /// + public class TalkedEventArgs : IScp127Event + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + public TalkedEventArgs(Scp127 scp127, Scp127VoiceLinesTranslation voiceLine, Scp127VoiceTriggerBase.VoiceLinePriority voiceLinePriority) + { + Scp127 = scp127; + VoiceLine = voiceLine; + Priority = voiceLinePriority; + } + + /// + public Player Player => Scp127.Owner; + + /// + public Item Item => Scp127; + + /// + public Scp127 Scp127 { get; } + + /// + /// Gets a voice line which is played. + /// + public Scp127VoiceLinesTranslation VoiceLine { get; } + + /// + /// Gets a priority for this play. + /// + public Scp127VoiceTriggerBase.VoiceLinePriority Priority { get; } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/EventArgs/Scp127/TalkingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp127/TalkingEventArgs.cs new file mode 100644 index 0000000000..b8934566a8 --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Scp127/TalkingEventArgs.cs @@ -0,0 +1,57 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp127 +{ + using Exiled.API.Features; + using Exiled.API.Features.Items; + using Exiled.Events.EventArgs.Interfaces; + using InventorySystem.Items.Firearms.Modules.Scp127; + + /// + /// Contains all information before SCP-127 voice line is played. + /// + public class TalkingEventArgs : IScp127Event, IDeniableEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + public TalkingEventArgs(Scp127 scp127, Scp127VoiceLinesTranslation voiceLine, Scp127VoiceTriggerBase.VoiceLinePriority voiceLinePriority, bool isAllowed = true) + { + Scp127 = scp127; + VoiceLine = voiceLine; + Priority = voiceLinePriority; + IsAllowed = isAllowed; + } + + /// + public Player Player => Scp127.Owner; + + /// + public Item Item => Scp127; + + /// + public Scp127 Scp127 { get; } + + /// + public bool IsAllowed { get; set; } + + /// + /// Gets or sets a voice line which is played. + /// + public Scp127VoiceLinesTranslation VoiceLine { get; set; } + + /// + /// Gets or sets a priority for this play. + /// + public Scp127VoiceTriggerBase.VoiceLinePriority Priority { get; set; } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Events.cs b/EXILED/Exiled.Events/Events.cs index 1645fe20a1..2bffa6a8f9 100644 --- a/EXILED/Exiled.Events/Events.cs +++ b/EXILED/Exiled.Events/Events.cs @@ -92,6 +92,11 @@ public override void OnEnabled() LabApi.Events.Handlers.PlayerEvents.ReloadingWeapon += Handlers.Player.OnReloadingWeapon; LabApi.Events.Handlers.PlayerEvents.UnloadingWeapon += Handlers.Player.OnUnloadingWeapon; + LabApi.Events.Handlers.Scp127Events.Talking += Handlers.Scp127.OnTalking; + LabApi.Events.Handlers.Scp127Events.Talked += Handlers.Scp127.OnTalked; + LabApi.Events.Handlers.Scp127Events.GainingExperience += Handlers.Scp127.OnGainingExperience; + LabApi.Events.Handlers.Scp127Events.GainExperience += Handlers.Scp127.OnGainedExperience; + ServerConsole.ReloadServerName(); } @@ -129,6 +134,11 @@ public override void OnDisabled() LabApi.Events.Handlers.PlayerEvents.ReloadingWeapon -= Handlers.Player.OnReloadingWeapon; LabApi.Events.Handlers.PlayerEvents.UnloadingWeapon -= Handlers.Player.OnUnloadingWeapon; + + LabApi.Events.Handlers.Scp127Events.Talking -= Handlers.Scp127.OnTalking; + LabApi.Events.Handlers.Scp127Events.Talked -= Handlers.Scp127.OnTalked; + LabApi.Events.Handlers.Scp127Events.GainingExperience -= Handlers.Scp127.OnGainingExperience; + LabApi.Events.Handlers.Scp127Events.GainExperience -= Handlers.Scp127.OnGainedExperience; } /// diff --git a/EXILED/Exiled.Events/Handlers/Scp127.cs b/EXILED/Exiled.Events/Handlers/Scp127.cs new file mode 100644 index 0000000000..b3f86534d3 --- /dev/null +++ b/EXILED/Exiled.Events/Handlers/Scp127.cs @@ -0,0 +1,81 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Handlers +{ + using Exiled.Events.EventArgs.Scp127; + using Exiled.Events.Features; + using LabApi.Events.Arguments.Scp127Events; + +#pragma warning disable SA1623 + /// + /// SCP-127 event handlers. + /// + public static class Scp127 + { + /// + /// Invoked before SCP-127 voice line is played. + /// + public static Event Talking { get; set; } = new(); + + /// + /// Invoked after SCP-127 voice line is played. + /// + public static Event Talked { get; set; } = new(); + + /// + /// Invoked before SCP-127 gains experience. + /// + public static Event GainingExperience { get; set; } = new(); + + /// + /// Invoked after SCP-127 gains experience. + /// + public static Event GainedExperience { get; set; } = new(); + + /// + /// Called before SCP-127 voice line is played. + /// + /// The instance. + public static void OnTalking(Scp127TalkingEventArgs ev) + { + TalkingEventArgs eventArgs = new(API.Features.Items.Item.Get(ev.Scp127Item.Base), ev.VoiceLine, ev.Priority, ev.IsAllowed); + Talking.InvokeSafely(eventArgs); + + ev.Priority = eventArgs.Priority; + ev.VoiceLine = eventArgs.VoiceLine; + ev.IsAllowed = eventArgs.IsAllowed; + } + + /// + /// Called after SCP-127 voice line is played. + /// + /// The instance. + public static void OnTalked(Scp127TalkedEventArgs ev) + => Talked.InvokeSafely(new(API.Features.Items.Item.Get(ev.Scp127Item.Base), ev.VoiceLine, ev.Priority)); + + /// + /// Called before SCP-127 gains experience. + /// + /// The instance. + public static void OnGainingExperience(Scp127GainingExperienceEventArgs ev) + { + GainingExperienceEventArgs eventArgs = new(API.Features.Items.Item.Get(ev.Scp127Item.Base), ev.ExperienceGain, ev.IsAllowed); + GainingExperience.InvokeSafely(eventArgs); + + ev.ExperienceGain = eventArgs.Experience; + ev.IsAllowed = eventArgs.IsAllowed; + } + + /// + /// Called after SCP-127 gains experience. + /// + /// The instance. + public static void OnGainedExperience(Scp127GainExperienceEventArgs ev) => + GainedExperience.InvokeSafely(new(API.Features.Items.Item.Get(ev.Scp127Item.Base), ev.ExperienceGain)); + } +} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Generic/Scp127MaxHs.cs b/EXILED/Exiled.Events/Patches/Generic/Scp127MaxHs.cs new file mode 100644 index 0000000000..c98d2d57c2 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Generic/Scp127MaxHs.cs @@ -0,0 +1,32 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic +{ + using Exiled.API.Features.Items; + using HarmonyLib; + using InventorySystem.Items.Firearms.Modules.Scp127; + +#pragma warning disable SA1313 + /// + /// Patches to implement setter. + /// + [HarmonyPatch(typeof(Scp127HumeModule), nameof(Scp127HumeModule.HsMax), MethodType.Getter)] + internal class Scp127MaxHs + { + private static void Postfix(Scp127HumeModule __instance, ref float __result) + { + Scp127 item = Item.Get(__instance.ItemSerial); + + if (item == null || !item.CustomHsMax.HasValue) + return; + + __result = item.CustomHsMax.Value; + return; + } + } +} \ No newline at end of file