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 rjw;
|
||||
using RJWSexperience.ExtensionMethods;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience
|
||||
|
@ -14,7 +13,7 @@ namespace RJWSexperience
|
|||
if (virgin != null) p.story.traits.RemoveTrait(virgin);
|
||||
ResetRecord(p, true);
|
||||
if (ResetRecord(p, false))
|
||||
p.AddVirginTrait();
|
||||
Virginity.TraitHandler.AddVirginTrait(p);
|
||||
MoteMaker.ThrowText(p.TrueCenter(), p.Map, "Records resetted!");
|
||||
}
|
||||
|
||||
|
@ -22,11 +21,10 @@ namespace RJWSexperience
|
|||
private static void ResetRecordsZero(Pawn p)
|
||||
{
|
||||
ResetRecord(p, true);
|
||||
p.AddVirginTrait();
|
||||
Virginity.TraitHandler.AddVirginTrait(p);
|
||||
MoteMaker.ThrowText(p.TrueCenter(), p.Map, "Records resetted!\nVirginified!");
|
||||
}
|
||||
|
||||
|
||||
[DebugAction("RJW Sexperience", "Reset lust", false, false, actionType = DebugActionType.ToolMapForPawns, allowedGameStates = AllowedGameStates.PlayingOnMap)]
|
||||
private static void ResetLust(Pawn p)
|
||||
{
|
||||
|
|
|
@ -86,14 +86,14 @@ namespace RJWSexperience
|
|||
if (pawn.IsVirgin())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RJWUtility.RemoveVirginTrait(pawn, partner, props);
|
||||
Virginity.TraitHandler.RemoveVirginTrait(pawn, partner, props);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,24 +111,5 @@ namespace RJWSexperience
|
|||
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);
|
||||
|
||||
if (doVirginTrait)
|
||||
__result.AddVirginTrait();
|
||||
Virginity.TraitHandler.AddVirginTrait(__result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@
|
|||
<Compile Include="Utility.cs" />
|
||||
<Compile Include="VariousDefOf.cs" />
|
||||
<Compile Include="Virginity\TraitDegree.cs" />
|
||||
<Compile Include="Virginity\TraitHandler.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Krafs.Rimworld.Ref">
|
||||
|
|
|
@ -11,22 +11,6 @@ namespace RJWSexperience
|
|||
{
|
||||
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>
|
||||
/// For ideo patch
|
||||
/// </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