2023-07-17 04:58:00 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Verse;
|
|
|
|
|
|
|
|
|
|
namespace RJW_Genes
|
|
|
|
|
{
|
|
|
|
|
internal class ModExtensionHelper
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static int GetDistanceFromModExtension(GeneDef defOf, int fallback)
|
|
|
|
|
{
|
|
|
|
|
DistanceExtension distanceExt = defOf.GetModExtension<DistanceExtension>();
|
|
|
|
|
|
2023-07-17 05:09:05 +00:00
|
|
|
|
int potentialDistance = distanceExt?.distance ?? fallback;
|
2023-07-17 04:58:00 +00:00
|
|
|
|
|
|
|
|
|
if (potentialDistance > 0)
|
|
|
|
|
{
|
|
|
|
|
return potentialDistance;
|
|
|
|
|
} else {
|
|
|
|
|
ModLog.Warning($"Retrieved a bad distance ({potentialDistance}) reading the RJW_Genes.DistanceExtension for {defOf.defName}");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static int GetTickIntervalFromModExtension(GeneDef defOf, int fallback)
|
|
|
|
|
{
|
|
|
|
|
TickIntervalExtension tickExt = defOf.GetModExtension<TickIntervalExtension>();
|
|
|
|
|
|
|
|
|
|
int potentialTickInterval = tickExt?.tickInterval ?? fallback;
|
|
|
|
|
|
|
|
|
|
if (potentialTickInterval > 0)
|
|
|
|
|
{
|
|
|
|
|
return potentialTickInterval;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ModLog.Warning($"Retrieved a bad distance ({potentialTickInterval}) reading the RJW_Genes.DistanceExtension for {defOf.defName}");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|