Skip to content

Commit

Permalink
Merge branch 'dev' into Round.IgnoredPlayers-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NaoUnderscore authored Dec 16, 2023
2 parents b2458db + 2804cf7 commit f219699
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 4 deletions.
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;
}
}
}
}
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 @@ -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
30 changes: 29 additions & 1 deletion docs/docs/Plugins/Events.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,32 @@ public void OnEnraging(EnragingEventArgs ev) // ev is the arguments for the even
{
Log.Info(ev.Player.Nickname + " has just been enraged!");
}
```
```

## Async events

_Async events allow you to seamlessly integrate coroutines and event functionalities.
You can find more information about MEC coroutines [here](https://github.com/Exiled-Team/EXILED#mec-coroutines)._
```cs
// Base plugin class
// This example assumes a method called "OnEnraging" exists in this class. For best practice, you should create a new class to handle events.
using Exiled.Events;
public override void OnEnabled()
{
Scp096.Enraging += OnEnraging; // Scp096 is the event handler, while Enraging is the name of the event. The += operator connects this event to the provided method.
}
public override void OnDisabled()
{
Scp096.Enraging -= OnEnraging; // The -= operator disconnects this event from the provided method.
}
// Some other class
using Sustem.Collections.Generic;

using Exiled.Events.EventArgs;
using MEC;
public IEnumerator<float> OnEnraging(EnragingEventArgs ev) // ev is the arguments for the event. Every event has a different argument class with different parameters, so make sure to check its documentation.
{
yield return Timing.WaitForSeconds(1f);
Log.Info(ev.Player.Nickname + " has just been enraged!");
}
```

0 comments on commit f219699

Please sign in to comment.