Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RJW Sexperience Ideology
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XyroxDev
RJW Sexperience Ideology
Commits
71df71a0
Commit
71df71a0
authored
1 year ago
by
amevarashi
Browse files
Options
Downloads
Patches
Plain Diff
Fixed: Pawns raping despite Rape-Abhorrent precept
parent
472933e1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/IdeologyAddon/HistoryEvents/HistoryEventDefExtensionMethods.cs
+2
-0
2 additions, 0 deletions
...ogyAddon/HistoryEvents/HistoryEventDefExtensionMethods.cs
Source/IdeologyAddon/Patches/RJW_Patch_Ideo.cs
+45
-0
45 additions, 0 deletions
Source/IdeologyAddon/Patches/RJW_Patch_Ideo.cs
with
47 additions
and
0 deletions
Source/IdeologyAddon/HistoryEvents/HistoryEventDefExtensionMethods.cs
+
2
−
0
View file @
71df71a0
...
...
@@ -2,6 +2,7 @@
using
Verse
;
using
System.Linq
;
using
System.Collections.Generic
;
using
System.Runtime.CompilerServices
;
namespace
RJWSexperience.Ideology.HistoryEvents
{
...
...
@@ -27,6 +28,7 @@ namespace RJWSexperience.Ideology.HistoryEvents
//Log.Message($"[RSI] Recorded event {historyEvent.def.ToStringWithPartner(pawn, partner)}");
}
[
MethodImpl
(
MethodImplOptions
.
AggressiveInlining
)]
public
static
HistoryEvent
CreateEvent
(
this
HistoryEventDef
def
,
Pawn
pawn
)
{
return
new
HistoryEvent
(
def
,
pawn
.
Named
(
HistoryEventArgsNames
.
Doer
));
...
...
This diff is collapsed.
Click to expand it.
Source/IdeologyAddon/Patches/RJW_Patch_Ideo.cs
+
45
−
0
View file @
71df71a0
...
...
@@ -7,10 +7,55 @@ using RJWSexperience.Ideology.HistoryEvents;
using
RJWSexperience.Ideology.Precepts
;
using
System
;
using
System.Collections.Generic
;
using
System.Reflection.Emit
;
using
Verse
;
namespace
RJWSexperience.Ideology.Patches
{
[
HarmonyPatch
(
typeof
(
xxx
),
nameof
(
xxx
.
can_rape
))]
public
static
class
RJW_Patch_CannotRapeBecauseIdeo
{
/// <summary>
/// Injects IdeoCanRape call into is_human block of xxx.can_rape
/// </summary>
/// <param name="instructions">Original method instructions</param>
/// <returns>Modified method instructions</returns>
[
HarmonyTranspiler
]
public
static
IEnumerable
<
CodeInstruction
>
AddIdeoCheck
(
IEnumerable
<
CodeInstruction
>
instructions
,
ILGenerator
generator
)
{
using
IEnumerator
<
CodeInstruction
>
enumerator
=
instructions
.
GetEnumerator
();
System
.
Reflection
.
FieldInfo
wildMode
=
AccessTools
.
Field
(
typeof
(
RJWSettings
),
nameof
(
RJWSettings
.
WildMode
));
Label
labelWildMode
=
generator
.
DefineLabel
();
bool
done
=
false
;
while
(
enumerator
.
MoveNext
())
{
if
(!
done
&&
enumerator
.
Current
.
LoadsField
(
wildMode
))
{
// Found RJWSettings.WildMode check, insert before
// Need to move labels to our instruction because previous check jumps to one of them, skipping our call
var
existingLabels
=
enumerator
.
Current
.
labels
;
enumerator
.
Current
.
labels
=
new
List
<
Label
>()
{
labelWildMode
};
// Load the first argument - Pawn
yield
return
new
CodeInstruction
(
OpCodes
.
Ldarg_0
)
{
labels
=
existingLabels
};
// Call the check. Consumes pawn and pushes bool
yield
return
CodeInstruction
.
Call
(
typeof
(
RJW_Patch_CannotRapeBecauseIdeo
),
nameof
(
IdeoCanRape
));;
// If bool is true, jump to the next check
yield
return
new
CodeInstruction
(
OpCodes
.
Brtrue_S
,
labelWildMode
);
// The bool was false, push false and exit the method
yield
return
new
CodeInstruction
(
OpCodes
.
Ldc_I4_0
);
yield
return
new
CodeInstruction
(
OpCodes
.
Ret
);
done
=
true
;
}
yield
return
enumerator
.
Current
;
}
}
public
static
bool
IdeoCanRape
(
Pawn
pawn
)
=>
RsiDefOf
.
HistoryEvent
.
RSI_Raped
.
CreateEvent
(
pawn
).
DoerWillingToDo
();
}
[
HarmonyPatch
(
typeof
(
xxx
),
nameof
(
xxx
.
is_rapist
))]
public
static
class
RJW_Patch_is_rapist
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment