code
stringlengths 0
56.1M
| repo_name
stringlengths 3
57
| path
stringlengths 2
176
| language
stringclasses 672
values | license
stringclasses 8
values | size
int64 0
56.8M
|
|---|---|---|---|---|---|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Extensions;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using System;
using System.Linq;
namespace rjw.Modules.Interactions.Implementation
{
public class LewdInteractionService : ILewdInteractionService
{
private static ILog _log = LogManager.GetLogger<LewdInteractionService, InteractionLogProvider>();
public static ILewdInteractionService Instance { get; private set; }
static LewdInteractionService()
{
Instance = new LewdInteractionService();
_interactionTypeDetectorService = InteractionTypeDetectorService.Instance;
_reverseDetectorService = ReverseDetectorService.Instance;
_interactionSelectorService = InteractionSelectorService.Instance;
_interactionBuilderService = InteractionBuilderService.Instance;
_blockedPartDetectorService = BlockedPartDetectorService.Instance;
_partPreferenceDetectorService = PartPreferenceDetectorService.Instance;
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private LewdInteractionService() { }
private readonly static IInteractionTypeDetectorService _interactionTypeDetectorService;
private readonly static IReverseDetectorService _reverseDetectorService;
private readonly static IInteractionSelectorService _interactionSelectorService;
private readonly static IInteractionBuilderService _interactionBuilderService;
private readonly static IBlockedPartDetectorService _blockedPartDetectorService;
private readonly static IPartPreferenceDetectorService _partPreferenceDetectorService;
public InteractionOutputs GenerateInteraction(InteractionInputs inputs)
{
///TODO : remove the logs once it works
InteractionContext context = new InteractionContext(inputs);
_log.Debug($"Generating Interaction for {context.Inputs.Initiator.GetName()} and {context.Inputs.Partner.GetName()}");
Initialize(context);
_log.Debug($"Initialized as InteractionType : {context.Internals.InteractionType} IsReverse : {context.Internals.IsReverse}");
//Detect parts that are unusable / missing
_blockedPartDetectorService.DetectBlockedParts(context.Internals);
_log.Debug($"Blocked parts for dominant {context.Internals.Dominant.BlockedParts.Select(e => $"[{e}]").Aggregate(String.Empty, (e,f) => $"{e}-{f}")}");
_log.Debug($"Blocked parts for submissive {context.Internals.Submissive.BlockedParts.Select(e => $"[{e}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
//Calculate parts usage preferences for Dominant and Submissive
_partPreferenceDetectorService.DetectPartPreferences(context);
_log.Debug($"Part preferences for dominant {context.Internals.Dominant.PartPreferences.Select(e => $"[{e.Key}-{e.Value}]").Aggregate(String.Empty, (e,f)=> $"{e}-{f}")}");
_log.Debug($"Part preferences for submissive {context.Internals.Submissive.PartPreferences.Select(e => $"[{e.Key}-{e.Value}]").Aggregate(String.Empty, (e,f)=> $"{e}-{f}")}");
context.Internals.Selected = _interactionSelectorService.Select(context);
_log.Message($"Selected Interaction [{context.Internals.Selected.Interaction.defName}] for {context.Inputs.Initiator.GetName()} and {context.Inputs.Partner.GetName()}");
_interactionBuilderService.Build(context);
_log.Debug($"SelectedParts for dominant {context.Outputs.Generated.SelectedDominantParts.Select(e => $"[{e.PartKind}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
_log.Debug($"SelectedParts for submissive {context.Outputs.Generated.SelectedSubmissiveParts.Select(e => $"[{e.PartKind}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
return context.Outputs;
}
private void Initialize(InteractionContext context)
{
context.Internals.InteractionType =
context.Outputs.Generated.InteractionType =
_interactionTypeDetectorService.DetectInteractionType(context);
context.Internals.Dominant = new Objects.InteractionPawn
{
Pawn = context.Inputs.Initiator,
Parts = context.Inputs.Initiator.GetSexablePawnParts()
};
context.Internals.Submissive = new Objects.InteractionPawn
{
Pawn = context.Inputs.Partner,
Parts = context.Inputs.Partner.GetSexablePawnParts()
};
context.Internals.Dominant.Gender = Genitals.Helpers.GenderHelper.GetGender(context.Internals.Dominant);
context.Internals.Submissive.Gender = Genitals.Helpers.GenderHelper.GetGender(context.Internals.Submissive);
context.Internals.IsReverse = _reverseDetectorService.IsReverse(context);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Implementation/LewdInteractionService.cs
|
C#
|
mit
| 4,644
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.DefModExtensions;
using rjw.Modules.Interactions.Extensions;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using System;
using System.Linq;
using RimWorld;
using Verse;
namespace rjw.Modules.Interactions.Implementation
{
public class LewdInteractionValidatorService : ILewdInteractionValidatorService
{
private static ILog _log = LogManager.GetLogger<LewdInteractionService, InteractionLogProvider>();
public static ILewdInteractionValidatorService Instance { get; private set; }
static LewdInteractionValidatorService()
{
Instance = new LewdInteractionValidatorService();
_interactionRequirementService = InteractionRequirementService.Instance;
_blockedPartDetectorService = BlockedPartDetectorService.Instance;
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private LewdInteractionValidatorService() { }
private readonly static IInteractionRequirementService _interactionRequirementService;
private readonly static IBlockedPartDetectorService _blockedPartDetectorService;
public bool IsValid(InteractionDef interaction, Pawn dominant, Pawn submissive)
{
InteractionPawn iDominant, iSubmissive;
InteractionWithExtension iInteraction;
try
{
Assert(interaction);
}
catch(NotImplementedException)
{
return false;
}
iDominant = ConvertPawn(dominant);
iSubmissive = ConvertPawn(submissive);
iInteraction = ConvertInteraction(interaction);
//Detect parts that are unusable / missing
iDominant.BlockedParts = _blockedPartDetectorService.BlockedPartsForPawn(iDominant);
iSubmissive.BlockedParts = _blockedPartDetectorService.BlockedPartsForPawn(iSubmissive);
return _interactionRequirementService.FufillRequirements(iInteraction, iDominant, iSubmissive);
}
private void Assert(InteractionDef interaction)
{
if (interaction.HasModExtension<InteractionSelectorExtension>() == false)
{
string message = $"The interaction {interaction.defName} doesn't have the required {nameof(InteractionSelectorExtension)} extention";
_log.Error(message);
throw new NotImplementedException(message);
}
if (interaction.HasModExtension<InteractionExtension>() == false)
{
string message = $"The interaction {interaction.defName} doesn't have the required {nameof(InteractionExtension)} extention";
_log.Error(message);
throw new NotImplementedException(message);
}
}
private InteractionWithExtension ConvertInteraction(InteractionDef interaction)
{
return new InteractionWithExtension
{
Interaction = interaction,
Extension = interaction.GetModExtension<InteractionExtension>(),
SelectorExtension = interaction.GetModExtension<InteractionSelectorExtension>()
};
}
private InteractionPawn ConvertPawn(Pawn pawn)
{
return new InteractionPawn
{
Pawn = pawn,
Parts = pawn.GetSexablePawnParts()
};
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Implementation/LewdInteractionValidatorService.cs
|
C#
|
mit
| 3,152
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Extensions;
using rjw.Modules.Interactions.Helpers;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using System;
using System.Linq;
namespace rjw.Modules.Interactions.Implementation
{
public class SpecificLewdInteractionService : ISpecificLewdInteractionService
{
private static ILog _log = LogManager.GetLogger<SpecificLewdInteractionService, InteractionLogProvider>();
public static ISpecificLewdInteractionService Instance { get; private set; }
static SpecificLewdInteractionService()
{
Instance = new SpecificLewdInteractionService();
_interactionTypeDetectorService = InteractionTypeDetectorService.Instance;
_interactionBuilderService = InteractionBuilderService.Instance;
_blockedPartDetectorService = BlockedPartDetectorService.Instance;
_partPreferenceDetectorService = PartPreferenceDetectorService.Instance;
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private SpecificLewdInteractionService() { }
private readonly static IInteractionTypeDetectorService _interactionTypeDetectorService;
private readonly static IInteractionBuilderService _interactionBuilderService;
private readonly static IBlockedPartDetectorService _blockedPartDetectorService;
private readonly static IPartPreferenceDetectorService _partPreferenceDetectorService;
public InteractionOutputs GenerateSpecificInteraction(SpecificInteractionInputs inputs)
{
///TODO : remove the logs once it works
InteractionContext context = new InteractionContext();
_log.Debug($"Generating Specific Interaction {inputs.Interaction.defName} for {context.Inputs.Initiator?.GetName()} and {context.Inputs.Partner?.GetName()}");
Initialize(context, inputs);
//Detect parts that are unusable / missing
_blockedPartDetectorService.DetectBlockedParts(context.Internals);
_log.Debug($"Blocked parts for dominant {context.Internals.Dominant.BlockedParts.Select(e => $"[{e}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
_log.Debug($"Blocked parts for submissive {context.Internals.Submissive.BlockedParts.Select(e => $"[{e}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
//Calculate parts usage preferences for Dominant and Submissive
_partPreferenceDetectorService.DetectPartPreferences(context);
_log.Debug($"Part preferences for dominant {context.Internals.Dominant.PartPreferences.Select(e => $"[{e.Key}-{e.Value}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
_log.Debug($"Part preferences for submissive {context.Internals.Submissive.PartPreferences.Select(e => $"[{e.Key}-{e.Value}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
_interactionBuilderService.Build(context);
_log.Debug($"SelectedParts for dominant {context.Outputs.Generated.SelectedDominantParts.Select(e => $"[{e.PartKind}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
_log.Debug($"SelectedParts for submissive {context.Outputs.Generated.SelectedSubmissiveParts.Select(e => $"[{e.PartKind}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
return context.Outputs;
}
private void Initialize(InteractionContext context, SpecificInteractionInputs inputs)
{
context.Internals.Selected = InteractionHelper.GetWithExtension(inputs.Interaction);
context.Outputs.Generated = new Objects.Interaction()
{
InteractionDef = context.Internals.Selected
};
context.Inputs = new InteractionInputs()
{
Initiator = inputs.Initiator,
Partner = inputs.Partner,
IsRape = context.Outputs.Generated.InteractionDef.HasInteractionTag(Enums.InteractionTag.Rape),
IsWhoring = context.Outputs.Generated.InteractionDef.HasInteractionTag(Enums.InteractionTag.Whoring)
};
context.Internals.InteractionType =
context.Outputs.Generated.InteractionType =
_interactionTypeDetectorService.DetectInteractionType(
context
);
context.Internals.Dominant = new Objects.InteractionPawn
{
Pawn = context.Inputs.Initiator,
Parts = context.Inputs.Initiator.GetSexablePawnParts()
};
context.Internals.Submissive = new Objects.InteractionPawn
{
Pawn = context.Inputs.Partner,
Parts = context.Inputs.Partner.GetSexablePawnParts()
};
context.Internals.Dominant.Gender = Genitals.Helpers.GenderHelper.GetGender(context.Internals.Dominant);
context.Internals.Submissive.Gender = Genitals.Helpers.GenderHelper.GetGender(context.Internals.Submissive);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Implementation/SpecificLewdInteractionService.cs
|
C#
|
mit
| 4,627
|
using rjw.Modules.Shared.Logs;
namespace rjw.Modules.Interactions
{
public class InteractionLogProvider : ILogProvider
{
public bool IsActive => RJWSettings.DebugInteraction;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/InteractionLogProvider.cs
|
C#
|
mit
| 188
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using System.Collections.Generic;
namespace rjw.Modules.Interactions.Internals
{
public interface IBlockedPartDetectorService
{
IList<LewdablePartKind> BlockedPartsForPawn(InteractionPawn pawn);
/// <summary>
/// Detect the blocked parts for both pawn and fill
/// <see cref="InteractionPawn.BlockedParts"/>
/// </summary>
/// <param name="context"></param>
void DetectBlockedParts(InteractionInternals context);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IBlockedPartDetectorService.cs
|
C#
|
mit
| 558
|
using rjw.Modules.Interactions.Contexts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals
{
public interface IInteractionBuilderService
{
/// <summary>
/// Fill the output interaction with all the good stuff !
/// </summary>
void Build(InteractionContext context);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IInteractionBuilderService.cs
|
C#
|
mit
| 396
|
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals
{
public interface IInteractionRepository
{
IEnumerable<InteractionWithExtension> List();
IEnumerable<InteractionWithExtension> ListForMasturbation();
IEnumerable<InteractionWithExtension> ListForAnimal();
IEnumerable<InteractionWithExtension> ListForBestiality();
IEnumerable<InteractionWithExtension> ListForRape();
IEnumerable<InteractionWithExtension> ListForConsensual();
IEnumerable<InteractionWithExtension> ListForMechanoid();
IEnumerable<InteractionWithExtension> ListForWhoring();
IEnumerable<InteractionWithExtension> ListForNecrophilia();
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IInteractionRepository.cs
|
C#
|
mit
| 782
|
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals
{
public interface IInteractionScoringService
{
InteractionScore Score(InteractionWithExtension interaction, InteractionPawn dominant, InteractionPawn submissive);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IInteractionScoringService.cs
|
C#
|
mit
| 378
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals
{
public interface IInteractionSelectorService
{
InteractionWithExtension Select(InteractionContext context);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IInteractionSelectorService.cs
|
C#
|
mit
| 403
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using Verse;
namespace rjw.Modules.Interactions.Internals
{
public interface IInteractionTypeDetectorService
{
InteractionType DetectInteractionType(InteractionContext context);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IInteractionTypeDetectorService.cs
|
C#
|
mit
| 270
|
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Objects.Parts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals
{
public interface IPartFinderService
{
IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, string partProp);
IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, LewdablePartKind partKind);
IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, GenitalFamily family);
IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, GenitalFamily family, IList<string> partProp);
IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, GenitalTag tag);
IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, GenitalTag tag, IList<string> partProp);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IPartFinderService.cs
|
C#
|
mit
| 942
|
using rjw.Modules.Interactions.Contexts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals
{
public interface IPartPreferenceDetectorService
{
void DetectPartPreferences(InteractionContext context);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IPartPreferenceDetectorService.cs
|
C#
|
mit
| 323
|
using rjw.Modules.Interactions.Defs.DefFragment;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Objects.Parts;
using System.Collections.Generic;
namespace rjw.Modules.Interactions.Internals
{
public interface IPartSelectorService
{
IList<ILewdablePart> SelectPartsForPawn(InteractionPawn pawn, InteractionRequirement requirement);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IPartSelectorService.cs
|
C#
|
mit
| 368
|
using rjw.Modules.Interactions.Contexts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals
{
public interface IReverseDetectorService
{
bool IsReverse(InteractionContext context);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IReverseDetectorService.cs
|
C#
|
mit
| 304
|
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Internals
{
public interface IRulePackService
{
RulePackDef FindInteractionRulePack(InteractionWithExtension interaction);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/IRulePackService.cs
|
C#
|
mit
| 340
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Rules.PartBlockedRules;
using rjw.Modules.Interactions.Rules.PartBlockedRules.Implementation;
using System.Collections.Generic;
using System.Linq;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class BlockedPartDetectorService : IBlockedPartDetectorService
{
public static IBlockedPartDetectorService Instance { get; private set; }
static BlockedPartDetectorService()
{
Instance = new BlockedPartDetectorService();
_partBlockedRules = new List<IPartBlockedRule>()
{
DeadPartBlockedRule.Instance,
DownedPartBlockedRule.Instance,
UnconsciousPartBlockedRule.Instance,
MainPartBlockedRule.Instance,
PartAvailibilityPartBlockedRule.Instance,
};
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private BlockedPartDetectorService() { }
private readonly static IList<IPartBlockedRule> _partBlockedRules;
public void DetectBlockedParts(InteractionInternals context)
{
context.Dominant.BlockedParts = BlockedPartsForPawn(context.Dominant);
context.Submissive.BlockedParts = BlockedPartsForPawn(context.Submissive);
}
public IList<LewdablePartKind> BlockedPartsForPawn(InteractionPawn pawn)
{
return _partBlockedRules
.SelectMany(e => e.BlockedParts(pawn))
//Eliminate the duplicates
.Distinct()
.ToList();
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/BlockedPartDetectorService.cs
|
C#
|
mit
| 1,509
|
using rjw.Modules.Interactions.Contexts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class InteractionBuilderService : IInteractionBuilderService
{
public static IInteractionBuilderService Instance { get; private set; }
static InteractionBuilderService()
{
Instance = new InteractionBuilderService();
_rulePackService = RulePackService.Instance;
_partSelectorService = PartSelectorService.Instance;
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private InteractionBuilderService() { }
private readonly static IRulePackService _rulePackService;
private readonly static IPartSelectorService _partSelectorService;
public void Build(InteractionContext context)
{
context.Outputs.Generated.Dominant = context.Internals.Dominant;
context.Outputs.Generated.Submissive = context.Internals.Submissive;
//Participants
if (context.Internals.IsReverse)
{
context.Outputs.Generated.Initiator = context.Internals.Submissive;
context.Outputs.Generated.Receiver = context.Internals.Dominant;
}
else
{
context.Outputs.Generated.Initiator = context.Internals.Dominant;
context.Outputs.Generated.Receiver = context.Internals.Submissive;
}
context.Outputs.Generated.InteractionDef = context.Internals.Selected;
context.Outputs.Generated.RjwSexType = ParseHelper.FromString<xxx.rjwSextype>(context.Internals.Selected.Extension.rjwSextype);
context.Outputs.Generated.RulePack = _rulePackService.FindInteractionRulePack(context.Internals.Selected);
context.Outputs.Generated.SelectedDominantParts = _partSelectorService.SelectPartsForPawn(
context.Internals.Dominant,
context.Internals.Selected.SelectorExtension.dominantRequirement
);
context.Outputs.Generated.SelectedSubmissiveParts = _partSelectorService.SelectPartsForPawn(
context.Internals.Submissive,
context.Internals.Selected.SelectorExtension.submissiveRequirement
);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/InteractionBuilderService.cs
|
C#
|
mit
| 2,137
|
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class InteractionRepository : IInteractionRepository
{
public static IInteractionRepository Instance { get; private set; }
static InteractionRepository()
{
Instance = new InteractionRepository();
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private InteractionRepository() { }
public IEnumerable<InteractionWithExtension> List()
{
return InteractionDefOf.Interactions;
}
public IEnumerable<InteractionWithExtension> ListForMasturbation()
{
return List()
.Where(interaction => interaction.HasInteractionTag(InteractionTag.Masturbation));
}
public IEnumerable<InteractionWithExtension> ListForAnimal()
{
return List()
.Where(interaction => interaction.HasInteractionTag(InteractionTag.Animal));
}
public IEnumerable<InteractionWithExtension> ListForBestiality()
{
return List()
.Where(interaction => interaction.HasInteractionTag(InteractionTag.Bestiality));
}
public IEnumerable<InteractionWithExtension> ListForConsensual()
{
return List()
.Where(interaction => interaction.HasInteractionTag(InteractionTag.Consensual));
}
public IEnumerable<InteractionWithExtension> ListForRape()
{
return List()
.Where(interaction => interaction.HasInteractionTag(InteractionTag.Rape));
}
public IEnumerable<InteractionWithExtension> ListForWhoring()
{
return List()
.Where(interaction => interaction.HasInteractionTag(InteractionTag.Whoring));
}
public IEnumerable<InteractionWithExtension> ListForNecrophilia()
{
return List()
.Where(interaction => interaction.HasInteractionTag(InteractionTag.Necrophilia));
}
public IEnumerable<InteractionWithExtension> ListForMechanoid()
{
return List()
.Where(interaction => interaction.HasInteractionTag(InteractionTag.MechImplant));
}
public IEnumerable<InteractionWithExtension> List(InteractionType interactionType)
{
switch (interactionType)
{
case InteractionType.Whoring:
return ListForWhoring();
case InteractionType.Rape:
return ListForRape();
case InteractionType.Bestiality:
return ListForBestiality();
case InteractionType.Animal:
return ListForAnimal();
case InteractionType.Necrophilia:
return ListForNecrophilia();
case InteractionType.Mechanoid:
return ListForMechanoid();
case InteractionType.Consensual:
default:
return ListForConsensual();
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/InteractionRepository.cs
|
C#
|
mit
| 2,797
|
using rjw.Modules.Interactions.Defs.DefFragment;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Objects.Parts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Verse;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class InteractionScoringService : IInteractionScoringService
{
public static IInteractionScoringService Instance { get; private set; }
static InteractionScoringService()
{
Instance = new InteractionScoringService();
_partFinderService = PartFinderService.Instance;
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private InteractionScoringService() { }
private static readonly IPartFinderService _partFinderService;
public InteractionScore Score(InteractionWithExtension interaction, InteractionPawn dominant, InteractionPawn submissive)
{
return new InteractionScore()
{
Dominant = Score(interaction.SelectorExtension.dominantRequirement, dominant),
Submissive = Score(interaction.SelectorExtension.submissiveRequirement, submissive),
Setting = SettingScore(interaction)
};
}
private float Score(InteractionRequirement requirement, InteractionPawn pawn)
{
int allowed = 1;
IList<ILewdablePart> availableParts;
IEnumerable<(ILewdablePart Part, float Score)> scoredParts;
//Find the parts !
availableParts = GetAvailablePartsForInteraction(requirement, pawn);
//Score the parts !
scoredParts = availableParts
.Select(e => (e, pawn.PartPreferences[e.PartKind]));
//Order the parts !
scoredParts = scoredParts
.OrderByDescending(e => e.Score);
if (requirement.minimumCount.HasValue == true && requirement.minimumCount.Value > 0)
{
allowed = requirement.minimumCount.Value;
}
return scoredParts
//Take the allowed part count
.Take(allowed)
.Select(e => e.Score)
//Multiply the parts scores
.Aggregate(1f, (e, f) => e * f);
}
private IList<ILewdablePart> GetAvailablePartsForInteraction(InteractionRequirement requirement, InteractionPawn pawn)
{
List<ILewdablePart> result = new List<ILewdablePart>();
//need hand
if (requirement.hand == true)
{
result.AddRange(_partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Hand));
}
//need foot
if (requirement.foot == true)
{
result.AddRange(_partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Foot));
}
//need mouth
if (requirement.mouth == true || requirement.mouthORbeak == true)
{
result.AddRange(_partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Mouth));
}
//need beak
if (requirement.beak == true || requirement.mouthORbeak == true)
{
result.AddRange(_partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Beak));
}
//need tongue
if (requirement.tongue == true)
{
result.AddRange(_partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Tongue));
}
//need tail
if (requirement.tail == true)
{
result.AddRange(_partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Tail));
}
//need family
if (requirement.families != null && requirement.families.Any())
{
foreach (GenitalFamily family in requirement.families)
{
result.AddRange(_partFinderService.FindUnblockedForPawn(pawn, family));
}
}
//need tag
if (requirement.tags != null && requirement.tags.Any())
{
foreach (GenitalTag tag in requirement.tags)
{
result.AddRange(_partFinderService.FindUnblockedForPawn(pawn, tag));
}
}
return result;
}
private float SettingScore(InteractionWithExtension interaction)
{
xxx.rjwSextype type = ParseHelper.FromString<xxx.rjwSextype>(interaction.Extension.rjwSextype);
switch (type)
{
case xxx.rjwSextype.Vaginal:
return RJWPreferenceSettings.vaginal;
case xxx.rjwSextype.Anal:
return RJWPreferenceSettings.anal;
case xxx.rjwSextype.DoublePenetration:
return RJWPreferenceSettings.double_penetration;
case xxx.rjwSextype.Boobjob:
return RJWPreferenceSettings.breastjob;
case xxx.rjwSextype.Handjob:
return RJWPreferenceSettings.handjob;
case xxx.rjwSextype.Footjob:
return RJWPreferenceSettings.footjob;
case xxx.rjwSextype.Fingering:
return RJWPreferenceSettings.fingering;
case xxx.rjwSextype.Scissoring:
return RJWPreferenceSettings.scissoring;
case xxx.rjwSextype.MutualMasturbation:
return RJWPreferenceSettings.mutual_masturbation;
case xxx.rjwSextype.Fisting:
return RJWPreferenceSettings.fisting;
case xxx.rjwSextype.Rimming:
return RJWPreferenceSettings.rimming;
case xxx.rjwSextype.Fellatio:
return RJWPreferenceSettings.fellatio;
case xxx.rjwSextype.Cunnilingus:
return RJWPreferenceSettings.cunnilingus;
case xxx.rjwSextype.Sixtynine:
return RJWPreferenceSettings.sixtynine;
default:
return 1;
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/InteractionScoringService.cs
|
C#
|
mit
| 5,099
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Extensions;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Rules.InteractionRules;
using rjw.Modules.Interactions.Rules.InteractionRules.Implementation;
using rjw.Modules.Shared;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Helpers;
using rjw.Modules.Shared.Logs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class InteractionSelectorService : IInteractionSelectorService
{
private static ILog _log = LogManager.GetLogger<InteractionSelectorService, InteractionLogProvider>();
public static IInteractionSelectorService Instance { get; private set; }
static InteractionSelectorService()
{
Instance = new InteractionSelectorService();
_interactionCompatibilityService = InteractionRequirementService.Instance;
_interactionScoringService = InteractionScoringService.Instance;
_interactionRules = new List<IInteractionRule>()
{
new MasturbationInteractionRule(),
new AnimalInteractionRule(),
new BestialityInteractionRule(),
new ConsensualInteractionRule(),
new RapeInteractionRule(),
new WhoringInteractionRule(),
new NecrophiliaInteractionRule(),
new MechImplantInteractionRule()
};
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private InteractionSelectorService() { }
private static readonly IInteractionRequirementService _interactionCompatibilityService;
private static readonly IInteractionScoringService _interactionScoringService;
private static readonly IList<IInteractionRule> _interactionRules;
public InteractionWithExtension Select(InteractionContext context)
{
IInteractionRule rule = FindRule(context.Internals.InteractionType);
_log.Debug($"[available] {rule.Interactions.Select(e => $"[{e.Interaction.defName}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
IEnumerable<InteractionWithExtension> interactions = rule.Interactions
.FilterReverse(context.Internals.IsReverse)
// Filter the interaction by removing those where the requirements are not met
.Where(e => _interactionCompatibilityService.FufillRequirements(e, context.Internals.Dominant, context.Internals.Submissive));
_log.Debug($"[available] {rule.Interactions.Select(e => $"[{e.Interaction.defName}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
//Now we score each remaining interactions
IList<Weighted<InteractionWithExtension>> scored = interactions
.Select(e => new Weighted<InteractionWithExtension>(Score(context, e, rule), e))
.ToList();
_log.Debug($"[Scores] {scored.Select(e => $"[{e.Element.Interaction.defName}-{e.Weight}]").Aggregate(String.Empty, (e, f) => $"{e}-{f}")}");
InteractionWithExtension result = RandomHelper.WeightedRandom(scored);
if (result == null)
{
result = rule.Default;
_log.Warning($"No eligible interaction found for Type {context.Internals.InteractionType}, IsReverse {context.Internals.IsReverse}, Initiator {context.Inputs.Initiator.GetName()}, Partner {context.Inputs.Partner.GetName()}. Using default {result?.Interaction.defName}.");
}
return result;
}
private float Score(InteractionContext context, InteractionWithExtension interaction, IInteractionRule rule)
{
return _interactionScoringService.Score(interaction, context.Internals.Dominant, context.Internals.Submissive)
.GetScore(rule.SubmissivePreferenceWeight);
}
private IInteractionRule FindRule(InteractionType interactionType)
{
return _interactionRules
.Where(e => e.InteractionType == interactionType)
.FirstOrDefault();
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/InteractionSelectorService.cs
|
C#
|
mit
| 3,880
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class InteractionTypeDetectorService : IInteractionTypeDetectorService
{
private static ILog _log = LogManager.GetLogger<InteractionTypeDetectorService, InteractionLogProvider>();
public static IInteractionTypeDetectorService Instance { get; private set; }
static InteractionTypeDetectorService()
{
Instance = new InteractionTypeDetectorService();
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private InteractionTypeDetectorService() { }
public InteractionType DetectInteractionType(InteractionContext context)
{
InteractionType result = DetectInteractionType(
context.Inputs.Initiator,
context.Inputs.Partner,
context.Inputs.IsRape,
context.Inputs.IsWhoring
);
if (result == InteractionType.Masturbation)
{
context.Inputs.Partner = context.Inputs.Initiator;
}
return result;
}
private InteractionType DetectInteractionType(Pawn initiator, Pawn partner, bool isRape, bool isWhoring)
{
_log.Debug(initiator.GetName());
_log.Debug(partner.GetName());
if (initiator == partner || partner == null)
{
partner = initiator;
return InteractionType.Masturbation;
}
if (partner.health.Dead == true)
{
return InteractionType.Necrophilia;
}
if (xxx.is_mechanoid(initiator))
{
return InteractionType.Mechanoid;
}
//Either one or the other but not both
if (xxx.is_animal(initiator) ^ xxx.is_animal(partner))
{
return InteractionType.Bestiality;
}
if (xxx.is_animal(initiator) && xxx.is_animal(partner))
{
return InteractionType.Animal;
}
if (isWhoring)
{
return InteractionType.Whoring;
}
if (isRape)
{
return InteractionType.Rape;
}
return InteractionType.Consensual;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/InteractionTypeDetectorService.cs
|
C#
|
mit
| 2,185
|
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Extensions;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Objects.Parts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class PartFinderService : IPartFinderService
{
public static IPartFinderService Instance { get; private set; }
static PartFinderService()
{
Instance = new PartFinderService();
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private PartFinderService() { }
public IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, string partProp)
{
return pawn.ListLewdableParts()
.Where(e => pawn.BlockedParts.Contains(e.PartKind) == false)
.OfType<RJWLewdablePart>()
.Where(e => e.Props.Contains(partProp));
}
public IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, LewdablePartKind partKind)
{
if (pawn.BlockedParts.Contains(partKind))
{
return Enumerable.Empty<ILewdablePart>();
}
return pawn.ListLewdableParts()
.Where(e => e.PartKind == partKind);
}
public IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, GenitalFamily family)
{
return pawn.ListLewdableParts()
.Where(e => pawn.BlockedParts.Contains(e.PartKind) == false)
.OfType<RJWLewdablePart>()
.Where(e => e.Part.Def.genitalFamily == family);
}
public IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, GenitalFamily family, IList<string> partProp)
{
var eligibles = pawn.ListLewdableParts()
.Where(e => pawn.BlockedParts.Contains(e.PartKind) == false)
.OfType<RJWLewdablePart>()
.Where(e => e.Part.Def.genitalFamily == family);
if (partProp == null || partProp.Any() == false)
{
return eligibles;
}
return eligibles
.Where(e => e.Props.Any())
.Where(e => partProp.All(prop => e.Props.Contains(prop)));
}
public IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, GenitalTag tag)
{
return pawn.ListLewdableParts()
.Where(e => pawn.BlockedParts.Contains(e.PartKind) == false)
.OfType<RJWLewdablePart>()
.Where(e => e.Part.Def.genitalTags.Contains(tag));
}
public IEnumerable<ILewdablePart> FindUnblockedForPawn(InteractionPawn pawn, GenitalTag tag, IList<string> partProp)
{
var eligibles = pawn.ListLewdableParts()
.Where(e => pawn.BlockedParts.Contains(e.PartKind) == false)
.OfType<RJWLewdablePart>()
.Where(e => e.Part.Def.genitalTags.Contains(tag));
if (partProp == null || partProp.Any() == false)
{
return eligibles;
}
return eligibles
.Where(e => e.Props.Any())
.Where(e => partProp.All(prop => e.Props.Contains(prop)));
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/PartFinderService.cs
|
C#
|
mit
| 2,883
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Rules.PartKindUsageRules;
using rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class PartPreferenceDetectorService : IPartPreferenceDetectorService
{
public static IPartPreferenceDetectorService Instance { get; private set; }
static PartPreferenceDetectorService()
{
Instance = new PartPreferenceDetectorService();
_partKindUsageRules = new List<IPartPreferenceRule>()
{
new AnimalPartKindUsageRule(),
new BestialityForZoophilePartKindUsageRule(),
new BestialityPartKindUsageRule(),
new BigBreastsPartKindUsageRule(),
new MainPartKindUsageRule(),
new PawnAlreadySatisfiedPartKindUsageRule(),
new QuirksPartKindUsageRule(),
new RapePartKindUsageRule(),
new SizeDifferencePartKindUsageRule(),
new WhoringPartKindUsageRule(),
new PregnancyApproachPartKindUsageRule(),
};
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private PartPreferenceDetectorService() { }
private readonly static IList<IPartPreferenceRule> _partKindUsageRules;
public void DetectPartPreferences(InteractionContext context)
{
context.Internals.Dominant.PartPreferences = PartPreferencesForDominant(context);
context.Internals.Submissive.PartPreferences = BlockedPartsForSubmissive(context);
}
private IDictionary<LewdablePartKind, float> PartPreferencesForDominant(InteractionContext context)
{
IList<Weighted<LewdablePartKind>> preferences = _partKindUsageRules
.SelectMany(e => e.ModifiersForDominant(context))
.ToList();
return MergeWithDefaultDictionary(context.Internals.Dominant, preferences);
}
private IDictionary<LewdablePartKind, float> BlockedPartsForSubmissive(InteractionContext context)
{
IList<Weighted<LewdablePartKind>> preferences = _partKindUsageRules
.SelectMany(e => e.ModifiersForSubmissive(context))
.ToList();
return MergeWithDefaultDictionary(context.Internals.Submissive, preferences);
}
private IDictionary<LewdablePartKind, float> MergeWithDefaultDictionary(InteractionPawn pawn, IList<Weighted<LewdablePartKind>> preferences)
{
//A dictionary containing every part kind with a value of 1.0f (aka defaults)
//it'll prevent exceptions to be thrown if you did preferences[missingKey]
IDictionary<LewdablePartKind, float> result = Enum.GetValues(typeof(LewdablePartKind))
.OfType<LewdablePartKind>()
//We don't want that ...
.Where(e => e != LewdablePartKind.Unsupported)
//We don't want these either
.Where(e => pawn.BlockedParts.Contains(e) == false)
.ToDictionary(e => e, e => 1.0f);
//Put the values in the dictionary
foreach (KeyValuePair<LewdablePartKind, float> element in result.ToList())
{
if (preferences.Where(e => e.Element == element.Key).Any())
{
result[element.Key] *= preferences
.Where(e => e.Element == element.Key)
.Select(e => e.Weight)
.Aggregate((e, f) => e * f);
}
}
return result;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/PartPreferenceDetectorService.cs
|
C#
|
mit
| 3,360
|
using rjw.Modules.Interactions.Defs.DefFragment;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Objects.Parts;
using System.Collections.Generic;
using System.Linq;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class PartSelectorService : IPartSelectorService
{
public static IPartSelectorService Instance { get; private set; }
static PartSelectorService()
{
Instance = new PartSelectorService();
_partFinderService = PartFinderService.Instance;
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private PartSelectorService() { }
private readonly static IPartFinderService _partFinderService;
public IList<ILewdablePart> SelectPartsForPawn(InteractionPawn pawn, InteractionRequirement requirement)
{
int required = 1;
if (requirement.minimumCount.HasValue)
{
required = requirement.minimumCount.Value;
}
return EligebleParts(pawn, requirement)
.Where(e => pawn.PartPreferences.ContainsKey(e.PartKind))
.Select(e => new { Part = e, Preference = pawn.PartPreferences[e.PartKind] })
.OrderByDescending(e => e.Preference)
.Take(required)
.Select(e => e.Part)
.ToList();
}
private IEnumerable<ILewdablePart> EligebleParts(InteractionPawn pawn, InteractionRequirement requirement)
{
if (requirement.hand == true)
{
foreach (var part in _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Hand))
{
yield return part;
}
}
if (requirement.foot == true)
{
foreach (var part in _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Foot))
{
yield return part;
}
}
if (requirement.mouth == true || requirement.mouthORbeak == true)
{
foreach (var part in _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Mouth))
{
yield return part;
}
}
if (requirement.beak == true || requirement.mouthORbeak == true)
{
foreach (var part in _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Beak))
{
yield return part;
}
}
if (requirement.tongue == true)
{
foreach (var part in _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Tongue))
{
yield return part;
}
}
if (requirement.tail == true)
{
foreach (var part in _partFinderService.FindUnblockedForPawn(pawn, LewdablePartKind.Tail))
{
yield return part;
}
}
if (requirement.families != null && requirement.families.Any())
{
foreach (GenitalFamily family in requirement.families)
{
foreach (var part in _partFinderService.FindUnblockedForPawn(pawn, family))
{
yield return part;
}
}
}
if (requirement.tags != null && requirement.tags.Any())
{
foreach (GenitalTag tag in requirement.tags)
{
foreach (var part in _partFinderService.FindUnblockedForPawn(pawn, tag))
{
yield return part;
}
}
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/PartSelectorService.cs
|
C#
|
mit
| 3,032
|
using Multiplayer.API;
using rjw.Modules.Genitals.Enums;
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Shared.Logs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class ReverseDetectorService : IReverseDetectorService
{
private static ILog _log = LogManager.GetLogger<ReverseDetectorService, InteractionLogProvider>();
public static IReverseDetectorService Instance { get; private set; }
static ReverseDetectorService()
{
Instance = new ReverseDetectorService();
_random = new Random();
}
private static readonly Random _random;
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private ReverseDetectorService() { }
private const float ReverseRapeChanceForFemale = 90 / 100f;
private const float ReverseRapeChanceForMale = 10 / 100f;
private const float ReverseRapeChanceForFuta = (ReverseRapeChanceForFemale + ReverseRapeChanceForMale) / 2f;
private const float ReverseConsensualChanceForFemale = 75 / 100f;
private const float ReverseConsensualChanceForMale = 25 / 100f;
private const float ReverseConsensualChanceForFuta = (ReverseConsensualChanceForFemale + ReverseConsensualChanceForMale) / 2f;
private const float ReverseBestialityChanceForFemale = 90 / 100f;
private const float ReverseBestialityChanceForMale = 10 / 100f;
private const float ReverseBestialityChanceForFuta = (ReverseBestialityChanceForFemale + ReverseBestialityChanceForMale) / 2f;
private const float ReverseAnimalChanceForFemale = 90 / 100f;
private const float ReverseAnimalChanceForMale = 10 / 100f;
private const float ReverseAnimalChanceForFuta = (ReverseAnimalChanceForFemale + ReverseAnimalChanceForMale) / 2f;
private const float ReverseWhoringChanceForFemale = 90 / 100f;
private const float ReverseWhoringChanceForMale = 10 / 100f;
private const float ReverseWhoringChanceForFuta = (ReverseWhoringChanceForFemale + ReverseWhoringChanceForMale) / 2f;
[SyncMethod]
public bool IsReverse(InteractionContext context)
{
//Necrophilia
if (context.Internals.InteractionType == Enums.InteractionType.Necrophilia)
{
context.Internals.IsReverse = false;
}
//MechImplant
if (context.Internals.InteractionType == Enums.InteractionType.Mechanoid)
{
context.Internals.IsReverse = false;
}
//Masturbation
if (context.Internals.InteractionType == Enums.InteractionType.Masturbation)
{
context.Internals.IsReverse = false;
}
Gender initiatorGender = context.Internals.Dominant.Gender;
Gender partnerGender = context.Internals.Submissive.Gender;
float roll = (float)_random.NextDouble();
bool result;
if (context.Outputs.Generated.InteractionType == Enums.InteractionType.Consensual)
{
result = IsReverseRape(initiatorGender, partnerGender, roll, ReverseConsensualChanceForFemale, ReverseConsensualChanceForMale, ReverseConsensualChanceForFuta);
}
else
if (context.Outputs.Generated.InteractionType == Enums.InteractionType.Animal)
{
result = IsReverseRape(initiatorGender, partnerGender, roll, ReverseAnimalChanceForFemale, ReverseAnimalChanceForMale, ReverseAnimalChanceForFuta);
}
else
if (context.Outputs.Generated.InteractionType == Enums.InteractionType.Whoring)
{
result = IsReverseRape(initiatorGender, partnerGender, roll, ReverseWhoringChanceForFemale, ReverseWhoringChanceForMale, ReverseWhoringChanceForFuta);
}
else
if (context.Outputs.Generated.InteractionType == Enums.InteractionType.Bestiality)
{
result = IsReverseRape(initiatorGender, partnerGender, roll, ReverseBestialityChanceForFemale, ReverseBestialityChanceForMale, ReverseBestialityChanceForFuta);
}
else
if (context.Outputs.Generated.InteractionType == Enums.InteractionType.Rape)
{
result = IsReverseRape(initiatorGender, partnerGender, roll, ReverseRapeChanceForFemale, ReverseRapeChanceForMale, ReverseRapeChanceForFuta);
}
else
{
result = false;
}
return result;
}
private bool IsReverseRape(Gender initiator, Gender partner, float roll, float femaleChance, float maleChance, float futaChance)
{
_log.Debug($"{initiator}/{partner} - {roll} -> [f{femaleChance},m{maleChance},fu{futaChance}]");
switch (initiator)
{
case Gender.Male:
return roll < maleChance;
case Gender.Female:
return roll < femaleChance;
case Gender.Trap:
return roll < maleChance;
case Gender.Futa:
case Gender.FemaleOvi:
return roll < futaChance;
case Gender.MaleOvi:
return roll < maleChance;
case Gender.Unknown:
break;
}
return false;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/ReverseDetectorService.cs
|
C#
|
mit
| 4,777
|
using Multiplayer.API;
using rjw.Modules.Interactions.DefModExtensions;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Internals.Implementation
{
public class RulePackService : IRulePackService
{
public static IRulePackService Instance { get; private set; }
static RulePackService()
{
Instance = new RulePackService();
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private RulePackService() { }
public RulePackDef FindInteractionRulePack(InteractionWithExtension interaction)
{
RulePackDef result;
if (TryFindRulePack(interaction.SelectorExtension, out result))
{
return result;
}
if (TryFindRulePack(interaction.Extension, out result))
{
return result;
}
return null;
}
[SyncMethod]
private bool TryFindRulePack(InteractionSelectorExtension extension, out RulePackDef def)
{
def = null;
if (extension.rulepacks == null || extension.rulepacks.Any() == false)
{
return false;
}
def = extension.rulepacks.RandomElement();
return def != null;
}
[SyncMethod]
private bool TryFindRulePack(InteractionExtension extension, out RulePackDef def)
{
def = null;
//no defs
if (extension.rulepack_defs == null || extension.rulepack_defs.Any() == false)
{
return false;
}
string defname = extension.rulepack_defs.RandomElement();
//null name ? should not happen
if (String.IsNullOrWhiteSpace(defname) == true)
{
return false;
}
def = RulePackDef.Named(defname);
return def != null;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Internals/Implementation/RulePackService.cs
|
C#
|
mit
| 1,729
|
using RimWorld;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects.Parts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Objects
{
public class Interaction
{
public InteractionPawn Dominant { get; set; }
public InteractionPawn Submissive { get; set; }
public InteractionPawn Initiator { get; set; }
public InteractionPawn Receiver { get; set; }
public InteractionWithExtension InteractionDef { get; set; }
public InteractionType InteractionType { get; internal set; }
public xxx.rjwSextype RjwSexType { get; set; }
public RulePackDef RulePack { get; set; }
public IList<ILewdablePart> SelectedDominantParts { get; set; }
public IList<ILewdablePart> SelectedSubmissiveParts { get; set; }
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Objects/Interaction.cs
|
C#
|
mit
| 866
|
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using rjw.Modules.Interactions.Extensions;
namespace rjw.Modules.Interactions.Objects
{
public class InteractionPawn
{
public Pawn Pawn { get; set; }
public SexablePawnParts Parts { get; set; }
public Genitals.Enums.Gender Gender { get; set; }
public IEnumerable<Parts.ILewdablePart> ListLewdableParts()
{
foreach (var part in Parts.Penises)
{
yield return new Parts.RJWLewdablePart(part, LewdablePartKind.Penis);
}
foreach (var part in Parts.Vaginas)
{
yield return new Parts.RJWLewdablePart(part, LewdablePartKind.Vagina);
}
foreach (var part in Parts.Anuses)
{
yield return new Parts.RJWLewdablePart(part, LewdablePartKind.Anus);
}
foreach (var part in Parts.FemaleOvipositors)
{
yield return new Parts.RJWLewdablePart(part, LewdablePartKind.FemaleOvipositor);
}
foreach (var part in Parts.MaleOvipositors)
{
yield return new Parts.RJWLewdablePart(part, LewdablePartKind.MaleOvipositor);
}
foreach (var part in Parts.Breasts)
{
yield return new Parts.RJWLewdablePart(part, LewdablePartKind.Breasts);
}
foreach (var part in Parts.Udders)
{
yield return new Parts.RJWLewdablePart(part, LewdablePartKind.Udders);
}
foreach (var part in Parts.Mouths)
{
yield return new Parts.VanillaLewdablePart(Pawn, part, LewdablePartKind.Mouth);
}
foreach (var part in Parts.Beaks)
{
yield return new Parts.VanillaLewdablePart(Pawn, part, LewdablePartKind.Beak);
}
foreach (var part in Parts.Tongues)
{
yield return new Parts.VanillaLewdablePart(Pawn, part, LewdablePartKind.Tongue);
}
foreach (var part in Parts.Hands)
{
yield return new Parts.VanillaLewdablePart(Pawn, part, LewdablePartKind.Hand);
}
foreach (var part in Parts.Feet)
{
yield return new Parts.VanillaLewdablePart(Pawn, part, LewdablePartKind.Foot);
}
foreach (var part in Parts.Tails)
{
yield return new Parts.VanillaLewdablePart(Pawn, part, LewdablePartKind.Tail);
}
}
public IList<LewdablePartKind> BlockedParts { get; set; }
public IDictionary<LewdablePartKind, float> PartPreferences { get; set; }
public bool HasBigBreasts()
{
return Parts.Breasts
.BigBreasts()
.Any();
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Objects/InteractionPawn.cs
|
C#
|
mit
| 2,455
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace rjw.Modules.Interactions.Objects
{
public class InteractionScore
{
/// <summary>
/// The dominant score, calculated using part preference
/// </summary>
public float Dominant { get; set; }
/// <summary>
/// The submissive score, calculated using part preference
/// </summary>
public float Submissive { get; set; }
/// <summary>
/// The interaction score, value from the settings
/// </summary>
public float Setting { get; set; }
/// <summary>
/// When compiling the final score of an interaction, we take into account a weight that can be applied to
/// the submissive score
/// for exemple, the submissive's preferences should not be taken into account in a rape
/// </summary>
/// <returns>
/// the final interaction score
/// </returns>
//public float GetScore(float submissiveWeight)
//{
// //if it's ignored, pulls toward 1
// float finalSubmissiveScore;
// {
// float invertedWeight = Mathf.Max(0, 1 - submissiveWeight);
// //no, i'm not sure that it's right
// finalSubmissiveScore = (1 * invertedWeight) + (Submissive * submissiveWeight);
// }
// return Dominant * finalSubmissiveScore * Setting;
//}
public float GetScore(float submissiveWeight)
{
// Get weighted average of dom and subs prefs and mutiply by the system weight
// Fix sub weights of less than zero
float fixedSubmissiveWeight = Mathf.Max(0, submissiveWeight);
float dominantWeight = 1f;
return Setting * (
(Dominant * dominantWeight + Submissive * fixedSubmissiveWeight) /
(dominantWeight + fixedSubmissiveWeight)
);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Objects/InteractionScore.cs
|
C#
|
mit
| 1,757
|
using RimWorld;
using rjw.Modules.Interactions.DefModExtensions;
using rjw.Modules.Interactions.Defs.DefFragment;
using rjw.Modules.Interactions.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Objects
{
public class InteractionWithExtension
{
public InteractionDef Interaction { get; set; }
public InteractionSelectorExtension SelectorExtension { get; set; }
public InteractionExtension Extension { get; set; }
#region InteractionTag
public bool HasInteractionTag(InteractionTag tag)
{
if (SelectorExtension == null || SelectorExtension.tags == null || SelectorExtension.tags.Any() == false)
{
return false;
}
return SelectorExtension.tags.Contains(tag);
}
#endregion
#region PartProps
public bool DominantHasPartProp(string partProp)
{
return HasPartProp(SelectorExtension.dominantRequirement, partProp);
}
public bool SubmissiveHasPartProp(string partProp)
{
return HasPartProp(SelectorExtension.submissiveRequirement, partProp);
}
private bool HasPartProp(InteractionRequirement requirement, string partProp)
{
if (requirement == null || requirement.partProps == null || requirement.partProps.Any() == false)
{
return false;
}
return requirement.partProps.Contains(partProp);
}
#endregion
#region Familly
public bool DominantHasFamily(GenitalFamily family)
{
return HasFamily(SelectorExtension.dominantRequirement, family);
}
public bool SubmissiveHasFamily(GenitalFamily family)
{
return HasFamily(SelectorExtension.submissiveRequirement, family);
}
private bool HasFamily(InteractionRequirement requirement, GenitalFamily family)
{
if (requirement == null || requirement.families == null || requirement.families.Any() == false)
{
return false;
}
return requirement.families.Contains(family);
}
#endregion
#region Tag
public bool DominantHasTag(GenitalTag tag)
{
return HasTag(SelectorExtension.dominantRequirement, tag);
}
public bool SubmissiveHasTag(GenitalTag tag)
{
return HasTag(SelectorExtension.submissiveRequirement, tag);
}
private bool HasTag(InteractionRequirement requirement, GenitalTag tag)
{
if (requirement == null || requirement.tags == null || requirement.tags.Any() == false)
{
return false;
}
return requirement.tags.Contains(tag);
}
#endregion
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Objects/InteractionWithExtension.cs
|
C#
|
mit
| 2,490
|
using rjw.Modules.Interactions.Objects.Parts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Objects
{
public class LewdablePartComparer : IEqualityComparer<ILewdablePart>
{
public bool Equals(ILewdablePart x, ILewdablePart y)
{
RJWLewdablePart rjwPartX = x as RJWLewdablePart;
RJWLewdablePart rjwPartY = y as RJWLewdablePart;
VanillaLewdablePart vanillaPartX = x as VanillaLewdablePart;
VanillaLewdablePart vanillaPartY = y as VanillaLewdablePart;
//One of them is rjw
if (rjwPartX != null || rjwPartY != null)
{
//Compare the hediffs
if (rjwPartX?.Part != rjwPartY?.Part)
{
return false;
}
}
//One of them is vanilla
if (vanillaPartX != null || vanillaPartY != null)
{
//Compare the BPR
if (vanillaPartX?.Part != vanillaPartY?.Part)
{
return false;
}
}
return true;
}
public int GetHashCode(ILewdablePart obj)
{
RJWLewdablePart rjwPart = obj as RJWLewdablePart;
VanillaLewdablePart vanillaPart = obj as VanillaLewdablePart;
if (rjwPart != null)
{
rjwPart.Part.GetHashCode();
}
if (vanillaPart != null)
{
vanillaPart.Part.GetHashCode();
}
return 0;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Objects/LewdablePartComparer.cs
|
C#
|
mit
| 1,303
|
using rjw.Modules.Interactions.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Objects.Parts
{
public interface ILewdablePart
{
LewdablePartKind PartKind { get; }
/// <summary>
/// The severity of the hediff
/// </summary>
float Size { get; }
IList<string> Props { get; }
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Objects/Parts/ILewdablePart.cs
|
C#
|
mit
| 407
|
using rjw.Modules.Interactions.Enums;
using System.Collections.Generic;
using Verse;
namespace rjw.Modules.Interactions.Objects.Parts
{
public class RJWLewdablePart : ILewdablePart
{
public ISexPartHediff Part { get; private set; }
public LewdablePartKind PartKind { get; private set; }
public float Size => Part.AsHediff.Severity;
private readonly IList<string> _props;
public IList<string> Props => _props;
public RJWLewdablePart(ISexPartHediff hediff, LewdablePartKind partKind)
{
Part = hediff;
PartKind = partKind;
_props = hediff.Def.partTags ?? new();
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Objects/Parts/RJWLewdablePart.cs
|
C#
|
mit
| 601
|
using rjw.Modules.Interactions.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Objects.Parts
{
public class VanillaLewdablePart : ILewdablePart
{
public Pawn Owner { get; private set; }
public BodyPartRecord Part { get; private set; }
public LewdablePartKind PartKind { get; private set; }
public float Size
{
get
{
//For reference, averge size penis = 0.25f
switch (PartKind)
{
case LewdablePartKind.Hand:
return 0.3f * Owner.BodySize;
case LewdablePartKind.Foot:
return 0.4f * Owner.BodySize;
case LewdablePartKind.Tail:
return 0.15f * Owner.BodySize;
default:
return 0.25f;
}
}
}
//No props in vanilla parts ... sad day ...
public IList<string> Props => new List<string>();
public VanillaLewdablePart(Pawn owner, BodyPartRecord part, LewdablePartKind partKind)
{
Owner = owner;
Part = part;
PartKind = partKind;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Objects/Parts/VanillaLewdablePart.cs
|
C#
|
mit
| 1,056
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Verse;
namespace rjw.Modules.Interactions.Objects
{
public class SexablePawnParts
{
public IEnumerable<BodyPartRecord> Mouths { get; set; }
public IEnumerable<BodyPartRecord> Beaks { get; set; }
public IEnumerable<BodyPartRecord> Tongues { get; set; }
public IEnumerable<BodyPartRecord> Feet { get; set; }
public IEnumerable<BodyPartRecord> Hands { get; set; }
public IEnumerable<BodyPartRecord> Tails { get; set; }
public bool HasMouth => Mouths == null ? false : Mouths.Any();
public bool HasHand => Hands == null ? false : Hands.Any();
public bool HasTail => Tails == null ? false : Tails.Any();
public IEnumerable<ISexPartHediff> AllParts { get; set; }
public IEnumerable<ISexPartHediff> Penises { get; set; }
public IEnumerable<ISexPartHediff> Vaginas { get; set; }
public IEnumerable<ISexPartHediff> Breasts { get; set; }
public IEnumerable<ISexPartHediff> Udders { get; set; }
public IEnumerable<ISexPartHediff> Anuses { get; set; }
public IEnumerable<ISexPartHediff> FemaleOvipositors { get; set; }
public IEnumerable<ISexPartHediff> MaleOvipositors { get; set; }
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Objects/SexablePawnParts.cs
|
C#
|
mit
| 1,262
|
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.InteractionRules
{
public interface IInteractionRule
{
InteractionType InteractionType { get; }
IEnumerable<InteractionWithExtension> Interactions { get; }
float SubmissivePreferenceWeight { get; }
InteractionWithExtension Default { get; }
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/InteractionRules/IInteractionRule.cs
|
C#
|
mit
| 497
|
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.InteractionRules.Implementation
{
public class AnimalInteractionRule : IInteractionRule
{
static AnimalInteractionRule()
{
_interactionRepository = InteractionRepository.Instance;
}
private readonly static IInteractionRepository _interactionRepository;
public InteractionType InteractionType => InteractionType.Animal;
public IEnumerable<InteractionWithExtension> Interactions => _interactionRepository
.ListForAnimal();
public float SubmissivePreferenceWeight
{
get
{
return 0.0f;
}
}
public InteractionWithExtension Default => InteractionDefOf.DefaultAnimalSex;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/InteractionRules/Implementation/AnimalInteractionRule.cs
|
C#
|
mit
| 990
|
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.InteractionRules.Implementation
{
public class BestialityInteractionRule : IInteractionRule
{
static BestialityInteractionRule()
{
_interactionRepository = InteractionRepository.Instance;
}
private readonly static IInteractionRepository _interactionRepository;
public InteractionType InteractionType => InteractionType.Bestiality;
public IEnumerable<InteractionWithExtension> Interactions => _interactionRepository
.ListForBestiality();
public float SubmissivePreferenceWeight
{
get
{
return 0.0f;
}
}
public InteractionWithExtension Default => InteractionDefOf.DefaultBestialitySex;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/InteractionRules/Implementation/BestialityInteractionRule.cs
|
C#
|
mit
| 1,010
|
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.InteractionRules.Implementation
{
public class ConsensualInteractionRule : IInteractionRule
{
static ConsensualInteractionRule()
{
_random = new Random();
_interactionRepository = InteractionRepository.Instance;
}
private readonly static Random _random;
private readonly static IInteractionRepository _interactionRepository;
public InteractionType InteractionType => InteractionType.Consensual;
public IEnumerable<InteractionWithExtension> Interactions => _interactionRepository
.ListForConsensual();
public float SubmissivePreferenceWeight
{
get
{
//+/- 20%
float variant = (-1 + (float)_random.NextDouble() * 2) * 0.2f;
return 1.0f + variant;
}
}
public InteractionWithExtension Default => InteractionDefOf.DefaultConsensualSex;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/InteractionRules/Implementation/ConsensualInteractionRule.cs
|
C#
|
mit
| 1,171
|
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.InteractionRules.Implementation
{
public class MasturbationInteractionRule : IInteractionRule
{
static MasturbationInteractionRule()
{
_interactionRepository = InteractionRepository.Instance;
}
private readonly static IInteractionRepository _interactionRepository;
public InteractionType InteractionType => InteractionType.Masturbation;
public IEnumerable<InteractionWithExtension> Interactions => _interactionRepository
.ListForMasturbation();
public float SubmissivePreferenceWeight
{
get
{
return 0.0f;
}
}
public InteractionWithExtension Default => InteractionDefOf.DefaultAnimalSex;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/InteractionRules/Implementation/MasturbationInteractionRule.cs
|
C#
|
mit
| 1,014
|
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.InteractionRules.Implementation
{
public class MechImplantInteractionRule : IInteractionRule
{
static MechImplantInteractionRule()
{
_random = new Random();
_interactionRepository = InteractionRepository.Instance;
}
private readonly static Random _random;
private readonly static IInteractionRepository _interactionRepository;
public InteractionType InteractionType => InteractionType.Mechanoid;
public IEnumerable<InteractionWithExtension> Interactions => _interactionRepository
.ListForMechanoid();
public float SubmissivePreferenceWeight
{
get
{
//+/- 20%
float variant = -1 + (float)_random.NextDouble() * 2;
return 1.0f + variant;
}
}
public InteractionWithExtension Default => InteractionDefOf.DefaultMechImplantSex;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/InteractionRules/Implementation/MechImplantInteractionRule.cs
|
C#
|
mit
| 1,163
|
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.InteractionRules.Implementation
{
public class NecrophiliaInteractionRule : IInteractionRule
{
static NecrophiliaInteractionRule()
{
_interactionRepository = InteractionRepository.Instance;
}
private readonly static IInteractionRepository _interactionRepository;
public InteractionType InteractionType => InteractionType.Necrophilia;
public IEnumerable<InteractionWithExtension> Interactions => _interactionRepository
.ListForNecrophilia();
public float SubmissivePreferenceWeight
{
get
{
return 0.0f;
}
}
public InteractionWithExtension Default => InteractionDefOf.DefaultNecrophiliaSex;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/InteractionRules/Implementation/NecrophiliaInteractionRule.cs
|
C#
|
mit
| 1,015
|
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.InteractionRules.Implementation
{
public class RapeInteractionRule : IInteractionRule
{
static RapeInteractionRule()
{
_random = new Random();
_interactionRepository = InteractionRepository.Instance;
}
private readonly static Random _random;
private readonly static IInteractionRepository _interactionRepository;
public InteractionType InteractionType => InteractionType.Rape;
public IEnumerable<InteractionWithExtension> Interactions => _interactionRepository
.ListForRape();
public float SubmissivePreferenceWeight
{
get
{
//+/- 20%
float variant = -1 + (float)_random.NextDouble() * 2;
return 0.0f + variant;
}
}
public InteractionWithExtension Default => InteractionDefOf.DefaultRapeSex;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/InteractionRules/Implementation/RapeInteractionRule.cs
|
C#
|
mit
| 1,132
|
using rjw.Modules.Interactions.Defs;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Internals;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.InteractionRules.Implementation
{
public class WhoringInteractionRule : IInteractionRule
{
static WhoringInteractionRule()
{
_random = new Random();
_interactionRepository = InteractionRepository.Instance;
}
private readonly static Random _random;
private readonly static IInteractionRepository _interactionRepository;
public InteractionType InteractionType => InteractionType.Whoring;
public IEnumerable<InteractionWithExtension> Interactions => _interactionRepository
.ListForWhoring();
public float SubmissivePreferenceWeight
{
get
{
return (float)_random.NextDouble(); // Full random !
}
}
public InteractionWithExtension Default => InteractionDefOf.DefaultWhoringSex;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/InteractionRules/Implementation/WhoringInteractionRule.cs
|
C#
|
mit
| 1,103
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Interactions.Objects.Parts;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Interactions.Rules.PartBlockedRules
{
public interface IPartBlockedRule
{
IEnumerable<LewdablePartKind> BlockedParts(InteractionPawn pawn);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartBlockedRules/IPartBlockedRule.cs
|
C#
|
mit
| 495
|
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using rjw.Modules.Shared.Implementation;
using System.Collections.Generic;
namespace rjw.Modules.Interactions.Rules.PartBlockedRules.Implementation
{
public class DeadPartBlockedRule : IPartBlockedRule
{
public static IPartBlockedRule Instance { get; private set; }
static DeadPartBlockedRule()
{
Instance = new DeadPartBlockedRule();
_pawnStateService = PawnStateService.Instance;
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private DeadPartBlockedRule() { }
private static readonly IPawnStateService _pawnStateService;
public IEnumerable<LewdablePartKind> BlockedParts(InteractionPawn pawn)
{
yield break;
//if (_pawnStateService.Detect(pawn.Pawn) == Shared.Enums.PawnState.Dead)
//{
//}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartBlockedRules/Implementation/DeadPartBlockedRule.cs
|
C#
|
mit
| 893
|
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using rjw.Modules.Shared.Implementation;
using System.Collections.Generic;
namespace rjw.Modules.Interactions.Rules.PartBlockedRules.Implementation
{
public class DownedPartBlockedRule : IPartBlockedRule
{
public static IPartBlockedRule Instance { get; private set; }
static DownedPartBlockedRule()
{
Instance = new DownedPartBlockedRule();
_pawnStateService = PawnStateService.Instance;
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private DownedPartBlockedRule() { }
private static readonly IPawnStateService _pawnStateService;
public IEnumerable<LewdablePartKind> BlockedParts(InteractionPawn pawn)
{
yield break;
//if (_pawnStateService.Detect(pawn.Pawn) == Shared.Enums.PawnState.Downed)
//{
//}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartBlockedRules/Implementation/DownedPartBlockedRule.cs
|
C#
|
mit
| 903
|
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using System.Collections.Generic;
namespace rjw.Modules.Interactions.Rules.PartBlockedRules.Implementation
{
public class MainPartBlockedRule : IPartBlockedRule
{
public static IPartBlockedRule Instance { get; private set; }
static MainPartBlockedRule()
{
Instance = new MainPartBlockedRule();
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private MainPartBlockedRule() { }
public IEnumerable<LewdablePartKind> BlockedParts(InteractionPawn pawn)
{
if (Genital_Helper.anus_blocked(pawn.Pawn))
{
yield return LewdablePartKind.Anus;
}
if (Genital_Helper.penis_blocked(pawn.Pawn))
{
yield return LewdablePartKind.Penis;
}
if (Genital_Helper.breasts_blocked(pawn.Pawn))
{
yield return LewdablePartKind.Breasts;
}
if (Genital_Helper.vagina_blocked(pawn.Pawn))
{
yield return LewdablePartKind.Vagina;
}
if (Genital_Helper.hands_blocked(pawn.Pawn))
{
yield return LewdablePartKind.Hand;
}
if (Genital_Helper.oral_blocked(pawn.Pawn))
{
yield return LewdablePartKind.Mouth;
yield return LewdablePartKind.Beak;
yield return LewdablePartKind.Tongue;
}
if (Genital_Helper.genitals_blocked(pawn.Pawn))
{
yield return LewdablePartKind.Penis;
yield return LewdablePartKind.Vagina;
yield return LewdablePartKind.FemaleOvipositor;
yield return LewdablePartKind.MaleOvipositor;
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartBlockedRules/Implementation/MainPartBlockedRule.cs
|
C#
|
mit
| 1,527
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartBlockedRules.Implementation
{
public class PartAvailibilityPartBlockedRule : IPartBlockedRule
{
public static IPartBlockedRule Instance { get; private set; }
static PartAvailibilityPartBlockedRule()
{
Instance = new PartAvailibilityPartBlockedRule();
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private PartAvailibilityPartBlockedRule() { }
public IEnumerable<LewdablePartKind> BlockedParts(InteractionPawn pawn)
{
if (pawn.Parts.Hands.Any() == false)
{
yield return LewdablePartKind.Hand;
}
if (pawn.Parts.Mouths.Any() == false)
{
yield return LewdablePartKind.Mouth;
}
if (pawn.Parts.Tails.Any() == false)
{
yield return LewdablePartKind.Tail;
}
//No feet detection, pawn always have thoose ... guess you can still do a good job with a peg leg !
//if (pawn.Parts.Feet.Any() == false)
//{
// yield return LewdablePartKind.Foot;
//}
if (pawn.Parts.Penises.Any() == false)
{
yield return LewdablePartKind.Penis;
}
if (pawn.Parts.Vaginas.Any() == false)
{
yield return LewdablePartKind.Vagina;
}
if (pawn.Parts.FemaleOvipositors.Any() == false)
{
yield return LewdablePartKind.FemaleOvipositor;
}
if (pawn.Parts.MaleOvipositors.Any() == false)
{
yield return LewdablePartKind.MaleOvipositor;
}
if (pawn.Parts.Anuses.Any() == false)
{
yield return LewdablePartKind.Anus;
}
if (pawn.Parts.Breasts.Where(e => e.AsHediff.CurStageIndex > 1).Any() == false)
{
yield return LewdablePartKind.Breasts;
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartBlockedRules/Implementation/PartAvailibilityPartBlockedRule.cs
|
C#
|
mit
| 1,885
|
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using rjw.Modules.Shared.Implementation;
using System.Collections.Generic;
namespace rjw.Modules.Interactions.Rules.PartBlockedRules.Implementation
{
public class UnconsciousPartBlockedRule : IPartBlockedRule
{
public static IPartBlockedRule Instance { get; private set; }
static UnconsciousPartBlockedRule()
{
Instance = new UnconsciousPartBlockedRule();
_pawnStateService = PawnStateService.Instance;
}
/// <summary>
/// Do not instantiate, use <see cref="Instance"/>
/// </summary>
private UnconsciousPartBlockedRule() { }
private static readonly IPawnStateService _pawnStateService;
public IEnumerable<LewdablePartKind> BlockedParts(InteractionPawn pawn)
{
yield break;
//if (_pawnStateService.Detect(pawn.Pawn) == Shared.Enums.PawnState.Unconscious)
//{
//}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartBlockedRules/Implementation/UnconsciousPartBlockedRule.cs
|
C#
|
mit
| 927
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using System.Collections.Generic;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules
{
public interface IPartPreferenceRule
{
IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context);
IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/IPartKindUsageRule.cs
|
C#
|
mit
| 477
|
using RimWorld;
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class AnimalPartKindUsageRule : IPartPreferenceRule
{
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
if (xxx.is_animal(context.Internals.Dominant.Pawn))
{
return ForAnimal();
}
return Enumerable.Empty<Weighted<LewdablePartKind>>();
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
if (xxx.is_animal(context.Internals.Submissive.Pawn))
{
return ForAnimal();
}
return Enumerable.Empty<Weighted<LewdablePartKind>>();
}
private IEnumerable<Weighted<LewdablePartKind>> ForAnimal()
{
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Foot);
yield return new Weighted<LewdablePartKind>(Multipliers.Never, LewdablePartKind.Tail);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Beak);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/AnimalPartKindUsageRule.cs
|
C#
|
mit
| 2,157
|
using RimWorld;
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class BestialityForZoophilePartKindUsageRule : IPartPreferenceRule
{
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
//Only bestiality here
if (context.Internals.InteractionType != InteractionType.Bestiality)
{
return Enumerable.Empty<Weighted<LewdablePartKind>>();
}
InteractionPawn pawn = context.Internals.Dominant;
if (xxx.is_zoophile(pawn.Pawn) && xxx.is_animal(pawn.Pawn) == false)
{
return ForPawn(pawn, context.Internals.Submissive);
}
return Enumerable.Empty<Weighted<LewdablePartKind>>();
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
//Only bestiality here
if (context.Internals.InteractionType != InteractionType.Bestiality)
{
return Enumerable.Empty<Weighted<LewdablePartKind>>();
}
InteractionPawn pawn = context.Internals.Submissive;
if (xxx.is_zoophile(pawn.Pawn) && xxx.is_animal(pawn.Pawn) == false)
{
return ForPawn(pawn, context.Internals.Dominant);
}
return Enumerable.Empty<Weighted<LewdablePartKind>>();
}
private IEnumerable<Weighted<LewdablePartKind>> ForPawn(InteractionPawn pawn, InteractionPawn animal)
{
//bonded
if (pawn.Pawn.relations.DirectRelationExists(PawnRelationDefOf.Bond, animal.Pawn))
{
yield return new Weighted<LewdablePartKind>(Multipliers.VeryFrequent, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryFrequent, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryFrequent, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryFrequent, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Breasts);
}
else
//faction animal
if (pawn.Pawn.Faction == animal.Pawn.Faction)
{
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Tail);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Foot);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Beak);
}
//wild or other faction
else
{
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Tail);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Foot);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Beak);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/BestialityForZoophilePartKindUsageRule.cs
|
C#
|
mit
| 4,738
|
using RimWorld;
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class BestialityPartKindUsageRule : IPartPreferenceRule
{
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
//Only bestiality here
if (context.Internals.InteractionType != InteractionType.Bestiality)
{
return Enumerable.Empty<Weighted<LewdablePartKind>>();
}
InteractionPawn pawn = context.Internals.Dominant;
if (xxx.is_zoophile(pawn.Pawn) == false && xxx.is_animal(pawn.Pawn) == false && context.Internals.InteractionType == InteractionType.Bestiality)
{
return ForPawn(pawn, context.Internals.Submissive, context.Inputs.Initiator == pawn.Pawn);
}
return Enumerable.Empty<Weighted<LewdablePartKind>>();
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
//Only bestiality here
if (context.Internals.InteractionType != InteractionType.Bestiality)
{
return Enumerable.Empty<Weighted<LewdablePartKind>>();
}
InteractionPawn pawn = context.Internals.Submissive;
if (xxx.is_zoophile(pawn.Pawn) == false && xxx.is_animal(pawn.Pawn) == false)
{
return ForPawn(pawn, context.Internals.Dominant, context.Inputs.Initiator == pawn.Pawn);
}
return Enumerable.Empty<Weighted<LewdablePartKind>>();
}
private IEnumerable<Weighted<LewdablePartKind>> ForPawn(InteractionPawn pawn, InteractionPawn animal, bool isInitiator)
{
//Well ... the pawn probably would not want anything penetrative ...
if (isInitiator == false)
{
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Tail);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Foot);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Beak);
}
//bonded
if (pawn.Pawn.relations.DirectRelationExists(PawnRelationDefOf.Bond, animal.Pawn))
{
yield return new Weighted<LewdablePartKind>(Multipliers.Average, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.Average, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.Average, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Average, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Tail);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Foot);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Beak);
}
else
{
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Tail);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Foot);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Beak);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/BestialityPartKindUsageRule.cs
|
C#
|
mit
| 5,502
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class BigBreastsPartKindUsageRule : IPartPreferenceRule
{
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
return Modifiers(context.Internals.Dominant);
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
return Modifiers(context.Internals.Submissive);
}
public IEnumerable<Weighted<LewdablePartKind>> Modifiers(InteractionPawn pawn)
{
if (pawn.HasBigBreasts())
{
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Foot);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Beak);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/BigBreastsPartKindUsageRule.cs
|
C#
|
mit
| 1,426
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class MainPartKindUsageRule : IPartPreferenceRule
{
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
return Modifiers(context.Internals.Dominant);
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
return Modifiers(context.Internals.Submissive);
}
private IEnumerable<Weighted<LewdablePartKind>> Modifiers(InteractionPawn pawn)
{
bool hasMainPart = false;
if (pawn.Parts.Penises.Any())
{
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.Penis);
hasMainPart = true;
}
if (pawn.Parts.Vaginas.Any())
{
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.Vagina);
hasMainPart = true;
}
if (pawn.Parts.FemaleOvipositors.Any())
{
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.FemaleOvipositor);
hasMainPart = true;
}
if (pawn.Parts.MaleOvipositors.Any())
{
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.MaleOvipositor);
hasMainPart = true;
}
//Since the pawn has a "main" part, we lower the rest
if (hasMainPart == true)
{
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Foot);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Tail);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Beak);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/MainPartKindUsageRule.cs
|
C#
|
mit
| 2,362
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class PawnAlreadySatisfiedPartKindUsageRule : IPartPreferenceRule
{
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
return Modifiers(context.Internals.Dominant);
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
return Modifiers(context.Internals.Submissive);
}
public IEnumerable<Weighted<LewdablePartKind>> Modifiers(InteractionPawn pawn)
{
Need_Sex need = pawn.Pawn.needs?.TryGetNeed<Need_Sex>();
if (need != null && need.CurLevel >= need.thresh_neutral())
{
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.MaleOvipositor);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/PawnAlreadySatisfiedPartKindUsageRule.cs
|
C#
|
mit
| 1,438
|
using System.Collections.Generic;
using RimWorld;
using Verse;
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Shared;
using rjw.Modules.Interactions.Objects;
using System.Linq;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class PregnancyApproachPartKindUsageRule : IPartPreferenceRule
{
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
return ModifiersForEither(context.Internals.Dominant, context.Internals.Submissive);
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
return ModifiersForEither(context.Internals.Submissive, context.Internals.Dominant);
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForEither(InteractionPawn OwO, InteractionPawn UwU)
{
if (OwO.Pawn.relations == null || UwU.Pawn.relations == null)
{
yield break;
}
float weight = OwO.Pawn.relations.GetPregnancyApproachForPartner(UwU.Pawn).GetPregnancyChanceFactor();
if (OwO.Parts.Vaginas.Any() && UwU.Parts.Penises.Any())
{
yield return new Weighted<LewdablePartKind>(weight, LewdablePartKind.Penis);
}
if (OwO.Parts.Penises.Any() && UwU.Parts.Vaginas.Any())
{
yield return new Weighted<LewdablePartKind>(weight, LewdablePartKind.Vagina);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/PregnancyApproachPartKindUsageRule.cs
|
C#
|
mit
| 1,556
|
using RimWorld;
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Quirks;
using rjw.Modules.Quirks.Implementation;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class QuirksPartKindUsageRule : IPartPreferenceRule
{
private IQuirkService _quirkService => QuirkService.Instance;
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
return Enumerable.Concat(
ModifierForPodophile(context.Internals.Dominant, context.Internals.Submissive, true),
ModifierForImpregnationFetish(context.Internals.Dominant, context.Internals.Submissive, true)
);
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
return Enumerable.Concat(
ModifierForPodophile(context.Internals.Submissive, context.Internals.Dominant, false),
ModifierForImpregnationFetish(context.Internals.Submissive, context.Internals.Dominant, false)
);
}
private IEnumerable<Weighted<LewdablePartKind>> ModifierForPodophile(InteractionPawn pawn, InteractionPawn partner, bool isDominant)
{
if(_quirkService.HasQuirk(pawn.Pawn, Quirks.Quirks.Podophile))
{
yield return new Weighted<LewdablePartKind>(Multipliers.Doubled, LewdablePartKind.Foot);
}
//Partner is podophile and dominant (aka requesting pawjob !)
if(_quirkService.HasQuirk(partner.Pawn, Quirks.Quirks.Podophile) && isDominant == false)
{
yield return new Weighted<LewdablePartKind>(Multipliers.Doubled, LewdablePartKind.Foot);
}
}
private IEnumerable<Weighted<LewdablePartKind>> ModifierForImpregnationFetish(InteractionPawn pawn, InteractionPawn partner, bool isDominant)
{
if (_quirkService.HasQuirk(pawn.Pawn, Quirks.Quirks.Impregnation))
{
yield return new Weighted<LewdablePartKind>(Multipliers.Doubled, LewdablePartKind.Vagina);
}
//Partner likes impregnation and is requesting the deal !
if (_quirkService.HasQuirk(partner.Pawn, Quirks.Quirks.Impregnation) && isDominant == false)
{
yield return new Weighted<LewdablePartKind>(Multipliers.Doubled, LewdablePartKind.Penis);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/QuirksPartKindUsageRule.cs
|
C#
|
mit
| 2,391
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class RapePartKindUsageRule : IPartPreferenceRule
{
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
if (context.Internals.InteractionType == InteractionType.Rape)
{
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Beak);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Tail);
yield return new Weighted<LewdablePartKind>(Multipliers.Average, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.Average, LewdablePartKind.Foot);
}
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
if (context.Internals.InteractionType == InteractionType.Rape)
{
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Beak);
yield return new Weighted<LewdablePartKind>(Multipliers.VeryRare, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Tail);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Foot);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/RapePartKindUsageRule.cs
|
C#
|
mit
| 3,021
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Objects;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class SizeDifferencePartKindUsageRule : IPartPreferenceRule
{
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
return Modifiers(context.Internals.Dominant, context.Internals.Submissive);
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
return Modifiers(context.Internals.Submissive, context.Internals.Dominant);
}
public IEnumerable<Weighted<LewdablePartKind>> Modifiers(InteractionPawn current, InteractionPawn partner)
{
if (current.Pawn.BodySize * 2 < partner.Pawn.BodySize)
{
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.FemaleOvipositor);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/SizeDifferencePartKindUsageRule.cs
|
C#
|
mit
| 1,261
|
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Interactions.Rules.PartKindUsageRules.Implementation
{
public class WhoringPartKindUsageRule : IPartPreferenceRule
{
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForDominant(InteractionContext context)
{
if (context.Internals.InteractionType == InteractionType.Whoring)
{
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Beak);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Foot);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Tail);
}
}
public IEnumerable<Weighted<LewdablePartKind>> ModifiersForSubmissive(InteractionContext context)
{
if (context.Internals.InteractionType == InteractionType.Whoring)
{
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.Vagina);
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.Penis);
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.FemaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Frequent, LewdablePartKind.MaleOvipositor);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Mouth);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Tongue);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Beak);
yield return new Weighted<LewdablePartKind>(Multipliers.Common, LewdablePartKind.Breasts);
yield return new Weighted<LewdablePartKind>(Multipliers.Uncommon, LewdablePartKind.Anus);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Hand);
yield return new Weighted<LewdablePartKind>(Multipliers.AlmostNever, LewdablePartKind.Foot);
yield return new Weighted<LewdablePartKind>(Multipliers.Rare, LewdablePartKind.Tail);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Interactions/Rules/PartPreferenceRules/Implementation/WhoringPartKindUsageRule.cs
|
C#
|
mit
| 3,056
|
using Verse;
using RimWorld;
using Multiplayer.API;
namespace rjw
{
[StaticConstructorOnStartup]
public static class RJW_Multiplayer
{
static RJW_Multiplayer()
{
if (!MP.enabled) return;
// This is where the magic happens and your attributes
// auto register, similar to Harmony's PatchAll.
MP.RegisterAll();
/*
Log.Message("RJW MP compat testing");
var type = AccessTools.TypeByName("rjw.RJWdesignations");
//Log.Message("rjw MP compat " + type.Name);
Log.Message("is host " + MP.IsHosting);
Log.Message("PlayerName " + MP.PlayerName);
Log.Message("IsInMultiplayer " + MP.IsInMultiplayer);
//MP.RegisterSyncMethod(type, "Comfort");
/*
MP.RegisterSyncMethod(type, "<GetGizmos>Service");
MP.RegisterSyncMethod(type, "<GetGizmos>BreedingHuman");
MP.RegisterSyncMethod(type, "<GetGizmos>BreedingAnimal");
MP.RegisterSyncMethod(type, "<GetGizmos>Breeder");
MP.RegisterSyncMethod(type, "<GetGizmos>Milking");
MP.RegisterSyncMethod(type, "<GetGizmos>Hero");
*/
// You can choose to not auto register and do it manually
// with the MP.Register* methods.
// Use MP.IsInMultiplayer to act upon it in other places
// user can have it enabled and not be in session
}
//generate PredictableSeed for Verse.Rand
public static int PredictableSeed()
{
int seed = 0;
try
{
Map map = Find.CurrentMap;
//int seedHourOfDay = GenLocalDate.HourOfDay(map);
//int seedDayOfYear = GenLocalDate.DayOfYear(map);
//int seedYear = GenLocalDate.Year(map);
seed = (GenLocalDate.HourOfDay(map) + GenLocalDate.DayOfYear(map)) * GenLocalDate.Year(map);
//int seed = (seedHourOfDay + seedDayOfYear) * seedYear;
//Log.Warning("seedHourOfDay: " + seedHourOfDay + "\nseedDayOfYear: " + seedDayOfYear + "\nseedYear: " + seedYear + "\n" + seed);
}
catch
{
seed = Rand.Int;
}
return seed;
}
//generate PredictableSeed for Verse.Rand
[SyncMethod]
public static float RJW_MP_RAND()
{
return Rand.Value;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Multiplayer/Multiplayer.cs
|
C#
|
mit
| 2,049
|
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Nymphs
{
public interface INymphService
{
Pawn GenerateNymph(Map map, PawnKindDef nymphKind = null, Faction faction = null);
IEnumerable<Pawn> GenerateNymphs(Map map, int count);
PawnKindDef RandomNymphKind();
IEnumerable<PawnKindDef> ListNymphKindDefs();
void SetManhunter(Pawn nymph);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/INymphService.cs
|
C#
|
mit
| 478
|
using Multiplayer.API;
using RimWorld;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Nymphs.Implementation
{
public class NymphService : INymphService
{
private static ILog _log = LogManager.GetLogger<NymphService, NymphLogProvider>();
public static readonly INymphService Instance;
static NymphService()
{
Instance = new NymphService();
}
public Pawn GenerateNymph(Map map, PawnKindDef nymphKind = null, Faction faction = null)
{
if (nymphKind == null)
{
nymphKind = RandomNymphKind();
}
PawnGenerationRequest request = new PawnGenerationRequest(
kind: nymphKind,
faction: faction,
tile: map.Tile,
forceGenerateNewPawn: true,
canGeneratePawnRelations: true,
colonistRelationChanceFactor: 0.0f,
inhabitant: true,
relationWithExtraPawnChanceFactor: 0
);
Pawn nymph = PawnGenerator.GeneratePawn(request);
_log.Debug($"Generated Nymph {nymph.GetName()}");
return nymph;
}
public IEnumerable<Pawn> GenerateNymphs(Map map, int count)
{
if (count <= 0)
{
yield break;
}
PawnKindDef nymphKind = RandomNymphKind();
for (int i = 0; i < count; i++)
{
yield return GenerateNymph(map, nymphKind);
}
}
[SyncMethod]
public PawnKindDef RandomNymphKind()
{
return ListNymphKindDefs()
.RandomElement();
}
public IEnumerable<PawnKindDef> ListNymphKindDefs()
{
return DefDatabase<PawnKindDef>.AllDefs
.Where(x => x.defName.Contains("Nymph"));
}
public void SetManhunter(Pawn nymph)
{
if (RJWSettings.NymphPermanentManhunter)
{
nymph.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
}
else
{
nymph.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/Implementation/NymphService.cs
|
C#
|
mit
| 1,969
|
using Multiplayer.API;
using RimWorld;
using rjw.Modules.Nymphs.Implementation;
using rjw.Modules.Shared.Logs;
using System.Collections.Generic;
using UnityEngine;
using Verse;
namespace rjw.Modules.Nymphs.Incidents
{
public abstract class IncidentWorker_BaseNymphRaid : IncidentWorker_NeutralGroup
{
private static ILog _log = LogManager.GetLogger<IncidentWorker_BaseNymphRaid, NymphLogProvider>();
protected static readonly INymphService _nymphGeneratorService;
static IncidentWorker_BaseNymphRaid()
{
_nymphGeneratorService = NymphService.Instance;
}
protected virtual float ThreatPointMultiplier => 1f;
[SyncMethod]
protected override bool CanFireNowSub(IncidentParms parms)
{
//No multiplayer support ... I guess
if (MP.IsInMultiplayer)
{
_log.Debug("Could not fire because multiplayer api is on");
return false;
}
//No map
if (parms.target is Map == false)
{
_log.Debug("Could not fire because the incident target is not a map");
return false;
}
return base.CanFireNowSub(parms);
}
protected virtual int GetNymphCount(IncidentParms parms, Map map)
{
//Calculating nymphs manyness
int count;
count = Mathf.RoundToInt(parms.points / parms.pawnKind.combatPower * ThreatPointMultiplier);
//Cap the min
count = Mathf.Max(count, 1);
return count;
}
[SyncMethod]
protected override void ResolveParmsPoints(IncidentParms parms)
{
if (parms.points <= 0)
{
parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target) * ThreatPointMultiplier;
}
_log.Debug($"Incident generated with {parms.points} points");
}
[SyncMethod]
protected override bool TryExecuteWorker(IncidentParms parms)
{
_log.Debug($"Generating incident");
//Walk from the edge
parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;
if (parms.raidArrivalMode.Worker.TryResolveRaidSpawnCenter(parms) == false)
{
_log.Debug($"Incident failed to fire, no spawn points available");
return false;
}
//Find PawnKind
parms.pawnKind = Nymph_Generator.GetFixedNymphPawnKindDef();
if(parms.pawnKind == null)
{
_log.Debug($"Incident failed to fire, no Pawn Kind for nymphs");
return false;
}
//Calculating nymphs manyness
int count = GetNymphCount(parms, (Map)parms.target);
_log.Debug($"Will generate {count} nymphs");
List<Pawn> nymphs = GenerateNymphs(parms.target as Map, count);
parms.raidArrivalMode.Worker.Arrive(nymphs, parms);
SetManhunters(nymphs);
Find.LetterStack.ReceiveLetter(
"RJW_nymph_incident_raid_title".Translate(),
"RJW_nymph_incident_raid_description".Translate(),
LetterDefOf.ThreatBig,
nymphs);
return true;
}
protected List<Pawn> GenerateNymphs(Map map, int count)
{
List<Pawn> result = new List<Pawn>();
PawnKindDef nymphKind = _nymphGeneratorService.RandomNymphKind();
for (int i = 1; i <= count; ++i)
{
Pawn nymph = _nymphGeneratorService.GenerateNymph(map, nymphKind);
//Set it wild
nymph.ChangeKind(PawnKindDefOf.WildMan);
result.Add(nymph);
}
return result;
}
protected void SetManhunters(List<Pawn> nymphs)
{
foreach (var nymph in nymphs)
{
_nymphGeneratorService.SetManhunter(nymph);
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/Incidents/IncidentWorker_BaseNymphRaid.cs
|
C#
|
mit
| 3,294
|
using Multiplayer.API;
using RimWorld;
using rjw.Modules.Nymphs.Implementation;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using System.Collections.Generic;
using Verse;
namespace rjw.Modules.Nymphs.Incidents
{
public class IncidentWorker_NymphJoin : IncidentWorker
{
private static ILog _log = LogManager.GetLogger<IncidentWorker_NymphJoin, NymphLogProvider>();
protected static readonly INymphService _nymphGeneratorService;
static IncidentWorker_NymphJoin()
{
_nymphGeneratorService = NymphService.Instance;
}
[SyncMethod]
protected override bool CanFireNowSub(IncidentParms parms)
{
//The event is disabled, don't fire !
if (RJWSettings.NymphTamed == false)
{
_log.Debug("The incident can't fire as it is disabled in RJW settings");
return false;
}
//No multiplayer support
if (MP.IsInMultiplayer)
{
_log.Debug("Could not fire because multiplayer api is on");
return false;
}
//No map
if (parms.target is Map == false)
{
_log.Debug("Could not fire because the incident target is not a map");
return false;
}
return base.CanFireNowSub(parms);
}
[SyncMethod]
protected override bool TryExecuteWorker(IncidentParms parms)
{
_log.Debug($"Generating incident");
//Walk from the edge
parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;
if (parms.raidArrivalMode.Worker.TryResolveRaidSpawnCenter(parms) == false)
{
_log.Debug($"Incident failed to fire, no spawn points available");
return false;
}
Pawn nymph = GenerateNymph(parms.target as Map);
_log.Debug($"Generated nymph {nymph.GetName()}");
parms.raidArrivalMode.Worker.Arrive(new List<Pawn>() { nymph }, parms);
JoinPlayerFaction(nymph);
Find.LetterStack.ReceiveLetter(
"RJW_nymph_incident_join_title".Translate(),
"RJW_nymph_incident_join_description".Translate(),
LetterDefOf.PositiveEvent,
nymph);
return true;
}
protected Pawn GenerateNymph(Map map)
{
Pawn nymph = _nymphGeneratorService.GenerateNymph(map);
nymph.ChangeKind(PawnKindDefOf.WildMan);
return nymph;
}
protected void JoinPlayerFaction(Pawn nymph)
{
nymph.SetFaction(Faction.OfPlayer);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/Incidents/IncidentWorker_NymphJoin.cs
|
C#
|
mit
| 2,245
|
using Multiplayer.API;
using RimWorld;
using rjw.Modules.Shared.Logs;
using UnityEngine;
using Verse;
namespace rjw.Modules.Nymphs.Incidents
{
public class IncidentWorker_NymphRaidEasy : IncidentWorker_BaseNymphRaid
{
private static ILog _log = LogManager.GetLogger<IncidentWorker_NymphRaidEasy, NymphLogProvider>();
[SyncMethod]
protected override bool CanFireNowSub(IncidentParms parms)
{
//The event is disabled, don't fire !
if (RJWSettings.NymphRaidEasy == false)
{
_log.Debug("The incident can't fire as it is disabled in RJW settings");
return false;
}
return base.CanFireNowSub(parms);
}
protected override int GetNymphCount(IncidentParms parms, Map map)
{
int count;
//Calculating nymphs manyness
if (RJWSettings.NymphRaidRP)
{
count = base.GetNymphCount(parms, map);
}
else
{
count = (Find.World.worldPawns.AllPawnsAlive.Count + map.mapPawns.FreeColonistsAndPrisonersSpawnedCount);
//Cap the max
count = Mathf.Min(count, 100);
//Cap the min
count = Mathf.Max(count, 1);
}
return count;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/Incidents/IncidentWorker_NymphRaidEasy.cs
|
C#
|
mit
| 1,103
|
using Multiplayer.API;
using RimWorld;
using rjw.Modules.Shared.Logs;
using UnityEngine;
using Verse;
namespace rjw.Modules.Nymphs.Incidents
{
public class IncidentWorker_NymphRaidHard : IncidentWorker_BaseNymphRaid
{
private static ILog _log = LogManager.GetLogger<IncidentWorker_NymphRaidHard, NymphLogProvider>();
protected override float ThreatPointMultiplier => 1.5f;
[SyncMethod]
protected override bool CanFireNowSub(IncidentParms parms)
{
//The event is disabled, don't fire !
if (RJWSettings.NymphRaidHard == false)
{
_log.Debug("The incident can't fire as it is disabled in RJW settings");
return false;
}
return base.CanFireNowSub(parms);
}
protected override int GetNymphCount(IncidentParms parms, Map map)
{
int count;
//Calculating nymphs manyness
if (RJWSettings.NymphRaidRP)
{
count = base.GetNymphCount(parms, map);
}
else
{
count = map.mapPawns.AllPawnsSpawnedCount;
//Cap the max
count = Mathf.Min(count, 1000);
//Cap the min
count = Mathf.Max(count, 1);
}
return count;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/Incidents/IncidentWorker_NymphRaidHard.cs
|
C#
|
mit
| 1,100
|
using Multiplayer.API;
using RimWorld;
using rjw.Modules.Nymphs.Implementation;
using rjw.Modules.Shared.Extensions;
using rjw.Modules.Shared.Logs;
using System.Collections.Generic;
using Verse;
namespace rjw.Modules.Nymphs.Incidents
{
public class IncidentWorker_NymphVisitor : IncidentWorker
{
private static ILog _log = LogManager.GetLogger<IncidentWorker_NymphVisitor, NymphLogProvider>();
protected static readonly INymphService _nymphService;
static IncidentWorker_NymphVisitor()
{
_nymphService = NymphService.Instance;
}
[SyncMethod]
protected override bool CanFireNowSub(IncidentParms parms)
{
//The event is disabled, don't fire !
if (RJWSettings.NymphWild == false)
{
_log.Debug("The incident can't fire as it is disabled in RJW settings");
return false;
}
//No multiplayer support ... I guess
if (MP.IsInMultiplayer)
{
_log.Debug("Could not fire because multiplayer api is on");
return false;
}
//No map
if (parms.target is Map == false)
{
_log.Debug("Could not fire because the incident target is not a map");
return false;
}
return base.CanFireNowSub(parms);
}
[SyncMethod]
protected override bool TryExecuteWorker(IncidentParms parms)
{
_log.Debug($"Generating incident");
//Walk from the edge
parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;
if (parms.raidArrivalMode.Worker.TryResolveRaidSpawnCenter(parms) == false)
{
_log.Debug($"Incident failed to fire, no spawn points available");
return false;
}
Pawn nymph = GenerateNymph(parms.target as Map);
_log.Debug($"Generated nymph {nymph.GetName()}");
parms.raidArrivalMode.Worker.Arrive(new List<Pawn>() { nymph }, parms);
SetManhunter(nymph);
Find.LetterStack.ReceiveLetter(
"RJW_nymph_incident_wander_title".Translate(),
"RJW_nymph_incident_wander_description".Translate(),
LetterDefOf.ThreatSmall,
nymph);
return true;
}
protected Pawn GenerateNymph(Map map)
{
Pawn nymph = _nymphService.GenerateNymph(map);
nymph.ChangeKind(PawnKindDefOf.WildMan);
return nymph;
}
protected void SetManhunter(Pawn nymph)
{
_nymphService.SetManhunter(nymph);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/Incidents/IncidentWorker_NymphVisitor.cs
|
C#
|
mit
| 2,229
|
using System;
using System.Linq;
using Verse;
using Verse.AI;
using Verse.AI.Group;
using RimWorld;
using Multiplayer.API;
namespace rjw
{
// Token: 0x020006B5 RID: 1717
public class JobGiver_NymphSapper : ThinkNode_JobGiver
{
// Token: 0x06002E54 RID: 11860 RVA: 0x001041A7 File Offset: 0x001023A7
public override ThinkNode DeepCopy(bool resolve = true)
{
JobGiver_NymphSapper jobGiver_NymphSapper = (JobGiver_NymphSapper)base.DeepCopy(resolve);
jobGiver_NymphSapper.canMineMineables = this.canMineMineables;
jobGiver_NymphSapper.canMineNonMineables = this.canMineNonMineables;
return jobGiver_NymphSapper;
}
// Token: 0x06002E55 RID: 11861 RVA: 0x001041D0 File Offset: 0x001023D0
[SyncMethod]
protected override Job TryGiveJob(Pawn pawn)
{
if (!RJWSettings.NymphSappers)
return null;
if (!xxx.is_nympho(pawn))
return null;
IntVec3 intVec;
{
IAttackTarget attackTarget;
if (!(from x in pawn.Map.mapPawns.FreeColonistsAndPrisonersSpawned
where !x.ThreatDisabled(pawn) && pawn.CanReach(x, PathEndMode.OnCell, Danger.Deadly, false, false, TraverseMode.PassAllDestroyableThings)
select x).TryRandomElement(out attackTarget))
{
return null;
}
intVec = attackTarget.Thing.Position;
}
using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, intVec, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassDoors, false), PathEndMode.OnCell))
{
IntVec3 cellBeforeBlocker;
Thing thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn);
if (thing != null)
{
Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, this.canMineMineables, this.canMineNonMineables);
if (job != null)
{
return job;
}
}
}
return JobMaker.MakeJob(JobDefOf.Goto, intVec, 500, true);
}
// Token: 0x04001A64 RID: 6756
private bool canMineMineables = false;
// Token: 0x04001A65 RID: 6757
private bool canMineNonMineables = false;
// Token: 0x04001A66 RID: 6758
private const float ReachDestDist = 10f;
// Token: 0x04001A67 RID: 6759
private const int CheckOverrideInterval = 500;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/JobGivers/JobGiver_NymphSapper.cs
|
C#
|
mit
| 2,162
|
using rjw.Modules.Shared.Logs;
namespace rjw.Modules.Nymphs
{
public class NymphLogProvider : ILogProvider
{
public bool IsActive => RJWSettings.DebugNymph;
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/NymphLogProvider.cs
|
C#
|
mit
| 170
|
using System.Collections.Generic;
using RimWorld;
using Verse;
using Multiplayer.API;
using System.Linq;
using System.Linq.Expressions;
using HarmonyLib;
namespace rjw
{
public struct nymph_passion_chances
{
public float major;
public float minor;
public nymph_passion_chances(float maj, float min)
{
major = maj;
minor = min;
}
}
public static class nymph_backstories
{
public static nymph_passion_chances get_passion_chances(BackstoryDef child_bs, BackstoryDef adult_bs, SkillDef skill_def)
{
var maj = 0.0f;
var min = 0.0f;
if (adult_bs.defName.Contains("feisty"))
{
if (skill_def == SkillDefOf.Melee) { maj = 0.50f; min = 1.00f; }
else if (skill_def == SkillDefOf.Shooting) { maj = 0.25f; min = 0.75f; }
else if (skill_def == SkillDefOf.Social) { maj = 0.10f; min = 0.67f; }
}
else if (adult_bs.defName.Contains("curious"))
{
if (skill_def == SkillDefOf.Construction) { maj = 0.15f; min = 0.40f; }
else if (skill_def == SkillDefOf.Crafting) { maj = 0.50f; min = 1.00f; }
else if (skill_def == SkillDefOf.Social) { maj = 0.20f; min = 1.00f; }
}
else if (adult_bs.defName.Contains("tender"))
{
if (skill_def == SkillDefOf.Medicine) { maj = 0.20f; min = 0.60f; }
else if (skill_def == SkillDefOf.Social) { maj = 0.50f; min = 1.00f; }
}
else if (adult_bs.defName.Contains("chatty"))
{
if (skill_def == SkillDefOf.Social) { maj = 1.00f; min = 1.00f; }
}
else if (adult_bs.defName.Contains("broken"))
{
if (skill_def == SkillDefOf.Artistic) { maj = 0.50f; min = 1.00f; }
else if (skill_def == SkillDefOf.Social) { maj = 0.00f; min = 0.33f; }
}
else if (adult_bs.defName.Contains("homekeeper"))
{
if (skill_def == SkillDefOf.Cooking) { maj = 0.50f; min = 1.00f; }
else if (skill_def == SkillDefOf.Social) { maj = 0.00f; min = 0.33f; }
}
return new nymph_passion_chances(maj, min);
}
// Randomly chooses backstories and traits for a nymph
[SyncMethod]
public static void generate(Pawn pawn)
{
var tr = pawn.story;
//reset stories
tr.Childhood = DefDatabase<BackstoryDef>.AllDefsListForReading.Where(x => x.slot == BackstorySlot.Childhood && x.spawnCategories.Contains("rjw_nymphsCategory")).RandomElement();
tr.Adulthood = DefDatabase<BackstoryDef>.AllDefsListForReading.Where(x => x.slot == BackstorySlot.Adulthood && x.spawnCategories.Contains("rjw_nymphsCategory")).RandomElement();
pawn.story.traits.allTraits.AddDistinct(new Trait(xxx.nymphomaniac, 0));
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
var beauty = 0;
var rv2 = Rand.Value;
if (tr.Adulthood.defName.Contains("feisty"))
{
beauty = Rand.RangeInclusive(0, 2);
if (rv2 < 0.33)
pawn.story.traits.allTraits.AddDistinct(new Trait(TraitDefOf.Brawler));
else if (rv2 < 0.67)
pawn.story.traits.allTraits.AddDistinct(new Trait(TraitDefOf.Bloodlust));
else
pawn.story.traits.allTraits.AddDistinct(new Trait(xxx.rapist));
}
else if (tr.Adulthood.defName.Contains("curious"))
{
beauty = Rand.RangeInclusive(0, 2);
if (rv2 < 0.33)
pawn.story.traits.allTraits.AddDistinct(new Trait(TraitDefOf.Transhumanist));
}
else if (tr.Adulthood.defName.Contains("tender"))
{
beauty = Rand.RangeInclusive(1, 2);
if (rv2 < 0.50)
pawn.story.traits.allTraits.AddDistinct(new Trait(TraitDefOf.Kind));
}
else if (tr.Adulthood.defName.Contains("chatty"))
{
beauty = 2;
if (rv2 < 0.33)
pawn.story.traits.allTraits.AddDistinct(new Trait(TraitDefOf.Greedy));
}
else if (tr.Adulthood.defName.Contains("broken"))
{
beauty = Rand.RangeInclusive(0, 2);
if (rv2 < 0.33)
pawn.story.traits.allTraits.AddDistinct(new Trait(TraitDefOf.DrugDesire, 1));
else if (rv2 < 0.67)
pawn.story.traits.allTraits.AddDistinct(new Trait(TraitDefOf.DrugDesire, 2));
}
else if (tr.Adulthood.defName.Contains("homekeeper"))
{
beauty = Rand.RangeInclusive(1, 2);
if (rv2 < 0.33)
pawn.story.traits.allTraits.AddDistinct(new Trait(TraitDefOf.Kind));
}
if (beauty > 0)
pawn.story.traits.allTraits.AddDistinct(new Trait(VanillaTraitDefOf.Beauty, beauty, false));
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/Pawns/Nymph_Backstories.cs
|
C#
|
mit
| 4,251
|
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
using System;
using Multiplayer.API;
using System.Linq;
namespace rjw
{
public static class Nymph_Generator
{
/// <summary>
/// Returns true if the given pawnGenerationRequest is for a nymph pawnKind.
/// </summary>
public static bool IsNymph(PawnGenerationRequest pawnGenerationRequest)
{
return pawnGenerationRequest.KindDef != null && pawnGenerationRequest.KindDef.defName.Contains("Nymph");
}
private static bool is_trait_conflicting_or_duplicate(Pawn pawn, Trait t)
{
foreach (var existing in pawn.story.traits.allTraits)
if ((existing.def == t.def) || (t.def.ConflictsWith(existing)))
return true;
return false;
}
public static bool IsNymphBodyType(Pawn pawn)
{
return pawn.story.bodyType == BodyTypeDefOf.Female || pawn.story.bodyType == BodyTypeDefOf.Thin;
}
[SyncMethod]
public static Gender RandomNymphGender()
{
//with males 100% its still 99%, coz im to lazy to fix it
//float rnd = Rand.Value;
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
float chance = RJWSettings.male_nymph_chance;
Gender Pawngender = Rand.Chance(chance) ? Gender.Male: Gender.Female;
//ModLog.Message(" setnymphsex: " + (rnd < chance) + " rnd:" + rnd + " chance:" + chance);
//ModLog.Message(" setnymphsex: " + Pawngender);
return Pawngender;
}
/// <summary>
/// Replaces a pawn's randomly generated backstory and traits to turn it into propper a nymph
/// </summary>
[SyncMethod]
public static void set_story(Pawn pawn)
{
//C# rjw story
nymph_backstories.generate(pawn);
//The mod More Trait Slots will adjust the max number of traits pawn can get, and therefore,
//I need to collect pawns' traits and assign other_traits back to the pawn after adding the nymph_story traits.
//backup generated + rjw traits
Stack<Trait> other_traits = new Stack<Trait>();
int numberOfTotalTraits = 0;
if (!pawn.story.traits.allTraits.NullOrEmpty())
{
foreach (Trait t in pawn.story.traits.allTraits)
{
other_traits.Push(t);
++numberOfTotalTraits;
}
}
pawn.story.traits.allTraits.Clear();
//xml nymph story forced traits
var trait_count = 0;
foreach (var t in pawn.story.Adulthood.forcedTraits)
{
pawn.story.traits.GainTrait(new Trait(t.def, t.degree));
++trait_count;
}
//xml story + rjw backup + w/e generator generated backup
while (trait_count < numberOfTotalTraits)
{
Trait t = other_traits.Pop();
if (!is_trait_conflicting_or_duplicate(pawn, t))
pawn.story.traits.GainTrait(t);
++trait_count;
}
// add broken body hediff to broken nymph
if (pawn.story.Adulthood.defName.Contains("broken"))
{
pawn.health.AddHediff(xxx.feelingBroken);
(pawn.health.hediffSet.GetFirstHediffOfDef(xxx.feelingBroken)).Severity = Rand.Range(0.4f, 1.0f);
}
//reset disabled skills/works
pawn.skills.Notify_SkillDisablesChanged();
pawn.Notify_DisabledWorkTypesChanged();
}
[SyncMethod]
private static int sum_previous_gains(SkillDef def, Pawn_StoryTracker sto, Pawn_AgeTracker age)
{
int total_gain = 0;
SkillGain gain;
// Gains from backstories
if((gain = sto.Childhood.skillGains.FirstOrDefault((SkillGain skillGain) => skillGain.skill == def )) != null)
total_gain += gain.amount;
if ((gain = sto.Adulthood.skillGains.FirstOrDefault((SkillGain skillGain) => skillGain.skill == def)) != null)
total_gain += gain.amount;
// Gains from traits
foreach (var trait in sto.traits.allTraits)
if ((gain = trait.CurrentData.skillGains.FirstOrDefault((SkillGain skillGain) => skillGain.skill == def)) != null)
total_gain += gain.amount;
// Gains from age
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
var rgain = Rand.Value * (float)total_gain * 0.35f;
var age_factor = Mathf.Clamp01((age.AgeBiologicalYearsFloat - 17.0f) / 10.0f); // Assume nymphs are 17~27
total_gain += (int)(age_factor * rgain);
return Mathf.Clamp(total_gain, 0, 20);
}
/// <summary>
/// Set a nymph's initial skills & passions from backstory, traits, and age
/// </summary>
[SyncMethod]
public static void set_skills(Pawn pawn)
{
foreach (var skill_def in DefDatabase<SkillDef>.AllDefsListForReading)
{
var rec = pawn.skills.GetSkill(skill_def);
if (!rec.TotallyDisabled)
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
rec.Level = sum_previous_gains(skill_def, pawn.story, pawn.ageTracker);
rec.xpSinceLastLevel = rec.XpRequiredForLevelUp * Rand.Range(0.10f, 0.90f);
var pas_cha = nymph_backstories.get_passion_chances(pawn.story.Childhood, pawn.story.Adulthood, skill_def);
var rv = Rand.Value;
if (rv < pas_cha.major) rec.passion = Passion.Major;
else if (rv < pas_cha.minor) rec.passion = Passion.Minor;
else rec.passion = Passion.None;
}
else
rec.passion = Passion.None;
}
}
[SyncMethod]
public static PawnKindDef GetFixedNymphPawnKindDef()
{
var def = DefDatabase<PawnKindDef>.AllDefs.Where(x => x.defName.Contains("Nymph")).RandomElement();
//var def = PawnKindDef.Named("Nymph");
// This is 18 in the xml but something is overwriting it to 5.
//def.minGenerationAge = 18;
return def;
}
[SyncMethod]
public static Pawn GenerateNymph(Faction faction = null)
{
// Most of the special properties of nymphs are in harmony patches to PawnGenerator.
PawnGenerationRequest request = new PawnGenerationRequest(
kind: GetFixedNymphPawnKindDef(),
faction: faction,
forceGenerateNewPawn: true,
canGeneratePawnRelations: true,
colonistRelationChanceFactor: 0.0f,
relationWithExtraPawnChanceFactor: 0
);
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
Pawn pawn = PawnGenerator.GeneratePawn(request);
//Log.Message(""+ pawn.Faction);
//IntVec3 spawn_loc = CellFinder.RandomClosewalkCellNear(around_loc, map, 6);//RandomSpawnCellForPawnNear could be an alternative
//GenSpawn.Spawn(pawn, spawn_loc, map);
return pawn;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Nymphs/Pawns/Nymph_Generator.cs
|
C#
|
mit
| 6,218
|
//using System;
//using RimWorld;
//using Verse;
//namespace rjw
//{
// public class BackstoryDef : Def
// {
// public BackstoryDef()
// {
// this.slot = BackstorySlot.Childhood;
// }
// public static BackstoryDef Named(string defName)
// {
// return DefDatabase<BackstoryDef>.GetNamed(defName, true);
// }
// public override void ResolveReferences()
// {
// base.ResolveReferences();
// if (BackstoryDatabase.allBackstories.ContainsKey(this.defName))
// {
// ModLog.Error("BackstoryDatabase already contains: " + this.defName);
// return;
// }
// {
// //Log.Warning("BackstoryDatabase does not contains: " + this.defName);
// }
// if (!this.title.NullOrEmpty())
// {
// Backstory backstory = new Backstory();
// backstory.SetTitle(this.title, this.titleFemale);
// backstory.SetTitleShort(this.titleShort, this.titleFemaleShort);
// backstory.baseDesc = this.baseDescription;
// backstory.slot = this.slot;
// backstory.spawnCategories.Add(this.categoryName);
// backstory.ResolveReferences();
// backstory.PostLoad();
// backstory.identifier = this.defName;
// BackstoryDatabase.allBackstories.Add(backstory.identifier, backstory);
// //Log.Warning("BackstoryDatabase added: " + backstory.identifier);
// //Log.Warning("BackstoryDatabase added: " + backstory.spawnCategories.ToCommaList());
// }
// }
// public string baseDescription;
// public string title;
// public string titleShort;
// public string titleFemale;
// public string titleFemaleShort;
// public string categoryName;
// public BackstorySlot slot;
// }
//}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/BackstoryDef.cs
|
C#
|
mit
| 1,621
|
using System.Collections.Generic;
using Verse;
using Multiplayer.API;
using RimWorld;
namespace rjw
{
//MicroComputer
internal class Hediff_MicroComputer : Hediff_MechImplants
{
protected int nextEventTick = GenDate.TicksPerDay;
public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look<int>(ref this.nextEventTick, "nextEventTick", GenDate.TicksPerDay, false);
}
[SyncMethod]
public override void PostMake()
{
base.PostMake();
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
nextEventTick = Rand.Range(mcDef.minEventInterval, mcDef.maxEventInterval);
}
[SyncMethod]
public override void Tick()
{
base.Tick();
if (this.pawn.IsHashIntervalTick(1000))
{
if (this.ageTicks >= nextEventTick)
{
HediffDef randomEffectDef = DefDatabase<HediffDef>.GetNamed(randomEffect);
if (randomEffectDef != null)
{
pawn.health.AddHediff(randomEffectDef);
}
else
{
//--ModLog.Message("" + this.GetType().ToString() + "::Tick() - There is no Random Effect");
}
this.ageTicks = 0;
}
}
}
protected HediffDef_MechImplants mcDef
{
get
{
return ((HediffDef_MechImplants)def);
}
}
protected List<string> randomEffects
{
get
{
return mcDef.randomHediffDefs;
}
}
protected string randomEffect
{
get
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
return randomEffects.RandomElement<string>();
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/HeDiff_MicroComputer.cs
|
C#
|
mit
| 1,534
|
#nullable enable
using System.Collections.Generic;
using Verse;
namespace rjw
{
[StaticConstructorOnStartup]
public class HediffDef_EnemyImplants : HediffDef
{
//single parent eggs
public string parentDef = "";
//multiparent eggs
public List<string> parentDefs = new();
//for implanting eggs
public bool CanHaveParent(string defName)
{
// Predefined parent eggs.
if (parentDef == defName) return true;
if (parentDefs.Contains(defName)) return true;
// Dynamic egg.
return RJWPregnancySettings.egg_pregnancy_implant_anyone;
}
}
[StaticConstructorOnStartup]
public class HediffDef_InsectEgg : HediffDef_EnemyImplants
{
//this is filled from xml
//1 day = 60000 ticks
public float eggsize = 1;
public bool selffertilized = false;
public List<string> childrenDefs = new();
public string? UnFertEggDef = null;
public string? FertEggDef = null;
}
[StaticConstructorOnStartup]
public class HediffDef_MechImplants : HediffDef_EnemyImplants
{
public List<string> randomHediffDefs = new();
public int minEventInterval = 30000;
public int maxEventInterval = 90000;
public List<string> childrenDefs = new();
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/HediffDef_EnemyImplants.cs
|
C#
|
mit
| 1,174
|
using System;
using System.Collections.Generic;
using RimWorld;
using Verse;
using UnityEngine;
using System.Text;
using Multiplayer.API;
using System.Linq;
using RimWorld.Planet;
using static rjw.PregnancyHelper;
namespace rjw
{
public abstract class Hediff_BasePregnancy : HediffWithComps
//public abstract class Hediff_BasePregnancy : HediffWithParents
{
///<summary>
///This hediff class simulates pregnancy.
///</summary>
//Static fields
private const int MiscarryCheckInterval = 1000;
protected const string starvationMessage = "MessageMiscarriedStarvation";
protected const string poorHealthMessage = "MessageMiscarriedPoorHealth";
protected static readonly HashSet<string> non_genetic_traits = new HashSet<string>(DefDatabase<StringListDef>.GetNamed("NonInheritedTraits").strings);
//Fields
///All babies should be premade and stored here
public List<Pawn> babies;
///Reference to daddy, goes null sometimes
public Pawn father;
///Is pregnancy visible?
public bool is_discovered = false;
public bool is_parent_known = false;
public bool ShouldMiscarry = false;
public bool ImmortalMiscarry = false;
///Is pregnancy type checked?
public bool is_checked = false;
///Mechanoid pregnancy, false - spawn aggressive mech
public bool is_hacked = false;
///Contractions duration, effectively additional hediff stage, a dirty hack to make birthing process notable
public int contractions;
///Gestation progress
public float p_start_tick = 0;
public float p_end_tick = 0;
public float lastTick = 0;
public GeneSet geneSet = null;
//public string last_name
//{
// get
// {
// string last_name = "";
// if (xxx.is_human(father))
// last_name = NameTriple.FromString(father.Name.ToStringFull).Last;
// else if (xxx.is_human(pawn))
// last_name = NameTriple.FromString(pawn.Name.ToStringFull).Last;
// return last_name;
// }
//}
//public float skin_whiteness
//{
// get
// {
// float skin_whiteness = Rand.Range(0, 1);
// if (xxx.has_traits(pawn) && pawn.RaceProps.Humanlike)
// {
// skin_whiteness = pawn.story.melanin;
// }
// if (father != null && xxx.has_traits(father) && father.RaceProps.Humanlike)
// {
// skin_whiteness = Rand.Range(skin_whiteness, father.story.melanin);
// }
// return skin_whiteness;
// }
//}
//public List<Trait> traitpool
//{
// get
// {
// List<Trait> traitpool = new List<Trait>();
// if (xxx.has_traits(pawn) && pawn.RaceProps.Humanlike)
// {
// foreach (Trait momtrait in pawn.story.traits.allTraits)
// {
// if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(momtrait.def.defName))
// traitpool.Add(momtrait);
// }
// }
// if (father != null && xxx.has_traits(father) && father.RaceProps.Humanlike)
// {
// foreach (Trait poptrait in father.story.traits.allTraits)
// {
// if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(poptrait.def.defName))
// traitpool.Add(poptrait);
// }
// }
// return traitpool;
// }
//}
//
// Properties
//
public float GestationProgress
{
get => Severity;
private set => Severity = value;
}
private bool IsSeverelyWounded
{
get
{
float num = 0;
List<Hediff> hediffs = pawn.health.hediffSet.hediffs;
foreach (Hediff h in hediffs)
{
//this errors somewhy,
//ModLog.Message(" 1 " + h.Part.IsCorePart);
//ModLog.Message(" 2 " + h.Part.parent.IsCorePart);
//if (h.Part.IsCorePart || h.Part.parent.IsCorePart)
if (h is Hediff_Injury && (!h.IsPermanent() || !h.IsTended()))
{
if (h.Part != null)
if (h.Part.IsCorePart || h.Part.parent.IsCorePart)
num += h.Severity;
}
}
List<Hediff_MissingPart> missingPartsCommonAncestors = pawn.health.hediffSet.GetMissingPartsCommonAncestors();
foreach (Hediff_MissingPart mp in missingPartsCommonAncestors)
{
if (mp.IsFreshNonSolidExtremity)
{
if (mp.Part != null)
if (mp.Part.IsCorePart || mp.Part.parent.IsCorePart)
num += mp.Part.def.GetMaxHealth(pawn);
}
}
return num > 38 * pawn.RaceProps.baseHealthScale;
}
}
/// <summary>
/// Indicates pregnancy can be aborted using usual means.
/// </summary>
public virtual bool canBeAborted
{
get
{
return true;
}
}
/// <summary>
/// Indicates pregnancy can be miscarried.
/// </summary>
public virtual bool canMiscarry
{
get
{
return true;
}
}
public override string TipStringExtra
{
get
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(base.TipStringExtra);
if(is_parent_known)
stringBuilder.AppendLine("Father: " + xxx.get_pawnname(father));
else
stringBuilder.AppendLine("Father: " + "Unknown");
return stringBuilder.ToString();
}
}
/// <summary>
/// do not merge pregnancies
/// </summary>
//public override bool TryMergeWith(Hediff other)
//{
// return false;
//}
public override void PostMake()
{
// Ensure the hediff always applies to the torso, regardless of incorrect directive
base.PostMake();
BodyPartRecord torso = pawn.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso");
if (Part != torso)
Part = torso;
//(debug->add heddif)
//init empty preg, instabirth, cause error during birthing
//Initialize(pawn, Trytogetfather(ref pawn));
}
public override bool Visible => is_discovered;
public virtual void DiscoverPregnancy()
{
is_discovered = true;
if (PawnUtility.ShouldSendNotificationAbout(this.pawn) && (RJWPregnancySettings.animal_pregnancy_notifications_enabled || !this.pawn.IsAnimal()))
{
if (!is_checked)
{
string key1 = "RJW_PregnantTitle";
string message_title = TranslatorFormattedStringExtensions.Translate(key1, pawn.LabelIndefinite()).CapitalizeFirst();
string key2 = "RJW_PregnantText";
string message_text = TranslatorFormattedStringExtensions.Translate(key2, pawn.LabelIndefinite()).CapitalizeFirst();
Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.NeutralEvent, pawn, null);
}
else
{
PregnancyMessage();
}
}
}
public virtual void CheckPregnancy()
{
is_checked = true;
if (!is_discovered)
DiscoverPregnancy();
else
PregnancyMessage();
}
public virtual void PregnancyMessage()
{
string key1 = "RJW_PregnantTitle";
string message_title = TranslatorFormattedStringExtensions.Translate(key1, pawn.LabelIndefinite());
string key2 = "RJW_PregnantNormal";
string message_text = TranslatorFormattedStringExtensions.Translate(key2, pawn.LabelIndefinite());
Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.NeutralEvent, pawn, null);
}
// Quick method to simply return a body part instance by a given part name
internal static BodyPartRecord GetPawnBodyPart(Pawn pawn, String bodyPart)
{
return pawn.RaceProps.body.AllParts.Find(x => x.def == DefDatabase<BodyPartDef>.GetNamed(bodyPart));
}
public virtual void Miscarry()
{
if (!babies.NullOrEmpty())
foreach (Pawn baby in babies)
{
baby.Destroy();
baby.Discard();
}
pawn.health?.RemoveHediff(this);
}
/// <summary>
/// Called on abortion (noy implemented yet)
/// </summary>
public virtual void Abort()
{
Miscarry();
}
/// <summary>
/// Mechanoids can remove pregnancy
/// </summary>
public virtual void Kill()
{
Miscarry();
}
[SyncMethod]
public Pawn partstospawn(Pawn baby, Pawn mother, Pawn dad)
{
//decide what parts to inherit
//default use own parts
Pawn partstospawn = baby;
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
//spawn with mother parts
if (mother != null && Rand.Range(0, 100) <= 10)
partstospawn = mother;
//spawn with father parts
if (dad != null && Rand.Range(0, 100) <= 10)
partstospawn = dad;
//ModLog.Message(" Pregnancy partstospawn " + partstospawn);
return partstospawn;
}
[SyncMethod]
public bool spawnfutachild(Pawn baby, Pawn mother, Pawn dad)
{
int futachance = 0;
if (mother != null && Genital_Helper.is_futa(mother))
futachance = futachance + 25;
if (dad != null && Genital_Helper.is_futa(dad))
futachance = futachance + 25;
//ModLog.Message(" Pregnancy spawnfutachild " + futachance);
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
//theres 1% change baby will be futa
//bug ... or ... feature ... nature finds a way
return (Rand.Range(0, 100) <= futachance);
}
[SyncMethod]
public static Pawn Trytogetfather(ref Pawn mother)
{
//birthing with debug has no father
//Postmake.initialize() has no father
ModLog.Warning("Hediff_BasePregnancy::Trytogetfather() - debug? no father defined, trying to add one");
Pawn pawn = mother;
Pawn father = null;
//possible fathers
List<Pawn> partners = pawn.relations.RelatedPawns.Where(x =>
Genital_Helper.has_penis_fertile(x) && !x.Dead &&
(pawn.relations.DirectRelationExists(PawnRelationDefOf.Lover, x) ||
pawn.relations.DirectRelationExists(PawnRelationDefOf.Fiance, x) ||
pawn.relations.DirectRelationExists(PawnRelationDefOf.Spouse, x))
).ToList();
//add bonded animal
if (RJWSettings.bestiality_enabled && xxx.is_zoophile(mother))
partners.AddRange(pawn.relations.RelatedPawns.Where(x =>
Genital_Helper.has_penis_fertile(x) &&
pawn.relations.DirectRelationExists(PawnRelationDefOf.Bond, x)).ToList());
if (partners.Any())
{
father = partners.RandomElement();
ModLog.Warning("Hediff_BasePregnancy::Trytogetfather() - father set to: " + xxx.get_pawnname(father));
}
if (father == null)
{
father = mother;
ModLog.Warning("Hediff_BasePregnancy::Trytogetfather() - father is null, set to: " + xxx.get_pawnname(mother));
}
return father;
}
public override void Tick()
{
ageTicks++;
float thisTick = Find.TickManager.TicksGame;
GestationProgress = (1 + thisTick - p_start_tick) / (p_end_tick - p_start_tick);
if ((thisTick - lastTick) >= 1000)
{
if (babies.NullOrEmpty())
{
ModLog.Warning(" no babies (debug?) " + this.GetType().Name);
if (father == null)
{
father = Trytogetfather(ref pawn);
}
Initialize(pawn, father, SelectDnaGivingParent(pawn, father));
GestationProgress = (1 + thisTick - p_start_tick) / (p_end_tick - p_start_tick);
return;
}
lastTick = thisTick;
if (canMiscarry)
{
//miscarry with immortal partners
if (ImmortalMiscarry)
{
if (RJWSettings.DevMode) ModLog.Message($"{this} parent(s) immortal, cancel pregnancy");
Miscarry();
return;
}
//ModLog.Message(" Pregnancy is ticking for " + pawn + " this is " + this.def.defName + " will end in " + 1/progress_per_tick/TicksPerDay + " days resulting in "+ babies[0].def.defName);
if (!Find.Storyteller.difficulty.babiesAreHealthy)
{
//miscarry after starving
if (pawn.needs.food != null && pawn.needs.food.CurCategory == HungerCategory.Starving)
{
var hed = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Malnutrition);
if (hed != null)
if (hed.Severity > 0.4)
{
if (Visible && PawnUtility.ShouldSendNotificationAbout(pawn))
{
string text = "MessageMiscarriedStarvation".Translate(pawn.LabelIndefinite()).CapitalizeFirst();
Messages.Message(text, pawn, MessageTypeDefOf.NegativeHealthEvent);
}
Miscarry();
return;
}
}
//let beatings only be important when pregnancy is developed somewhat
//miscarry after SeverelyWounded
if (Visible && (IsSeverelyWounded || ShouldMiscarry))
{
if (Visible && PawnUtility.ShouldSendNotificationAbout(pawn))
{
string text = "MessageMiscarriedPoorHealth".Translate(pawn.LabelIndefinite()).CapitalizeFirst();
Messages.Message(text, pawn, MessageTypeDefOf.NegativeHealthEvent);
}
Miscarry();
return;
}
}
}
// Check if pregnancy is far enough along to "show" for the body type
if (!is_discovered)
{
BodyTypeDef bodyT = pawn?.story?.bodyType;
//float threshold = 0f;
if ((bodyT == BodyTypeDefOf.Thin && GestationProgress > 0.25f) ||
(bodyT == BodyTypeDefOf.Female && GestationProgress > 0.35f) ||
(GestationProgress > 0.50f)) // todo: Modded bodies? (FemaleBB for, example)
DiscoverPregnancy();
//switch (bodyT)
//{
//case BodyType.Thin: threshold = 0.3f; break;
//case BodyType.Female: threshold = 0.389f; break;
//case BodyType.Male: threshold = 0.41f; break;
//default: threshold = 0.5f; break;
//}
//if (GestationProgress > threshold){ DiscoverPregnancy(); }
}
if (CurStageIndex == 3)
{
if (contractions == 0)
{
if (PawnUtility.ShouldSendNotificationAbout(pawn) && (RJWPregnancySettings.animal_pregnancy_notifications_enabled || !this.pawn.IsAnimal()))
{
string text = "RJW_Contractions".Translate(pawn.LabelIndefinite());
Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent);
}
contractions++;
}
if (GestationProgress >= 1 && (pawn.CarriedBy == null || pawn.CarriedByCaravan()))//birthing takes an hour
{
if (PawnUtility.ShouldSendNotificationAbout(pawn) && (RJWPregnancySettings.animal_pregnancy_notifications_enabled || !this.pawn.IsAnimal()))
{
string message_title = "RJW_GaveBirthTitle".Translate(pawn.LabelIndefinite()).CapitalizeFirst();
string message_text = "RJW_GaveBirthText".Translate(pawn.LabelIndefinite()).CapitalizeFirst();
string baby_text = ((babies.Count == 1) ? "RJW_ABaby".Translate() : "RJW_NBabies".Translate(babies.Count));
message_text = message_text + baby_text;
Find.LetterStack.ReceiveLetter(message_title, message_text, LetterDefOf.PositiveEvent, pawn);
}
GiveBirth();
}
}
}
}
/// <summary>
/// Give birth if contraction stage, even if mother died
/// </summary>
public override void Notify_PawnDied(DamageInfo? dinfo, Hediff culprit = null)
{
base.Notify_PawnDied(dinfo,culprit);
if (CurStageIndex == 3)
GiveBirth();
}
public override void ExposeData()
{
base.ExposeData();
Scribe_References.Look(ref father, "father", true);
Scribe_Deep.Look(ref geneSet, "genes");
Scribe_Values.Look(ref is_checked, "is_checked");
Scribe_Values.Look(ref is_hacked, "is_hacked");
Scribe_Values.Look(ref is_discovered, "is_discovered");
Scribe_Values.Look(ref is_parent_known, "is_parent_known");
Scribe_Values.Look(ref ShouldMiscarry, "ShouldMiscarry");
Scribe_Values.Look(ref ImmortalMiscarry, "ImmortalMiscarry");
Scribe_Values.Look(ref contractions, "contractions");
Scribe_Collections.Look(ref babies, "babies", saveDestroyedThings: true, lookMode: LookMode.Deep, ctorArgs: new object[0]);
Scribe_Values.Look(ref p_start_tick, "p_start_tick", 0);
Scribe_Values.Look(ref p_end_tick, "p_end_tick", 0);
Scribe_Values.Look(ref lastTick, "lastTick", 0);
}
/// <summary>
/// The parent that gives the "DNA" of a baby. Indicates whether the baby
/// should be the same species as its mother or as its father.
/// </summary>
public enum DnaGivingParent
{
Mother,
Father
}
/// <summary>
/// Decides which parent's species the baby should have. This method is
/// random for some configurations!
/// </summary>
[SyncMethod]
public static DnaGivingParent SelectDnaGivingParent(Pawn mother, Pawn father)
{
bool IsAndroidmother = AndroidsCompatibility.IsAndroid(mother);
bool IsAndroidfather = AndroidsCompatibility.IsAndroid(father);
//androids can only birth non androids
if (IsAndroidmother && !IsAndroidfather)
{
return DnaGivingParent.Father;
}
else if (!IsAndroidmother && IsAndroidfather)
{
return DnaGivingParent.Mother;
}
else if (IsAndroidmother && IsAndroidfather)
{
ModLog.Warning("Both parents are andoids, what have you done monster!");
//this should never happen but w/e
}
bool is_humanmother = xxx.is_human(mother);
bool is_humanfather = xxx.is_human(father);
//Decide on which parent is first to be inherited
if (father != null && RJWPregnancySettings.use_parent_method)
{
//Log.Message("The baby race needs definition");
//humanality
if (is_humanmother && is_humanfather)
{
//Log.Message("It's of two humanlikes");
if (!Rand.Chance(RJWPregnancySettings.humanlike_DNA_from_mother))
{
//Log.Message("Mother will birth father race");
return DnaGivingParent.Father;
}
else
{
//Log.Message("Mother will birth own race");
return DnaGivingParent.Mother;
}
}
//bestiality
else if (is_humanmother ^ is_humanfather)
{
//TODO: fix gene inheritance from mother if ModsConfig.BiotechActive(also line 528)
//if (RJWPregnancySettings.bestiality_DNA_inheritance == 0.0f || ModsConfig.BiotechActive)
if (RJWPregnancySettings.bestiality_DNA_inheritance == 0.0f)
{
//Log.Message("mother will birth beast");
if (is_humanmother)
return DnaGivingParent.Father;
else
return DnaGivingParent.Mother;
}
else if (RJWPregnancySettings.bestiality_DNA_inheritance == 1.0f)
{
//Log.Message("mother will birth humanlike");
if (is_humanmother)
return DnaGivingParent.Mother;
else
return DnaGivingParent.Father;
}
else
{
if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother))
{
//Log.Message("Mother will birth father race");
return DnaGivingParent.Father;
}
else
{
//Log.Message("Mother will birth own race");
return DnaGivingParent.Mother;
}
}
}
//animality
else
{
if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother))
{
//Log.Message("Mother will birth father race");
return DnaGivingParent.Father;
}
else
{
//Log.Message("Mother will birth own race");
return DnaGivingParent.Mother;
}
}
}
else
{
return DnaGivingParent.Mother;
}
}
//This should generate pawns to be born in due time. Should take into account all settings and parent races
[SyncMethod]
protected virtual void GenerateBabies(DnaGivingParent dnaGivingParent)
{
Pawn mother = pawn;
//Log.Message("Generating babies for " + this.def.defName);
if (mother == null)
{
ModLog.Error("Hediff_BasePregnancy::GenerateBabies() - no mother defined");
return;
}
if (father == null)
{
ModLog.Error("Hediff_BasePregnancy::GenerateBabies() - no father defined");
return;
}
//Babies will have average number of traits of their parents, this way it will hopefully be compatible with various mods that change number of allowed traits
//int trait_count = 0;
// not anymore. Using number of traits originally generated by game as a guide
Pawn parent = (dnaGivingParent == DnaGivingParent.Father) ? father : mother;
//ModLog.Message(" The main parent is " + parent);
//Log.Message("Mother: " + xxx.get_pawnname(mother) + " kind: " + mother.kindDef);
//Log.Message("Father: " + xxx.get_pawnname(father) + " kind: " + father.kindDef);
//Log.Message("Baby base: " + xxx.get_pawnname(parent) + " kind: " + parent.kindDef);
string last_name = "";
if (xxx.is_human(father))
last_name = NameTriple.FromString(father.Name.ToStringFull).Last;
else if (xxx.is_human(pawn))
last_name = NameTriple.FromString(pawn.Name.ToStringFull).Last;
//float skin_whiteness = Rand.Range(0, 1);
//if (xxx.has_traits(pawn) && pawn.RaceProps.Humanlike)
//{
// skin_whiteness = pawn.story.melanin;
//}
//if (father != null && xxx.has_traits(father) && father.RaceProps.Humanlike)
//{
// skin_whiteness = Rand.Range(skin_whiteness, father.story.melanin);
//}
List<Trait> traitpool = new List<Trait>();
List<Trait> momtraits = new List<Trait>();
List<Trait> poptraits = new List<Trait>();
List<Trait> traits_to_inherit = new List<Trait>();
System.Random rd = new System.Random();
int rand_trait_index = 0;
float max_num_momtraits_inherited = RJWPregnancySettings.max_num_momtraits_inherited;
float max_num_poptraits_inherited = RJWPregnancySettings.max_num_poptraits_inherited;
float max_num_traits_inherited = max_num_momtraits_inherited + max_num_poptraits_inherited;
int i = 1;
int j = 1;
//create list object to store traits of pop and mom
if (xxx.has_traits(pawn) && pawn.RaceProps.Humanlike)
{
foreach (Trait momtrait in pawn.story.traits.allTraits)
{
if (!non_genetic_traits.Contains(momtrait.def.defName) && !momtrait.ScenForced)
momtraits.Add(momtrait);
}
}
if (father != null && xxx.has_traits(father) && father.RaceProps.Humanlike)
{
foreach (Trait poptrait in father.story.traits.allTraits)
{
if (!non_genetic_traits.Contains(poptrait.def.defName) && !poptrait.ScenForced)
poptraits.Add(poptrait);
}
}
//add traits from pop and mom to list for traits to inherit
if(!momtraits.NullOrEmpty())
{
i = 1;
while (momtraits.Count > 0 && i <= max_num_momtraits_inherited)
{
rand_trait_index = rd.Next(0, momtraits.Count);
traits_to_inherit.Add(momtraits[rand_trait_index]);
momtraits.RemoveAt(rand_trait_index);
}
}
if(!poptraits.NullOrEmpty())
{
j = 1;
while (poptraits.Count > 0 && j <= max_num_poptraits_inherited)
{
rand_trait_index = rd.Next(0, poptraits.Count);
traits_to_inherit.Add(poptraits[rand_trait_index]);
poptraits.RemoveAt(rand_trait_index);
}
}
//if there is only mom or even no mom traits to be considered, then there is no need to check duplicated tratis from parents
//then the traits_to_inherit List is ready to be transfered into traitpool
if (poptraits.NullOrEmpty() || momtraits.NullOrEmpty())
{
foreach(Trait traits in traits_to_inherit)
{
traitpool.Add(traits);
}
}
//if there are traits from both pop and mom, need to check if there are duplicated traits from parents
else
{
//if length of traits_to_inherit equals maximum number of traits, then it means traits from bot parents reaches maximum value ,and no duplication, this list is ready to go
//then the following big if chunk is not going to be executed, it will go directly to the last foreach chunk
if (traits_to_inherit.Count() != max_num_traits_inherited)
{
//if not equivalent, it may due to removal of duplicated elements or number of traits of mom or pop are less than maximum number of traits can be inherited from mom or pop
//now check if all the traits of mom has been added to traitpool for babies and if number of traits from mom has reached maximum while make sure momtraits is not null first
if (momtraits.Count != 0 && i != max_num_momtraits_inherited)
{
while (poptraits != null && momtraits.Count > 0 && i <= max_num_momtraits_inherited)
{
rand_trait_index = rd.Next(0, momtraits.Count);
//if this newly selected traits is not duplciated with traits already in traits_to_inherit
if (!traits_to_inherit.Contains(momtraits[rand_trait_index]))
{
traits_to_inherit.Add(momtraits[rand_trait_index]);
}
momtraits.RemoveAt(rand_trait_index);
}
}
//do processing to poptraits in the same way as momtraits
if (poptraits != null && poptraits.Count != 0 && j != max_num_poptraits_inherited)
{
while (poptraits.Count > 0 && i <= max_num_poptraits_inherited)
{
rand_trait_index = rd.Next(0, poptraits.Count);
//if this newly selected traits is not duplciated with traits already in traits_to_inherit
if (!traits_to_inherit.Contains(poptraits[rand_trait_index]))
{
traits_to_inherit.Add(poptraits[rand_trait_index]);
}
poptraits.RemoveAt(rand_trait_index);
}
}
}
//add all traits in finalized trait_to_inherit List into traitpool List for further processing
//if the above if chunk is executed, the following foreach chunk still needs to be executed, therefore there is no need to put this foreach chunk into an else chunk
foreach (Trait traits in traits_to_inherit)
{
traitpool.Add(traits);
}
}
//Pawn generation request
PawnKindDef spawn_kind_def = parent.kindDef;
Faction spawn_faction = mother.IsPrisoner ? null : mother.Faction;
//ModLog.Message(" default child spawn_kind_def - " + spawn_kind_def);
string MotherRaceName = "";
string FatherRaceName = "";
MotherRaceName = mother.kindDef.race.defName;
if (father != null)
FatherRaceName = father.kindDef.race.defName;
//ModLog.Message(" MotherRaceName is " + MotherRaceName);
//ModLog.Message(" FatherRaceName is " + FatherRaceName);
if (MotherRaceName != FatherRaceName && FatherRaceName != "")
{
var groups = DefDatabase<RaceGroupDef>.AllDefs.Where(x => !x.hybridRaceParents.NullOrEmpty() && !x.hybridChildKindDef.NullOrEmpty());
//ModLog.Message(" found custom RaceGroupDefs " + groups.Count());
foreach (var t in groups)
{
//ModLog.Message(" trying custom RaceGroupDef " + t.defName);
//ModLog.Message(" custom hybridRaceParents " + t.hybridRaceParents.Count());
//ModLog.Message(" contains hybridRaceParents MotherRaceName? " + t.hybridRaceParents.Contains(MotherRaceName));
//ModLog.Message(" contains hybridRaceParents FatherRaceName? " + t.hybridRaceParents.Contains(FatherRaceName));
if ((t.hybridRaceParents.Contains(MotherRaceName) && t.hybridRaceParents.Contains(FatherRaceName))
|| (t.hybridRaceParents.Contains("Any") && (t.hybridRaceParents.Contains(MotherRaceName) || t.hybridRaceParents.Contains(FatherRaceName))))
{
//ModLog.Message(" has hybridRaceParents");
if (t.hybridChildKindDef.Contains("MotherKindDef"))
spawn_kind_def = mother.kindDef;
else if (t.hybridChildKindDef.Contains("FatherKindDef") && father != null)
spawn_kind_def = father.kindDef;
else
{
//ModLog.Message(" trying hybridChildKindDef " + t.defName);
var child_kind_def_list = new List<PawnKindDef>();
child_kind_def_list.AddRange(DefDatabase<PawnKindDef>.AllDefs.Where(x => t.hybridChildKindDef.Contains(x.defName)));
//ModLog.Message(" found custom hybridChildKindDefs " + t.hybridChildKindDef.Count);
if (!child_kind_def_list.NullOrEmpty())
spawn_kind_def = child_kind_def_list.RandomElement();
}
}
}
}
if (spawn_kind_def.defName.Contains("Nymph"))
{
//child is nymph, try to find other PawnKindDef
var spawn_kind_def_list = new List<PawnKindDef>();
spawn_kind_def_list.AddRange(DefDatabase<PawnKindDef>.AllDefs.Where(x => x.race == spawn_kind_def.race && !x.defName.Contains("Nymph")));
//no other PawnKindDef found try mother
if (spawn_kind_def_list.NullOrEmpty())
spawn_kind_def_list.AddRange(DefDatabase<PawnKindDef>.AllDefs.Where(x => x.race == mother.kindDef.race && !x.defName.Contains("Nymph")));
//no other PawnKindDef found try father
if (spawn_kind_def_list.NullOrEmpty() && father !=null)
spawn_kind_def_list.AddRange(DefDatabase<PawnKindDef>.AllDefs.Where(x => x.race == father.kindDef.race && !x.defName.Contains("Nymph")));
//no other PawnKindDef found fallback to generic colonist
if (spawn_kind_def_list.NullOrEmpty())
spawn_kind_def = PawnKindDefOf.Colonist;
spawn_kind_def = spawn_kind_def_list.RandomElement();
}
//ModLog.Message(" final child spawn_kind_def - " + spawn_kind_def);
//pregnancies with slimes birth only slimes
//should somehow merge with above
if (xxx.is_slime(mother))
{
parent = mother;
spawn_kind_def = parent.kindDef;
}
if (father != null)
{
if (xxx.is_slime(father))
{
parent = father;
spawn_kind_def = parent.kindDef;
}
}
PawnGenerationRequest request = new PawnGenerationRequest(
kind: spawn_kind_def,
faction: spawn_faction,
forceGenerateNewPawn: true,
developmentalStages: DevelopmentalStage.Newborn,
allowDowned: true,
canGeneratePawnRelations: false,
colonistRelationChanceFactor: 0,
allowFood: false,
allowAddictions: false,
relationWithExtraPawnChanceFactor: 0,
//fixedMelanin: skin_whiteness,
fixedLastName: last_name,
//forceNoIdeo: true,
forbidAnyTitle: true,
forceNoBackstory: true,
forcedEndogenes: PregnancyUtility.GetInheritedGenes(father, mother)
);
//ModLog.Message(" Generated request, making babies");
//Litter size. Let's use the main parent litter size, reduced by fertility.
float litter_size = (parent.RaceProps.litterSizeCurve == null) ? 1 : Rand.ByCurve(parent.RaceProps.litterSizeCurve);
//ModLog.Message(" base Litter size " + litter_size);
litter_size *= Math.Min(mother.health.capacities.GetLevel(xxx.reproduction), 1);
litter_size *= Math.Min(father == null ? 1 : father.health.capacities.GetLevel(xxx.reproduction), 1);
litter_size = Math.Max(1, litter_size);
//ModLog.Message(" Litter size (w fertility) " + litter_size);
//Babies body size vs mother body size (bonus childrens boost for multi children pregnancy, ~1.7 for humans ~ x2.2 orassans)
//assuming mother belly is 1/3 of mother body size
float baby_size = spawn_kind_def.RaceProps.lifeStageAges[0].def.bodySizeFactor; // adult size/5, probably?
baby_size *= spawn_kind_def.RaceProps.baseBodySize; // adult size
//ModLog.Message(" Baby size " + baby_size);
float max_litter = 1f / 3f / baby_size;
//ModLog.Message(" Max size " + max_litter);
max_litter *= (mother.Has(Quirk.Breeder) || mother.Has(Quirk.Incubator)) ? 2 : 1;
//ModLog.Message(" Max size (w quirks) " + max_litter);
//Generate random amount of babies within litter/max size
litter_size = (Rand.Range(litter_size, max_litter));
//ModLog.Message(" Litter size roll 1:" + litter_size);
litter_size = Mathf.RoundToInt(litter_size);
//ModLog.Message(" Litter size roll 2:" + litter_size);
litter_size = Math.Max(1, litter_size);
//ModLog.Message(" final Litter size " + litter_size);
for (i = 0; i < litter_size; i++)
{
Pawn baby = PawnGenerator.GeneratePawn(request);
if (xxx.is_human(baby))
{
if (mother.IsSlaveOfColony)
{
//Log.Message("mother.SlaveFaction " + mother.SlaveFaction);
//Log.Message("mother.HomeFaction " + mother.HomeFaction);
//Log.Message("mother.Faction " + mother.Faction);
if (mother.SlaveFaction != null)
baby.SetFaction(mother.SlaveFaction);
else if (mother.HomeFaction != null)
baby.SetFaction(mother.HomeFaction);
else if (mother.Faction != null)
baby.SetFaction(mother.Faction);
else
baby.SetFaction(Faction.OfPlayer);
baby.guest.SetGuestStatus(Faction.OfPlayer, GuestStatus.Slave);
}
else if (mother.IsPrisonerOfColony)
{
//Log.Message("mother.HomeFaction " + mother.HomeFaction);
if (mother.HomeFaction != null)
baby.SetFaction(mother.HomeFaction);
baby.guest.SetGuestStatus(Faction.OfPlayer, GuestStatus.Prisoner);
}
//Choose traits to add to the child. Unlike CnP this will allow for some random traits
if (traitpool.Count > 0)
{
updateTraits(baby, traitpool);
}
}
babies.Add(baby);
}
}
/// <summary>
/// Update pawns traits
/// Uses original pawns trains and given list of traits as a source of traits to select.
/// </summary>
/// <param name="pawn">humanoid pawn</param>
/// <param name="traitpool">list of parent traits</param>
/// <param name="traitLimit">maximum allowed number of traits</param>
[SyncMethod]
void updateTraits(Pawn pawn, List<Trait> parenttraitpool, int traitLimit = -1)
{
if (pawn?.story?.traits == null)
{
return;
}
if (traitLimit == -1)
{
traitLimit = pawn.story.traits.allTraits.Count;
}
//Personal pool
List<Trait> personalTraitPool = new List<Trait>(pawn.story.traits.allTraits);
//Parents pool
if (parenttraitpool != null)
{
personalTraitPool.AddRange(parenttraitpool);
}
//Game suggested traits.
var forcedTraits = personalTraitPool
.Where(x => x.ScenForced)
.Distinct(new TraitComparer(ignoreDegree: true)); // result can be a mess, because game allows this mess to be created in scenario editor
List<Trait> selectedTraits = new List<Trait>();
selectedTraits.AddRange(forcedTraits); // enforcing scenario forced traits
var comparer = new TraitComparer(); // trait comparision implementation, because without game compares traits *by reference*, makeing them all unique.
while (selectedTraits.Count < traitLimit && personalTraitPool.Count > 0)
{
int index = Rand.Range(0, personalTraitPool.Count); // getting trait and removing from the pull
var trait = personalTraitPool[index];
personalTraitPool.RemoveAt(index);
if (!selectedTraits.Any(x => comparer.Equals(x, trait) || // skipping traits conflicting with already added
x.def.ConflictsWith(trait)))
{
selectedTraits.Add(new Trait(trait.def, trait.Degree, false));
}
}
pawn.story.traits.allTraits = selectedTraits;
}
//Handles the spawning of pawns
//this is extended by other scripts
public abstract void GiveBirth();
//Add relations
//post pregnancy effects
//update birth stats
//make baby futa if needed
public virtual void PostBirth(Pawn mother, Pawn father, Pawn baby)
{
BabyPostBirth(mother, father, baby);
if (baby.playerSettings != null && mother.playerSettings != null)
{
baby.playerSettings.AreaRestrictionInPawnCurrentMap = mother.playerSettings.AreaRestrictionInPawnCurrentMap; //or should this be effective one?
}
//if (xxx.is_human(baby))
//{
// baby.story.melanin = skin_whiteness;
// baby.story.birthLastName = last_name;
//}
//ModLog.Message("" + this.GetType().ToString() + " post PostBirth 1: " + baby.story.birthLastName);
//spawn futa
bool isfuta = spawnfutachild(baby, mother, father);
if (!RacePartDef_Helper.TryRacePartDef_partAdders(baby))
{
RemoveBabyParts(baby, Genital_Helper.get_AllPartsHediffList(baby));
if (isfuta)
{
SexPartAdder.add_genitals(baby, partstospawn(baby, mother, father), Gender.Male);
SexPartAdder.add_genitals(baby, partstospawn(baby, mother, father), Gender.Female);
SexPartAdder.add_breasts(baby, partstospawn(baby, mother, father), Gender.Female);
baby.gender = Gender.Female; //set gender to female for futas, should cause no errors since babies already generated with relations n stuff
}
else
{
SexPartAdder.add_genitals(baby, partstospawn(baby, mother, father));
SexPartAdder.add_breasts(baby, partstospawn(baby, mother, father));
}
SexPartAdder.add_anus(baby, partstospawn(baby, mother, father));
}
//ModLog.Message("" + this.GetType().ToString() + " post PostBirth 2: " + baby.story.birthLastName);
if (mother.Spawned)
{
// Move the baby in front of the mother, rather than on top
if (mother.CurrentBed() != null)
{
baby.Position = baby.Position + new IntVec3(0, 0, 1).RotatedBy(mother.CurrentBed().Rotation);
}
// Spawn guck
FilthMaker.TryMakeFilth(mother.Position, mother.Map, ThingDefOf.Filth_AmnioticFluid, mother.LabelIndefinite(), 5);
mother.caller?.DoCall();
baby.caller?.DoCall();
father?.caller?.DoCall();
}
//ModLog.Message("" + this.GetType().ToString() + " post PostBirth 3: " + baby.story.birthLastName);
if (xxx.is_human(baby))
mother.records.AddTo(xxx.CountOfBirthHuman, 1);
if (xxx.is_animal(baby))
mother.records.AddTo(xxx.CountOfBirthAnimal, 1);
if ((mother.records.GetAsInt(xxx.CountOfBirthHuman) > 10 || mother.records.GetAsInt(xxx.CountOfBirthAnimal) > 20))
{
mother.Add(Quirk.Breeder);
mother.Add(Quirk.ImpregnationFetish);
}
}
public static void RemoveBabyParts(Pawn baby, List<Hediff> list)
{
//ModLog.Message(" RemoveBabyParts( " + xxx.get_pawnname(baby) + " ) - " + list.Count);
if (!list.NullOrEmpty())
foreach (var x in list)
{
//ModLog.Message(" RemoveBabyParts( " + xxx.get_pawnname(baby) + " ) - " + x.def.defName);
baby.health.RemoveHediff(x);
//baby.health.RemoveHediff(baby.health.hediffSet.hediffs.Remove(x));
}
}
[SyncMethod]
public static void BabyPostBirth(Pawn mother, Pawn father, Pawn baby)
{
if (!xxx.is_human(baby)) return;
baby.story.Childhood = null;
baby.story.Adulthood = null;
try
{
// set child to civil
String bsDef = null;
bool isTribal = false;
// set child to tribal if both parents tribals
if (father != null && father.story != null)
{
if (mother.story.GetBackstory(BackstorySlot.Adulthood) != null && father.story.GetBackstory(BackstorySlot.Adulthood).spawnCategories.Contains("Tribal"))
isTribal = true;
else if (mother.story.GetBackstory(BackstorySlot.Adulthood) == null && father.story.GetBackstory(BackstorySlot.Childhood).spawnCategories.Contains("Tribal"))
isTribal = true;
}
else
{
//(int)Find.GameInitData.playerFaction.def.techLevel < 4;
if ((int)mother.Faction.def.techLevel < 4)
isTribal = true;
}
if (isTribal)
{
bsDef = "rjw_childT";
if (baby.GetRJWPawnData().RaceSupportDef != null)
if (!baby.GetRJWPawnData().RaceSupportDef.backstoryChildTribal.NullOrEmpty())
bsDef = baby.GetRJWPawnData().RaceSupportDef.backstoryChildTribal.RandomElement();
}
else
{
bsDef = "rjw_childC";
if (baby.GetRJWPawnData().RaceSupportDef != null)
if (!baby.GetRJWPawnData().RaceSupportDef.backstoryChildCivil.NullOrEmpty())
bsDef = baby.GetRJWPawnData().RaceSupportDef.backstoryChildCivil.RandomElement();
}
baby.story.Childhood = DefDatabase<BackstoryDef>.AllDefsListForReading.FirstOrDefault(x => x.defName.Contains(bsDef));
}
catch (Exception e)
{
ModLog.Warning(e.ToString());
}
}
protected void InitializeIfNoBabies()
{
if (babies.NullOrEmpty())
{
ModLog.Warning(" no babies (debug?) " + this.GetType().Name);
if (father == null)
{
father = Trytogetfather(ref pawn);
}
Initialize(pawn, father, SelectDnaGivingParent(pawn, father));
}
}
//This method is doing the work of the constructor since hediffs are created through HediffMaker instead of normal oop way
//This can't be in PostMake() because there wouldn't be father.
public void Initialize(Pawn mother, Pawn dad, DnaGivingParent dnaGivingParent)
{
BodyPartRecord torso = mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso");
mother.health.AddHediff(this, torso);
//ModLog.Message("" + this.GetType().ToString() + " pregnancy hediff generated: " + this.Label);
//ModLog.Message("" + this.GetType().ToString() + " mother: " + mother + " father: " + dad);
father = dad;
if (father != null)
{
babies = new List<Pawn>();
contractions = 0;
//ModLog.Message("" + this.GetType().ToString() + " generating babies before: " + this.babies.Count);
GenerateBabies(dnaGivingParent);
//if (ModsConfig.BiotechActive)
// geneSet = PregnancyUtility.GetInheritedGeneSet(father, mother);
// SetParents(mother, father, PregnancyUtility.GetInheritedGeneSet(father, mother));
}
float p_end_tick_mods = 1;
if (babies[0].RaceProps?.gestationPeriodDays < 1)
{
if (xxx.is_human(babies[0]))
p_end_tick_mods = 45 * GenDate.TicksPerDay; //default human
else
p_end_tick_mods = GenDate.TicksPerDay;
}
else
{
p_end_tick_mods = babies[0].RaceProps.gestationPeriodDays * GenDate.TicksPerDay;
}
if (pawn.Has(Quirk.Breeder) || pawn.health.hediffSet.HasHediff(HediffDef.Named("FertilityEnhancer")))
p_end_tick_mods /= 1.25f;
p_end_tick_mods *= RJWPregnancySettings.normal_pregnancy_duration;
p_start_tick = Find.TickManager.TicksGame;
p_end_tick = p_start_tick + p_end_tick_mods;
lastTick = p_start_tick;
if (xxx.ImmortalsIsActive && (mother.health.hediffSet.HasHediff(xxx.IH_Immortal) || father.health.hediffSet.HasHediff(xxx.IH_Immortal)))
{
ImmortalMiscarry = true;
ShouldMiscarry = true;
}
//ModLog.Message("" + this.GetType().ToString() + " generating babies after: " + this.babies.Count);
}
private static Dictionary<Type, string> _hediffOfClass = null;
protected static Dictionary<Type, string> hediffOfClass
{
get
{
if (_hediffOfClass == null)
{
_hediffOfClass = new Dictionary<Type, string>();
var allRJWPregnancies = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(
a => a
.GetTypes()
.Where(t => t.IsSubclassOf(typeof(Hediff_BasePregnancy)))
);
foreach (var pregClass in allRJWPregnancies)
{
var attribute = (RJWAssociatedHediffAttribute)pregClass.GetCustomAttributes(typeof(RJWAssociatedHediffAttribute), false).FirstOrDefault();
if (attribute != null)
{
_hediffOfClass[pregClass] = attribute.defName;
}
}
}
return _hediffOfClass;
}
}
public static T Create<T>(Pawn mother, Pawn father) where T : Hediff_BasePregnancy
{
return Create<T>(mother, father, SelectDnaGivingParent(mother, father));
}
/// <summary>
/// Creates pregnancy hediff and assigns it to mother
/// </summary>
/// <typeparam name="T">type of pregnancy, should be subclass of Hediff_BasePregnancy</typeparam>
/// <param name="mother"></param>
/// <param name="father"></param>
/// <returns>created hediff</returns>
public static T Create<T>(Pawn mother, Pawn father, DnaGivingParent dnaGivingParent) where T : Hediff_BasePregnancy
{
if (mother == null)
return null;
//if (mother.RaceHasOviPregnancy() && !(T is Hediff_MechanoidPregnancy))
//{
// //return null;
//}
//else
//{
//}
BodyPartRecord torso = mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso");
string defName = hediffOfClass.ContainsKey(typeof(T)) ? hediffOfClass[typeof(T)] : "RJW_pregnancy";
if (RJWSettings.DevMode) ModLog.Message($"Hediff_BasePregnancy::create hediff:{defName} class:{typeof(T).FullName}");
T hediff = HediffHelper.MakeHediff<T>(HediffDef.Named(defName), mother, torso);
hediff.Initialize(mother, father, dnaGivingParent);
return hediff;
}
/// <summary>
/// list of all known RJW pregnancy hediff names (new can be regicreted by mods)
/// </summary>
/// <returns></returns>
public static IEnumerable<string> KnownPregnancies()
{
return hediffOfClass.Values.Distinct(); // todo: performance
}
public override string DebugString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(base.DebugString());
stringBuilder.AppendLine("Gestation progress: " + GestationProgress.ToStringPercent());
//stringBuilder.AppendLine("Time left: " + ((int)((1f - GestationProgress) * babies[babies.Count-1].RaceProps.gestationPeriodDays * TicksPerDay * RJWPregnancySettings.normal_pregnancy_duration)).ToStringTicksToPeriod());
return stringBuilder.ToString();
}
//public override IEnumerable<Gizmo> GetGizmos()
//{
// foreach (Gizmo gizmo in base.GetGizmos())
// {
// yield return gizmo;
// }
// if (!DebugSettings.ShowDevGizmos)
// {
// yield break;
// }
// if (CurStageIndex < 2)
// {
// Command_Action command_Action = new Command_Action();
// command_Action.defaultLabel = "DEV: Next trimester";
// command_Action.action = delegate
// {
// HediffStage hediffStage = def.stages[CurStageIndex + 1];
// severityInt = hediffStage.minSeverity;
// };
// yield return command_Action;
// }
// if (ModsConfig.BiotechActive && pawn.RaceProps.Humanlike && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PregnancyLabor) == null)
// {
// Command_Action command_Action2 = new Command_Action();
// command_Action2.defaultLabel = "DEV: Start Labor";
// command_Action2.action = delegate
// {
// StartLabor();
// pawn.health.RemoveHediff(this);
// };
// yield return command_Action2;
// }
//}
//public void StartLabor()
//{
// if (ModLister.CheckBiotech("labor"))
// {
// ((Hediff_Labor)pawn.health.AddHediff(HediffDefOf.PregnancyLabor)).SetParents(pawn, father, PregnancyUtility.GetInheritedGeneSet(father, pawn));
// Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.MorningSickness);
// if (firstHediffOfDef != null)
// {
// pawn.health.RemoveHediff(firstHediffOfDef);
// }
// Hediff firstHediffOfDef2 = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.PregnancyMood);
// if (firstHediffOfDef2 != null)
// {
// pawn.health.RemoveHediff(firstHediffOfDef2);
// }
// if (PawnUtility.ShouldSendNotificationAbout(pawn))
// {
// Find.LetterStack.ReceiveLetter("LetterColonistPregnancyLaborLabel".Translate(pawn), "LetterColonistPregnancyLabor".Translate(pawn), LetterDefOf.NeutralEvent);
// }
// }
//}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/Hediff_BasePregnancy.cs
|
C#
|
mit
| 45,752
|
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
namespace rjw
{
///<summary>
///This hediff class simulates pregnancy with animal children, mother may be human. It is not intended to be reasonable.
///Differences from humanlike pregnancy are that animals are given some training and that less punishing relations are used for parent-child.
///</summary>
[RJWAssociatedHediff("RJW_pregnancy_beast")]
public class Hediff_BestialPregnancy : Hediff_BasePregnancy
{
private static readonly PawnRelationDef relation_birthgiver = PawnRelationDefOf.Parent;
//static int max_train_level = TrainableUtility.TrainableDefsInListOrder.Sum(tr => tr.steps);
public override void PregnancyMessage()
{
string message_title = "RJW_PregnantTitle".Translate(pawn.LabelIndefinite()).CapitalizeFirst();
string message_text1 = "RJW_PregnantText".Translate(pawn.LabelIndefinite()).CapitalizeFirst();
string message_text2 = "RJW_PregnantStrange".Translate();
Find.LetterStack.ReceiveLetter(message_title, message_text1 + "\n" + message_text2, LetterDefOf.NeutralEvent, pawn);
}
//Makes half-human babies start off better. They start obedient, and if mother is a human, they get hediff to boost their training
protected void train(Pawn baby, Pawn mother, Pawn father)
{
bool _;
if (!xxx.is_human(baby) && baby.Faction == Faction.OfPlayer)
{
if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Obedience, out _).Accepted)
{
baby.training.Train(TrainableDefOf.Obedience, mother);
}
if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Tameness, out _).Accepted)
{
baby.training.Train(TrainableDefOf.Tameness, mother);
}
}
//baby.RaceProps.TrainableIntelligence.LabelCap.
//if (xxx.is_human(mother))
//{
// Let the animals be born as colony property
// if (mother.IsPrisonerOfColony || mother.IsColonist)
// {
// baby.SetFaction(Faction.OfPlayer);
// }
// let it be trained half to the max
// var baby_int = baby.RaceProps.TrainableIntelligence;
// int max_int = TrainableUtility.TrainableDefsInListOrder.FindLastIndex(tr => (tr.requiredTrainableIntelligence == baby_int));
// if (max_int == -1)
// return;
// Log.Message("RJW training " + baby + " max_int is " + max_int);
// var available_tricks = TrainableUtility.TrainableDefsInListOrder.GetRange(0, max_int + 1);
// int max_steps = available_tricks.Sum(tr => tr.steps);
// Log.Message("RJW training " + baby + " vill do " + max_steps/2 + " steps");
// int t_score = Rand.Range(Mathf.RoundToInt(max_steps / 4), Mathf.RoundToInt(max_steps / 2));
// for (int i = 1; i <= t_score; i++)
// {
// var tr = available_tricks.Where(t => !baby.training.IsCompleted(t)). RandomElement();
// Log.Message("RJW training " + baby + " for " + tr);
// baby.training.Train(tr, mother);
// }
// baby.health.AddHediff(HediffDef.Named("RJW_smartPup"));
//}
}
//Handles the spawning of pawns and adding relations
public override void GiveBirth()
{
Pawn mother = pawn;
if (mother == null)
return;
InitializeIfNoBabies();
List<Pawn> siblings = new List<Pawn>();
foreach (Pawn baby in babies)
{
//backup melanin, LastName for when baby reset by other mod on spawn/backstorychange
//var skin_whiteness = baby.story.melanin;
//var last_name = baby.story.birthLastName;
PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother);
Need_Sex sex_need = mother.needs?.TryGetNeed<Need_Sex>();
if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null)
{
sex_need.CurLevel = 1.0f;
}
if (!RJWSettings.Disable_bestiality_pregnancy_relations)
{
baby.relations.AddDirectRelation(relation_birthgiver, mother);
if (father != null && mother != father)
{
baby.relations.AddDirectRelation(relation_birthgiver, father);
}
}
train(baby, mother, father);
PostBirth(mother, father, baby);
//restore melanin, LastName for when baby reset by other mod on spawn/backstorychange
//baby.story.melanin = skin_whiteness;
//baby.story.birthLastName = last_name;
}
mother.health.RemoveHediff(this);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/Hediff_BestialPregnancy.cs
|
C#
|
mit
| 4,355
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse;
using UnityEngine;
namespace rjw
{
[RJWAssociatedHediff("RJW_pregnancy")]
public class Hediff_HumanlikePregnancy : Hediff_BasePregnancy
///<summary>
///This hediff class simulates pregnancy resulting in humanlike childs.
///</summary>
{
//Handles the spawning of pawns and adding relations
public override void GiveBirth()
{
Pawn mother = pawn;
if (mother == null)
return;
InitializeIfNoBabies();
List<Pawn> siblings = new List<Pawn>();
foreach (Pawn baby in babies)
{
//backup melanin, LastName for when baby reset by other mod on spawn/backstorychange
//var skin_whiteness = baby.story.melanin;
//var last_name = baby.story.birthLastName;
//ModLog.Message("" + this.GetType().ToString() + " pre TrySpawnHatchedOrBornPawn: " + baby.story.birthLastName);
PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother);
//ModLog.Message("" + this.GetType().ToString() + " post TrySpawnHatchedOrBornPawn: " + baby.story.birthLastName);
var sex_need = mother.needs?.TryGetNeed<Need_Sex>();
if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null)
{
sex_need.CurLevel = 1.0f;
}
if (mother.IsSlaveOfColony)
{
//Log.Message("mother.SlaveFaction " + mother.SlaveFaction);
//Log.Message("mother.HomeFaction " + mother.HomeFaction);
//Log.Message("mother.Faction " + mother.Faction);
if (mother.SlaveFaction != null)
baby.SetFaction(mother.SlaveFaction);
else if (mother.HomeFaction != null)
baby.SetFaction(mother.HomeFaction);
else if (mother.Faction != null)
baby.SetFaction(mother.Faction);
else
baby.SetFaction(Faction.OfPlayer);
baby.guest.SetGuestStatus(Faction.OfPlayer, GuestStatus.Slave);
}
else if (mother.IsPrisonerOfColony)
{
//Log.Message("mother.HomeFaction " + mother.HomeFaction);
if (mother.HomeFaction != null)
baby.SetFaction(mother.HomeFaction);
baby.guest.SetGuestStatus(Faction.OfPlayer, GuestStatus.Prisoner);
}
baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother);
if (father != null && mother != father)
{
baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
}
//ModLog.Message("" + this.GetType().ToString() + " pre PostBirth: " + baby.story.birthLastName);
PostBirth(mother, father, baby);
//ModLog.Message("" + this.GetType().ToString() + " post PostBirth: " + baby.story.birthLastName);
//restore melanin, LastName for when baby reset by other mod on spawn/backstorychange
//baby.story.melanin = skin_whiteness;
//baby.story.birthLastName = last_name;
}
mother.health.RemoveHediff(this);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/Hediff_HumanlikePregnancy.cs
|
C#
|
mit
| 2,833
|
using System;
using System.Linq;
using System.Collections.Generic;
using RimWorld;
using RimWorld.Planet;
using Verse;
using System.Text;
using Verse.AI.Group;
using Multiplayer.API;
namespace rjw
{
public class Hediff_InsectEgg : HediffWithComps
{
/*
* Dev Note: To easily test egg-birth, set the p_end_tick to p_start_tick + 10 in the SaveFile.
*/
public float p_start_tick = 0;
public float p_end_tick = 0;
public float lastTick = 0;
private HediffDef_InsectEgg HediffDefOfEgg => (HediffDef_InsectEgg)def;
public string parentDef => HediffDefOfEgg.parentDef;
public List<string> parentDefs => HediffDefOfEgg.parentDefs;
public List<GeneDef> eggGenes;
// TODO: I'd like to change "father" to "fertilizer" but that would be a breaking change.
public Pawn father; //can be parentkind defined in egg
public Pawn implanter; //can be any pawn
public bool canbefertilized = true;
public bool fertilized => father != null;
public float eggssize = 0.1f;
protected List<Pawn> babies;
float Gestation = 0f;
///Contractions duration, effectively additional hediff stage, a dirty hack to make birthing process notable
//protected const int TicksPerHour = 2500;
protected int contractions = 0;
public override string LabelBase
{
get
{
if (Prefs.DevMode && implanter != null)
{
return implanter.kindDef.race.label + "Hediff_InsectEgg_egg".Translate();
}
if (eggssize <= 0.10f)
return "Hediff_InsectEgg_small".Translate();
if (eggssize <= 0.3f)
return "Hediff_InsectEgg_medium".Translate();
else if (eggssize <= 0.5f)
return "Hediff_InsectEgg_big".Translate();
else
return "Hediff_InsectEgg_huge".Translate();
}
}
public override string LabelInBrackets
{
get
{
if (Prefs.DevMode)
{
if (fertilized)
return "Hediff_InsectEgg_fertilized".Translate();
else
return "Hediff_InsectEgg_unfertilized".Translate();
}
return null;
}
}
public float GestationProgress
{
get => Gestation;
set => Gestation = value;
}
public override bool TryMergeWith(Hediff other)
{
return false;
}
public override void Tick()
{
var thisTick = Find.TickManager.TicksGame;
GestationProgress = (1 + thisTick - p_start_tick) / (p_end_tick - p_start_tick);
if ((thisTick - lastTick) >= 1000)
{
lastTick = thisTick;
//birthing takes an hour
if (GestationProgress >= 1 && contractions == 0 && !(pawn.jobs.curDriver is JobDriver_Sex))
{
if (PawnUtility.ShouldSendNotificationAbout(pawn) && (pawn.IsColonist || pawn.IsPrisonerOfColony))
{
string key = "RJW_EggContractions";
string text = TranslatorFormattedStringExtensions.Translate(key, pawn.LabelIndefinite());
Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent);
}
contractions++;
if (!Genital_Helper.has_ovipositorF(pawn))
pawn.health.AddHediff(xxx.submitting);
}
else if (GestationProgress >= 1 && contractions != 0 && (pawn.CarriedBy == null || pawn.CarriedByCaravan()))
{
if (PawnUtility.ShouldSendNotificationAbout(pawn) && (pawn.IsColonist || pawn.IsPrisonerOfColony))
{
string key1 = "RJW_GaveBirthEggTitle";
string message_title = TranslatorFormattedStringExtensions.Translate(key1, pawn.LabelIndefinite());
string key2 = "RJW_GaveBirthEggText";
string message_text = TranslatorFormattedStringExtensions.Translate(key2, pawn.LabelIndefinite());
Messages.Message(message_text, pawn, MessageTypeDefOf.SituationResolved);
}
GiveBirth();
}
}
}
public override void ExposeData()
{
base.ExposeData();
Scribe_References.Look(ref father, "father", true);
Scribe_References.Look(ref implanter, "implanter", true);
Scribe_Values.Look(ref Gestation, "Gestation");
Scribe_Values.Look(ref p_start_tick, "p_start_tick", 0);
Scribe_Values.Look(ref p_end_tick, "p_end_tick", 0);
Scribe_Values.Look(ref lastTick, "lastTick", 0);
Scribe_Values.Look(ref eggssize, "eggssize", 0.1f);
Scribe_Values.Look(ref canbefertilized, "canbefertilized", true);
Scribe_Collections.Look(ref eggGenes, label: "genes", lookMode: LookMode.Def);
Scribe_Collections.Look(ref babies, "babies", saveDestroyedThings: true, lookMode: LookMode.Deep, ctorArgs: new object[0]);
}
public override void Notify_PawnDied(DamageInfo? dinfo, Hediff culprit = null)
{
base.Notify_PawnDied(dinfo, culprit);
GiveBirth();
}
//should someday remake into birth eggs and then within few ticks hatch them
[SyncMethod]
public void GiveBirth()
{
Pawn mother = pawn;
Pawn baby = null;
if (RJWSettings.DevMode) ModLog.Message($"{pawn} is giving birth to an InsectEgg");
if (fertilized)
{
if (RJWSettings.DevMode) ModLog.Message($"Egg was fertilized - Fertilizer {father} and Implanter {implanter}");
PawnKindDef spawn_kind_def = implanter.kindDef;
Faction spawn_faction = DetermineSpawnFaction(mother);
spawn_kind_def = AdjustSpawnKindDef(mother, spawn_kind_def);
if (!spawn_kind_def.RaceProps.Humanlike)
{
BirthFertilizedAnimalEgg(mother, spawn_kind_def);
}
else //humanlike baby
{
baby = ProcessHumanLikeInsectEgg(mother, spawn_kind_def, spawn_faction);
}
UpdateBirtherRecords(mother);
}
else
{
BirthUnfertilizedEggs(mother);
}
// Post birth
ProcessPostBirth(mother, baby);
mother.health.RemoveHediff(this);
}
/// <summary>
/// Bumps the Birth-Statistic for eggs and maybe adds fitting quirks for the mother.
/// </summary>
/// <param name="mother">The pawn that birthed a new egg</param>
private static void UpdateBirtherRecords(Pawn mother)
{
if (RJWSettings.DevMode) ModLog.Message($"Updating {mother}s records after birthing an egg");
mother.records.AddTo(xxx.CountOfBirthEgg, 1);
if (mother.records.GetAsInt(xxx.CountOfBirthEgg) > 100)
{
mother.Add(Quirk.Incubator);
mother.Add(Quirk.ImpregnationFetish);
}
}
/// <summary>
/// Adjusts the Pawn_Kind_Def if it is a Nymph.
/// Issue is that later processing cannot nicely deal with Nymphs.
/// </summary>
/// <param name="mother">The mother, for potential back-up lookup</param>
/// <param name="spawn_kind_def">The current spawn_kind_def</param>
/// <returns></returns>
[SyncMethod]
private PawnKindDef AdjustSpawnKindDef(Pawn mother, PawnKindDef spawn_kind_def)
{
if (spawn_kind_def.defName.Contains("Nymph"))
{
//child is nymph, try to find other PawnKindDef
var spawn_kind_def_list = new List<PawnKindDef>();
spawn_kind_def_list.AddRange(DefDatabase<PawnKindDef>.AllDefs.Where(x => x.race == spawn_kind_def.race && !x.defName.Contains("Nymph")));
//no other PawnKindDef found try mother
if (spawn_kind_def_list.NullOrEmpty())
spawn_kind_def_list.AddRange(DefDatabase<PawnKindDef>.AllDefs.Where(x => x.race == mother.kindDef.race && !x.defName.Contains("Nymph")));
//no other PawnKindDef found try implanter
if (spawn_kind_def_list.NullOrEmpty() && implanter != null)
spawn_kind_def_list.AddRange(DefDatabase<PawnKindDef>.AllDefs.Where(x => x.race == implanter.kindDef.race && !x.defName.Contains("Nymph")));
//no other PawnKindDef found fallback to generic colonist
if (spawn_kind_def_list.NullOrEmpty())
spawn_kind_def = PawnKindDefOf.Colonist;
spawn_kind_def = spawn_kind_def_list.RandomElement();
}
return spawn_kind_def;
}
[SyncMethod]
private void ProcessPostBirth(Pawn mother, Pawn baby)
{
if (mother.Spawned)
{
// Spawn guck
if (mother.caller != null)
{
mother.caller.DoCall();
}
if (baby != null)
{
if (baby.caller != null)
{
baby.caller.DoCall();
}
}
FilthMaker.TryMakeFilth(mother.Position, mother.Map, ThingDefOf.Filth_AmnioticFluid, mother.LabelIndefinite(), 5);
int howmuch = xxx.has_quirk(mother, "Incubator") ? Rand.Range(1, 3) * 2 : Rand.Range(1, 3);
int i = 0;
if (xxx.is_insect(baby) || xxx.is_insect(mother) || xxx.is_insect(implanter) || xxx.is_insect(father))
{
while (i++ < howmuch)
{
Thing jelly = ThingMaker.MakeThing(ThingDefOf.InsectJelly);
if (mother.MapHeld?.areaManager?.Home[mother.PositionHeld] == false)
jelly.SetForbidden(true, false);
GenPlace.TryPlaceThing(jelly, mother.PositionHeld, mother.MapHeld, ThingPlaceMode.Near);
}
}
}
}
/// <summary>
/// Pops out eggs that are not fertilized.
/// </summary>
/// <param name="mother"></param>
private void BirthUnfertilizedEggs(Pawn mother)
{
if (RJWSettings.DevMode) ModLog.Message($"{mother} is giving 'birth' to unfertilized Insect-Eggs.");
if (PawnUtility.ShouldSendNotificationAbout(pawn) && (pawn.IsColonist || pawn.IsPrisonerOfColony))
{
string key = "EggDead";
string text = TranslatorFormattedStringExtensions.Translate(key, pawn.LabelIndefinite()).CapitalizeFirst();
Messages.Message(text, pawn, MessageTypeDefOf.SituationResolved);
}
Thing egg;
var UEgg = DefDatabase<ThingDef>.GetNamedSilentFail(HediffDefOfEgg.UnFertEggDef);
if (UEgg == null)
UEgg = (DefDatabase<ThingDef>.GetNamedSilentFail("RJW_EggInsectUnfertilized"));
egg = ThingMaker.MakeThing(UEgg);
if (mother.MapHeld?.areaManager?.Home[mother.PositionHeld] == false)
egg.SetForbidden(true, false);
GenPlace.TryPlaceThing(egg, mother.PositionHeld, mother.MapHeld, ThingPlaceMode.Near);
}
private Pawn ProcessHumanLikeInsectEgg(Pawn mother, PawnKindDef spawn_kind_def, Faction spawn_faction)
{
ModLog.Message("Hediff_InsectEgg::BirthBaby() " + spawn_kind_def + " of " + spawn_faction + " in " + (int)(50 * implanter.GetStatValue(StatDefOf.PsychicSensitivity)) + " chance!");
PawnGenerationRequest request = new PawnGenerationRequest(
kind: spawn_kind_def,
faction: spawn_faction,
forceGenerateNewPawn: true,
developmentalStages: DevelopmentalStage.Newborn,
allowDowned: true,
canGeneratePawnRelations: false,
colonistRelationChanceFactor: 0,
allowFood: false,
allowAddictions: false,
relationWithExtraPawnChanceFactor: 0,
//forceNoIdeo: true,
forbidAnyTitle: true,
forceNoBackstory: true);
Pawn baby = PawnGenerator.GeneratePawn(request);
// If we have genes, and the baby has not set any, add the ones stored from fertilization as endogenes
if (RJWPregnancySettings.egg_pregnancy_genes && eggGenes != null && eggGenes.Count > 0)
{
if (RJWSettings.DevMode) ModLog.Message($"Setting {eggGenes.Count} genes for {baby}");
foreach (var gene in baby.genes.GenesListForReading)
baby.genes.RemoveGene(gene);
foreach (var gene in eggGenes)
baby.genes.AddGene(gene, false);
} else
{
if (RJWSettings.DevMode) ModLog.Message($"Did not find genes for {baby}");
}
DetermineIfBabyIsPrisonerOrSlave(mother, baby);
SetBabyRelations(baby,implanter,father, mother);
PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother);
if (spawn_faction == Faction.OfInsects || (spawn_faction != null && (spawn_faction.def.defName.Contains("insect") || spawn_faction == implanter.Faction)))
{
Lord lord = implanter.GetLord();
if (lord != null)
{
lord.AddPawn(baby);
}
}
Hediff_BasePregnancy.BabyPostBirth(mother, father, baby);
Sexualizer.sexualize_pawn(baby);
// Move the baby in front of the mother, rather than on top
if (mother.Spawned)
if (mother.CurrentBed() != null)
{
baby.Position = baby.Position + new IntVec3(0, 0, 1).RotatedBy(mother.CurrentBed().Rotation);
}
return baby;
}
private void SetBabyRelations(Pawn Baby, Pawn EggProducer, Pawn Fertilizer, Pawn Host)
{
if (RJWSettings.DevMode) ModLog.Message($"Setting Relations for {Baby}: Egg-Mother={EggProducer}, Egg-Fertilizer={Fertilizer}, Egg-Host={Host}");
if (!RJWSettings.Disable_egg_pregnancy_relations)
if (Baby.RaceProps.IsFlesh)
{
if (EggProducer != null)
Baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, EggProducer);
// Note: Depending on the Sex of the Fertilizer, it's labelled as "Mother" too.
if (Fertilizer != null)
Baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, Fertilizer);
if (Host != null && Host != EggProducer)
Baby.relations.AddDirectRelation(PawnRelationDefOf.ParentBirth, Host);
}
}
private static void DetermineIfBabyIsPrisonerOrSlave(Pawn mother, Pawn baby)
{
if (mother.IsSlaveOfColony)
{
if (mother.SlaveFaction != null)
baby.SetFaction(mother.SlaveFaction);
else if (mother.HomeFaction != null)
baby.SetFaction(mother.HomeFaction);
else if (mother.Faction != null)
baby.SetFaction(mother.Faction);
else
baby.SetFaction(Faction.OfPlayer);
baby.guest.SetGuestStatus(Faction.OfPlayer, GuestStatus.Slave);
}
else if (mother.IsPrisonerOfColony)
{
if (mother.HomeFaction != null)
baby.SetFaction(mother.HomeFaction);
baby.guest.SetGuestStatus(Faction.OfPlayer, GuestStatus.Prisoner);
}
}
[SyncMethod]
private void BirthFertilizedAnimalEgg(Pawn mother, PawnKindDef spawn_kind_def)
{
if (RJWSettings.DevMode) ModLog.Message($"{mother} is birthing an fertilized egg of {spawn_kind_def} ");
Thing egg;
ThingDef EggDef;
string childrendef = "";
PawnKindDef children = null;
//make egg
EggDef = DefDatabase<ThingDef>.GetNamedSilentFail(HediffDefOfEgg.FertEggDef); //try to find predefined
if (EggDef == null) //fail, use generic
EggDef = (DefDatabase<ThingDef>.GetNamedSilentFail("RJW_EggInsectFertilized"));
egg = ThingMaker.MakeThing(EggDef);
//make child
List<string> childlist = new List<string>();
if (!HediffDefOfEgg.childrenDefs.NullOrEmpty())
{
foreach (var child in HediffDefOfEgg.childrenDefs)
{
if (DefDatabase<PawnKindDef>.GetNamedSilentFail(child) != null)
childlist.AddDistinct(child);
}
childrendef = childlist.RandomElement(); //try to find predefined
}
if (!childrendef.NullOrEmpty())
children = DefDatabase<PawnKindDef>.GetNamedSilentFail(childrendef);
if (children == null) //use fatherDef
children = spawn_kind_def;
//put child into egg
if (children != null)
{
var t = egg.TryGetComp<CompHatcher>();
t.Props.hatcherPawn = children;
t.hatcheeParent = implanter;
t.otherParent = father;
t.hatcheeFaction = implanter.Faction;
}
if (mother.MapHeld?.areaManager?.Home[mother.PositionHeld] == false)
egg.SetForbidden(true, false);
//poop egg
GenPlace.TryPlaceThing(egg, mother.PositionHeld, mother.MapHeld, ThingPlaceMode.Near);
}
private Faction DetermineSpawnFaction(Pawn mother)
{
Faction spawn_faction;
//core Hive Insects... probably
if (implanter.Faction == Faction.OfInsects || father.Faction == Faction.OfInsects || mother.Faction == Faction.OfInsects)
{
spawn_faction = Faction.OfInsects;
int chance = 5;
//random chance to make insect neutral/tamable
if (father.Faction == Faction.OfInsects)
chance = 5;
if (father.Faction != Faction.OfInsects)
chance = 10;
if (father.Faction == Faction.OfPlayer)
chance = 25;
if (implanter.Faction == Faction.OfPlayer)
chance += 25;
if (implanter.Faction == Faction.OfPlayer && xxx.is_human(implanter))
chance += (int)(25 * implanter.GetStatValue(StatDefOf.PsychicSensitivity));
if (Rand.Range(0, 100) <= chance)
spawn_faction = null;
//chance tame insect on birth
if (spawn_faction == null)
if (implanter.Faction == Faction.OfPlayer && xxx.is_human(implanter))
if (Rand.Range(0, 100) <= (int)(50 * implanter.GetStatValue(StatDefOf.PsychicSensitivity)))
spawn_faction = Faction.OfPlayer;
}
//humanlikes
else if (xxx.is_human(implanter))
{
spawn_faction = implanter.Faction;
}
//animal, spawn implanter faction (if not player faction/not tamed)
else if (!xxx.is_human(implanter) && !(implanter.Faction?.IsPlayer ?? false))
{
spawn_faction = implanter.Faction;
}
//spawn factionless(tamable, probably)
else
{
spawn_faction = null;
}
return spawn_faction;
}
/// <summary>
/// Sets the Father of an egg.
/// If possible, the genes of the baby are determined too and stored in the egg-pregnancy.
/// Exception is for androids or immortals (mod content).
/// </summary>
/// <param name="Pawn"> Pawn to be set as Father </param>
public void Fertilize(Pawn Pawn)
{
if (implanter == null)
{
return;
}
if (xxx.ImmortalsIsActive && (Pawn.health.hediffSet.HasHediff(xxx.IH_Immortal) || pawn.health.hediffSet.HasHediff(xxx.IH_Immortal)))
{
if (RJWSettings.DevMode) ModLog.Message($"{xxx.get_pawnname(pawn)} is immortal no Fertilize egg {this} cancel");
return;
}
if (AndroidsCompatibility.IsAndroid(pawn))
{
return;
}
if (!fertilized && canbefertilized && GestationProgress < 0.5)
{
if (RJWSettings.DevMode) ModLog.Message($"{xxx.get_pawnname(pawn)} had eggs inside fertilized (Fertilized by {xxx.get_pawnname(father)}): {this}");
father = Pawn;
ChangeEgg(implanter);
}
// If both parents are human / have genes, set the genes of the offspring
if (RJWPregnancySettings.egg_pregnancy_genes && father != null && implanter != null && father.genes != null && implanter.genes != null)
{
if (RJWSettings.DevMode) ModLog.Message($"Setting InsectEgg-Genes for {this}");
DetermineChildGenes();
} else
{
if (RJWSettings.DevMode) ModLog.Message($"Could not set Genes for {this}");
}
}
/// <summary>
/// Sets the genes of the child if both Implanter and Fertilizer have genes.
/// Intentionally in it's own method for easier access with Harmony Patches.
/// </summary>
private void DetermineChildGenes()
{
eggGenes = PregnancyUtility.GetInheritedGenes(father, implanter);
if (RJWSettings.DevMode) ModLog.Message($"Set Genes for {this} from {father} & {implanter} - total of {eggGenes.Count} genes set.");
}
/// <summary>
/// Sets the Implanter and thus the base-egg type.
/// If the egg is Self-Fertilized, the egg also gets fertilized (with Implanter as father, too).
/// </summary>
/// <param name="pawn">Pawn to be implanter.</param>
public void InitImplanter(Pawn pawn)
{
if (implanter == null)
{
if (RJWSettings.DevMode) ModLog.Message("Hediff_InsectEgg:: set implanter:" + xxx.get_pawnname(pawn));
implanter = pawn;
ChangeEgg(implanter);
if (!implanter.health.hediffSet.HasHediff(xxx.sterilized))
{
if (HediffDefOfEgg.selffertilized)
Fertilize(implanter);
}
else
canbefertilized = false;
}
}
//Change egg type after implanting/fertilizing
public void ChangeEgg(Pawn Pawn)
{
if (Pawn != null)
{
float p_end_tick_mods = 1;
if (Pawn.RaceProps?.gestationPeriodDays < 1)
{
p_end_tick_mods = GenDate.TicksPerDay;
}
else
{
p_end_tick_mods = Pawn.RaceProps.gestationPeriodDays * GenDate.TicksPerDay;
}
if (xxx.has_quirk(pawn, "Incubator") || pawn.health.hediffSet.HasHediff(HediffDef.Named("FertilityEnhancer")))
p_end_tick_mods /= 2f;
p_end_tick_mods *= RJWPregnancySettings.egg_pregnancy_duration;
p_start_tick = Find.TickManager.TicksGame;
p_end_tick = p_start_tick + p_end_tick_mods;
lastTick = p_start_tick;
eggssize = Pawn.RaceProps.baseBodySize / 5 * (this.def as HediffDef_InsectEgg).eggsize * RJWPregnancySettings.egg_pregnancy_eggs_size;
// no 0 severity egg size
if (eggssize < 0.01f)
eggssize = 0.01f;
// cap egg size in ovi to 10%
if (this.part.def == xxx.genitalsDef)
if (eggssize > 0.1f && Genital_Helper.has_ovipositorF(pawn))
if (Genital_Helper.has_ovipositorF(pawn))
eggssize = 0.1f;
Severity = eggssize;
}
}
//for setting implanter/fertilize eggs
public bool IsParent(Pawn parent)
{
//anyone can fertilize
if (RJWPregnancySettings.egg_pregnancy_fertilize_anyone) return true;
//only set egg parent or implanter can fertilize
else return parentDef == parent.kindDef.defName
|| parentDefs.Contains(parent.kindDef.defName)
|| implanter.kindDef == parent.kindDef; // unknown eggs
}
public override string DebugString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(base.DebugString());
stringBuilder.AppendLine(" Gestation progress: " + GestationProgress.ToStringPercent());
if (RJWSettings.DevMode) stringBuilder.AppendLine(" Implanter: " + xxx.get_pawnname(implanter));
if (RJWSettings.DevMode) stringBuilder.AppendLine(" Father: " + xxx.get_pawnname(father));
return stringBuilder.ToString();
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/Hediff_InsectEggPregnancy.cs
|
C#
|
mit
| 21,038
|
using RimWorld;
using System.Linq;
using Verse;
using Verse.AI;
namespace rjw
{
public class Hediff_Orgasm : HediffWithComps
{
public override void PostAdd(DamageInfo? dinfo)
{
string key = "FeltOrgasm";
string text = TranslatorFormattedStringExtensions.Translate(key, pawn.LabelIndefinite()).CapitalizeFirst();
Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent);
}
}
public class Hediff_TransportCums : HediffWithComps
{
public override void PostAdd(DamageInfo? dinfo)
{
if (pawn.gender == Gender.Female)
{
string key = "CumsTransported";
string text = TranslatorFormattedStringExtensions.Translate(key, pawn.LabelIndefinite()).CapitalizeFirst();
Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent);
PawnGenerationRequest req = new PawnGenerationRequest(PawnKindDefOf.Drifter, fixedGender:Gender.Male );
Pawn cumSender = PawnGenerator.GeneratePawn(req);
Find.WorldPawns.PassToWorld(cumSender);
//Pawn cumSender = (from p in Find.WorldPawns.AllPawnsAlive where p.gender == Gender.Male select p).RandomElement<Pawn>();
//--ModLog.Message("" + this.GetType().ToString() + "PostAdd() - Sending " + xxx.get_pawnname(cumSender) + "'s cum into " + xxx.get_pawnname(pawn) + "'s vagina");
//PregnancyHelper.impregnate(pawn, cumSender, xxx.rjwSextype.Vaginal);
}
pawn.health.RemoveHediff(this);
}
}
public class Hediff_TransportEggs : HediffWithComps
{
public override void PostAdd(DamageInfo? dinfo)
{
if (pawn.gender == Gender.Female)
{
string key = "EggsTransported";
string text = TranslatorFormattedStringExtensions.Translate(key, pawn.LabelIndefinite()).CapitalizeFirst();
Messages.Message(text, pawn, MessageTypeDefOf.NeutralEvent);
PawnKindDef spawn = PawnKindDefOf.Megascarab;
PawnGenerationRequest req1 = new PawnGenerationRequest(spawn, fixedGender:Gender.Female );
PawnGenerationRequest req2 = new PawnGenerationRequest(spawn, fixedGender:Gender.Male );
Pawn implanter = PawnGenerator.GeneratePawn(req1);
Pawn fertilizer = PawnGenerator.GeneratePawn(req2);
Find.WorldPawns.PassToWorld(implanter);
Find.WorldPawns.PassToWorld(fertilizer);
Sexualizer.sexualize_pawn(implanter);
Sexualizer.sexualize_pawn(fertilizer);
//Pawn cumSender = (from p in Find.WorldPawns.AllPawnsAlive where p.gender == Gender.Male select p).RandomElement<Pawn>();
//--ModLog.Message("" + this.GetType().ToString() + "PostAdd() - Sending " + xxx.get_pawnname(cumSender) + "'s cum into " + xxx.get_pawnname(pawn) + "'s vagina");
//PregnancyHelper.impregnate(pawn, implanter, xxx.rjwSextype.Vaginal);
//PregnancyHelper.impregnate(pawn, fertilizer, xxx.rjwSextype.Vaginal);
}
pawn.health.RemoveHediff(this);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/Hediff_MCEvents.cs
|
C#
|
mit
| 2,770
|
using System.Collections.Generic;
using Verse;
namespace rjw
{
internal class Hediff_MechImplants : HediffWithComps
{
public override bool TryMergeWith(Hediff other)
{
return false;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/Hediff_MechImplants.cs
|
C#
|
mit
| 203
|
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI.Group;
using System.Linq;
using UnityEngine;
using Multiplayer.API;
namespace rjw
{
///<summary>
///This hediff class simulates pregnancy with mechanoids, mother may be human. It is not intended to be reasonable.
///Differences from bestial pregnancy are that ... it is lethal
///TODO: extend with something "friendlier"? than Mech_Scyther.... two Mech_Scyther's? muhahaha
///</summary>
[RJWAssociatedHediff("RJW_pregnancy_mech")]
public class Hediff_MechanoidPregnancy : Hediff_BasePregnancy
{
public override bool canBeAborted
{
get
{
return false;
}
}
public override bool canMiscarry
{
get
{
return false;
}
}
public override void PregnancyMessage()
{
string message_title = "RJW_PregnantTitle".Translate(pawn.LabelIndefinite()).CapitalizeFirst();
string message_text1 = "RJW_PregnantText".Translate(pawn.LabelIndefinite()).CapitalizeFirst();
string message_text2 = "RJW_PregnantMechStrange".Translate();
Find.LetterStack.ReceiveLetter(message_title, message_text1 + "\n" + message_text2, LetterDefOf.ThreatBig, pawn);
}
public void Hack()
{
is_hacked = true;
}
public override void Notify_PawnDied(DamageInfo? dinfo, Hediff culprit = null)
{
base.Notify_PawnDied(dinfo, culprit);
GiveBirth();
}
//Handles the spawning of pawns
[SyncMethod]
public override void GiveBirth()
{
Pawn mother = pawn;
if (mother == null)
return;
if (!babies.NullOrEmpty())
{
foreach (Pawn baby in babies)
{
baby.Destroy();
baby.Discard(true);
}
babies.Clear();
}
Faction spawn_faction = null;
if (!is_hacked)
{
spawn_faction = father?.Faction;
spawn_faction ??= Faction.OfMechanoids;
}
else if (ModsConfig.BiotechActive)
spawn_faction = Faction.OfPlayer;
PawnKindDef children = null;
if (RJWSettings.DevMode) ModLog.Message(xxx.get_pawnname(pawn) + " birth:" + this.ToString());
foreach (HediffDef_MechImplants implant in DefDatabase<HediffDef_MechImplants>.AllDefs.Where(x => x.parentDefs.Contains(father.kindDef.ToString()))) //try to find predefined
{
string childrendef; //try to find predefined
List<string> childlist = new List<string>();
if (!implant.childrenDefs.NullOrEmpty())
{
foreach (var child in (implant.childrenDefs))
{
if (DefDatabase<PawnKindDef>.GetNamedSilentFail(child) != null)
childlist.AddDistinct(child);
}
childrendef = childlist.RandomElement(); //try to find predefined
children = DefDatabase<PawnKindDef>.GetNamedSilentFail(childrendef);
if (children != null)
continue;
}
}
if (children == null) //fallback, use fatherDef
children = father.kindDef;
PawnGenerationRequest request = new PawnGenerationRequest(
kind: children,
faction: spawn_faction,
forceGenerateNewPawn: true,
developmentalStages: DevelopmentalStage.Newborn
);
Pawn mech = PawnGenerator.GeneratePawn(request);
PawnUtility.TrySpawnHatchedOrBornPawn(mech, mother);
if (!is_hacked)
{
LordJob_MechanoidsDefend lordJob = new LordJob_MechanoidsDefend();
Lord lord = LordMaker.MakeNewLord(mech.Faction, lordJob, mech.Map);
lord.AddPawn(mech);
}
FilthMaker.TryMakeFilth(mech.PositionHeld, mech.MapHeld, mother.RaceProps.BloodDef, mother.LabelIndefinite());
IEnumerable<BodyPartRecord> source = from x in mother.health.hediffSet.GetNotMissingParts() where
x.IsInGroup(BodyPartGroupDefOf.Torso)
&& !x.IsCorePart
//&& x.groups.Contains(BodyPartGroupDefOf.Torso)
//&& x.depth == BodyPartDepth.Inside
//&& x.height == BodyPartHeight.Bottom
//someday include depth filter
//so it doesn't cut out external organs (breasts)?
//vag is genital part and genital is external
//anal is internal
//make sep part of vag?
//&& x.depth == BodyPartDepth.Inside
select x;
mother.health.RemoveHediff(this);
if (source.Any())
{
foreach (BodyPartRecord part in source)
{
mother.health.DropBloodFilth();
}
if (RJWPregnancySettings.safer_mechanoid_pregnancy && is_checked)
{
foreach (BodyPartRecord part in source)
{
DamageDef surgicalCut = DamageDefOf.SurgicalCut;
float amount = 5f;
float armorPenetration = 999f;
mother.TakeDamage(new DamageInfo(surgicalCut, amount, armorPenetration, -1f, null, part, null, DamageInfo.SourceCategory.ThingOrUnknown, null));
}
}
else
{
foreach (BodyPartRecord part in source)
{
Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, mother, part);
hediff_MissingPart.lastInjury = HediffDefOf.Cut;
hediff_MissingPart.IsFresh = true;
mother.health.AddHediff(hediff_MissingPart);
}
}
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/Hediff_MechanoidPregnancy.cs
|
C#
|
mit
| 5,131
|
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Verse;
using Multiplayer.API;
namespace rjw
{
internal class Hediff_Parasite : Hediff_Pregnant
{
[SyncMethod]
new public static void DoBirthSpawn(Pawn mother, Pawn father)
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
int num = (mother.RaceProps.litterSizeCurve == null) ? 1 : Mathf.RoundToInt(Rand.ByCurve(mother.RaceProps.litterSizeCurve));
if (num < 1)
{
num = 1;
}
PawnGenerationRequest request = new PawnGenerationRequest(
kind: father.kindDef,
faction: father.Faction,
forceGenerateNewPawn: true,
developmentalStages: DevelopmentalStage.Newborn,
allowDowned: true,
canGeneratePawnRelations: false,
mustBeCapableOfViolence: true,
colonistRelationChanceFactor: 0,
allowFood: false,
allowAddictions: false,
relationWithExtraPawnChanceFactor: 0
);
Pawn pawn = null;
for (int i = 0; i < num; i++)
{
pawn = PawnGenerator.GeneratePawn(request);
if (PawnUtility.TrySpawnHatchedOrBornPawn(pawn, mother))
{
if (pawn.playerSettings != null && mother.playerSettings != null)
{
pawn.playerSettings.AreaRestrictionInPawnCurrentMap = father.playerSettings.AreaRestrictionInPawnCurrentMap; //TODO is this correct?
}
if (pawn.RaceProps.IsFlesh)
{
pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother);
if (father != null)
{
pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
}
}
}
else
{
Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
}
}
if (mother.Spawned)
{
FilthMaker.TryMakeFilth(mother.Position, mother.Map, ThingDefOf.Filth_AmnioticFluid, mother.LabelIndefinite(), 5);
if (mother.caller != null)
{
mother.caller.DoCall();
}
if (pawn.caller != null)
{
pawn.caller.DoCall();
}
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/Hediff_ParasitePregnancy.cs
|
C#
|
mit
| 1,978
|
using System;
using System.Collections.Generic;
using System.Text;
using RimWorld;
using Verse;
using Multiplayer.API;
namespace rjw
{
public static class AgeStage
{
public const int Baby = 0;
public const int Toddler = 1;
public const int Child = 2;
public const int Teenager = 3;
public const int Adult = 4;
}
public class Hediff_SimpleBaby : HediffWithComps
{
// Keeps track of what stage the pawn has grown to
private int grown_to = 0;
private int stage_completed = 0;
public float lastTick = 0;
public float dayTick = 0;
//Properties
public int Grown_To
{
get
{
return grown_to;
}
}
public override string DebugString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(base.DebugString());
stringBuilder.Append("Current CurLifeStageIndex: " + pawn.ageTracker.CurLifeStageIndex + ", grown_to: " + grown_to);
return stringBuilder.ToString();
}
public override void PostMake()
{
Severity = Math.Max(0.01f, Severity);
if (grown_to == 0 && !pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_NoManipulationFlag")))
{
pawn.health.AddHediff(HediffDef.Named("RJW_NoManipulationFlag"), null, null);
}
base.PostMake();
if (!pawn.RaceProps.lifeStageAges.Any(x => x.def.reproductive))
{
if (pawn.health.hediffSet.HasHediff(xxx.RJW_NoManipulationFlag))
{
pawn.health.hediffSet.hediffs.Remove(pawn.health.hediffSet.GetFirstHediffOfDef(xxx.RJW_NoManipulationFlag));
}
pawn.health.RemoveHediff(this);
}
}
public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look(ref grown_to, "grown_to", 0);
Scribe_Values.Look(ref lastTick, "lastTick", 0);
Scribe_Values.Look(ref dayTick, "dayTick", 0);
}
internal void GrowUpTo(int stage)
{
GrowUpTo(stage, true);
}
[SyncMethod]
internal void GrowUpTo(int stage, bool generated)
{
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
if (grown_to < stage)
grown_to = stage;
// Update the Colonist Bar
PortraitsCache.SetDirty(pawn);
pawn.Drawer.renderer.SetAllGraphicsDirty();
// At the toddler stage. Now we can move and talk.
if ((stage >= 1 || pawn.ageTracker.CurLifeStage.reproductive) && stage_completed < 1)
{
Severity = Math.Max(0.5f, Severity);
stage_completed++;
}
// Re-enable skills that were locked out from toddlers
if ((stage >= 2 || pawn.ageTracker.CurLifeStage.reproductive) && stage_completed < 2)
{
// Remove the hidden hediff stopping pawns from manipulating
if (pawn.health.hediffSet.HasHediff(xxx.RJW_NoManipulationFlag))
{
pawn.health.hediffSet.hediffs.Remove(pawn.health.hediffSet.GetFirstHediffOfDef(xxx.RJW_NoManipulationFlag));
}
Severity = Math.Max(0.75f, Severity);
stage_completed++;
}
// The child has grown to a teenager so we no longer need this effect
if ((stage >= 3 || pawn.ageTracker.CurLifeStage.reproductive) && stage_completed < 3)
{
// Gain traits from life experiences
if (pawn.story.traits.allTraits.Count < 3)
{
List<Trait> life_traitpool = new List<Trait>();
// Try get cannibalism
if (pawn.needs.mood.thoughts.memories.Memories.Find(x => x.def == VanillaThoughtDefOf.AteHumanlikeMeatAsIngredient) != null)
{
life_traitpool.Add(new Trait(VanillaTraitDefOf.Cannibal, 0, false));
}
// Try to get bloodlust
if (pawn.records.GetValue(RecordDefOf.KillsHumanlikes) > 0 || pawn.records.GetValue(RecordDefOf.AnimalsSlaughtered) >= 2)
{
life_traitpool.Add(new Trait(TraitDefOf.Bloodlust, 0, false));
}
// Try to get shooting accuracy
if (pawn.records.GetValue(RecordDefOf.ShotsFired) > 100 && (int)pawn.records.GetValue(RecordDefOf.PawnsDowned) > 0)
{
life_traitpool.Add(new Trait(TraitDef.Named("ShootingAccuracy"), 1, false));
}
else if (pawn.records.GetValue(RecordDefOf.ShotsFired) > 100 && (int)pawn.records.GetValue(RecordDefOf.PawnsDowned) == 0)
{
life_traitpool.Add(new Trait(TraitDef.Named("ShootingAccuracy"), -1, false));
}
// Try to get brawler
else if (pawn.records.GetValue(RecordDefOf.ShotsFired) < 15 && pawn.records.GetValue(RecordDefOf.PawnsDowned) > 1)
{
life_traitpool.Add(new Trait(TraitDefOf.Brawler, 0, false));
}
// Try to get necrophiliac
if (pawn.records.GetValue(RecordDefOf.CorpsesBuried) > 50)
{
life_traitpool.Add(new Trait(xxx.necrophiliac, 0, false));
}
// Try to get nymphomaniac
if (pawn.records.GetValue(RecordDefOf.BodiesStripped) > 50)
{
life_traitpool.Add(new Trait(xxx.nymphomaniac, 0, false));
}
// Try to get rapist
if (pawn.records.GetValue(RecordDefOf.TimeAsPrisoner) > 300)
{
life_traitpool.Add(new Trait(xxx.rapist, 0, false));
}
// Try to get Dislikes Men/Women
int male_rivals = 0;
int female_rivals = 0;
foreach (Pawn colinist in Find.AnyPlayerHomeMap.mapPawns.AllPawnsSpawned)
{
if (pawn.relations.OpinionOf(colinist) <= -20)
{
if (colinist.gender == Gender.Male)
male_rivals++;
else
female_rivals++;
}
}
// Find which gender we hate
if (male_rivals > 3 || female_rivals > 3)
{
if (male_rivals > female_rivals)
life_traitpool.Add(new Trait(TraitDefOf.DislikesMen, 0, false));
else if (female_rivals > male_rivals)
life_traitpool.Add(new Trait(TraitDefOf.DislikesWomen, 0, false));
}
// Pyromaniac never put out any fires. Seems kinda stupid
/*if ((int)pawn.records.GetValue (RecordDefOf.FiresExtinguished) == 0) {
life_traitpool.Add (new Trait (TraitDefOf.Pyromaniac, 0, false));
}*/
// Neurotic
if (pawn.records.GetValue(RecordDefOf.TimesInMentalState) > 6)
{
life_traitpool.Add(new Trait(TraitDef.Named("Neurotic"), 2, false));
}
else if (pawn.records.GetValue(RecordDefOf.TimesInMentalState) > 3)
{
life_traitpool.Add(new Trait(TraitDef.Named("Neurotic"), 1, false));
}
// People(male or female) can turn gay during puberty
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
if (Rand.Value <= 0.03f && pawn.story.traits.allTraits.Count <= 3)
{
pawn.story.traits.GainTrait(new Trait(TraitDefOf.Gay, 0, true));
}
// Now let's try to add some life experience traits
if (life_traitpool.Count > 0)
{
int i = 3;
while (pawn.story.traits.allTraits.Count < 3 && i > 0)
{
Trait newtrait = life_traitpool.RandomElement();
if (pawn.story.traits.HasTrait(newtrait.def) == false)
pawn.story.traits.GainTrait(newtrait);
i--;
}
}
}
stage_completed++;
pawn.health.RemoveHediff(this);
}
}
//everyday grow 1 year until reproductive
public void GrowFast()
{
if (RJWPregnancySettings.phantasy_pregnancy)
{
if (!pawn.ageTracker.CurLifeStage.reproductive || pawn.ageTracker.Growth >= 1)
{
pawn.ageTracker.AgeBiologicalTicks = (pawn.ageTracker.AgeBiologicalYears + 1) * GenDate.TicksPerYear + 1;
pawn.ageTracker.DebugForceBirthdayBiological();
GrowUpTo(pawn.ageTracker.CurLifeStageIndex, false);
}
}
}
public void TickRare()
{
//--ModLog.Message("Hediff_SimpleBaby::TickRare is called");
if (pawn.ageTracker.CurLifeStageIndex > Grown_To)
{
GrowUpTo(pawn.ageTracker.CurLifeStageIndex, false);
}
}
public override void Tick()
{
//This void call every frame. should not logmes no reason
//--ModLog.Message("Hediff_SimpleBaby::PostTick is called");
base.Tick();
if (pawn.Spawned)
{
var thisTick = Find.TickManager.TicksGame;
if ((thisTick - dayTick) >= GenDate.TicksPerDay)
{
GrowFast();
dayTick = thisTick;
}
if ((thisTick - lastTick) >= 250)
{
TickRare();
lastTick = thisTick;
}
}
}
public override bool Visible
{
get { return false; }
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/Hediff_SimpleBaby.cs
|
C#
|
mit
| 8,063
|
using System;
namespace rjw
{
public class RJWAssociatedHediffAttribute : Attribute
{
public string defName { get; private set; }
public RJWAssociatedHediffAttribute(string defName)
{
this.defName = defName;
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Hediffs/RJWAssociatedHediffAttribute.cs
|
C#
|
mit
| 232
|
using RimWorld;
using Verse;
using System;
using System.Linq;
using System.Collections.Generic;
using Multiplayer.API;
using rjw.Modules.Interactions.Enums;
using rjw.Modules.Interactions.Extensions;
using static rjw.Hediff_BasePregnancy;
namespace rjw
{
/// <summary>
/// This handles pregnancy chosing between different types of pregnancy awailable to it
/// 1:RJW pregnancy for humanlikes
/// 2:RJW pregnancy for bestiality
/// 3:RJW pregnancy for insects
/// 4:RJW pregnancy for mechanoids
/// </summary>
public static class PregnancyHelper
{
// TODO: Move this and all HediifDef.Named calls to a proper DefOf class
private static HediffDef RJW_IUD = HediffDef.Named("RJW_IUD");
//called by aftersex (including rape, breed, etc)
//called by mcevent
//pawn - "father"; partner = mother
//TODO: this needs rewrite to account receiver group sex (props?)
public static void impregnate(SexProps props)
{
if (RJWSettings.DevMode) ModLog.Message("Rimjobworld::impregnate(" + props.sexType + "):: " + xxx.get_pawnname(props.pawn) + " + " + xxx.get_pawnname(props.partner) + ":");
//"mech" pregnancy
if (props.sexType == xxx.rjwSextype.MechImplant)
{
if (RJWPregnancySettings.mechanoid_pregnancy_enabled && xxx.is_mechanoid(props.pawn))
{
// removing old pregnancies
var p = GetPregnancies(props.partner);
if (!p.NullOrEmpty())
{
var i = p.Count;
while (i > 0)
{
i -= 1;
var h = GetPregnancies(props.partner);
if (h[i] is Hediff_MechanoidPregnancy)
{
if (RJWSettings.DevMode) ModLog.Message(" already pregnant by mechanoid");
}
else if (h[i] is Hediff_BasePregnancy)
{
if (RJWSettings.DevMode) ModLog.Message(" removing rjw normal pregnancy");
(h[i] as Hediff_BasePregnancy).Kill();
}
else
{
if (RJWSettings.DevMode) ModLog.Message(" removing vanilla or other mod pregnancy");
props.partner.health.RemoveHediff(h[i]);
}
}
}
// new pregnancy
if (RJWSettings.DevMode) ModLog.Message(" mechanoid pregnancy started");
Hediff_MechanoidPregnancy hediff = Hediff_BasePregnancy.Create<Hediff_MechanoidPregnancy>(props.partner, props.pawn);
return;
/*
// Not an actual pregnancy. This implants mechanoid tech into the target.
//may lead to pregnancy
//old "chip pregnancies", maybe integrate them somehow?
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
HediffDef_MechImplants egg = (from x in DefDatabase<HediffDef_MechImplants>.AllDefs select x).RandomElement();
if (egg != null)
{
if (RJWSettings.DevMode) Log.Message(" planting MechImplants:" + egg.ToString());
PlantSomething(egg, partner, !Genital_Helper.has_vagina(partner), 1);
return;
}
else
{
if (RJWSettings.DevMode) Log.Message(" no mech implant found");
}*/
}
return;
}
//"ovi" pregnancy/egglaying
var AnalOk = props.sexType == xxx.rjwSextype.Anal && RJWPregnancySettings.insect_anal_pregnancy_enabled;
var OralOk = props.sexType == xxx.rjwSextype.Oral && RJWPregnancySettings.insect_oral_pregnancy_enabled;
// Sextype can result in pregnancy.
if (!(props.sexType == xxx.rjwSextype.Vaginal || props.sexType == xxx.rjwSextype.DoublePenetration ||
AnalOk || OralOk))
return;
Pawn giver = props.pawn; // orgasmer
Pawn receiver = props.partner;
List<Hediff> pawnparts = giver.GetGenitalsList();
List<Hediff> partnerparts = receiver.GetGenitalsList();
var interaction = Modules.Interactions.Helpers.InteractionHelper.GetWithExtension(props.dictionaryKey);
//ModLog.Message(" RaceImplantEggs()" + pawn.RaceImplantEggs());
//"insect" pregnancy
//straight, female (partner) recives egg insertion from other/sex starter (pawn)
if (CouldBeEgging(props, giver, receiver, pawnparts, partnerparts))
{
//TODO: add widget toggle for bind all/neutral/hostile pawns
//Initiator/rapist puts victim in cocoon, maybe move it to aftersex?
if (!props.isReceiver)
if (CanCocoon(giver))
if (giver.HostileTo(receiver) || receiver.IsPrisonerOfColony || receiver.health.hediffSet.HasHediff(xxx.submitting))
if (!receiver.health.hediffSet.HasHediff(HediffDef.Named("RJW_Cocoon")))
{
receiver.health.AddHediff(HediffDef.Named("RJW_Cocoon"));
}
if (RJWSettings.DevMode) ModLog.Message(" 'egg' pregnancy checks");
//see who penetrates who in interaction
if (!props.isReceiver &&
interaction.DominantHasTag(GenitalTag.CanPenetrate))
{
if (RJWSettings.DevMode) ModLog.Message(" impregnate(egg) - by initiator");
}
else if (props.isReceiver && props.isRevese &&
interaction.SubmissiveHasTag(GenitalTag.CanPenetrate))
{
if (RJWSettings.DevMode) ModLog.Message(" impregnate(egg) - by receiver (reverse)");
}
else
{
if (RJWSettings.DevMode) ModLog.Message(" no valid interaction tags/family");
return;
}
//implant/fertilise eggs
DoEgg(props);
return;
}
if (!(props.sexType == xxx.rjwSextype.Vaginal || props.sexType == xxx.rjwSextype.DoublePenetration))
return;
//"normal" and "beastial" pregnancy
if (RJWSettings.DevMode) ModLog.Message(" 'normal' pregnancy checks");
//interaction stuff if for handling futa/see who penetrates who in interaction
if (!props.isReceiver &&
interaction.DominantHasTag(GenitalTag.CanPenetrate) &&
interaction.SubmissiveHasFamily(GenitalFamily.Vagina))
{
if (RJWSettings.DevMode) ModLog.Message(" impregnate - by initiator");
}
else if (props.isReceiver && props.isRevese &&
interaction.DominantHasFamily(GenitalFamily.Vagina) &&
interaction.SubmissiveHasTag(GenitalTag.CanPenetrate))
{
if (RJWSettings.DevMode) ModLog.Message(" impregnate - by receiver (reverse)");
}
else
{
if (RJWSettings.DevMode) ModLog.Message(" no valid interaction tags/family");
return;
}
if (!Modules.Interactions.Helpers.PartHelper.FindParts(giver, GenitalTag.CanFertilize).Any())
{
if (RJWSettings.DevMode) ModLog.Message(xxx.get_pawnname(giver) + " has no parts to Fertilize with");
return;
}
if (!Modules.Interactions.Helpers.PartHelper.FindParts(receiver, GenitalTag.CanBeFertilized).Any())
{
if (RJWSettings.DevMode) ModLog.Message(xxx.get_pawnname(receiver) + " has no parts to be Fertilized");
return;
}
if (CanImpregnate(giver, receiver, props.sexType))
{
DoImpregnate(giver, receiver);
}
}
private static bool CouldBeEgging(SexProps props, Pawn giver, Pawn reciever, List<Hediff> pawnparts, List<Hediff> partnerparts)
{
List<Hediff_InsectEgg> eggs = new();
reciever.health.hediffSet.GetHediffs(ref eggs);
//no ovipositor or fertilization possible
if ((Genital_Helper.has_ovipositorF(giver, pawnparts) ||
Genital_Helper.has_ovipositorM(giver, pawnparts) ||
(Genital_Helper.has_penis_fertile(giver, pawnparts) && (giver.RaceImplantEggs() || eggs.Any()))
) == false)
{
return false;
}
if ((props.sexType == xxx.rjwSextype.Vaginal || props.sexType == xxx.rjwSextype.DoublePenetration) &&
Genital_Helper.has_vagina(reciever, partnerparts))
{
return true;
}
if ((props.sexType == xxx.rjwSextype.Anal || props.sexType == xxx.rjwSextype.DoublePenetration) &&
Genital_Helper.has_anus(reciever) &&
RJWPregnancySettings.insect_anal_pregnancy_enabled)
{
return true;
}
if (props.sexType == xxx.rjwSextype.Oral &&
RJWPregnancySettings.insect_oral_pregnancy_enabled)
{
return true;
}
return false;
}
private static bool CanCocoon(Pawn pawn)
{
return xxx.is_insect(pawn);
}
/// <summary>
/// Gets the pregnancy that is likely to complete first, when there are multiple
/// pregnancies, such as from egg implants.
/// </summary>
/// <param name="pawn">The pawn to inspect.</param>
/// <returns>The pregnancy likely to complete first.</returns>
public static Hediff GetPregnancy(Pawn pawn)
{
var allPregnancies = GetPregnancies(pawn);
if (allPregnancies.Count == 0) return null;
allPregnancies.SortBy((preg) =>
{
(var ticksCompleted, var ticksToBirth) = GetProgressTicks(preg);
return ticksToBirth - ticksCompleted;
});
return allPregnancies[0];
}
/// <summary>
/// Gets the gestation progress of a pregnancy.
/// </summary>
/// <param name="hediff">The pregnancy hediff.</param>
/// <returns>The current progress, a value between 0 and 1.</returns>
public static float GetProgress(Hediff hediff) => hediff switch
{
Hediff_BasePregnancy rjwPreg => rjwPreg.GestationProgress,
Hediff_Pregnant vanillaPreg => vanillaPreg.GestationProgress,
_ => 0f
};
/// <summary>
/// <para>Gets gestation ticks completed and the total needed for birth. Both
/// of these values are approximate, as things like malnutrition can affect
/// the gestation rate.</para>
/// </summary>
/// <param name="hediff">The pregnancy hediff.</param>
/// <returns>A tuple of ticks.</returns>
public static (int ticksCompleted, int ticksToBirth) GetProgressTicks(Hediff hediff)
{
if (hediff is Hediff_BasePregnancy rjwPreg)
{
// RJW pregnancies maintain these numbers internally, so they don't
// need to be inferred.
var ticksToBirth = rjwPreg.p_end_tick - rjwPreg.p_start_tick;
return (rjwPreg.ageTicks, Convert.ToInt32(ticksToBirth));
}
else
{
var progress = GetProgress(hediff);
var raceProps = GetGestatingRace(hediff);
var ticksToBirth = (int)(raceProps.gestationPeriodDays * GenDate.TicksPerDay);
var ticksCompleted = (int)(progress * ticksToBirth);
return (ticksCompleted, ticksToBirth);
}
}
/// <summary>
/// <para>Gets the race-props that are providing the gestation rate of a pregnancy.</para>
/// <para>This may or may not be accurate, depending on how the pregnancy is ultimately
/// implemented.</para>
/// </summary>
/// <param name="hediff">The pregnancy hediff.</param>
/// <returns>The properties of the assumed gestating race.</returns>
public static RaceProperties GetGestatingRace(Hediff hediff) => hediff switch
{
// Insect eggs use the implanter, if it is set. Otherwise, the egg is probably
// still inside the genetic mother, so we can use the carrier instead.
Hediff_InsectEgg eggPreg when eggPreg.implanter is { } implanter =>
implanter.RaceProps,
// Some RJW pregnancies will store the gestating babies; the first pawn in
// the list is treated as the gestation source.
Hediff_BasePregnancy rjwPreg when rjwPreg.babies is { } babies && babies.Count > 0 =>
babies[0].RaceProps,
// For anything else, assume the carrying pawn is the source.
_ => hediff.pawn.RaceProps
};
/// <summary>
/// Gets all pregnancies of the pawn as a list. This may include both RJW
/// and vanilla pregnancies.
/// </summary>
/// <param name="pawn">The pawn to inspect.</param>
/// <returns>A list of pregnancy hediffs.</returns>
public static List<Hediff> GetPregnancies(Pawn pawn) =>
pawn.health.hediffSet.hediffs
.Where(x => x is Hediff_BasePregnancy or Hediff_Pregnant)
.ToList();
///<summary>Can get preg with above conditions, do impregnation.</summary>
[SyncMethod]
public static void DoEgg(SexProps props)
{
if (RJWPregnancySettings.insect_pregnancy_enabled)
{
if (RJWSettings.DevMode) ModLog.Message(" insect pregnancy");
//female "insect" plant eggs
//futa "insect" 50% plant eggs, 50% fertilize eggs
if ((Genital_Helper.has_ovipositorF(props.pawn) && !Genital_Helper.has_penis_fertile(props.pawn)) ||
(Rand.Value > 0.5f && Genital_Helper.has_ovipositorF(props.pawn)))
//penis eggs someday?
//(Rand.Value > 0.5f && (Genital_Helper.has_ovipositorF(pawn) || Genital_Helper.has_penis_fertile(pawn) && pawn.RaceImplantEggs())))
{
float maxeggssize = (props.partner.BodySize / 5) * (xxx.has_quirk(props.partner, "Incubator") ? 2f : 1f)
* (Genital_Helper.has_ovipositorF(props.partner)
? 2f * RJWPregnancySettings.egg_pregnancy_ovipositor_capacity_factor
: 1f);
float eggedsize = 0;
// get implanter eggs
List<Hediff_InsectEgg> eggs = new();
props.partner.health.hediffSet.GetHediffs(ref eggs);
// check if fertilised eggs/ non generic eggs
foreach (Hediff_InsectEgg egg in eggs)
{
eggedsize += egg.eggssize;
}
if (RJWSettings.DevMode) ModLog.Message(" determine " + xxx.get_pawnname(props.partner) + " size of eggs inside: " + eggedsize + ", max: " + maxeggssize);
BodyPartRecord targetBodyPart = Genital_Helper.get_genitalsBPR(props.pawn); //Get our genitals
Predicate<Hediff> filterByGenitalia = hediff => hediff.Part == targetBodyPart; //make filter
props.pawn.health.hediffSet.GetHediffs(ref eggs, filterByGenitalia); //pick only eggs from our genitals (not from anus or stomach)
BodyPartRecord partnerGenitals = null;
if (props.sexType == xxx.rjwSextype.Anal)
partnerGenitals = Genital_Helper.get_anusBPR(props.partner);
else if (props.sexType == xxx.rjwSextype.Oral)
partnerGenitals = Genital_Helper.get_stomachBPR(props.partner);
else if (props.sexType == xxx.rjwSextype.DoublePenetration && Rand.Value > 0.5f && RJWPregnancySettings.insect_anal_pregnancy_enabled)
partnerGenitals = Genital_Helper.get_anusBPR(props.partner);
else
partnerGenitals = Genital_Helper.get_genitalsBPR(props.partner);
while (eggs.Any() && eggedsize < maxeggssize)
{
if (props.sexType == xxx.rjwSextype.Vaginal)
{
// removing old pregnancies
var p = GetPregnancies(props.partner);
if (!p.NullOrEmpty())
{
var i = p.Count;
while (i > 0)
{
i -= 1;
var h = GetPregnancies(props.partner);
if (h[i] is Hediff_MechanoidPregnancy)
{
if (RJWSettings.DevMode) ModLog.Message(" egging - pregnant by mechanoid, skip");
}
else if (h[i] is Hediff_BasePregnancy)
{
if (RJWSettings.DevMode) ModLog.Message(" egging - removing rjw normal pregnancy");
(h[i] as Hediff_BasePregnancy).Kill();
}
else
{
if (RJWSettings.DevMode) ModLog.Message(" egging - removing vanilla or other mod pregnancy");
props.partner.health.RemoveHediff(h[i]);
}
}
}
}
var egg = eggs.First();
eggs.Remove(egg);
props.pawn.health.RemoveHediff(egg);
props.partner.health.AddHediff(egg, partnerGenitals);
egg.InitImplanter(props.pawn);
eggedsize += egg.eggssize;
}
}
//male or futa fertilize eggs
else if (!props.pawn.health.hediffSet.HasHediff(xxx.sterilized))
{
if (Genital_Helper.has_penis_fertile(props.pawn))
if ((Genital_Helper.has_ovipositorF(props.pawn) || Genital_Helper.has_ovipositorM(props.pawn)) || (props.pawn.health.capacities.GetLevel(xxx.reproduction) > 0))
{
List<Hediff_InsectEgg> eggs = new();
props.partner.health.hediffSet.GetHediffs(ref eggs);
if (!RJWPregnancySettings.egg_pregnancy_fertOrificeCheck_enabled)
{
foreach (var egg in eggs)
egg.Fertilize(props.pawn);
}
else
{
//Gargulecode
BodyPartRecord targetBodyPart;
if (props.sexType == xxx.rjwSextype.Anal || props.sexType == xxx.rjwSextype.DoublePenetration)
targetBodyPart = Genital_Helper.get_anusBPR(props.partner); //Anal? get anus
else if (props.sexType == xxx.rjwSextype.Oral)
targetBodyPart = Genital_Helper.get_stomachBPR(props.partner); //Oral? get stomach
else
targetBodyPart = Genital_Helper.get_genitalsBPR(props.partner); //nothing above? get genitals
//End Gargulecode
foreach (var egg in eggs.Where(x=> x.Part == targetBodyPart))
egg.Fertilize(props.pawn);
if (props.sexType == xxx.rjwSextype.DoublePenetration)
{
targetBodyPart = Genital_Helper.get_genitalsBPR(props.partner);
foreach (var egg in eggs.Where(x => x.Part == targetBodyPart))
egg.Fertilize(props.pawn);
}
}
}
}
return;
}
}
[SyncMethod]
public static void DoImpregnate(Pawn pawn, Pawn partner)
{
if (RJWSettings.DevMode) ModLog.Message(" Doimpregnate " + xxx.get_pawnname(pawn) + " is a father, " + xxx.get_pawnname(partner) + " is a mother");
if (AndroidsCompatibility.IsAndroid(pawn) && !AndroidsCompatibility.AndroidPenisFertility(pawn))
{
if (RJWSettings.DevMode) ModLog.Message(" Father is android with no arcotech penis, abort");
return;
}
if (AndroidsCompatibility.IsAndroid(partner) && !AndroidsCompatibility.AndroidVaginaFertility(partner))
{
if (RJWSettings.DevMode) ModLog.Message(" Mother is android with no arcotech vagina, abort");
return;
}
// fertility check
float basePregnancyChance = RJWPregnancySettings.humanlike_impregnation_chance / 100f;
if (xxx.is_animal(partner))
basePregnancyChance = RJWPregnancySettings.animal_impregnation_chance / 100f;
// Interspecies modifier
if (pawn.def.defName != partner.def.defName)
{
if (RJWPregnancySettings.complex_interspecies)
basePregnancyChance *= SexUtility.BodySimilarity(pawn, partner);
else
basePregnancyChance *= RJWPregnancySettings.interspecies_impregnation_modifier;
}
else
{
//Egg fertility check
CompEggLayer compEggLayer = partner.TryGetComp<CompEggLayer>();
if (compEggLayer != null)
basePregnancyChance = 1.0f;
}
//Rand.PopState();
//Rand.PushState(RJW_Multiplayer.PredictableSeed());
float fertility = Math.Min(pawn.health.capacities.GetLevel(xxx.reproduction), partner.health.capacities.GetLevel(xxx.reproduction));
if (partner.health.hediffSet.HasHediff(RJW_IUD))
{
fertility /= 99f;
}
float pregnancyChance = basePregnancyChance * fertility;
if (!Rand.Chance(pregnancyChance))
{
if (RJWSettings.DevMode) ModLog.Message(" Impregnation failed. Chance: " + pregnancyChance.ToStringPercent());
return;
}
if (RJWSettings.DevMode) ModLog.Message(" Impregnation succeeded. Chance: " + pregnancyChance.ToStringPercent());
AddPregnancyHediff(partner, pawn);
}
///<summary>For checking normal pregnancy, should not for egg implantion or such.</summary>
public static bool CanImpregnate(Pawn fucker, Pawn fucked, xxx.rjwSextype sexType = xxx.rjwSextype.Vaginal)
{
if (fucker == null || fucked == null) return false;
if (RJWSettings.DevMode) ModLog.Message("Rimjobworld::CanImpregnate checks (" + sexType + "):: " + xxx.get_pawnname(fucker) + " + " + xxx.get_pawnname(fucked) + ":");
if (sexType == xxx.rjwSextype.MechImplant && !RJWPregnancySettings.mechanoid_pregnancy_enabled)
{
if (RJWSettings.DevMode) ModLog.Message(" mechanoid 'pregnancy' disabled");
return false;
}
if (!(sexType == xxx.rjwSextype.Vaginal || sexType == xxx.rjwSextype.DoublePenetration))
{
if (RJWSettings.DevMode) ModLog.Message(" sextype cannot result in pregnancy");
return false;
}
if (AndroidsCompatibility.IsAndroid(fucker) && AndroidsCompatibility.IsAndroid(fucked))
{
if (RJWSettings.DevMode) ModLog.Message(xxx.get_pawnname(fucked) + " androids cant breed/reproduce androids");
return false;
}
if ((fucker.IsUnsexyRobot() || fucked.IsUnsexyRobot()) && !(sexType == xxx.rjwSextype.MechImplant))
{
if (RJWSettings.DevMode) ModLog.Message(" unsexy robot cant be pregnant");
return false;
}
if (!fucker.RaceHasPregnancy())
{
if (RJWSettings.DevMode) ModLog.Message(xxx.get_pawnname(fucked) + " filtered race that cant be pregnant");
return false;
}
if (!fucked.RaceHasPregnancy())
{
if (RJWSettings.DevMode) ModLog.Message(xxx.get_pawnname(fucker) + " filtered race that cant impregnate");
return false;
}
if (fucked.IsPregnant())
{
if (RJWSettings.DevMode) ModLog.Message(" already pregnant.");
return false;
}
List<Hediff_InsectEgg> eggs = new();
fucked.health.hediffSet.GetHediffs(ref eggs);
if ((from x in eggs where x.def == DefDatabase<HediffDef_InsectEgg>.GetNamed(x.def.defName) select x).Any())
{
if (RJWSettings.DevMode) ModLog.Message(xxx.get_pawnname(fucked) + " cant get pregnant while eggs inside");
return false;
}
var pawnparts = fucker.GetGenitalsList();
var partnerparts = fucked.GetGenitalsList();
if (!(Genital_Helper.has_penis_fertile(fucker, pawnparts) && Genital_Helper.has_vagina(fucked, partnerparts)) && !(Genital_Helper.has_penis_fertile(fucked, partnerparts) && Genital_Helper.has_vagina(fucker, pawnparts)))
{
if (RJWSettings.DevMode) ModLog.Message(" missing genitals for impregnation");
return false;
}
if (fucker.health.capacities.GetLevel(xxx.reproduction) <= 0 || fucked.health.capacities.GetLevel(xxx.reproduction) <= 0)
{
if (RJWSettings.DevMode) ModLog.Message(" one (or both) pawn(s) infertile");
return false;
}
if (xxx.is_human(fucked) && xxx.is_human(fucker) && (RJWPregnancySettings.humanlike_impregnation_chance == 0 || !RJWPregnancySettings.humanlike_pregnancy_enabled))
{
if (RJWSettings.DevMode) ModLog.Message(" human pregnancy chance set to 0% or pregnancy disabled.");
return false;
}
else if (((xxx.is_animal(fucker) && xxx.is_human(fucked)) || (xxx.is_human(fucker) && xxx.is_animal(fucked))) && !RJWPregnancySettings.bestial_pregnancy_enabled)
{
if (RJWSettings.DevMode) ModLog.Message(" bestiality pregnancy chance set to 0% or pregnancy disabled.");
return false;
}
else if (xxx.is_animal(fucked) && xxx.is_animal(fucker) && (RJWPregnancySettings.animal_impregnation_chance == 0 || !RJWPregnancySettings.animal_pregnancy_enabled))
{
if (RJWSettings.DevMode) ModLog.Message(" animal-animal pregnancy chance set to 0% or pregnancy disabled.");
return false;
}
else if (fucker.def.defName != fucked.def.defName && (RJWPregnancySettings.interspecies_impregnation_modifier <= 0.0f && !RJWPregnancySettings.complex_interspecies))
{
if (RJWSettings.DevMode) ModLog.Message(" interspecies pregnancy disabled.");
return false;
}
if (!(fucked.RaceProps.gestationPeriodDays > 0))
{
CompEggLayer compEggLayer = fucked.TryGetComp<CompEggLayer>();
if (compEggLayer == null)
{
if (RJWSettings.DevMode) ModLog.Message(xxx.get_pawnname(fucked) + " mother.RaceProps.gestationPeriodDays is " + fucked.RaceProps.gestationPeriodDays + " cant impregnate");
return false;
}
}
return true;
}
//Plant babies for human/bestiality pregnancy
public static void AddPregnancyHediff(Pawn mother, Pawn father)
{
//human-human
if (RJWPregnancySettings.humanlike_pregnancy_enabled && xxx.is_human(mother) && xxx.is_human(father))
{
CompEggLayer compEggLayer = mother.TryGetComp<CompEggLayer>();
if (compEggLayer != null)
{
// fertilize eggs of humanlikes ?!
if (!compEggLayer.FullyFertilized)
{
compEggLayer.Fertilize(father);
//if (!mother.kindDef.defName.Contains("Chicken"))
// if (compEggLayer.Props.eggFertilizedDef.defName.Contains("RJW"))
}
}
else
{
if (RJWPregnancySettings.UseVanillaPregnancy)
{
// vanilla 1.4 human pregnancy hediff
ModLog.Message("preg hediffdefof PregnantHuman " + HediffDefOf.PregnantHuman);
StartVanillaPregnancy(mother, father);
}
else
{
// use RJW hediff
Hediff_BasePregnancy.Create<Hediff_HumanlikePregnancy>(mother, father);
}
}
}
//human-animal
//maybe make separate option for human males vs female animals???
else if (RJWPregnancySettings.bestial_pregnancy_enabled && (xxx.is_human(mother) ^ xxx.is_human(father)))
{
CompEggLayer compEggLayer = mother.TryGetComp<CompEggLayer>();
if (compEggLayer != null)
{
if (!compEggLayer.FullyFertilized)
compEggLayer.Fertilize(father);
}
else
{
DnaGivingParent dnaGivingParent = Hediff_BasePregnancy.SelectDnaGivingParent(mother, father);
if (RJWPregnancySettings.UseVanillaPregnancy && xxx.is_human(mother) && dnaGivingParent == DnaGivingParent.Mother)
{
// vanilla 1.4 human pregnancy hediff
ModLog.Message("preg hediffdefof PregnantHuman " + HediffDefOf.PregnantHuman);
StartVanillaPregnancy(mother, father);
}
else
{
Hediff_BasePregnancy.Create<Hediff_BestialPregnancy>(mother, father, dnaGivingParent);
}
}
}
//animal-animal
else if (xxx.is_animal(mother) && xxx.is_animal(father))
{
CompEggLayer compEggLayer = mother.TryGetComp<CompEggLayer>();
if (compEggLayer != null)
{
// fertilize eggs of same species
if (!compEggLayer.FullyFertilized)
if (mother.kindDef == father.kindDef)
compEggLayer.Fertilize(father);
}
else if (RJWPregnancySettings.animal_pregnancy_enabled)
{
Hediff_BasePregnancy.Create<Hediff_BestialPregnancy>(mother, father);
}
}
}
public static void StartVanillaPregnancy(Pawn mother, Pawn father, Pawn geneticMother = null, HediffDef def = null)
{
def ??= HediffDefOf.PregnantHuman;
Hediff_Pregnant pregnancy = (Hediff_Pregnant) HediffMaker.MakeHediff(def, mother);
pregnancy.SetParents(geneticMother, father, PregnancyUtility.GetInheritedGeneSet(father, mother));
mother.health.AddHediff(pregnancy);
}
//Plant Insect eggs/mech chips/other preg mod hediff?
public static bool PlantSomething(HediffDef def, Pawn target, bool isToAnal = false, int amount = 1)
{
if (def == null)
return false;
if (!isToAnal && !Genital_Helper.has_vagina(target))
return false;
if (isToAnal && !Genital_Helper.has_anus(target))
return false;
BodyPartRecord Part = (isToAnal) ? Genital_Helper.get_anusBPR(target) : Genital_Helper.get_genitalsBPR(target);
if (Part != null || Part.parts.Count != 0)
{
//killoff normal preg
if (!isToAnal)
{
if (RJWSettings.DevMode) ModLog.Message(" removing other pregnancies");
var p = GetPregnancies(target);
if (!p.NullOrEmpty())
{
foreach (var x in p)
{
if (x is Hediff_BasePregnancy)
{
var preg = x as Hediff_BasePregnancy;
preg.Kill();
}
else
{
target.health.RemoveHediff(x);
}
}
}
}
for (int i = 0; i < amount; i++)
{
if (RJWSettings.DevMode) ModLog.Message(" planting something weird");
target.health.AddHediff(def, Part);
}
return true;
}
return false;
}
/// <summary>
/// Remove CnP Pregnancy, that is added without passing rjw checks
/// </summary>
public static void cleanup_CnP(Pawn pawn)
{
//They do subpar probability checks and disrespect our settings, but I fail to just prevent their doloving override.
//probably needs harmonypatch
//So I remove the hediff if it is created and recreate it if needed in our handler later
if (RJWSettings.DevMode) ModLog.Message(" cleanup_CnP after love check");
var h = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy"));
if (h != null && h.ageTicks < 100)
{
pawn.health.RemoveHediff(h);
if (RJWSettings.DevMode) ModLog.Message(" removed hediff from " + xxx.get_pawnname(pawn));
}
}
/// <summary>
/// Remove Vanilla Pregnancy
/// </summary>
public static void cleanup_vanilla(Pawn pawn)
{
if (RJWSettings.DevMode) ModLog.Message(" cleanup_vanilla after love check");
var h = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Pregnant);
if (h != null && h.ageTicks < 100)
{
pawn.health.RemoveHediff(h);
if (RJWSettings.DevMode) ModLog.Message(" removed hediff from " + xxx.get_pawnname(pawn));
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Pregnancy_Helper.cs
|
C#
|
mit
| 28,055
|
using RimWorld;
using System;
using System.Linq;
using Verse;
using System.Collections.Generic;
namespace rjw
{
public class Recipe_Abortion : Recipe_RemoveHediff
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
BodyPartRecord part = pawn.RaceProps.body.corePart;
if (recipe.appliedOnFixedBodyParts[0] != null)
part = pawn.RaceProps.body.AllParts.Find(x => x.def == recipe.appliedOnFixedBodyParts[0]);
if (part != null)
{
bool isMatch = Hediff_BasePregnancy.KnownPregnancies() // For every known pregnancy
.Where(x => pawn.health.hediffSet.HasHediff(HediffDef.Named(x), true) && recipe.removesHediff == HediffDef.Named(x)) // Find matching bodyparts
.Select(x => (Hediff_BasePregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named(x))) // get pregnancy hediff
.Where(pregnancy => pregnancy.is_discovered &&
(!pregnancy.is_checked || !(pregnancy is Hediff_MechanoidPregnancy))) // Find visible pregnancies or unchecked mech
.Any(); // return true if found something
if (isMatch)
{
yield return part;
}
}
}
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients, Bill bill)
{
if (this is not Recipe_PregnancyAbortMech)
foreach (Hediff x in pawn.health.hediffSet.hediffs.Where(x => x is Hediff_MechanoidPregnancy))
{
(x as Hediff_MechanoidPregnancy).GiveBirth();
return;
}
base.ApplyOnPawn(pawn, part, billDoer, ingredients, bill);
}
}
public class Recipe_PregnancyAbortMech : Recipe_Abortion
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
BodyPartRecord part = pawn.RaceProps.body.corePart;
if (recipe.appliedOnFixedBodyParts[0] != null)
part = pawn.RaceProps.body.AllParts.Find(x => x.def == recipe.appliedOnFixedBodyParts[0]);
if (part != null)
{
bool isMatch = Hediff_BasePregnancy.KnownPregnancies() // For every known pregnancy
.Where(x => pawn.health.hediffSet.HasHediff(HediffDef.Named(x), true) && recipe.removesHediff == HediffDef.Named(x)) // Find matching bodyparts
.Select(x => (Hediff_BasePregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named(x))) // get pregnancy hediff
.Where(pregnancy => pregnancy.is_checked && pregnancy is Hediff_MechanoidPregnancy) // Find checked/visible pregnancies
.Any(); // return true if found something
if (isMatch)
{
yield return part;
}
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Recipes/Recipe_Abortion.cs
|
C#
|
mit
| 2,543
|
using System.Collections.Generic;
using RimWorld;
using Verse;
namespace rjw
{
public class Recipe_ClaimChild : RecipeWorker
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
if (pawn != null)//I have no idea how it works but Recipe_ShutDown : RecipeWorker does not return values when not applicable
{
//Log.Message("RJW Claim child check on " + pawn);
if (xxx.is_human(pawn) && !pawn.IsColonist)
{
if ( (pawn.ageTracker.CurLifeStageIndex < 2))//Guess it is hardcoded for now to `baby` and `toddler` of standard 4 stages of human life
{
BodyPartRecord brain = pawn.health.hediffSet.GetBrain();
if (brain != null)
{
//Log.Message("RJW Claim child is applicable");
yield return brain;
}
}
}
}
}
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients, Bill bill)
{
if (pawn == null)
{
ModLog.Error("Error applying medical recipe, pawn is null");
return;
}
pawn.SetFaction(Faction.OfPlayer);
//we could do
//pawn.SetFaction(billDoer.Faction);
//but that is useless because GetPartsToApplyOn does not support factions anyway and all recipes are hardcoded to player.
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Recipes/Recipe_ClaimChild.cs
|
C#
|
mit
| 1,289
|
using RimWorld;
using System;
using System.Linq;
using Verse;
using System.Collections.Generic;
namespace rjw
{
public class Recipe_DeterminePregnancy : RecipeWorker
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
/* Males can be impregnated by mechanoids, probably
if (!xxx.is_female(pawn))
{
yield break;
}
*/
BodyPartRecord part = pawn.RaceProps.body.corePart;
if (recipe.appliedOnFixedBodyParts[0] != null)
part = pawn.RaceProps.body.AllParts.Find(x => x.def == recipe.appliedOnFixedBodyParts[0]);
if (part != null && (pawn.ageTracker.CurLifeStage.reproductive)
|| pawn.IsPregnant(true))
{
yield return part;
}
}
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients, Bill bill)
{
var p = PregnancyHelper.GetPregnancies(pawn);
if (p.NullOrEmpty())
{
Messages.Message(xxx.get_pawnname(billDoer) + " has determined " + xxx.get_pawnname(pawn) + " is not pregnant.", MessageTypeDefOf.NeutralEvent);
return;
}
foreach (var x in p)
{
if (x is Hediff_BasePregnancy)
{
var preg = x as Hediff_BasePregnancy;
preg.CheckPregnancy();
}
}
}
}
public class Recipe_DeterminePaternity : RecipeWorker
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
BodyPartRecord part = pawn.RaceProps.body.corePart;
if (recipe.appliedOnFixedBodyParts[0] != null)
part = pawn.RaceProps.body.AllParts.Find(x => x.def == recipe.appliedOnFixedBodyParts[0]);
if (part != null && pawn.IsPregnant(true))
{
yield return part;
}
}
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients, Bill bill)
{
var p = PregnancyHelper.GetPregnancies(pawn);
if (p.NullOrEmpty())
{
Messages.Message(xxx.get_pawnname(billDoer) + " has determined " + xxx.get_pawnname(pawn) + " is not pregnant.", MessageTypeDefOf.NeutralEvent);
return;
}
foreach (var x in p)
{
if (x is Hediff_BasePregnancy)
{
var preg = x as Hediff_BasePregnancy;
Messages.Message(xxx.get_pawnname(billDoer) + " has determined " + xxx.get_pawnname(pawn) + " is pregnant and " + preg.father + " is the father.", MessageTypeDefOf.NeutralEvent);
preg.CheckPregnancy();
preg.is_parent_known = true;
}
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Recipes/Recipe_DeterminePregnancy.cs
|
C#
|
mit
| 2,435
|
using System.Collections.Generic;
using System.Linq;
using Verse;
namespace rjw
{
/// <summary>
/// IUD - prevent pregnancy
/// </summary>
public class Recipe_InstallIUD : Recipe_InstallImplantToExistParts
{
public override bool AvailableOnNow(Thing thing, BodyPartRecord part = null)
{
if (RJWPregnancySettings.UseVanillaPregnancy)
{
return false;
}
return base.AvailableOnNow(thing, part);
}
// Let's comment it out. What's the worst that could happen?
// public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
// {
// if (!xxx.is_female(pawn))
// {
// return Enumerable.Empty<BodyPartRecord>();
// }
// return base.GetPartsToApplyOn(pawn, recipe);
// }
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Recipes/Recipe_InstallIUD.cs
|
C#
|
mit
| 753
|
using RimWorld;
using System;
using Verse;
using System.Collections.Generic;
namespace rjw
{
public class Recipe_PregnancyHackMech : RecipeWorker
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
BodyPartRecord part = pawn.RaceProps.body.corePart;
if (recipe.appliedOnFixedBodyParts[0] != null)
part = pawn.RaceProps.body.AllParts.Find(x => x.def == recipe.appliedOnFixedBodyParts[0]);
if (part != null && pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy_mech"), part, true))
{
Hediff_MechanoidPregnancy pregnancy = (Hediff_MechanoidPregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_mech"));
//Log.Message("RJW_pregnancy_mech hack check: " + pregnancy.is_checked);
if (pregnancy.is_checked && !pregnancy.is_hacked)
yield return part;
}
}
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients, Bill bill)
{
if (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy_mech")))
{
Hediff_MechanoidPregnancy pregnancy = (Hediff_MechanoidPregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_mech"));
pregnancy.Hack();
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Recipes/Recipe_PregnancyHackMech.cs
|
C#
|
mit
| 1,273
|
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using Verse;
namespace rjw
{
/// <summary>
/// Sterilization
/// </summary>
public class Recipe_InstallImplantToExistParts : Recipe_InstallImplant
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
bool blocked = Genital_Helper.genitals_blocked(pawn) || xxx.is_slime(pawn);
if (!blocked)
foreach (BodyPartRecord record in pawn.RaceProps.body.AllParts.Where(x => recipe.appliedOnFixedBodyParts.Contains(x.def)))
{
if (!pawn.health.hediffSet.hediffs.Any((Hediff x) => x.def == recipe.addsHediff))
{
yield return record;
}
}
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Pregnancy/Recipes/Recipe_Sterilize.cs
|
C#
|
mit
| 697
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Quirks
{
public interface IQuirkService
{
bool HasQuirk(Pawn pawn, string quirk);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Quirks/IQuirkService.cs
|
C#
|
mit
| 246
|
using rjw.Modules.Quirks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjw.Modules.Quirks.Implementation
{
public class QuirkService : IQuirkService
{
public static IQuirkService Instance { get; private set; }
static QuirkService()
{
Instance = new QuirkService();
}
private QuirkService() { }
public bool HasQuirk(Pawn pawn, string quirk)
{
//No paw ! hum ... I meant pawn !
if (pawn == null)
{
return false;
}
//No quirk !
if (string.IsNullOrWhiteSpace(quirk))
{
return false;
}
string loweredQuirk = quirk.ToLower();
string pawnQuirks = pawn.GetCompRJW().quirks
.ToString()
.ToLower();
return pawnQuirks.Contains(loweredQuirk);
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Quirks/Implementation/QuirkService.cs
|
C#
|
mit
| 813
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Quirks
{
public static class Quirks
{
public const string Podophile = "Podophile";
public const string Impregnation = "Impregnation fetish";
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Quirks/Quirks.cs
|
C#
|
mit
| 294
|
using Verse;
namespace rjw.Modules.Rand
{
/// <summary>
/// <para>When used with a `using` statement, creates a seeded RNG context.</para>
/// <para>Once the block is exited, the original RNG state is restored.</para>
/// <example>
/// <para>How to create a seeded context:</para>
/// <code>
/// // Pull in the `Seeded` type at the top of the C# file.
/// using Seeded = rjw.Modules.Rand.Seeded;
///
/// string RandomYepNah(Pawn pawn)
/// {
/// // Put it in a `using` with a new seed or a good seed source (like this
/// // pawn here), and then do your random stuff inside. There's no need to
/// // bind it to a variable.
/// using (Seeded.With(pawn))
/// {
/// var someChance = Verse.Rand.Chance(0.5f);
/// return someChance ? "Yep!" : "Nah...";
/// }
/// }
/// </code>
/// <para>When the block is exited, the ref-struct is disposed, which pops the
/// RNG state for you. It even does this if there's an exception thrown in the
/// using block, so the RNG state won't be borked.</para>
/// <para>It should be safe to layer multiple RNG contexts. They should pop
/// in the correct order.</para>
/// </example>
/// </summary>
public readonly ref struct Seeded
{
public readonly int seed;
private Seeded(int replacementSeed)
{
seed = replacementSeed;
Verse.Rand.PushState(replacementSeed);
}
public void Dispose()
{
Verse.Rand.PopState();
}
/// <summary>
/// <para>When used with a `using` statement, creates an isolated RNG context.</para>
/// <para>Once the block is exited, the original RNG state is restored.</para>
/// <para>This version will use the given seed.</para>
/// </summary>
/// <param name="replacementSeed">The seed to use.</param>
/// <returns>An RNG context.</returns>
public static Seeded With(int replacementSeed) =>
new(replacementSeed);
/// <summary>
/// <para>When used with a `using` statement, creates an isolated RNG context.</para>
/// <para>Once the block is exited, the original RNG state is restored.</para>
/// <para>This version will use a seed based on the thing's ID and so the
/// randomness will be reproducible for that thing each time the block is
/// entered. As long as you always do the same operations, it will always
/// produce the same RNG.</para>
/// </summary>
/// <param name="thing">The thing to use as a seed source.</param>
/// <returns>An RNG context.</returns>
public static Seeded With(Thing thing) =>
new(thing.HashOffset());
/// <summary>
/// <para>When used with a `using` statement, creates an isolated RNG context.</para>
/// <para>Once the block is exited, the original RNG state is restored.</para>
/// <para>This is similar to <see cref="With"/>, but it will use a special seed
/// associated with the given thing that will be stable for the current in-game
/// hour.</para>
/// <para>You can get the seed from the context's struct, if needed. Just
/// assign the context to a variable.</para>
/// </summary>
/// <param name="thing">The thing to use as a seed source.</param>
/// <param name="salt">Salt that can be added to munge the seed further.</param>
/// <returns>An RNG context.</returns>
public static Seeded ForHour(Thing thing, int salt = 42) =>
new(Verse.Rand.RandSeedForHour(thing, salt));
/// <summary>
/// <para>When used with a `using` statement, creates an isolated RNG context.</para>
/// <para>Once the block is exited, the original RNG state is restored.</para>
/// <para>This is similar to <see cref="With"/>, but it will use a random seed
/// based on the last RNG state. This should be stable for multiplayer.</para>
/// <para>You can get the seed from the context's struct, if needed. Just
/// assign the context to a variable.</para>
/// </summary>
/// <returns>An RNG context.</returns>
public static Seeded Randomly() =>
new(Verse.Rand.Int);
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Rand/SeededContext.cs
|
C#
|
mit
| 3,923
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace rjw.Modules.Shared.Comparers
{
public class StringComparer_IgnoreCase : IEqualityComparer<string>
{
public bool Equals(string x, string y)
{
return String.Equals(x, y, StringComparison.InvariantCultureIgnoreCase);
}
public int GetHashCode(string obj)
{
if (obj == null)
{
return 0;
}
return obj.GetHashCode();
}
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Shared/Comparers/StringComparer_IgnoreCase.cs
|
C#
|
mit
| 482
|
namespace rjw
{
public enum GenitalFamily
{
Undefined,
Vagina,
Penis,
Breasts,
Udders, // Unsupported
Anus,
FemaleOvipositor,
MaleOvipositor
}
}
|
jojo1541/rjw
|
1.5/Source/Modules/Shared/Enums/GenitalFamily.cs
|
C#
|
mit
| 167
|