forked from Exiled-Official/EXILED
-
Notifications
You must be signed in to change notification settings - Fork 110
RecontainedWhenNoScps feature
#16
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
56c0f1b
scp079 recantain feat
IRacle1 991e24b
eh
IRacle1 6908cfd
labels.add
IRacle1 5ec9a21
Update EXILED/Exiled.Events/Config.cs
louis1706 04d53cd
Update EXILED/Exiled.Events/Patches/Generic/Scp079Recontain.cs
louis1706 49b1009
Update EXILED/Exiled.Events/Patches/Generic/Scp079Recontain.cs
louis1706 28f1567
Merge branch 'dev' into rec079
louis1706 2f58ca2
Merge branch 'dev' into rec079
louis1706 c182ebf
`RecontainScp079IfNoScpsLeft`
IRacle1 1c84e5c
Merge branch 'dev' into rec079
Misaka-ZeroTwo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,54 @@ | ||
| // ----------------------------------------------------------------------- | ||
| // <copyright file="Scp079Recontain.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.Generic.Scp079API | ||
| { | ||
| using System.Collections.Generic; | ||
| using System.Reflection.Emit; | ||
|
|
||
| using API.Features.Pools; | ||
|
|
||
| using HarmonyLib; | ||
|
|
||
| using PlayerRoles.PlayableScps.Scp079; | ||
|
|
||
| using static HarmonyLib.AccessTools; | ||
|
|
||
| /// <summary> | ||
| /// Patches <see cref="Scp079Recontainer.OnServerRoleChanged(ReferenceHub, PlayerRoles.RoleTypeId, PlayerRoles.RoleChangeReason)"/>. | ||
| /// Adds the <see cref="Exiled.Events.Config.ShouldScp079RecontainedWhenNoScps" /> support. | ||
|
louis1706 marked this conversation as resolved.
Outdated
|
||
| /// </summary> | ||
| [HarmonyPatch(typeof(Scp079Recontainer), nameof(Scp079Recontainer.OnServerRoleChanged))] | ||
| internal class Scp079Recontain | ||
| { | ||
| private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) | ||
| { | ||
| List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions); | ||
|
|
||
| Label ret = generator.DefineLabel(); | ||
|
|
||
| newInstructions.InsertRange( | ||
| 0, | ||
| new[] | ||
| { | ||
| // if (!Events.Instance.Config.ShouldScp079RecontainedWhenNoScps) | ||
| // return; | ||
| new CodeInstruction(OpCodes.Call, PropertyGetter(typeof(Exiled.Events.Events), nameof(Exiled.Events.Events.Instance))), | ||
| new(OpCodes.Callvirt, PropertyGetter(typeof(Exiled.Events.Events), nameof(Exiled.Events.Events.Config))), | ||
| new(OpCodes.Callvirt, PropertyGetter(typeof(Exiled.Events.Config), nameof(Exiled.Events.Config.ShouldScp079RecontainedWhenNoScps))), | ||
|
louis1706 marked this conversation as resolved.
Outdated
|
||
| new(OpCodes.Brfalse_S, ret), | ||
|
louis1706 marked this conversation as resolved.
|
||
| }); | ||
|
|
||
| newInstructions[newInstructions.Count - 1].labels.Add(ret); | ||
|
|
||
| for (int z = 0; z < newInstructions.Count; z++) | ||
| yield return newInstructions[z]; | ||
|
|
||
| ListPool<CodeInstruction>.Pool.Return(newInstructions); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.