mirror of
https://github.com/amevarashi/RJW-Sexperience.git
synced 2024-08-14 23:54:08 +00:00
Rename source folder
This commit is contained in:
parent
0a412a0060
commit
a4c046a841
55 changed files with 0 additions and 0 deletions
97
Source/RJWSexperience/ExtensionMethods/PawnExtensions.cs
Normal file
97
Source/RJWSexperience/ExtensionMethods/PawnExtensions.cs
Normal file
|
@ -0,0 +1,97 @@
|
|||
using RimWorld;
|
||||
using rjw;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience
|
||||
{
|
||||
public static class PawnExtensions
|
||||
{
|
||||
public static bool IsIncest(this Pawn pawn, Pawn otherpawn)
|
||||
{
|
||||
if (otherpawn == null)
|
||||
return false;
|
||||
|
||||
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(otherpawn);
|
||||
if (relations.EnumerableNullOrEmpty())
|
||||
return false;
|
||||
|
||||
foreach (PawnRelationDef relation in relations)
|
||||
{
|
||||
if (relation.incestOpinionOffset < 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static float GetSexStat(this Pawn pawn)
|
||||
{
|
||||
if (xxx.is_human(pawn) && !pawn.Dead)
|
||||
return pawn.GetStatValue(VariousDefOf.SexAbility);
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public static T GetAdjacentBuilding<T>(this Pawn pawn) where T : Building
|
||||
{
|
||||
if (!pawn.Spawned)
|
||||
return null;
|
||||
|
||||
EdificeGrid edifice = pawn.Map.edificeGrid;
|
||||
if (edifice[pawn.Position] is T building)
|
||||
return building;
|
||||
foreach (IntVec3 pos in GenAdjFast.AdjacentCells8Way(pawn.Position))
|
||||
{
|
||||
if (edifice[pos] is T adjBuilding)
|
||||
return adjBuilding;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IEnumerable<T> GetAdjacentBuildings<T>(this Pawn pawn) where T : Building
|
||||
{
|
||||
var results = new List<T>();
|
||||
|
||||
if (!pawn.Spawned)
|
||||
return results;
|
||||
|
||||
EdificeGrid edifice = pawn.Map.edificeGrid;
|
||||
if (edifice[pawn.Position] is T building)
|
||||
results.Add(building);
|
||||
foreach (IntVec3 pos in GenAdjFast.AdjacentCells8Way(pawn.Position))
|
||||
{
|
||||
if (edifice[pos] is T adjBuilding)
|
||||
results.Add(adjBuilding);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the pawn is virgin, return true.
|
||||
/// </summary>
|
||||
public static bool IsVirgin(this Pawn pawn)
|
||||
{
|
||||
return pawn.records.GetValue(VariousDefOf.VaginalSexCount) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If pawn is virgin, lose his/her virginity.
|
||||
/// </summary>
|
||||
public static void PoptheCherry(this Pawn pawn, Pawn partner, SexProps props)
|
||||
{
|
||||
if (props?.sexType != xxx.rjwSextype.Vaginal)
|
||||
return;
|
||||
|
||||
int? removedDegree = Virginity.TraitHandler.RemoveVirginTrait(pawn);
|
||||
|
||||
if (pawn.IsVirgin())
|
||||
{
|
||||
pawn.TryGetComp<SexHistory.SexHistoryComp>()?.RecordFirst(partner, props);
|
||||
if (removedDegree != null)
|
||||
Messages.Message(Keyed.RS_LostVirgin(pawn.LabelShort, partner.LabelShort), MessageTypeDefOf.NeutralEvent, true);
|
||||
}
|
||||
|
||||
if (removedDegree != null)
|
||||
RJWUtility.ThrowVirginHistoryEvent(pawn, partner, props, (int)removedDegree);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue