Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for PostXMAS #2383

Merged
merged 5 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
567 changes: 5 additions & 562 deletions .editorconfig

Large diffs are not rendered by default.

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
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
2 changes: 1 addition & 1 deletion Exiled.API/Features/Effect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Effect()
/// <param name="statusEffectBase">Get all the information of the effect>.</param>
public Effect(StatusEffectBase statusEffectBase)
{
if (statusEffectBase.TryGetEffectType(out EffectType effect))
if (!statusEffectBase.TryGetEffectType(out EffectType effect))
Log.Error($"EffectType not found please report to Exiled BugReport : {statusEffectBase}");
Type = effect;
Duration = statusEffectBase.Duration;
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
5 changes: 5 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 Down
13 changes: 8 additions & 5 deletions Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public string CustomInfo
// NW Client check.
if (value.Contains('<'))
{
foreach (var token in value.Split('<'))
foreach (string token in value.Split('<'))
{
if (token.StartsWith("/", StringComparison.Ordinal) ||
token.StartsWith("b>", StringComparison.Ordinal) ||
Expand Down Expand Up @@ -736,7 +736,7 @@ public bool IsBypassModeEnabled
/// <remarks>This property will NOT persistently mute and unmute the player. For persistent mutes, see <see cref="Mute(bool)"/> and <see cref="UnMute(bool)"/>.</remarks>
public bool IsMuted
{
get => VoiceChatMutes.Mutes.Contains(UserId) && (VoiceChatMuteFlags.HasFlag(VcMuteFlags.GlobalRegular) || VoiceChatMuteFlags.HasFlag(VcMuteFlags.LocalRegular));
get => VoiceChatMutes.QueryLocalMute(UserId, false);
set
{
if (value)
Expand Down Expand Up @@ -768,7 +768,7 @@ public bool IsGlobalMuted
/// <remarks>This property will NOT persistently mute and unmute the player. For persistent mutes, see <see cref="Mute(bool)"/> and <see cref="UnMute(bool)"/>.</remarks>
public bool IsIntercomMuted
{
get => VoiceChatMutes.Mutes.Contains(UserId) && (VoiceChatMuteFlags.HasFlag(VcMuteFlags.GlobalIntercom) || VoiceChatMuteFlags.HasFlag(VcMuteFlags.LocalIntercom));
get => VoiceChatMutes.QueryLocalMute(UserId, true);
set
{
if (value)
Expand Down Expand Up @@ -2662,7 +2662,7 @@ public bool TryAddCandy(CandyKindID candyType)
/// <param name="newItems">The new items that have to be added to the inventory.</param>
public void ResetInventory(IEnumerable<ItemType> newItems)
{
ClearInventory();
ClearItems();

foreach (ItemType item in newItems)
AddItem(item);
Expand All @@ -2674,7 +2674,7 @@ public void ResetInventory(IEnumerable<ItemType> newItems)
/// <param name="newItems">The new items that have to be added to the inventory.</param>
public void ResetInventory(IEnumerable<Item> newItems)
{
ClearInventory();
ClearItems();

foreach (Item item in newItems)
AddItem(item);
Expand Down Expand Up @@ -2702,6 +2702,9 @@ public void ClearInventory(bool destroy = true)
/// <seealso cref="DropItems()"/>
public void ClearItems(bool destroy = true)
{
if (CurrentArmor is not null)
CurrentArmor.RemoveExcessOnDrop = true;

while (Items.Count > 0)
RemoveItem(Items.ElementAt(0), destroy);
}
Expand Down
7 changes: 5 additions & 2 deletions Exiled.API/Features/Ragdoll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace Exiled.API.Features

using UnityEngine;

using BaseScp3114Ragdoll = PlayerRoles.PlayableScps.Scp3114.Scp3114Ragdoll;

using Object = UnityEngine.Object;

/// <summary>
Expand Down Expand Up @@ -298,11 +300,12 @@ public static bool TryCreate(RagdollData networkInfo, out Ragdoll ragdoll)

basicRagdoll.NetworkInfo = networkInfo;

ragdoll = new(basicRagdoll)
ragdoll = basicRagdoll is BaseScp3114Ragdoll scp3114Ragdoll ? new Scp3114Ragdoll(scp3114Ragdoll) : new Ragdoll(basicRagdoll)
{
Position = networkInfo.StartPosition,
Rotation = networkInfo.StartRotation,
};

return true;
}

Expand Down Expand Up @@ -377,7 +380,7 @@ public static Ragdoll CreateAndSpawn(RoleTypeId roleType, string name, string de
/// <param name="ragdoll">The <see cref="BasicRagdoll"/> to get.</param>
/// <returns>A <see cref="Ragdoll"/> or <see langword="null"/> if not found.</returns>
public static Ragdoll Get(BasicRagdoll ragdoll) => ragdoll == null ? null :
BasicRagdollToRagdoll.TryGetValue(ragdoll, out Ragdoll doll) ? doll : new Ragdoll(ragdoll);
BasicRagdollToRagdoll.TryGetValue(ragdoll, out Ragdoll doll) ? doll : ragdoll is BaseScp3114Ragdoll scp3114Ragdoll ? new Scp3114Ragdoll(scp3114Ragdoll) : new Ragdoll(ragdoll);

/// <summary>
/// Gets the <see cref="IEnumerable{T}"/> of <see cref="Ragdoll"/> belonging to the <see cref="Player"/>, if any.
Expand Down
2 changes: 1 addition & 1 deletion Exiled.API/Features/Roles/Scp079Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ public void ActivateTesla(bool consumeEnergy = true)
Scp079Camera cam = CurrentCameraSync.CurrentCamera;
RewardManager.MarkRoom(cam.Room);

if (!TeslaGateController.Singleton.TeslaGates.TryGetFirst(x => RoomIdUtils.IsTheSameRoom(cam.Position, x.transform.position), out var teslaGate))
if (!TeslaGateController.Singleton.TeslaGates.TryGetFirst(x => RoomIdUtils.IsTheSameRoom(cam.Position, x.transform.position), out global::TeslaGate teslaGate))
return;

if (consumeEnergy)
Expand Down
78 changes: 78 additions & 0 deletions Exiled.API/Features/Scp3114Ragdoll.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// -----------------------------------------------------------------------
// <copyright file="Scp3114Ragdoll.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Features
{
using Exiled.API.Interfaces;
using PlayerRoles;

using BaseScp3114Ragdoll = PlayerRoles.PlayableScps.Scp3114.Scp3114Ragdoll;

/// <summary>
/// A wrapper for SCP-3114 ragdolls.
/// </summary>
public class Scp3114Ragdoll : Ragdoll, IWrapper<BaseScp3114Ragdoll>
{
/// <summary>
/// Initializes a new instance of the <see cref="Scp3114Ragdoll"/> class.
/// </summary>
/// <param name="ragdoll">The base ragdoll to wrap. <inheritdoc cref="Base"/></param>
internal Scp3114Ragdoll(BaseScp3114Ragdoll ragdoll)
: base(ragdoll)
{
Base = ragdoll;
}

/// <inheritdoc/>
public new BaseScp3114Ragdoll Base { get; }

/// <summary>
/// Gets or sets the role that the corpse is disguised as.
/// </summary>
public RoleTypeId DisguiseRole
{
get => Base._disguiseRole;
set => Base.Network_disguiseRole = value;
}

/// <summary>
/// Gets or sets the delay between when SCP-3114 can disguise this corpse.
/// </summary>
public float RevealDelay
{
get => Base._revealDelay;
set => Base._revealDelay = value;
}

/// <summary>
/// Gets or sets the time required to reveal this corpse.
/// </summary>
public float RevealDuration
{
get => Base._revealDuration;
set => Base._revealDuration = value;
}

/// <summary>
/// Gets or sets the current time of revealing this corpse.
/// </summary>
public float RevealElapsed
{
get => Base._revealElapsed;
set => Base._revealElapsed = value;
}

/// <summary>
/// Gets or sets a value indicating whether or not this corpse will trigger animation.
/// </summary>
public bool IsPlayingAnimation
{
get => Base._playingAnimation;
set => Base._playingAnimation = value;
}
}
}
4 changes: 2 additions & 2 deletions Exiled.CustomItems/API/Features/CustomGrenade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ public virtual Pickup Throw(Vector3 position, float force, float weight, float f
player = Server.Host;

player.Role.Is(out FpcRole fpcRole);
var velocity = fpcRole.FirstPersonController.FpcModule.Motor.Velocity;
Vector3 velocity = fpcRole.FirstPersonController.FpcModule.Motor.Velocity;

Throwable throwable = (Throwable)Item.Create(grenadeType, player);

ThrownProjectile thrownProjectile = Object.Instantiate(throwable.Base.Projectile, position, throwable.Owner.CameraTransform.rotation);
Transform transform = thrownProjectile.transform;

PickupSyncInfo newInfo = new()
{
ItemId = throwable.Type,
Expand Down
Loading
Loading