mirror of
https://github.com/amevarashi/RJW-Sexperience.git
synced 2024-08-14 23:54:08 +00:00
Move trait manipulation to a separate class
This commit is contained in:
parent
1e24da5312
commit
eab18ce2bb
6 changed files with 52 additions and 42 deletions
|
@ -1,6 +1,5 @@
|
||||||
using RimWorld;
|
using RimWorld;
|
||||||
using rjw;
|
using rjw;
|
||||||
using RJWSexperience.ExtensionMethods;
|
|
||||||
using Verse;
|
using Verse;
|
||||||
|
|
||||||
namespace RJWSexperience
|
namespace RJWSexperience
|
||||||
|
@ -14,7 +13,7 @@ namespace RJWSexperience
|
||||||
if (virgin != null) p.story.traits.RemoveTrait(virgin);
|
if (virgin != null) p.story.traits.RemoveTrait(virgin);
|
||||||
ResetRecord(p, true);
|
ResetRecord(p, true);
|
||||||
if (ResetRecord(p, false))
|
if (ResetRecord(p, false))
|
||||||
p.AddVirginTrait();
|
Virginity.TraitHandler.AddVirginTrait(p);
|
||||||
MoteMaker.ThrowText(p.TrueCenter(), p.Map, "Records resetted!");
|
MoteMaker.ThrowText(p.TrueCenter(), p.Map, "Records resetted!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,11 +21,10 @@ namespace RJWSexperience
|
||||||
private static void ResetRecordsZero(Pawn p)
|
private static void ResetRecordsZero(Pawn p)
|
||||||
{
|
{
|
||||||
ResetRecord(p, true);
|
ResetRecord(p, true);
|
||||||
p.AddVirginTrait();
|
Virginity.TraitHandler.AddVirginTrait(p);
|
||||||
MoteMaker.ThrowText(p.TrueCenter(), p.Map, "Records resetted!\nVirginified!");
|
MoteMaker.ThrowText(p.TrueCenter(), p.Map, "Records resetted!\nVirginified!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[DebugAction("RJW Sexperience", "Reset lust", false, false, actionType = DebugActionType.ToolMapForPawns, allowedGameStates = AllowedGameStates.PlayingOnMap)]
|
[DebugAction("RJW Sexperience", "Reset lust", false, false, actionType = DebugActionType.ToolMapForPawns, allowedGameStates = AllowedGameStates.PlayingOnMap)]
|
||||||
private static void ResetLust(Pawn p)
|
private static void ResetLust(Pawn p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,14 +86,14 @@ namespace RJWSexperience
|
||||||
if (pawn.IsVirgin())
|
if (pawn.IsVirgin())
|
||||||
{
|
{
|
||||||
pawn.TryGetComp<SexHistoryComp>()?.RecordFirst(partner, props);
|
pawn.TryGetComp<SexHistoryComp>()?.RecordFirst(partner, props);
|
||||||
if (RJWUtility.RemoveVirginTrait(pawn, partner, props))
|
if (Virginity.TraitHandler.RemoveVirginTrait(pawn, partner, props))
|
||||||
{
|
{
|
||||||
Messages.Message(Keyed.RS_LostVirgin(pawn.LabelShort, partner.LabelShort), MessageTypeDefOf.NeutralEvent, true);
|
Messages.Message(Keyed.RS_LostVirgin(pawn.LabelShort, partner.LabelShort), MessageTypeDefOf.NeutralEvent, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RJWUtility.RemoveVirginTrait(pawn, partner, props);
|
Virginity.TraitHandler.RemoveVirginTrait(pawn, partner, props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,24 +111,5 @@ namespace RJWSexperience
|
||||||
else return Gender.Male;
|
else return Gender.Male;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddVirginTrait(this Pawn pawn)
|
|
||||||
{
|
|
||||||
if (pawn.story?.traits == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (pawn.IsVirgin())
|
|
||||||
{
|
|
||||||
Virginity.TraitDegree degree = Virginity.TraitDegree.MaleVirgin;
|
|
||||||
if (pawn.gender == Gender.Female) degree = Virginity.TraitDegree.FemaleVirgin;
|
|
||||||
Trait virgin = new Trait(VariousDefOf.Virgin, (int)degree, true);
|
|
||||||
pawn.story.traits.GainTrait(virgin);
|
|
||||||
}
|
|
||||||
else if (pawn.gender == Gender.Female && Rand.Chance(0.05f))
|
|
||||||
{
|
|
||||||
Trait virgin = new Trait(VariousDefOf.Virgin, (int)Virginity.TraitDegree.FemaleAfterSurgery, true);
|
|
||||||
pawn.story.traits.GainTrait(virgin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace RJWSexperience
|
||||||
doVirginTrait = RecordRandomizer.Randomize(__result);
|
doVirginTrait = RecordRandomizer.Randomize(__result);
|
||||||
|
|
||||||
if (doVirginTrait)
|
if (doVirginTrait)
|
||||||
__result.AddVirginTrait();
|
Virginity.TraitHandler.AddVirginTrait(__result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
<Compile Include="Utility.cs" />
|
<Compile Include="Utility.cs" />
|
||||||
<Compile Include="VariousDefOf.cs" />
|
<Compile Include="VariousDefOf.cs" />
|
||||||
<Compile Include="Virginity\TraitDegree.cs" />
|
<Compile Include="Virginity\TraitDegree.cs" />
|
||||||
|
<Compile Include="Virginity\TraitHandler.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Krafs.Rimworld.Ref">
|
<PackageReference Include="Krafs.Rimworld.Ref">
|
||||||
|
|
|
@ -11,22 +11,6 @@ namespace RJWSexperience
|
||||||
{
|
{
|
||||||
public static class RJWUtility
|
public static class RJWUtility
|
||||||
{
|
{
|
||||||
public static bool RemoveVirginTrait(Pawn pawn, Pawn partner, SexProps props)
|
|
||||||
{
|
|
||||||
Trait virgin = pawn.story?.traits?.GetTrait(VariousDefOf.Virgin);
|
|
||||||
if (virgin == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int degree = virgin.Degree;
|
|
||||||
if (pawn.gender == Gender.Female && degree > 0 && !pawn.Dead)
|
|
||||||
{
|
|
||||||
FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, ThingDefOf.Filth_Blood, pawn.LabelShort, 1, FilthSourceFlags.Pawn);
|
|
||||||
}
|
|
||||||
ThrowVirginHIstoryEvent(pawn, partner, props, degree);
|
|
||||||
pawn.story.traits.RemoveTrait(virgin);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For ideo patch
|
/// For ideo patch
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
46
RJWSexperience/RJWSexperience/Virginity/TraitHandler.cs
Normal file
46
RJWSexperience/RJWSexperience/Virginity/TraitHandler.cs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
using RimWorld;
|
||||||
|
using rjw;
|
||||||
|
using Verse;
|
||||||
|
|
||||||
|
namespace RJWSexperience.Virginity
|
||||||
|
{
|
||||||
|
public static class TraitHandler
|
||||||
|
{
|
||||||
|
private const float hymenSurgeryChance = 0.05f;
|
||||||
|
|
||||||
|
public static void AddVirginTrait(Pawn pawn)
|
||||||
|
{
|
||||||
|
if (pawn.story?.traits == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (pawn.IsVirgin())
|
||||||
|
{
|
||||||
|
TraitDegree degree = TraitDegree.MaleVirgin;
|
||||||
|
if (pawn.gender == Gender.Female) degree = TraitDegree.FemaleVirgin;
|
||||||
|
Trait virgin = new Trait(VariousDefOf.Virgin, (int)degree, true);
|
||||||
|
pawn.story.traits.GainTrait(virgin);
|
||||||
|
}
|
||||||
|
else if (pawn.gender == Gender.Female && Rand.Chance(hymenSurgeryChance))
|
||||||
|
{
|
||||||
|
Trait virgin = new Trait(VariousDefOf.Virgin, (int)TraitDegree.FemaleAfterSurgery, true);
|
||||||
|
pawn.story.traits.GainTrait(virgin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool RemoveVirginTrait(Pawn pawn, Pawn partner, SexProps props)
|
||||||
|
{
|
||||||
|
Trait virgin = pawn.story?.traits?.GetTrait(VariousDefOf.Virgin);
|
||||||
|
if (virgin == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int degree = virgin.Degree;
|
||||||
|
if (pawn.gender == Gender.Female && degree > 0 && !pawn.Dead)
|
||||||
|
{
|
||||||
|
FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, ThingDefOf.Filth_Blood, pawn.LabelShort, 1, FilthSourceFlags.Pawn);
|
||||||
|
}
|
||||||
|
RJWUtility.ThrowVirginHIstoryEvent(pawn, partner, props, degree);
|
||||||
|
pawn.story.traits.RemoveTrait(virgin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue