Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
NaoUnderscore committed Jan 29, 2024
2 parents 9e94a54 + fec1183 commit 14abdd5
Show file tree
Hide file tree
Showing 385 changed files with 3,605 additions and 2,836 deletions.
567 changes: 5 additions & 562 deletions .editorconfig

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion EXILED.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PropertyGroup>
<!-- This is the global version and is used for all projects that don't have a version -->
<Version Condition="$(Version) == ''">8.4.3</Version>
<Version Condition="$(Version) == ''">8.7.0</Version>
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
<PublicBeta>false</PublicBeta>

Expand Down
8 changes: 7 additions & 1 deletion Exiled.API/Enums/EffectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ namespace Exiled.API.Enums
/// <summary>
/// Status effects as enum.
/// </summary>
/// <seealso cref="EffectTypeExtension.Type(EffectType)"/>
/// <seealso cref="EffectTypeExtension.TryGetEffectType(CustomPlayerEffects.StatusEffectBase, out EffectType)"/>
/// <seealso cref="EffectTypeExtension.TryGetType(EffectType, out Type)"/>
public enum EffectType
{
/// <summary>
/// This EffectType do not exist it's only use when not found or error.
/// </summary>
None = -1, // TODO: remove = -1

/// <summary>
/// The player isn't able to open their inventory or reload a weapon.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Exiled.API/Enums/Side.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public enum Side
/// <summary>
/// SCP team. Same as <see cref="Team.SCPs"/>.
/// Contains all SCP-related roles: <see cref="RoleTypeId.Scp049"/>, <see cref="RoleTypeId.Scp0492"/>, <see cref="RoleTypeId.Scp079"/>, <see cref="RoleTypeId.Scp096"/>,
/// <see cref="RoleTypeId.Scp106"/>, <see cref="RoleTypeId.Scp173"/>, and <see cref="RoleTypeId.Scp939"/>.
/// <see cref="RoleTypeId.Scp106"/>, <see cref="RoleTypeId.Scp173"/>, <see cref="RoleTypeId.Scp939"/>, and <see cref="RoleTypeId.Scp3114"/>.
/// </summary>
Scp,

Expand Down
4 changes: 2 additions & 2 deletions Exiled.API/Extensions/CommonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static class CommonExtensions
/// <returns>The new modfied curve.</returns>
public static AnimationCurve Multiply(this AnimationCurve curve, float amount)
{
for (var i = 0; i < curve.length; i++)
for (int i = 0; i < curve.length; i++)
curve.keys[i].value *= amount;

return curve;
Expand All @@ -56,7 +56,7 @@ public static AnimationCurve Multiply(this AnimationCurve curve, float amount)
/// <returns>The new modfied curve.</returns>
public static AnimationCurve Add(this AnimationCurve curve, float amount)
{
for (var i = 0; i < curve.length; i++)
for (int i = 0; i < curve.length; i++)
curve.keys[i].value += amount;

return curve;
Expand Down
32 changes: 29 additions & 3 deletions Exiled.API/Extensions/EffectTypeExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public static class EffectTypeExtension
public static Type Type(this EffectType effect)
=> EffectTypeToType.TryGetValue(effect, out Type type) ? type : throw new InvalidOperationException("Invalid effect enum provided");

/// <summary>
/// Gets an instance of <see cref="System.Type"/> points to an effect.
/// </summary>
/// <param name="effect">The <see cref="EffectType"/> enum.</param>
/// <param name="type">The type found with the corresponding EffecType.</param>
/// <returns>Whether or not the effectType has been found.</returns>
public static bool TryGetType(this EffectType effect, out Type type)
=> EffectTypeToType.TryGetValue(effect, out type);

/// <summary>
/// Gets the <see cref="EffectType"/> of the specified <see cref="StatusEffectBase"/>.
/// </summary>
Expand All @@ -93,6 +102,23 @@ public static Type Type(this EffectType effect)
public static EffectType GetEffectType(this StatusEffectBase statusEffectBase)
=> TypeToEffectType.TryGetValue(statusEffectBase.GetType(), out EffectType effect) ? effect : throw new InvalidOperationException("Invalid effect status base provided");

/// <summary>
/// Gets the <see cref="EffectType"/> of the specified <see cref="StatusEffectBase"/>.
/// </summary>
/// <param name="statusEffectBase">The <see cref="StatusEffectBase"/> enum.</param>
/// <param name="effect">The effect found.</param>
/// <returns>Whether or not the effect has been found.</returns>
public static bool TryGetEffectType(this StatusEffectBase statusEffectBase, out EffectType effect)
{
if (statusEffectBase == null || !TypeToEffectType.TryGetValue(statusEffectBase.GetType(), out effect))
{
effect = EffectType.None;
return false;
}

return true;
}

/// <summary>
/// Returns whether or not the provided <paramref name="effect"/> drains health over time.
/// </summary>
Expand All @@ -109,7 +135,7 @@ public static EffectType GetEffectType(this StatusEffectBase statusEffectBase)
/// <param name="effect">The <see cref="EffectType"/>.</param>
/// <returns>Whether or not the effect heals.</returns>
/// <seealso cref="IsHarmful(EffectType)"/>
public static bool IsHealing(this EffectType effect) => typeof(IHealablePlayerEffect).IsAssignableFrom(effect.Type());
public static bool IsHealing(this EffectType effect) => effect.TryGetType(out Type type) && typeof(IHealablePlayerEffect).IsAssignableFrom(type);

/// <summary>
/// Returns whether or not the provided <paramref name="effect"/> is a negative effect.
Expand Down Expand Up @@ -137,14 +163,14 @@ public static EffectType GetEffectType(this StatusEffectBase statusEffectBase)
/// </summary>
/// <param name="effect">The <see cref="EffectType"/>.</param>
/// <returns>Whether or not the effect modifies the player's movement speed.</returns>
public static bool IsMovement(this EffectType effect) => typeof(IMovementSpeedModifier).IsAssignableFrom(effect.Type());
public static bool IsMovement(this EffectType effect) => effect.TryGetType(out Type type) && typeof(IMovementSpeedModifier).IsAssignableFrom(type);

/// <summary>
/// Returns whether or not the provided <paramref name="effect"/> is displayed to spectators as text.
/// </summary>
/// <param name="effect">The <see cref="EffectType"/>.</param>
/// <returns>Whether or not the effect is displayed to spectators as text.</returns>
public static bool IsDisplayed(this EffectType effect) => typeof(ISpectatorDataPlayerEffect).IsAssignableFrom(effect.Type());
public static bool IsDisplayed(this EffectType effect) => effect.TryGetType(out Type type) && typeof(ISpectatorDataPlayerEffect).IsAssignableFrom(type);

/// <summary>
/// Returns the <see cref="EffectCategory"/> of the given <paramref name="effect"/>.
Expand Down
9 changes: 8 additions & 1 deletion Exiled.API/Extensions/ItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Exiled.API.Extensions
using InventorySystem;
using InventorySystem.Items;
using InventorySystem.Items.Firearms.Attachments;

using InventorySystem.Items.Pickups;
using Structs;

/// <summary>
Expand Down Expand Up @@ -96,6 +96,13 @@ public static ItemBase GetItemBase(this ItemType type)
return itemBase;
}

/// <summary>
/// Given an <see cref="ItemType"/>, returns the matching <see cref="ItemPickupBase"/>.
/// </summary>
/// <param name="type">The <see cref="ItemType"/>.</param>
/// <returns>The <see cref="ItemPickupBase"/>, or <see langword="null"/> if not found.</returns>
public static ItemPickupBase GetPickupBase(this ItemType type) => GetItemBase(type)?.PickupDropModel;

/// <summary>
/// Given an <see cref="ItemType"/>, returns the matching <see cref="ItemBase"/>, casted to <typeparamref name="T"/>.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Exiled.API/Extensions/ReflectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public static void InvokeStaticMethod(this Type type, string methodName, object[
/// <param name="param">The event arguments.</param>
public static void InvokeStaticEvent(this Type type, string eventName, object[] param)
{
var eventDelegate = (MulticastDelegate)type.GetField(eventName, AccessTools.all).GetValue(null);
MulticastDelegate eventDelegate = (MulticastDelegate)type.GetField(eventName, AccessTools.all).GetValue(null);
if (eventDelegate != null)
{
foreach (var handler in eventDelegate.GetInvocationList())
foreach (Delegate handler in eventDelegate.GetInvocationList())
{
handler.Method.Invoke(handler.Target, param);
}
Expand Down
6 changes: 3 additions & 3 deletions Exiled.API/Features/Doors/CheckpointDoor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public float Health
{
float health = value / Subdoors.Count;

foreach (var door in Subdoors)
foreach (BreakableDoor door in Subdoors)
{
door.Health = health;
}
Expand All @@ -108,7 +108,7 @@ public float MaxHealth
{
float health = value / Subdoors.Count;

foreach (var door in Subdoors)
foreach (BreakableDoor door in Subdoors)
{
door.MaxHealth = health;
}
Expand All @@ -121,7 +121,7 @@ public DoorDamageType IgnoredDamage
get => Subdoors.Aggregate(DoorDamageType.None, (current, door) => current | door.IgnoredDamage);
set
{
foreach (var door in Subdoors)
foreach (BreakableDoor door in Subdoors)
{
door.IgnoredDamage = value;
}
Expand Down
6 changes: 3 additions & 3 deletions Exiled.API/Features/Doors/Gate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ public Gate(PryableDoor door, List<Room> room)
/// <summary>
/// Gets a value indicating whether or not the door is fully closed.
/// </summary>
public override bool IsFullyClosed => base.IsFullyClosed && RemainingPryCooldown > 0;
public override bool IsFullyClosed => base.IsFullyClosed && RemainingPryCooldown <= 0;

/// <summary>
/// Gets a value indicating whether the door is fully open.
/// </summary>
public override bool IsFullyOpen => base.IsFullyOpen && RemainingPryCooldown <= 0;
public override bool IsFullyOpen => base.IsFullyOpen;

/// <summary>
/// Gets a value indicating whether or not the door is currently moving.
/// </summary>
public override bool IsMoving => base.IsMoving && RemainingPryCooldown > 0;
public override bool IsMoving => base.IsMoving || RemainingPryCooldown > 0;

/// <summary>
/// Gets or sets remaining cooldown for prying.
Expand Down
4 changes: 3 additions & 1 deletion Exiled.API/Features/Effect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public Effect()
/// <param name="statusEffectBase">Get all the information of the effect>.</param>
public Effect(StatusEffectBase statusEffectBase)
{
Type = statusEffectBase.GetEffectType();
if (!statusEffectBase.TryGetEffectType(out EffectType effect))
Log.Error($"EffectType not found please report to Exiled BugReport : {statusEffectBase}");
Type = effect;
Duration = statusEffectBase.Duration;
Intensity = statusEffectBase.Intensity;
IsEnabled = statusEffectBase.IsEnabled;
Expand Down
2 changes: 1 addition & 1 deletion Exiled.API/Features/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public bool IsActivating
public bool IsOpen
{
get => Base.HasFlag(Base.Network_flags, Scp079Generator.GeneratorFlags.Open);
set => Base.ServerSetFlag(Scp079Generator.GeneratorFlags.Unlocked, value);
set => Base.ServerSetFlag(Scp079Generator.GeneratorFlags.Open, value);
}

/// <summary>
Expand Down
13 changes: 13 additions & 0 deletions Exiled.API/Features/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,19 @@ public virtual Pickup CreatePickup(Vector3 position, Quaternion rotation = defau
/// <returns>A string containing Item-related data.</returns>
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* ={Owner}=";

/// <summary>
/// Changes the owner of the <see cref="Item"/>.
/// </summary>
/// <param name="oldOwner">Old <see cref="Item"/> owner.</param>
/// <param name="newOwner">New <see cref="Item"/> owner.</param>
public void ChangeItemOwner(Player oldOwner, Player newOwner)
{
if (oldOwner != null && newOwner != null)
{
ChangeOwner(oldOwner, newOwner);
}
}

/// <summary>
/// Change the owner of the <see cref="Item"/>.
/// </summary>
Expand Down
36 changes: 36 additions & 0 deletions Exiled.API/Features/Items/Scp244.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Exiled.API.Features.Items
{
using Exiled.API.Extensions;
using Exiled.API.Features.Pickups;
using Exiled.API.Interfaces;

Expand All @@ -29,6 +30,10 @@ public Scp244(Scp244Item itemBase)
: base(itemBase)
{
Base = itemBase;
Scp244DeployablePickup scp244Pickup = (Scp244DeployablePickup)Type.GetPickupBase();
Health = scp244Pickup._health;
ActivationDot = scp244Pickup._activationDot;
MaxDiameter = scp244Pickup.MaxDiameter;
}

/// <summary>
Expand All @@ -54,6 +59,22 @@ public bool Primed
set => Base._primed = value;
}

/// <summary>
/// Gets or sets the Scp244's remaining health.
/// </summary>
public float Health { get; set; }

/// <summary>
/// Gets or sets the activation angle, where 1 is the minimum and -1 is the maximum activation angle.
/// </summary>
public float ActivationDot { get; set; }

/// <summary>
/// Gets or sets the maximum diameter within which SCP-244's hypothermia effect is dealt.
/// </summary>
/// <remarks>This does not prevent visual effects.</remarks>
public float MaxDiameter { get; set; }

/// <summary>
/// Creates the <see cref="Pickup"/> that based on this <see cref="Item"/>.
/// </summary>
Expand Down Expand Up @@ -86,12 +107,27 @@ public override Pickup CreatePickup(Vector3 position, Quaternion rotation = defa
public override Item Clone() => new Scp244(Type)
{
Primed = Primed,
MaxDiameter = MaxDiameter,
Health = Health,
ActivationDot = ActivationDot,
};

/// <summary>
/// Returns the SCP-244 in a human readable format.
/// </summary>
/// <returns>A string containing SCP-244 related data.</returns>
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* -{Primed}-";

/// <inheritdoc/>
internal override void ReadPickupInfo(Pickup pickup)
{
base.ReadPickupInfo(pickup);
if (pickup is Scp244Pickup scp244)
{
Health = scp244.Health;
ActivationDot = scp244.ActivationDot;
MaxDiameter = scp244.MaxDiameter;
}
}
}
}
4 changes: 2 additions & 2 deletions Exiled.API/Features/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public static void Send(string message, Discord.LogLevel level, ConsoleColor col
/// Sends an <see cref="Error(object)"/> with the provided message if the condition is false and stops the execution.
/// <example> For example:
/// <code>
/// Player ply = Player.Get(2);
/// Log.Assert(ply is not null, "The player with the id 2 is null");
/// Player ply = Player.Get(2);
/// Log.Assert(ply is not null, "The player with the id 2 is null");
/// </code>
/// results in it logging an error if the player is null and not continuing.
/// </example>
Expand Down
25 changes: 24 additions & 1 deletion Exiled.API/Features/Pickups/Scp244Pickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ namespace Exiled.API.Features.Pickups
using System;

using Exiled.API.Features.DamageHandlers;
using Exiled.API.Features.Items;
using Exiled.API.Interfaces;

using InventorySystem.Items;
using InventorySystem.Items.Usables.Scp244;

using UnityEngine;
Expand Down Expand Up @@ -75,6 +76,16 @@ public float CurrentSizePercent
set => Base.CurrentSizePercent = value;
}

/// <summary>
/// Gets or sets the maximum diameter within which SCP-244's hypothermia effect is dealt.
/// </summary>
/// <remarks>This does not prevent visual effects.</remarks>
public float MaxDiameter
{
get => Base.MaxDiameter;
set => Base.MaxDiameter = value;
}

/// <summary>
/// Gets or sets the Scp244's remaining health.
/// </summary>
Expand Down Expand Up @@ -124,5 +135,17 @@ public float ActivationDot
/// </summary>
/// <returns>A string containing Scp244Pickup related data.</returns>
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{Health}| -{State}- ={CurrentSizePercent}=";

/// <inheritdoc/>
internal override void ReadItemInfo(Item item)
{
base.ReadItemInfo(item);
if (item is Scp244 scp244)
{
ActivationDot = scp244.ActivationDot;
MaxDiameter = scp244.MaxDiameter;
Health = scp244.Health;
}
}
}
}
Loading

0 comments on commit 14abdd5

Please sign in to comment.