Skip to content

Commit

Permalink
Merge branch 'Dev-Generic' of https://github.com/warquys/EXILED into …
Browse files Browse the repository at this point in the history
…Dev-Generic
  • Loading branch information
warquys committed Dec 19, 2023
2 parents 37942bc + 1ec4bd9 commit 79b2e3c
Show file tree
Hide file tree
Showing 19 changed files with 281 additions and 50 deletions.
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
31 changes: 31 additions & 0 deletions Exiled.API/Features/Items/Scp244.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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 +102,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;
}
}
}
}
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;
}
}
}
}
4 changes: 2 additions & 2 deletions Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences
/// <summary>
/// Gets a value indicating whether or not the player is jumping.
/// </summary>
public bool IsJumping { get; internal set; }
public bool IsJumping => Role is FpcRole fpc && fpc.FirstPersonController.FpcModule.Motor.IsJumping;

/// <summary>
/// Gets the player's IP address.
Expand Down Expand Up @@ -3134,7 +3134,7 @@ public void ChangeEffectIntensity(EffectType type, byte intensity, float duratio
if (TryGetEffect(type, out StatusEffectBase statusEffect))
{
statusEffect.Intensity = intensity;
statusEffect.ServerChangeDuration(duration, true);
statusEffect.ServerChangeDuration(duration, false);
}
}

Expand Down
14 changes: 12 additions & 2 deletions Exiled.API/Features/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,19 @@ public static Room FindParentRoom(GameObject objectInRoom)
/// <summary>
/// Flickers the room's lights off for a duration.
/// </summary>
/// <param name="duration">Duration in seconds.</param>
public void TurnOffLights(float duration)
/// <param name="duration">Duration in seconds, or -1 for an indefinite duration.</param>
public void TurnOffLights(float duration = -1)
{
if (duration == -1)
{
foreach (RoomLightController light in RoomLightControllers)
{
light.SetLights(false);
}

return;
}

foreach (RoomLightController light in RoomLightControllers)
{
light.ServerFlickerLights(duration);
Expand Down
2 changes: 1 addition & 1 deletion Exiled.API/Features/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static class Round
/// <summary>
/// Gets a list of players who will be ignored from determining round end.
/// </summary>
public static HashSet<ReferenceHub> IgnoredPlayers { get; } = new(20);
public static HashSet<ReferenceHub> IgnoredPlayers { get; } = new(20); // TODO: Replace ReferenceHub to Player remind to change RoundEnd transpiler

/// <summary>
/// Gets the time elapsed from the start of the round.
Expand Down
11 changes: 11 additions & 0 deletions Exiled.API/Features/Scp914.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Exiled.API.Features
using System.Collections.Generic;
using System.Linq;

using Exiled.API.Features.Doors;
using Exiled.API.Features.Pickups;
using Exiled.API.Features.Pools;
using global::Scp914;
Expand Down Expand Up @@ -63,6 +64,11 @@ public static Scp914Mode ConfigMode
/// </summary>
public static Vector3 OutputPosition => Scp914Controller.OutputChamber.localPosition;

/// <summary>
/// Gets the position offset in which item is moving.
/// </summary>
public static Vector3 MovingVector => OutputPosition - IntakePosition;

/// <summary>
/// Gets a value indicating whether SCP-914 is active and currently processing items.
/// </summary>
Expand All @@ -83,6 +89,11 @@ public static Scp914Mode ConfigMode
/// </summary>
public static Transform OutputBooth => Scp914Controller.OutputChamber;

/// <summary>
/// Gets the list with <see cref="Door"/> which SCP-914 has.
/// </summary>
public static IReadOnlyCollection<Door> Doors => Scp914Controller._doors.Select(Door.Get).ToList();

/// <summary>
/// Filters all GameObjects inside SCP-914's intake chamber into players and items.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Exiled.Events/Commands/PluginManager/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override void LoadGeneratedCommands()
/// <inheritdoc/>
protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
response = "Please, specify a valid subcommand! Available ones: enable, disable, show";
response = "Please, specify a valid subcommand! Available ones: enable, disable, show, patches";
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

namespace Exiled.Events.EventArgs.Scp914
{
using System;

using API.Features;
using API.Features.Items;

using global::Scp914;

using Interfaces;

using InventorySystem.Items;

/// <summary>
Expand All @@ -38,7 +37,6 @@ public class UpgradingInventoryItemEventArgs : IPlayerEvent, IItemEvent, IDeniab
/// </param>
public UpgradingInventoryItemEventArgs(Player player, ItemBase item, Scp914KnobSetting knobSetting, bool isAllowed = true)
{
Scp914 = API.Features.Scp914.Scp914Controller;
Player = player;
Item = Item.Get(item);
KnobSetting = knobSetting;
Expand All @@ -48,7 +46,8 @@ public UpgradingInventoryItemEventArgs(Player player, ItemBase item, Scp914KnobS
/// <summary>
/// Gets the <see cref="Scp914Controller" /> instance.
/// </summary>
public Scp914Controller Scp914 { get; }
[Obsolete("Use Scp914::Scp914Controller instead.")]
public Scp914Controller Scp914 => API.Features.Scp914.Scp914Controller;

/// <summary>
/// Gets or sets SCP-914 working knob setting.
Expand Down
9 changes: 4 additions & 5 deletions Exiled.Events/EventArgs/Scp914/UpgradingPickupEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

namespace Exiled.Events.EventArgs.Scp914
{
using System;

using Exiled.API.Features.Pickups;
using Exiled.Events.EventArgs.Interfaces;

using global::Scp914;

using InventorySystem.Items.Pickups;

using UnityEngine;

/// <summary>
Expand All @@ -35,7 +34,6 @@ public class UpgradingPickupEventArgs : IPickupEvent, IDeniableEvent
/// </param>
public UpgradingPickupEventArgs(ItemPickupBase item, Vector3 newPos, Scp914KnobSetting knobSetting)
{
Scp914 = API.Features.Scp914.Scp914Controller;
Pickup = Pickup.Get(item);
OutputPosition = newPos;
KnobSetting = knobSetting;
Expand All @@ -49,7 +47,8 @@ public UpgradingPickupEventArgs(ItemPickupBase item, Vector3 newPos, Scp914KnobS
/// <summary>
/// Gets the <see cref="Scp914Controller" /> instance.
/// </summary>
public Scp914Controller Scp914 { get; }
[Obsolete("Use Scp914::Scp914Controller instead.")]
public Scp914Controller Scp914 => API.Features.Scp914.Scp914Controller;

/// <summary>
/// Gets or sets the position the item will be output to.
Expand Down
35 changes: 35 additions & 0 deletions Exiled.Events/EventArgs/Server/SelectingRespawnTeamEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// -----------------------------------------------------------------------
// <copyright file="SelectingRespawnTeamEventArgs.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Server
{
using System;

using Exiled.API.Features;
using Exiled.Events.EventArgs.Interfaces;
using Respawning;

/// <summary>
/// Contains all information before selecting the team to respawn next.
/// </summary>
public class SelectingRespawnTeamEventArgs : IExiledEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="SelectingRespawnTeamEventArgs"/> class.
/// </summary>
/// <param name="type">The <see cref="SpawnableTeamType"/> used as the starting value for this event.</param>
public SelectingRespawnTeamEventArgs(SpawnableTeamType type)
{
Team = type;
}

/// <summary>
/// Gets or sets <see cref="SpawnableTeamType"/> that represents the team chosen to spawn.
/// </summary>
public SpawnableTeamType Team { get; set; }
}
}
11 changes: 11 additions & 0 deletions Exiled.Events/Handlers/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public static class Server
/// </summary>
public static Event<ChoosingStartTeamQueueEventArgs> ChoosingStartTeamQueue { get; set; } = new();

/// <summary>
/// Invoked before selecting the team that will respawn.
/// </summary>
public static Event<SelectingRespawnTeamEventArgs> SelectingRespawnTeam { get; set; } = new();

/// <summary>
/// Invoked after the "reload configs" command is ran.
/// </summary>
Expand Down Expand Up @@ -184,5 +189,11 @@ public static class Server
/// Called after the "reload permissions" command is ran.
/// </summary>
public static void OnReloadedPermissions() => ReloadedPermissions.InvokeSafely();

/// <summary>
/// Called before selecting the team that will respawn next.
/// </summary>
/// <param name="ev">The <see cref="SelectingRespawnTeamEventArgs"/> instance.</param>
public static void OnSelectingRespawnTeam(SelectingRespawnTeamEventArgs ev) => SelectingRespawnTeam.InvokeSafely(ev);
}
}
6 changes: 0 additions & 6 deletions Exiled.Events/Patches/Events/Player/Landing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,9 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

// LandingEventArgs ev = new(Player)
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(LandingEventArgs))[0]),
new(OpCodes.Dup),

// Player.OnLanding(ev)
new(OpCodes.Call, Method(typeof(Player), nameof(Player.OnLanding))),

// player.IsJumping = false
new(OpCodes.Callvirt, PropertyGetter(typeof(LandingEventArgs), nameof(LandingEventArgs.Player))),
new(OpCodes.Ldc_I4_0),
new(OpCodes.Callvirt, PropertySetter(typeof(API.Features.Player), nameof(API.Features.Player.IsJumping))),
});

for (int z = 0; z < newInstructions.Count; z++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new CodeInstruction[]
{
// Player.Get(base.Owner)
new(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]),
new(OpCodes.Call, PropertyGetter(typeof(StandardSubroutine<Scp173Role>), nameof(StandardSubroutine<Scp173Role>.Owner))),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),

Expand Down
Loading

0 comments on commit 79b2e3c

Please sign in to comment.