Skip to content

Commit

Permalink
refactor: use get effect instead of creating a new instance
Browse files Browse the repository at this point in the history
  • Loading branch information
BoltonDev committed Jun 2, 2024
1 parent ae4fbf3 commit 2331888
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Exiled.API/Extensions/EffectTypeExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Exiled.API.Extensions
using CustomPlayerEffects;
using CustomRendering;
using Enums;
using Exiled.API.Features;
using InventorySystem.Items.MarshmallowMan;
using InventorySystem.Items.Usables.Scp244.Hypothermia;
using PlayerRoles.FirstPersonControl;
Expand Down Expand Up @@ -154,15 +155,15 @@ or EffectType.Corroding or EffectType.Decontaminating or EffectType.Hemorrhage o
/// <param name="effect">The <see cref="EffectType"/>.</param>
/// <returns>Whether or not the effect is a negative effect.</returns>
/// <seealso cref="IsHarmful(EffectType)"/>
public static bool IsNegative(this EffectType effect) => IsHarmful(effect) || (EffectTypeToType.TryGetValue(effect, out Type type) && type.IsSubclassOf(typeof(StatusEffectBase)) && ((StatusEffectBase)Activator.CreateInstance(type)).Classification == StatusEffectBase.EffectClassification.Negative);
public static bool IsNegative(this EffectType effect) => IsHarmful(effect) || Server.Host.GetEffect(effect).Classification == StatusEffectBase.EffectClassification.Negative;

/// <summary>
/// Returns whether or not the provided <paramref name="effect"/> is a positive effect.
/// </summary>
/// <param name="effect">The <see cref="EffectType"/>.</param>
/// <returns>Whether or not the effect is a positive effect.</returns>
/// <seealso cref="IsHealing(EffectType)"/>
public static bool IsPositive(this EffectType effect) => EffectTypeToType.TryGetValue(effect, out Type type) && type.IsSubclassOf(typeof(StatusEffectBase)) && ((StatusEffectBase)Activator.CreateInstance(type)).Classification == StatusEffectBase.EffectClassification.Positive;
public static bool IsPositive(this EffectType effect) => Server.Host.GetEffect(effect).Classification == StatusEffectBase.EffectClassification.Positive;

/// <summary>
/// Returns whether or not the provided <paramref name="effect"/> affects the player's movement speed.
Expand Down

0 comments on commit 2331888

Please sign in to comment.