mirror of
https://github.com/amevarashi/RJW-Sexperience.git
synced 2024-08-14 23:54:08 +00:00
Optimized Ate Cum thought
This commit is contained in:
parent
cdc79acfa3
commit
8a48d2e463
5 changed files with 61 additions and 56 deletions
|
@ -15,12 +15,12 @@
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label>ate cum</label>
|
<label>ate cum</label>
|
||||||
<description>Tastes bad and stinky.</description>
|
<description>It's stinky and tastes bad.</description>
|
||||||
<baseMoodEffect>-2</baseMoodEffect>
|
<baseMoodEffect>-2</baseMoodEffect>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label>ate cum</label>
|
<label>ate cum</label>
|
||||||
<description>Tastes bad. But i liked it.</description>
|
<description>Tastes bad. But I liked it.</description>
|
||||||
<baseMoodEffect>1</baseMoodEffect>
|
<baseMoodEffect>1</baseMoodEffect>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -1,39 +1,17 @@
|
||||||
using RimWorld;
|
namespace RJWSexperience // Change in namespace will lead to save incompatibility
|
||||||
|
|
||||||
namespace RJWSexperience // Change in namespace will lead to save incompatibility
|
|
||||||
{
|
{
|
||||||
public class Thought_AteCum : Thought_Recordbased
|
public class Thought_AteCum : Thought_Recordbased
|
||||||
{
|
{
|
||||||
public override int CurStageIndex
|
protected override void UpdateCurStage()
|
||||||
{
|
{
|
||||||
get
|
if (pawn?.health?.hediffSet?.HasHediff(VariousDefOf.CumAddiction) ?? false)
|
||||||
{
|
{
|
||||||
if (pawn?.health?.hediffSet?.HasHediff(VariousDefOf.CumAddiction) ?? false)
|
SetForcedStage(def.stages.Count - 1);
|
||||||
return def.stages.Count - 1;
|
|
||||||
return base.CurStageIndex;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
public override bool TryMergeWithExistingMemory(out bool showBubble)
|
|
||||||
{
|
|
||||||
ThoughtHandler thoughts = pawn.needs.mood.thoughts;
|
|
||||||
if (thoughts.memories.NumMemoriesInGroup(this) >= def.stackLimit)
|
|
||||||
{
|
{
|
||||||
Thought_AteCum thought_Memory = (Thought_AteCum)thoughts.memories.OldestMemoryInGroup(this);
|
base.UpdateCurStage();
|
||||||
if (thought_Memory != null)
|
|
||||||
{
|
|
||||||
showBubble = thought_Memory.age > thought_Memory.def.DurationTicks / 2;
|
|
||||||
thought_Memory.Merged();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
showBubble = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Merged()
|
|
||||||
{
|
|
||||||
age = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,6 @@ namespace RJWSexperience.SexHistory.UI
|
||||||
{
|
{
|
||||||
if (window._context.Pawn != history.ParentPawn)
|
if (window._context.Pawn != history.ParentPawn)
|
||||||
{
|
{
|
||||||
SoundDefOf.TabOpen.PlayOneShotOnCamera();
|
|
||||||
window.ChangePawn(history);
|
window.ChangePawn(history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,7 +285,6 @@ namespace RJWSexperience.SexHistory.UI
|
||||||
|
|
||||||
Listing_Standard listmain = new Listing_Standard();
|
Listing_Standard listmain = new Listing_Standard();
|
||||||
listmain.Begin(infoRect);
|
listmain.Begin(infoRect);
|
||||||
//listmain.Gap(20f);
|
|
||||||
|
|
||||||
if (_context.VirginLabel != null)
|
if (_context.VirginLabel != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,11 +5,51 @@ using Verse;
|
||||||
|
|
||||||
namespace RJWSexperience
|
namespace RJWSexperience
|
||||||
{
|
{
|
||||||
|
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
||||||
public class ThoughtDefExtension_StageFromRecord : DefModExtension
|
public class ThoughtDefExtension_StageFromRecord : DefModExtension
|
||||||
{
|
{
|
||||||
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
|
||||||
public RecordDef recordDef;
|
public RecordDef recordDef;
|
||||||
[SuppressMessage("Minor Code Smell", "S1104:Fields should not have public accessibility", Justification = "Field value loaded from XML")]
|
|
||||||
public List<float> minimumValueforStage = new List<float>();
|
public List<float> minimumValueforStage = new List<float>();
|
||||||
|
|
||||||
|
public int GetStageIndex(Pawn pawn)
|
||||||
|
{
|
||||||
|
float value = pawn?.records?.GetValue(recordDef) ?? 0f;
|
||||||
|
|
||||||
|
for (int i = minimumValueforStage.Count - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
if (minimumValueforStage[i] < value)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> ConfigErrors()
|
||||||
|
{
|
||||||
|
foreach (string error in base.ConfigErrors())
|
||||||
|
{
|
||||||
|
yield return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recordDef == null)
|
||||||
|
{
|
||||||
|
yield return "<recordDef> is null";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minimumValueforStage.NullOrEmpty())
|
||||||
|
{
|
||||||
|
yield return "<minimumValueforStage> should have an entry for every stage";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < minimumValueforStage.Count - 1; i++)
|
||||||
|
{
|
||||||
|
if (minimumValueforStage[i] > minimumValueforStage[i + 1])
|
||||||
|
{
|
||||||
|
yield return "Values in <minimumValueforStage> should be ordered from the lowest to the highest";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,28 @@
|
||||||
using RimWorld;
|
using RimWorld;
|
||||||
using System.Collections.Generic;
|
using Verse;
|
||||||
|
|
||||||
namespace RJWSexperience
|
namespace RJWSexperience
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Thought class using record.
|
/// Thought class that uses record to select active stage
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Thought_Recordbased : Thought_Memory
|
public class Thought_Recordbased : Thought_Memory
|
||||||
{
|
{
|
||||||
private ThoughtDefExtension_StageFromRecord extension;
|
private ThoughtDefExtension_StageFromRecord extension;
|
||||||
|
protected ThoughtDefExtension_StageFromRecord Extension => extension ?? (extension = def.GetModExtension<ThoughtDefExtension_StageFromRecord>());
|
||||||
|
|
||||||
protected ThoughtDefExtension_StageFromRecord Extension
|
/// <summary>
|
||||||
|
/// This method is called for every thought right after the pawn is assigned
|
||||||
|
/// </summary>
|
||||||
|
public override bool TryMergeWithExistingMemory(out bool showBubble)
|
||||||
{
|
{
|
||||||
get
|
UpdateCurStage();
|
||||||
{
|
return base.TryMergeWithExistingMemory(out showBubble);
|
||||||
if (extension == null)
|
|
||||||
extension = def.GetModExtension<ThoughtDefExtension_StageFromRecord>();
|
|
||||||
return extension;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RecordDef RecordDef => Extension.recordDef;
|
protected virtual void UpdateCurStage()
|
||||||
protected List<float> MinimumValueforStage => Extension.minimumValueforStage;
|
|
||||||
|
|
||||||
public override int CurStageIndex
|
|
||||||
{
|
{
|
||||||
get
|
SetForcedStage(Extension.GetStageIndex(pawn));
|
||||||
{
|
|
||||||
float value = pawn?.records?.GetValue(RecordDef) ?? 0f;
|
|
||||||
for (int i = MinimumValueforStage.Count - 1; i > 0; i--)
|
|
||||||
{
|
|
||||||
if (MinimumValueforStage[i] < value) return i;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue