Skip to content

Commit

Permalink
suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
VALERA771 committed Aug 11, 2024
1 parent 3f404c9 commit c40c52f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
28 changes: 28 additions & 0 deletions EXILED/Exiled.Events/EventArgs/Player/EscapedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

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

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

/// <summary>
/// Contains all information after player has escaped.
Expand All @@ -25,6 +29,10 @@ public EscapedEventArgs(Player player, EscapeScenario escapeScenario)
{
Player = player;
EscapeScenario = escapeScenario;
Team = EscapeScenario is EscapeScenario.Scientist or EscapeScenario.CuffedClassD ? SpawnableTeamType.NineTailedFox : SpawnableTeamType.ChaosInsurgency;
Tickets = Team == SpawnableTeamType.ChaosInsurgency ? 4 : 3;
OldRole = EscapeScenario is EscapeScenario.Scientist or EscapeScenario.CuffedScientist ? RoleTypeId.Scientist : RoleTypeId.ClassD;
EscapeTime = (int)Math.Ceiling(player.Role.ActiveTime.TotalSeconds);
}

/// <inheritdoc/>
Expand All @@ -34,5 +42,25 @@ public EscapedEventArgs(Player player, EscapeScenario escapeScenario)
/// Gets the type of escape.
/// </summary>
public EscapeScenario EscapeScenario { get; }

/// <summary>
/// Gets the <see cref="SpawnableTeamType"/> that gained tickets for this escape.
/// </summary>
public SpawnableTeamType Team { get; }

/// <summary>
/// Gets the amount of tickets gained for this escape.
/// </summary>
public int Tickets { get; }

/// <summary>
/// Gets the previous role for this player.
/// </summary>
public RoleTypeId OldRole { get; }

/// <summary>
/// Gets the time in seconds since round started.
/// </summary>
public int EscapeTime { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,12 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

newInstructions.InsertRange(newInstructions.Count - 1, new CodeInstruction[]
{
// loading EscapingEventArgs instance 2 times
new(OpCodes.Ldloc_S, ev.LocalIndex),
new(OpCodes.Ldloc_S, ev.LocalIndex),

// ev.Player
new(OpCodes.Ldloc_S, ev.LocalIndex),
new(OpCodes.Callvirt, PropertyGetter(typeof(EscapingEventArgs), nameof(EscapingEventArgs.Player))),

// ev.EscapeScenario
new(OpCodes.Callvirt, PropertyGetter(typeof(EscapingEventArgs), nameof(EscapingEventArgs.EscapeScenario))),
new(OpCodes.Ldloc_1),

// EscapedEventArgs ev2 = new(ev.Player, ev.EscapeScenario);
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(EscapedEventArgs))[0]),
Expand Down

0 comments on commit c40c52f

Please sign in to comment.