Split Ideology addon from base?

This commit is contained in:
amevarashi 2022-02-25 19:15:48 +05:00
parent a483e7c1d0
commit 527da1ac0f
10 changed files with 333 additions and 411 deletions

View file

@ -1,23 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using System.Reflection;
using HarmonyLib;
using Verse;
namespace RJWSexperience.Ideology
{
[StaticConstructorOnStartup]
internal static class First
{
static First()
{
var har = new Harmony("RJW_Sexperience.Ideology");
har.PatchAll(Assembly.GetExecutingAssembly());
var harmony = new Harmony("RJW_Sexperience.Ideology");
harmony.PatchAll(Assembly.GetExecutingAssembly());
if (ModLister.HasActiveModWithName("RJW Sexperience"))
{
//Log.Message("[RJWSexperience.Ideology] Found RJWSexperience, patching");
harmony.Patch(AccessTools.Method("RJWSexperience.Utility:IsIncest"),
prefix: new HarmonyMethod(typeof(Sexperience_Patch_IsIncest), nameof(Sexperience_Patch_IsIncest.Prefix)),
postfix: null
);
harmony.Patch(AccessTools.Method("RJWSexperience.RJWUtility:ThrowVirginHIstoryEvent"),
prefix: null,
postfix: new HarmonyMethod(typeof(Sexperience_Patch_ThrowVirginHIstoryEvent), nameof(Sexperience_Patch_ThrowVirginHIstoryEvent.Postfix))
);
}
}
}
}

View file

@ -0,0 +1,15 @@
using Verse;
namespace RJWSexperience
{
public static class Keyed
{
public static string MemeStatFactor(string value) => "MemeStatFactor".Translate(value);
public static readonly string RSVictimCondition = "RSVictimCondition".Translate();
public static readonly string RSBreederCondition = "RSBreederCondition".Translate();
public static readonly string RSNotHuman = "RSNotHuman".Translate();
public static readonly string RSNotAnimal = "RSNotAnimal".Translate();
public static readonly string RSShouldCanFuck = "RSShouldCanFuck".Translate();
}
}

View file

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using RimWorld;
using Verse;
namespace RJWSexperience.Ideology
@ -23,17 +18,12 @@ namespace RJWSexperience.Ideology
public const string NotSpouse = "[NotSpouse]";
public static string Gender(Pawn pawn) => "[" + pawn.gender + "]";
}
public class PreceptComp_SelfTookThoughtTagged : PreceptComp_SelfTookMemoryThought
{
public string tag;
public bool exclusive = false;
//public RecordDef recordDef;
//public float? recordoffset;
public PreceptComp_SelfTookThoughtTagged() { }
@ -43,33 +33,20 @@ namespace RJWSexperience.Ideology
{
if (ev.args.TryGetArg(HistoryEventArgsNamesCustom.Tag, out string tags))
{
if (tags.ContainAll(tag.Replace(" ","").Split(',')) ^ exclusive)
if (IdeoUtility.ContainAll(tags, tag.Replace(" ", "").Split(',')) ^ exclusive)
{
TookThought(ev, precept, canApplySelfTookThoughts);
//if (ev.args.TryGetArg(HistoryEventArgsNames.Doer, out Pawn pawn))
//{
// AdjustRecord(pawn);
//}
}
}
else if (exclusive)
{
TookThought(ev, precept, canApplySelfTookThoughts);
//if (ev.args.TryGetArg(HistoryEventArgsNames.Doer, out Pawn pawn))
//{
// AdjustRecord(pawn);
//}
}
}
else
{
TookThought(ev, precept, canApplySelfTookThoughts);
//if (ev.args.TryGetArg(HistoryEventArgsNames.Doer, out Pawn pawn))
//{
// AdjustRecord(pawn);
//}
}
}
protected virtual void TookThought(HistoryEvent ev, Precept precept, bool canApplySelfTookThoughts)
@ -102,20 +79,8 @@ namespace RJWSexperience.Ideology
arg.needs.mood.thoughts.memories.TryGainMemory(thought_Memory, partner);
}
}
//protected void AdjustRecord(Pawn pawn)
//{
// if (recordDef != null)
// {
// pawn.records.AddTo(recordDef, recordoffset ?? 1f);
// }
//}
}
public class PreceptComp_KnowsMemoryThoughtTagged : PreceptComp_KnowsMemoryThought
{
public string tag;
@ -137,7 +102,7 @@ namespace RJWSexperience.Ideology
{
if (ev.args.TryGetArg(HistoryEventArgsNamesCustom.Tag, out string tags))
{
if (tags.ContainAll(tag.Replace(" ", "").Split(',')) ^ exclusive) base.Notify_MemberWitnessedAction(ev, precept, member);
if (IdeoUtility.ContainAll(tags, tag.Replace(" ", "").Split(',')) ^ exclusive) base.Notify_MemberWitnessedAction(ev, precept, member);
}
else if (exclusive)
{
@ -150,5 +115,4 @@ namespace RJWSexperience.Ideology
}
}
}
}

View file

@ -7,8 +7,6 @@ using HarmonyLib;
using rjw;
using RimWorld;
using Verse;
using UnityEngine;
using SexperienceDefOf = RJWSexperience.VariousDefOf;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Objects;
@ -177,7 +175,7 @@ namespace RJWSexperience.Ideology
public static void AfterSexHuman(Pawn human, Pawn partner, bool usedCondom, bool rape, bool isCoreLovin, xxx.rjwSextype sextype, bool isHumanReceiving = false)
{
string tag = "";
if (human.IsIncest(partner))
if (IdeoUtility.IsIncest(human, partner))
{
tag += HETag.Incestous;
}
@ -358,7 +356,7 @@ namespace RJWSexperience.Ideology
Ideo ideo = fucker.Ideo;
if (ideo != null)
{
if (fucker.IsIncest(fucked))
if (IdeoUtility.IsIncest(fucker, fucked))
{
if (ideo.HasPrecept(VariousDefOf.Incestuos_IncestOnly)) __result *= 2.0f;
else if (!fucker.relations?.DirectRelationExists(PawnRelationDefOf.Spouse, fucked) ?? false)

View file

@ -1,15 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using HarmonyLib;
using RimWorld;
using Verse;
using rjw;
using System.Collections.Generic;
using Verse;
namespace RJWSexperience.Ideology
{
@ -18,14 +11,12 @@ namespace RJWSexperience.Ideology
{
public static void Postfix(Pawn firstPawn, Pawn secondPawn)
{
if (firstPawn.IsIncest(secondPawn))
if (IdeoUtility.IsIncest(firstPawn, secondPawn))
{
Find.HistoryEventsManager.RecordEvent(new HistoryEvent(VariousDefOf.Incestuos_Marriage, firstPawn.Named(HistoryEventArgsNames.Doer)));
Find.HistoryEventsManager.RecordEvent(new HistoryEvent(VariousDefOf.Incestuos_Marriage, secondPawn.Named(HistoryEventArgsNames.Doer)));
}
}
}
[HarmonyPatch(typeof(Pawn_RelationsTracker), "SecondaryRomanceChanceFactor")]
@ -36,7 +27,7 @@ namespace RJWSexperience.Ideology
Ideo ideo = ___pawn.Ideo;
if (ideo != null)
{
if (ideo.HasPrecept(VariousDefOf.Incestuos_IncestOnly) && ___pawn.IsIncest(otherPawn))
if (ideo.HasPrecept(VariousDefOf.Incestuos_IncestOnly) && IdeoUtility.IsIncest(___pawn, otherPawn))
{
__result *= 8f;
}
@ -65,7 +56,7 @@ namespace RJWSexperience.Ideology
PreceptDef_RequirementExtended def = precept as PreceptDef_RequirementExtended;
if (!def.requiredAllMemes.NullOrEmpty())
{
for (int i=0; i< def.requiredAllMemes.Count; i++)
for (int i = 0; i < def.requiredAllMemes.Count; i++)
{
if (!__instance.ideo.memes.Contains(def.requiredAllMemes[i]))
{
@ -77,14 +68,7 @@ namespace RJWSexperience.Ideology
}
}
}
}
}
}
}

View file

@ -1,18 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using RimWorld;
using rjw;
using RJWSexperience;
using Verse;
using RimWorld;
namespace RJWSexperience.Ideology
{
[HarmonyPatch(typeof(RJWUtility), "ThrowVirginHIstoryEvent")]
public static class Sexperience_Patch_ThrowVirginHIstoryEvent
{
public static void Postfix(Pawn pawn, Pawn partner, SexProps props, int degree)
@ -28,7 +19,6 @@ namespace RJWSexperience.Ideology
tag += HETag.NotSpouse;
}
if (pawn.gender == Gender.Male)
{
if (degree > 1) Find.HistoryEventsManager.RecordEvent(VariousDefOf.Virgin_TakenM.TaggedEvent(pawn, tag + HETag.Gender(pawn), partner));
@ -39,35 +29,14 @@ namespace RJWSexperience.Ideology
if (degree > 1) Find.HistoryEventsManager.RecordEvent(VariousDefOf.Virgin_TakenF.TaggedEvent(pawn, tag + HETag.Gender(pawn), partner));
Find.HistoryEventsManager.RecordEvent(VariousDefOf.Virgin_TookF.TaggedEvent(partner, tag + HETag.Gender(pawn), pawn));
}
}
}
[HarmonyPatch(typeof(Utility), "IsIncest")]
public static class Sexperience_Patch_IsIncest
{
public static bool Prefix(Pawn pawn, Pawn otherpawn, ref bool __result)
{
__result = IsIncest(pawn, otherpawn);
return false;
}
private static bool IsIncest(Pawn pawn, Pawn partner)
{
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner);
Ideo ideo = pawn.Ideo;
bool wide = false;
if (ideo != null) wide = ideo.HasPrecept(VariousDefOf.Incestuos_Disapproved_CloseOnly);
if (!relations.EnumerableNullOrEmpty()) foreach (PawnRelationDef relation in relations)
{
if (wide)
{
if (relation.incestOpinionOffset < 0) return true;
}
else if (relation.familyByBloodRelation) return true;
}
__result = IdeoUtility.IsIncest(pawn, otherpawn);
return false;
}
}

View file

@ -1,19 +1,12 @@
using System;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;
using rjw;
using UnityEngine;
namespace RJWSexperience.Ideology
{
public static class IdeoUtility
{
public static bool IsSubmissive(this Pawn pawn)
{
Ideo ideo = pawn.Ideo;
@ -26,5 +19,31 @@ namespace RJWSexperience.Ideology
return false;
}
public static bool ContainAll(string str, string[] tags)
{
string lstr = str.ToLower();
if (!tags.NullOrEmpty()) for (int i = 0; i < tags.Count(); i++)
{
if (!lstr.Contains('[' + tags[i].ToLower() + ']')) return false;
}
return true;
}
public static bool IsIncest(Pawn pawn, Pawn partner)
{
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(partner);
Ideo ideo = pawn.Ideo;
bool wide = false;
if (ideo != null) wide = ideo.HasPrecept(VariousDefOf.Incestuos_Disapproved_CloseOnly);
if (!relations.EnumerableNullOrEmpty()) foreach (PawnRelationDef relation in relations)
{
if (wide)
{
if (relation.incestOpinionOffset < 0) return true;
}
else if (relation.familyByBloodRelation) return true;
}
return false;
}
}
}

View file

@ -59,6 +59,7 @@
<ItemGroup>
<Compile Include="Ideology\GoodwillSituationWorker_MemeCompatibility.cs" />
<Compile Include="Harmony.cs" />
<Compile Include="Ideology\Keyed.cs" />
<Compile Include="Ideology\PreceptDef_RequirementExtended.cs" />
<Compile Include="Ideology\Rituals\JobGiver_GangbangConsensual.cs" />
<Compile Include="Ideology\Rituals\LordJob_Rituals.cs" />
@ -76,13 +77,6 @@
<Compile Include="Ideology\Utility.cs" />
<Compile Include="VariousDefOf.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RJWSexperience\RJWSexperience.csproj">
<Project>{9c728e06-573b-4b04-a07f-acbf60cb424d}</Project>
<Name>RJWSexperience</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>

View file

@ -1,13 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using rjw;
using UnityEngine;
using rjw;
using RJWSexperience.UI;
using UnityEngine;
using Verse;
namespace RJWSexperience
{
@ -15,19 +9,13 @@ namespace RJWSexperience
{
public static string LustStatFactor(string value) => "LustStatFactor".Translate(value);
public static string SlaveStatFactor(string value) => "SlaveStatFactor".Translate(value);
public static string MemeStatFactor(string value) => "MemeStatFactor".Translate(value);
public static string RS_LostVirgin(string pawn, string partner) => "RS_LostVirgin".Translate(pawn.Colorize(Color.yellow),partner.Colorize(Color.yellow));
public static string RS_LostVirgin(string pawn, string partner) => "RS_LostVirgin".Translate(pawn.Colorize(Color.yellow), partner.Colorize(Color.yellow));
public static string RS_Sex_Info(string sextype, string sexcount) => "RS_Sex_Info".Translate(sextype, sexcount);
public static string RS_SAT_AVG(string avgsat) => "RS_SAT_AVG".Translate(avgsat);
public static string RS_HadBestSexDaysAgo(string days) => "RS_HadBestSexDaysAgo".Translate(days);
public static readonly string Mod_Title = "RS_Mod_Title".Translate();
public static readonly string SlaveStatFactorDefault = "SlaveStatFactorDefault".Translate();
public static readonly string RSVictimCondition = "RSVictimCondition".Translate();
public static readonly string RSBreederCondition = "RSBreederCondition".Translate();
public static readonly string RSNotHuman = "RSNotHuman".Translate();
public static readonly string RSNotAnimal = "RSNotAnimal".Translate();
public static readonly string RSShouldCanFuck = "RSShouldCanFuck".Translate();
public static readonly string RSTotalGatheredCum = "RSTotalGatheredCum".Translate();
public static readonly string RS_FloatMenu_CleanSelf = "RS_FloatMenu_CleanSelf".Translate();
public static readonly string RS_Best_Sextype = "RS_Best_Sextype".Translate();
@ -48,7 +36,6 @@ namespace RJWSexperience
public static readonly string RS_Most_Sex_Partner_ToolTip = "RS_Most_Sex_Partner_ToolTip".Translate();
public static readonly string RS_Best_Sex_Partner_ToolTip = "RS_Best_Sex_Partner_ToolTip".Translate();
public static readonly string RS_VirginsTaken_ToolTip = "RS_VirginsTaken_ToolTip".Translate();
public static readonly string RS_TotalSexHad_ToolTip = "RS_TotalSexHad_ToolTip".Translate();
public static readonly string RS_Raped = "RS_Raped".Translate();
public static readonly string RS_RapedMe = "RS_RapedMe".Translate();
public static readonly string RS_Sex_History = "RS_Sex_History".Translate();
@ -65,7 +52,6 @@ namespace RJWSexperience
public static readonly string None = "None".Translate();
public static readonly string RS_Bestiality = "RS_Bestiality".Translate();
public static readonly string RS_Interspecies = "RS_Interspecies".Translate();
public static readonly string RS_Normal = "RS_Normal".Translate();
public static readonly string RS_Necrophile = "RS_Necrophile".Translate();
public static readonly string RS_GatherCum = "RS_GatherCum".Translate();
public static readonly string RS_SexSkill = "RS_SexSkill".Translate();
@ -77,7 +63,6 @@ namespace RJWSexperience
public static readonly string RS_Ago = "RS_Ago".Translate();
public static readonly string RS_LastSex = "RS_LastSex".Translate();
public static readonly string Option_1_Label = "RSOption_1_Label".Translate();
public static readonly string Option_1_Desc = "RSOption_1_Desc".Translate();
public static readonly string Option_2_Label = "RSOption_2_Label".Translate();
@ -156,6 +141,5 @@ namespace RJWSexperience
((Orientation)9).ToString().Translate(),
((Orientation)10).ToString().Translate()
};
}
}

View file

@ -65,17 +65,6 @@ namespace RJWSexperience
return value;
}
public static bool ContainAll(this string str, string[] tags)
{
string lstr = str.ToLower();
if (!tags.NullOrEmpty()) for (int i=0; i< tags.Count(); i++)
{
if (!lstr.Contains('[' + tags[i].ToLower() + ']')) return false;
}
return true;
}
public static float LustFactor(this Pawn pawn)
{
float lust = pawn.records.GetValue(VariousDefOf.Lust) * Configurations.LustEffectPower;