Ideology code cleanup

This commit is contained in:
amevarashi 2022-07-11 21:07:35 +05:00
parent ee61ba6694
commit 111b5b2450
17 changed files with 118 additions and 195 deletions

View file

@ -2,10 +2,8 @@
<LanguageData>
<RS_Mod_Title>RJW 性经验</RS_Mod_Title>
<LustStatFactor>性欲: x{0}%</LustStatFactor>
<SlaveStatFactor>囚犯: x{0}%</SlaveStatFactor>
<SlaveStatFactorDefault>非囚犯: x100%</SlaveStatFactorDefault>
<MemeStatFactor>迷因: x{0}%</MemeStatFactor>
<Lust>性欲</Lust>
<MemeStatFactor>迷因</MemeStatFactor>
<RSOption_1_Label>开启随机性记录</RSOption_1_Label>
<RSOption_1_Desc>随机化小人的性记录。</RSOption_1_Desc>

View file

@ -3,7 +3,7 @@
<RS_Mod_Title>RJW Sexperience</RS_Mod_Title>
<!-- Sex status screen -->
<MemeStatFactor>Meme: x{0}%</MemeStatFactor>
<MemeStatFactor>Meme</MemeStatFactor>
<RSVictimCondition>slave, prisoner, submissive gender only</RSVictimCondition>
<RSBreederCondition>improper animal: cannot breed or forbidden by precepts</RSBreederCondition>
<RSNotHuman>not human</RSNotHuman>

View file

@ -2,10 +2,7 @@
<LanguageData>
<RS_Mod_Title>RJW Sexperience</RS_Mod_Title>
<LustStatFactor>음란함: x{0}%</LustStatFactor>
<SlaveStatFactor>노예: x{0}%</SlaveStatFactor>
<SlaveStatFactorDefault>노예가 아님: x100%</SlaveStatFactorDefault>
<MemeStatFactor>문화 요소: x{0}%</MemeStatFactor>
<MemeStatFactor>문화 요소</MemeStatFactor>
<RSVictimCondition>노예, 죄수, 순종적인 성별만 가능합니다.</RSVictimCondition>
<RSBreederCondition>부적절한 동물: 번식할수 없거나 규율에의해 금지된 동물입니다.</RSBreederCondition>
<RSNotHuman>사람이 아님</RSNotHuman>

View file

@ -2,10 +2,7 @@
<LanguageData>
<RS_Mod_Title>RJW Sexperience</RS_Mod_Title>
<LustStatFactor>Похоть: x{0}%</LustStatFactor>
<SlaveStatFactor>Раб: x{0}%</SlaveStatFactor>
<SlaveStatFactorDefault>Не раб: x100%</SlaveStatFactorDefault>
<MemeStatFactor>Принцип идеологии: x{0}%</MemeStatFactor>
<MemeStatFactor>Принцип идеологии</MemeStatFactor>
<RSVictimCondition>раб, заключенный, подчиненный только по полу</RSVictimCondition>
<RSBreederCondition>неподходящее животное: не может размножаться или запрещено правилами</RSBreederCondition>
<RSNotHuman>не человек</RSNotHuman>

View file

@ -1,32 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;
using RimWorld;
namespace RJWSexperience.Ideology
{
public class GoodwillSituationWorker_OneWayReceive : GoodwillSituationWorker_MemeCompatibility
{
public override int GetNaturalGoodwillOffset(Faction other)
{
public class GoodwillSituationWorker_OneWayReceive : GoodwillSituationWorker_MemeCompatibility
{
public override int GetNaturalGoodwillOffset(Faction other)
{
if (!Applies(other))
return 0;
return def.naturalGoodwillOffset;
}
if (!Applies(other)) return 0;
return def.naturalGoodwillOffset;
}
protected bool Applies(Faction other)
{
Ideo primaryideo = Faction.OfPlayer.ideos?.PrimaryIdeo;
Ideo primaryideo2 = other.ideos?.PrimaryIdeo;
if (primaryideo == null || primaryideo2 == null)
return false;
protected bool Applies(Faction other)
{
Ideo primaryideo = Faction.OfPlayer.ideos?.PrimaryIdeo;
Ideo primaryideo2 = other.ideos?.PrimaryIdeo;
if (primaryideo == null || primaryideo2 == null) return false;
return primaryideo.memes.Contains(def.meme) && !primaryideo2.memes.Contains(def.meme);
}
}
return primaryideo.memes.Contains(def.meme) && !primaryideo2.memes.Contains(def.meme);
}
}
}

View file

@ -19,20 +19,6 @@ namespace RJWSexperience.Ideology
return false;
}
public static bool ContainAll(string str, string[] tags)
{
if (tags.NullOrEmpty())
return true;
string lstr = str.ToLower();
for (int i = 0; i < tags.Length; i++)
{
if (!lstr.Contains('[' + tags[i].ToLower() + ']'))
return false;
}
return true;
}
public static float GetPreceptsMtbMultiplier<T>(Ideo ideo) where T : Precepts.DefExtension_ModifyMtb
{
float finalMultiplier = 1f;

View file

@ -1,33 +0,0 @@
using RimWorld;
using System.Collections.Generic;
using Verse;
namespace RJWSexperience.Ideology
{
public static class IssueUtility
{
private static readonly Dictionary<IssueDef, List<PreceptDef>> issuePrecepts = new Dictionary<IssueDef, List<PreceptDef>>();
public static List<PreceptDef> GetAllPrecepts(this IssueDef issue)
{
if (issuePrecepts.TryGetValue(issue, out List<PreceptDef> precepts))
return precepts;
precepts = DefDatabase<PreceptDef>.AllDefsListForReading.FindAll(x => x.issue == issue);
issuePrecepts.Add(issue, precepts);
return precepts;
}
public static Precept GetPreceptOfIssue(this Ideo ideo, IssueDef issue)
{
foreach (PreceptDef preceptDef in issue.GetAllPrecepts())
{
Precept precept = ideo.GetPrecept(preceptDef);
if (precept != null)
return precept;
}
return null;
}
}
}

View file

@ -4,8 +4,7 @@ namespace RJWSexperience
{
public static class Keyed
{
public static string MemeStatFactor(string value) => "MemeStatFactor".Translate(value);
public static readonly string MemeStatFactor = "MemeStatFactor".Translate();
public static readonly string RSVictimCondition = "RSVictimCondition".Translate();
public static readonly string RSBreederCondition = "RSBreederCondition".Translate();
public static readonly string RSNotHuman = "RSNotHuman".Translate();

View file

@ -14,7 +14,7 @@ namespace RJWSexperience.Ideology.Patches
if (__result < 0f || pawn.Ideo == null) // ideo is null if don't have dlc
return;
if (!VariousDefOf.RSI_SexWithAnimal.CreateEvent(pawn).DoerWillingToDo())
if (!RsiHistoryEventDefOf.RSI_SexWithAnimal.CreateEvent(pawn).DoerWillingToDo())
{
__result = -2f;
return;
@ -31,7 +31,7 @@ namespace RJWSexperience.Ideology.Patches
if (__result < 0f || pawn.Ideo == null) // ideo is null if don't have dlc
return;
if (!VariousDefOf.RSI_Raped.CreateEvent(pawn).DoerWillingToDo())
if (!RsiHistoryEventDefOf.RSI_Raped.CreateEvent(pawn).DoerWillingToDo())
{
__result = -2f;
return;
@ -47,7 +47,7 @@ namespace RJWSexperience.Ideology.Patches
if (__result < 0f || pawn.Ideo == null) // ideo is null if don't have dlc
return;
if (!VariousDefOf.RSI_SexWithCorpse.CreateEvent(pawn).DoerWillingToDo())
if (!RsiHistoryEventDefOf.RSI_SexWithCorpse.CreateEvent(pawn).DoerWillingToDo())
{
__result = -2f;
return;

View file

@ -10,7 +10,7 @@ using Verse;
namespace RJWSexperience.Ideology.Patches
{
[HarmonyPatch(typeof(xxx), "is_rapist")]
[HarmonyPatch(typeof(xxx), nameof(xxx.is_rapist))]
public static class RJW_Patch_is_rapist
{
public static void Postfix(Pawn pawn, ref bool __result)
@ -23,7 +23,7 @@ namespace RJWSexperience.Ideology.Patches
}
}
[HarmonyPatch(typeof(xxx), "is_zoophile")]
[HarmonyPatch(typeof(xxx), nameof(xxx.is_zoophile))]
public static class RJW_Patch_is_zoophile
{
public static void Postfix(Pawn pawn, ref bool __result)
@ -36,7 +36,7 @@ namespace RJWSexperience.Ideology.Patches
}
}
[HarmonyPatch(typeof(xxx), "is_necrophiliac")]
[HarmonyPatch(typeof(xxx), nameof(xxx.is_necrophiliac))]
public static class RJW_Patch_is_necrophiliac
{
public static void Postfix(Pawn pawn, ref bool __result)
@ -92,17 +92,17 @@ namespace RJWSexperience.Ideology.Patches
public static void AfterSexHuman(Pawn human, Pawn partner, bool rape)
{
VariousDefOf.RSI_NonIncestuosSex.RecordEventWithPartner(human, partner);
VariousDefOf.RSI_NonIncestuosSex.RecordEventWithPartner(partner, human);
RsiHistoryEventDefOf.RSI_NonIncestuosSex.RecordEventWithPartner(human, partner);
RsiHistoryEventDefOf.RSI_NonIncestuosSex.RecordEventWithPartner(partner, human);
if (partner.IsAnimal())
{
VariousDefOf.RSI_SexWithAnimal.RecordEventWithPartner(human, partner);
RsiHistoryEventDefOf.RSI_SexWithAnimal.RecordEventWithPartner(human, partner);
}
else if (xxx.is_human(partner) && rape)
{
VariousDefOf.RSI_Raped.RecordEventWithPartner(human, partner);
VariousDefOf.RSI_WasRaped.RecordEventWithPartner(partner, human);
RsiHistoryEventDefOf.RSI_Raped.RecordEventWithPartner(human, partner);
RsiHistoryEventDefOf.RSI_WasRaped.RecordEventWithPartner(partner, human);
}
}
@ -168,7 +168,7 @@ namespace RJWSexperience.Ideology.Patches
}
}
[HarmonyPatch(typeof(PawnDesignations_Breedee), "UpdateCanDesignateBreeding")]
[HarmonyPatch(typeof(PawnDesignations_Breedee), nameof(PawnDesignations_Breedee.UpdateCanDesignateBreeding))]
public static class RJW_Patch_UpdateCanDesignateBreeding
{
public static void Postfix(Pawn pawn, ref bool __result)
@ -182,7 +182,7 @@ namespace RJWSexperience.Ideology.Patches
}
}
[HarmonyPatch(typeof(PawnDesignations_Comfort), "UpdateCanDesignateComfort")]
[HarmonyPatch(typeof(PawnDesignations_Comfort), nameof(PawnDesignations_Comfort.UpdateCanDesignateComfort))]
public static class RJW_PatchUpdateCanDesignateComfort
{
public static void Postfix(Pawn pawn, ref bool __result)
@ -195,18 +195,46 @@ namespace RJWSexperience.Ideology.Patches
}
}
[HarmonyPatch(typeof(Hediff_BasePregnancy), "PostBirth")]
[HarmonyPatch(typeof(Hediff_BasePregnancy), nameof(Hediff_BasePregnancy.PostBirth))]
public static class RJW_Patch_PostBirth
{
public static void Postfix(Pawn mother, Pawn father, Pawn baby)
public static void Postfix(Pawn mother, Pawn baby)
{
if (!mother.IsAnimal())
{
Faction faction = baby.GetFactionUsingPrecept(out Ideo ideo);
if (baby.Faction != faction) baby.SetFaction(faction);
if (baby.Faction != faction)
baby.SetFaction(faction);
baby.ideo?.SetIdeo(ideo);
if (baby.Faction == Find.FactionManager.OfPlayer && !baby.IsSlave) baby.guest?.SetGuestStatus(null, GuestStatus.Guest);
if (baby.Faction == Find.FactionManager.OfPlayer && !baby.IsSlave)
baby.guest?.SetGuestStatus(null, GuestStatus.Guest);
}
}
private static Faction GetFactionUsingPrecept(this Pawn baby, out Ideo ideo)
{
Faction playerfaction = Find.FactionManager.OfPlayer;
Ideo mainideo = playerfaction.ideos.PrimaryIdeo;
if (mainideo != null)
{
if (mainideo.HasPrecept(VariousDefOf.BabyFaction_AlwaysFather))
{
Pawn parent = baby.GetFather() ?? baby.GetMother();
ideo = parent.Ideo;
return parent.Faction;
}
else if (mainideo.HasPrecept(VariousDefOf.BabyFaction_AlwaysColony))
{
ideo = mainideo;
return playerfaction;
}
}
Pawn mother = baby.GetMother();
ideo = mother?.Ideo;
return mother?.Faction ?? baby.Faction;
}
}
}

View file

@ -7,31 +7,29 @@ using Verse;
namespace RJWSexperience.Ideology.Patches
{
[HarmonyPatch(typeof(MarriageCeremonyUtility), "Married")]
[HarmonyPatch(typeof(MarriageCeremonyUtility), nameof(MarriageCeremonyUtility.Married))]
public static class Rimworld_Patch_Marriage
{
public static void Postfix(Pawn firstPawn, Pawn secondPawn)
{
VariousDefOf.RSI_NonIncestuosMarriage.RecordEventWithPartner(firstPawn, secondPawn);
VariousDefOf.RSI_NonIncestuosMarriage.RecordEventWithPartner(secondPawn, firstPawn);
RsiHistoryEventDefOf.RSI_NonIncestuosMarriage.RecordEventWithPartner(firstPawn, secondPawn);
RsiHistoryEventDefOf.RSI_NonIncestuosMarriage.RecordEventWithPartner(secondPawn, firstPawn);
}
}
[HarmonyPatch(typeof(RitualOutcomeEffectWorker_FromQuality), "GiveMemoryToPawn")]
public static class Rimworld_Patch_GiveMemoryToPawn
public static class Rimworld_Patch_RitualOutcome_DontGiveMemoryToAnimals
{
public static bool Prefix(Pawn pawn, ThoughtDef memory, LordJob_Ritual jobRitual)
public static bool Prefix(Pawn pawn)
{
if (pawn.IsAnimal()) return false;
return true;
return !pawn.IsAnimal();
}
}
[HarmonyPatch(typeof(IdeoFoundation), "CanAdd")]
[HarmonyPatch(typeof(IdeoFoundation), nameof(IdeoFoundation.CanAdd))]
public static class Rimworld_Patch_IdeoFoundation
{
public static void Postfix(PreceptDef precept, bool checkDuplicates, ref IdeoFoundation __instance, ref AcceptanceReport __result)
public static void Postfix(PreceptDef precept, ref IdeoFoundation __instance, ref AcceptanceReport __result)
{
DefExtension_MultipleMemesRequired extension = precept.GetModExtension<DefExtension_MultipleMemesRequired>();

View file

@ -10,11 +10,11 @@ namespace RJWSexperience.Ideology.Patches
const int femaleAfterSurgery = 1;
if (props.isRape && exVirgin == props.partner)
VariousDefOf.RSI_VirginStolen.RecordEventWithPartner(exVirgin, partner);
RsiHistoryEventDefOf.RSI_VirginStolen.RecordEventWithPartner(exVirgin, partner);
else if (degree != femaleAfterSurgery)
VariousDefOf.RSI_VirginTaken.RecordEventWithPartner(exVirgin, partner);
RsiHistoryEventDefOf.RSI_VirginTaken.RecordEventWithPartner(exVirgin, partner);
VariousDefOf.RSI_TookVirgin.RecordEventWithPartner(partner, exVirgin);
RsiHistoryEventDefOf.RSI_TookVirgin.RecordEventWithPartner(partner, exVirgin);
}
}
}

View file

@ -42,29 +42,5 @@ namespace RJWSexperience.Ideology
return new HistoryEvent(def, pawn.Named(HistoryEventArgsNames.Doer), partner.Named(ArgsNamesCustom.Partner));
}
public static Faction GetFactionUsingPrecept(this Pawn baby, out Ideo ideo)
{
Faction playerfaction = Find.FactionManager.OfPlayer;
Ideo mainideo = playerfaction.ideos.PrimaryIdeo;
if (mainideo != null)
{
if (mainideo.HasPrecept(VariousDefOf.BabyFaction_AlwaysFather))
{
Pawn parent = baby.GetFather() ?? baby.GetMother();
ideo = parent.Ideo;
return parent.Faction;
}
else if (mainideo.HasPrecept(VariousDefOf.BabyFaction_AlwaysColony))
{
ideo = mainideo;
return playerfaction;
}
}
Pawn mother = baby.GetMother();
ideo = mother?.Ideo;
return mother?.Faction ?? baby.Faction;
}
}
}

View file

@ -0,0 +1,20 @@
using RimWorld;
using Verse;
namespace RJWSexperience.Ideology
{
[DefOf]
public static class RsiHistoryEventDefOf
{
[MayRequireIdeology] public static readonly HistoryEventDef RSI_SexWithAnimal;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_Raped;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_WasRaped;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_NonIncestuosMarriage;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_NonIncestuosSex;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_SexWithCorpse;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_VirginTaken;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_VirginStolen;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_TookVirgin;
}
}

View file

@ -1,5 +1,4 @@
using RimWorld;
using System;
using System.Diagnostics.CodeAnalysis;
using Verse;
@ -15,28 +14,7 @@ namespace RJWSexperience.Ideology
if (!req.HasThing || !(req.Thing is Pawn pawn))
return null;
Ideo ideo = pawn.Ideo;
float fact = 1f;
if (ideo?.memes.NullOrEmpty() == false)
{
for (int i = 0; i < ideo.memes.Count; i++)
{
if (ideo.memes[i] == MemeDefOf.MaleSupremacy)
{
if (pawn.gender == Gender.Male) fact = modifier;
else if (pawn.gender == Gender.Female) fact = 1 / modifier;
break;
}
else if (ideo.memes[i] == MemeDefOf.FemaleSupremacy)
{
if (pawn.gender == Gender.Male) fact = 1 / modifier;
else if (pawn.gender == Gender.Female) fact = modifier;
break;
}
}
}
return Keyed.MemeStatFactor(String.Format("{0:0.##}", fact * 100));
return $"{Keyed.MemeStatFactor}: x{GetModifier(pawn).ToStringPercent()}";
}
public override void TransformValue(StatRequest req, ref float val)
@ -44,26 +22,22 @@ namespace RJWSexperience.Ideology
if (!req.HasThing || !(req.Thing is Pawn pawn))
return;
Ideo ideo = pawn.Ideo;
val *= GetModifier(pawn);
}
if (ideo?.memes.NullOrEmpty() == false)
{
for (int i = 0; i < ideo.memes.Count; i++)
{
if (ideo.memes[i] == MemeDefOf.MaleSupremacy)
{
if (pawn.gender == Gender.Male) val *= modifier;
else if (pawn.gender == Gender.Female) val /= modifier;
break;
}
else if (ideo.memes[i] == MemeDefOf.FemaleSupremacy)
{
if (pawn.gender == Gender.Male) val /= modifier;
else if (pawn.gender == Gender.Female) val *= modifier;
break;
}
}
}
private float GetModifier(Pawn pawn)
{
if (pawn.Ideo == null)
return 1f;
Gender supremeGender = pawn.Ideo.SupremeGender;
if (pawn.gender == supremeGender)
return modifier;
else if (pawn.gender == supremeGender.Opposite())
return 1f / modifier;
return 1f;
}
}
}

View file

@ -16,15 +16,6 @@ namespace RJWSexperience.Ideology
[MayRequireIdeology] public static readonly MemeDef Zoophile;
[MayRequireIdeology] public static readonly MemeDef Rapist;
[MayRequireIdeology] public static readonly MemeDef Necrophile;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_SexWithAnimal;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_Raped;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_WasRaped;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_NonIncestuosMarriage;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_NonIncestuosSex;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_SexWithCorpse;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_VirginTaken;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_VirginStolen;
[MayRequireIdeology] public static readonly HistoryEventDef RSI_TookVirgin;
[MayRequireIdeology] public static readonly PreceptDef Bestiality_OnlyVenerated;
[MayRequireIdeology] public static readonly PreceptDef BabyFaction_AlwaysFather;
[MayRequireIdeology] public static readonly PreceptDef BabyFaction_AlwaysColony;

View file

@ -50,9 +50,9 @@
<Compile Include="Ideology\GoodwillSituationWorker_MemeCompatibility.cs" />
<Compile Include="Harmony.cs" />
<Compile Include="Ideology\HistoryEvents\ArgsNamesCustom.cs" />
<Compile Include="Ideology\IssueUtility.cs" />
<Compile Include="Ideology\Keyed.cs" />
<Compile Include="Ideology\RelationFilter.cs" />
<Compile Include="Ideology\RsiHistoryEventDefOf.cs" />
<Compile Include="Ideology\TwoPawnFilter.cs" />
<Compile Include="Ideology\SinglePawnFilter.cs" />
<Compile Include="Ideology\Precepts\Comp_SelfTookMemoryThought_Gendered.cs" />
@ -83,7 +83,7 @@
<Compile Include="Thoughts\ThoughtDefExtension_StageFromOpinion.cs" />
<Compile Include="Thoughts\Thought_IncreaseRecord.cs" />
<Compile Include="Thoughts\Thought_Opinionbased.cs" />
<Compile Include="VariousDefOf.cs" />
<Compile Include="Ideology\VariousDefOf.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Krafs.Rimworld.Ref">