-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More features and events for SCP-1507 (#2348)
* scp-1507 * minor changes * added role * new * IHumeShieldRole * . * lots of new * still something new * Update Scp1507Role.cs * Update Scp1507Role.cs --------- Co-authored-by: Yamato <louismonneyron5@yahoo.com> Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com>
- Loading branch information
1 parent
b095edc
commit c7cf955
Showing
8 changed files
with
285 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="Scp1507Ragdoll.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.Extensions; | ||
using Exiled.API.Features.Roles; | ||
using Exiled.API.Interfaces; | ||
using PlayerRoles; | ||
|
||
using Scp1507BaseRagdoll = PlayerRoles.PlayableScps.Scp1507.Scp1507Ragdoll; | ||
|
||
/// <summary> | ||
/// A wrapper for <see cref="Scp1507BaseRagdoll"/>. | ||
/// </summary> | ||
public class Scp1507Ragdoll : Ragdoll, IWrapper<Scp1507BaseRagdoll> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Scp1507Ragdoll"/> class. | ||
/// </summary> | ||
/// <param name="ragdoll">The encapsulated <see cref="Scp1507BaseRagdoll"/>.</param> | ||
internal Scp1507Ragdoll(Scp1507BaseRagdoll ragdoll) | ||
: base(ragdoll) | ||
{ | ||
Base = ragdoll; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public new Scp1507BaseRagdoll Base { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets current progress of revival process. | ||
/// </summary> | ||
public float RevivalProgress | ||
{ | ||
get => Base._revivalProgress; | ||
set => Base.Network_revivalProgress = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether or not this ragdoll has been revived. | ||
/// </summary> | ||
public bool IsRevived | ||
{ | ||
get => Base._hasAlreadyRevived; | ||
set => Base.Network_hasAlreadyRevived = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets amount of time when ragdoll was reset last time. | ||
/// </summary> | ||
public double ResetTime | ||
{ | ||
get => Base._lastResetTime; | ||
set => Base.Network_lastResetTime = value; | ||
} | ||
|
||
/// <summary> | ||
/// Spawns a variant from available ragdolls for chosen role. | ||
/// </summary> | ||
/// <param name="role">Role. Can be <see cref="RoleTypeId.Flamingo"/>, <see cref="RoleTypeId.AlphaFlamingo"/> or <see cref="RoleTypeId.ZombieFlamingo"/>.</param> | ||
public void SpawnVariant(RoleTypeId role) => Base.SpawnVariant(role); | ||
|
||
/// <summary> | ||
/// Vocalizes ragdoll. | ||
/// </summary> | ||
/// <param name="player">Player who vocalizes. If <see langword="null"/>, will be chosen random.</param> | ||
public void Vocalize(Player player = null) => Base.OnVocalize((player ?? Player.Get(x => x.Role.Is(out Scp1507Role _)).GetRandomValue()).ReferenceHub); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="ScreamingEventArgs.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.Scp1507 | ||
{ | ||
using Exiled.API.Features; | ||
using Exiled.API.Features.Roles; | ||
using Exiled.Events.EventArgs.Interfaces; | ||
|
||
/// <summary> | ||
/// Contains all information before SCP-1507 screams. | ||
/// </summary> | ||
public class ScreamingEventArgs : IScp1507Event, IDeniableEvent | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ScreamingEventArgs"/> class. | ||
/// </summary> | ||
/// <param name="player"><inheritdoc cref="Player"/></param> | ||
/// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param> | ||
public ScreamingEventArgs(Player player, bool isAllowed = true) | ||
{ | ||
Player = player; | ||
Scp1507 = player.Role.As<Scp1507Role>(); | ||
IsAllowed = isAllowed; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Player Player { get; } | ||
|
||
/// <inheritdoc/> | ||
public Scp1507Role Scp1507 { get; } | ||
|
||
/// <inheritdoc/> | ||
public bool IsAllowed { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="Scream.cs" company="Exiled Team"> | ||
// Copyright (c) Exiled Team. All rights reserved. | ||
// Licensed under the CC BY-SA 3.0 license. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
namespace Exiled.Events.Patches.Events.Scp1507 | ||
{ | ||
using System.Collections.Generic; | ||
using System.Reflection.Emit; | ||
|
||
using Exiled.API.Features; | ||
using Exiled.API.Features.Pools; | ||
using Exiled.Events.Attributes; | ||
using Exiled.Events.EventArgs.Scp1507; | ||
using HarmonyLib; | ||
using PlayerRoles.PlayableScps.Scp1507; | ||
|
||
using static HarmonyLib.AccessTools; | ||
|
||
/// <summary> | ||
/// Patches <see cref="Scp1507VocalizeAbility.ServerProcessCmd"/> | ||
/// to add <see cref="Handlers.Scp1507.Screaming"/> event. | ||
/// </summary> | ||
[EventPatch(typeof(Handlers.Scp1507), nameof(Handlers.Scp1507.Screaming))] | ||
[HarmonyPatch(typeof(Scp1507VocalizeAbility), nameof(Scp1507VocalizeAbility.ServerProcessCmd))] | ||
public class Scream | ||
{ | ||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) | ||
{ | ||
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions); | ||
|
||
int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ldarg_0); | ||
|
||
Label retLabel = generator.DefineLabel(); | ||
|
||
newInstructions[newInstructions.Count - 1].labels.Add(retLabel); | ||
|
||
newInstructions.InsertRange( | ||
index, | ||
new CodeInstruction[] | ||
{ | ||
// Player.Get(this.Owner); | ||
new(OpCodes.Ldarg_0), | ||
new(OpCodes.Callvirt, PropertyGetter(typeof(Scp1507VocalizeAbility), nameof(Scp1507VocalizeAbility.Owner))), | ||
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), | ||
|
||
// true | ||
new(OpCodes.Ldc_I4_1), | ||
|
||
// ScreamingEventArgs ev = new(Player, true); | ||
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ScreamingEventArgs))[0]), | ||
new(OpCodes.Dup), | ||
|
||
// Handlers.Scp1507.OnScreaming(ev); | ||
new(OpCodes.Call, Method(typeof(Handlers.Scp1507), nameof(Handlers.Scp1507.OnScreaming))), | ||
|
||
// if (!ev.IsAllowed) | ||
// goto retLabel; | ||
new(OpCodes.Callvirt, PropertyGetter(typeof(ScreamingEventArgs), nameof(ScreamingEventArgs.IsAllowed))), | ||
new(OpCodes.Brfalse_S, retLabel), | ||
}); | ||
|
||
for (int z = 0; z < newInstructions.Count; z++) | ||
yield return newInstructions[z]; | ||
|
||
ListPool<CodeInstruction>.Pool.Return(newInstructions); | ||
} | ||
} | ||
} |