mirror of
https://github.com/amevarashi/RJW-Sexperience.git
synced 2024-08-14 23:54:08 +00:00
Hide log spam behind Debug option
This commit is contained in:
parent
fbf894e5a0
commit
ad7c00d665
7 changed files with 135 additions and 5 deletions
|
@ -87,6 +87,8 @@
|
|||
<RSOption_MaxSingleLustChange_Desc>Set how much lust can change from a single sex act</RSOption_MaxSingleLustChange_Desc>
|
||||
<RSOption_EnableBastardRelation_Label>Enable Bastard relation</RSOption_EnableBastardRelation_Label>
|
||||
<RSOption_EnableBastardRelation_Desc>Child is marked as a bastard if they have only one parent or their parents are (or was) married</RSOption_EnableBastardRelation_Desc>
|
||||
<RSOption_Debug_Label>Debug</RSOption_Debug_Label>
|
||||
<RSOption_Debug_Desc>Enable debug logs</RSOption_Debug_Desc>
|
||||
<Button_ResetToDefault>Reset to default</Button_ResetToDefault>
|
||||
|
||||
<!-- Sex types -->
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace RJWSexperience
|
|||
public const bool MinSexableFromLifestageDefault = true;
|
||||
public const float MinSexablePercentDefault = 0.2f;
|
||||
public const float VirginRatioDefault = 0.01f;
|
||||
public const bool DebugDefault = false;
|
||||
|
||||
private float maxLustDeviation = MaxInitialLustDefault;
|
||||
private float avgLust = AvgLustDefault;
|
||||
|
@ -33,6 +34,7 @@ namespace RJWSexperience
|
|||
private float minSexablePercent = MinSexablePercentDefault;
|
||||
private float virginRatio = VirginRatioDefault;
|
||||
private float maxSingleLustChange = MaxSingleLustChangeDefault;
|
||||
private bool debug = DebugDefault;
|
||||
|
||||
public float MaxLustDeviation { get => maxLustDeviation; }
|
||||
public float AvgLust { get => avgLust; }
|
||||
|
@ -47,6 +49,7 @@ namespace RJWSexperience
|
|||
public float MinSexablePercent { get => minSexablePercent; }
|
||||
public float VirginRatio { get => virginRatio; }
|
||||
public float MaxSingleLustChange { get => maxSingleLustChange; }
|
||||
public bool Debug { get => debug; }
|
||||
|
||||
private bool selectionLocked = false;
|
||||
|
||||
|
@ -68,6 +71,7 @@ namespace RJWSexperience
|
|||
minSexableFromLifestage = MinSexableFromLifestageDefault;
|
||||
minSexablePercent = MinSexablePercentDefault;
|
||||
virginRatio = VirginRatioDefault;
|
||||
debug = DebugDefault;
|
||||
}
|
||||
|
||||
public override void ExposeData()
|
||||
|
@ -85,6 +89,7 @@ namespace RJWSexperience
|
|||
Scribe_Values.Look(ref minSexableFromLifestage, "MinSexableFromLifestage", MinSexableFromLifestageDefault, true);
|
||||
Scribe_Values.Look(ref minSexablePercent, "MinSexablePercent", MinSexablePercentDefault, true);
|
||||
Scribe_Values.Look(ref virginRatio, "VirginRatio", VirginRatioDefault, true);
|
||||
Scribe_Values.Look(ref debug, "Debug", DebugDefault, true);
|
||||
Scribe_Values.Look(ref selectionLocked, "SelectionLocked");
|
||||
base.ExposeData();
|
||||
}
|
||||
|
@ -127,6 +132,7 @@ namespace RJWSexperience
|
|||
}
|
||||
|
||||
listmain.CheckboxLabeled(Keyed.Option_EnableBastardRelation_Label, ref enableBastardRelation, Keyed.Option_EnableBastardRelation_Desc);
|
||||
listmain.CheckboxLabeled(Keyed.Option_Debug_Label, ref debug, Keyed.Option_Debug_Desc);
|
||||
|
||||
if (listmain.ButtonText(Keyed.Button_ResetToDefault))
|
||||
{
|
||||
|
|
|
@ -89,6 +89,8 @@ namespace RJWSexperience
|
|||
public static readonly string Option_MaxSingleLustChange_Desc = "RSOption_MaxSingleLustChange_Desc".Translate();
|
||||
public static readonly string Option_EnableBastardRelation_Label = "RSOption_EnableBastardRelation_Label".Translate();
|
||||
public static readonly string Option_EnableBastardRelation_Desc = "RSOption_EnableBastardRelation_Desc".Translate();
|
||||
public static readonly string Option_Debug_Label = "RSOption_Debug_Label".Translate();
|
||||
public static readonly string Option_Debug_Desc = "RSOption_Debug_Desc".Translate();
|
||||
public static readonly string Button_ResetToDefault = "Button_ResetToDefault".Translate();
|
||||
|
||||
public static string Translate(this PartnerOrderMode mode)
|
||||
|
|
9
RJWSexperience/RJWSexperience/Logs/DebugLogProvider.cs
Normal file
9
RJWSexperience/RJWSexperience/Logs/DebugLogProvider.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
using rjw.Modules.Shared.Logs;
|
||||
|
||||
namespace RJWSexperience.Logs
|
||||
{
|
||||
public class DebugLogProvider : ILogProvider
|
||||
{
|
||||
public bool IsActive => SexperienceMod.Settings.Debug;
|
||||
}
|
||||
}
|
107
RJWSexperience/RJWSexperience/Logs/LogManager.cs
Normal file
107
RJWSexperience/RJWSexperience/Logs/LogManager.cs
Normal file
|
@ -0,0 +1,107 @@
|
|||
using rjw.Modules.Shared.Logs;
|
||||
using System;
|
||||
using Verse;
|
||||
|
||||
namespace RJWSexperience.Logs
|
||||
{
|
||||
// Copy of RJW code because of hardcoded mod name prefix. Maybe TODO: update RJW's version to accept prefix from LogProvider
|
||||
public static class LogManager
|
||||
{
|
||||
private class Logger : ILog
|
||||
{
|
||||
private readonly string _loggerTypeName;
|
||||
private readonly ILogProvider _logProvider;
|
||||
|
||||
public Logger(string typeName, ILogProvider logProvider = null)
|
||||
{
|
||||
_loggerTypeName = typeName;
|
||||
_logProvider = logProvider;
|
||||
}
|
||||
|
||||
public void Debug(string message)
|
||||
{
|
||||
LogDebug(CreateLogMessage(message));
|
||||
}
|
||||
public void Debug(string message, Exception e)
|
||||
{
|
||||
LogDebug(CreateLogMessage(message, e));
|
||||
}
|
||||
|
||||
public void Message(string message)
|
||||
{
|
||||
LogMessage(CreateLogMessage(message));
|
||||
}
|
||||
public void Message(string message, Exception e)
|
||||
{
|
||||
LogMessage(CreateLogMessage(message, e));
|
||||
}
|
||||
|
||||
public void Warning(string message)
|
||||
{
|
||||
LogWarning(CreateLogMessage(message));
|
||||
}
|
||||
public void Warning(string message, Exception e)
|
||||
{
|
||||
LogWarning(CreateLogMessage(message, e));
|
||||
}
|
||||
|
||||
public void Error(string message)
|
||||
{
|
||||
LogError(CreateLogMessage(message));
|
||||
}
|
||||
public void Error(string message, Exception e)
|
||||
{
|
||||
LogError(CreateLogMessage(message, e));
|
||||
}
|
||||
|
||||
private string CreateLogMessage(string message)
|
||||
{
|
||||
return $"[Sexperience] [{_loggerTypeName}] {message}";
|
||||
}
|
||||
private string CreateLogMessage(string message, Exception exception)
|
||||
{
|
||||
return $"{CreateLogMessage(message)}{Environment.NewLine}{exception}";
|
||||
}
|
||||
|
||||
private void LogDebug(string message)
|
||||
{
|
||||
if (_logProvider?.IsActive != false)
|
||||
{
|
||||
Log.Message(message);
|
||||
}
|
||||
}
|
||||
private void LogMessage(string message)
|
||||
{
|
||||
if (_logProvider?.IsActive != false)
|
||||
{
|
||||
Log.Message(message);
|
||||
}
|
||||
}
|
||||
private void LogWarning(string message)
|
||||
{
|
||||
if (_logProvider?.IsActive != false)
|
||||
{
|
||||
Log.Warning(message);
|
||||
}
|
||||
}
|
||||
private void LogError(string message)
|
||||
{
|
||||
if (_logProvider?.IsActive != false)
|
||||
{
|
||||
Log.Error(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ILog GetLogger<TType, TLogProvider>()
|
||||
where TLogProvider : ILogProvider, new()
|
||||
{
|
||||
return new Logger(typeof(TType).Name, new TLogProvider());
|
||||
}
|
||||
public static ILog GetLogger<TLogProvider>(string staticTypeName)
|
||||
where TLogProvider : ILogProvider, new()
|
||||
{
|
||||
return new Logger(staticTypeName, new TLogProvider());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ using RimWorld;
|
|||
using rjw;
|
||||
using rjw.Modules.Interactions.Enums;
|
||||
using RJWSexperience.ExtensionMethods;
|
||||
using RJWSexperience.Logs;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
|
@ -96,7 +97,7 @@ namespace RJWSexperience
|
|||
if (lustDelta == 0)
|
||||
return;
|
||||
|
||||
rjw.Modules.Shared.Logs.LogManager.GetLogger<SexperienceMod>().Message($"{props.pawn.NameShortColored}'s lust changed by {lustDelta} (from {lust})");
|
||||
LogManager.GetLogger<DebugLogProvider>("RJW_Patch_SatisfyPersonal").Message($"{props.pawn.NameShortColored}'s lust changed by {lustDelta} (from {lust})");
|
||||
props.pawn.records.AddTo(VariousDefOf.Lust, lustDelta);
|
||||
}
|
||||
|
||||
|
@ -223,11 +224,12 @@ namespace RJWSexperience
|
|||
if (partner != null)
|
||||
return true; // Not masturbation
|
||||
|
||||
Log.Message($"CasualSex_Helper.FindSexLocation for {pawn.NameShortColored}");
|
||||
var log = LogManager.GetLogger<DebugLogProvider>("RJW_Patch_CasualSex_Helper_FindSexLocation");
|
||||
log.Message($"Called for {pawn.NameShortColored}");
|
||||
|
||||
if (!pawn.Faction?.IsPlayer ?? true)
|
||||
{
|
||||
Log.Message("Not player faction");
|
||||
log.Message("Not player faction");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -235,12 +237,12 @@ namespace RJWSexperience
|
|||
|
||||
if (bucket == null)
|
||||
{
|
||||
Log.Message("Bucket not found");
|
||||
log.Message("Bucket not found");
|
||||
return true;
|
||||
}
|
||||
|
||||
__result = bucket.RandomAdjacentCell8Way();
|
||||
Log.Message($"Bucket location: {__result}");
|
||||
log.Message($"Bucket location: {__result}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@
|
|||
<Compile Include="Harmony.cs" />
|
||||
<Compile Include="IngestionOutcomeDoers.cs" />
|
||||
<Compile Include="JobDrivers.cs" />
|
||||
<Compile Include="Logs\DebugLogProvider.cs" />
|
||||
<Compile Include="Logs\LogManager.cs" />
|
||||
<Compile Include="Patches\DefInjection.cs" />
|
||||
<Compile Include="Patches\GetGizmos.cs" />
|
||||
<Compile Include="Recipe_HymenSurgery.cs" />
|
||||
|
|
Loading…
Reference in a new issue