mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
Fix null reference on missing hybrid def
This commit is contained in:
parent
9e374f3350
commit
7a58d3ed3b
3 changed files with 8 additions and 4 deletions
Binary file not shown.
|
@ -492,7 +492,7 @@ namespace RJW_Menstruation
|
|||
string MotherRaceName = "";
|
||||
string FatherRaceName = "";
|
||||
MotherRaceName = mother.kindDef?.race?.defName;
|
||||
PawnKindDef tmp = spawn_kind_def;
|
||||
PawnKindDef non_hybrid_kind_def = spawn_kind_def;
|
||||
if (father != null)
|
||||
FatherRaceName = father.kindDef?.race?.defName;
|
||||
|
||||
|
@ -507,7 +507,7 @@ namespace RJW_Menstruation
|
|||
{
|
||||
if (!Configurations.UseHybridExtention || spawn_kind_def == null)
|
||||
{
|
||||
spawn_kind_def = tmp;
|
||||
spawn_kind_def = non_hybrid_kind_def;
|
||||
var groups = DefDatabase<RaceGroupDef>.AllDefs.Where(x => !(x.hybridRaceParents.NullOrEmpty() || x.hybridChildKindDef.NullOrEmpty()));
|
||||
|
||||
|
||||
|
|
|
@ -50,9 +50,13 @@ namespace RJW_Menstruation
|
|||
{
|
||||
string key = hybridInfo.RandomElementByWeight(x => x.Value).Key;
|
||||
res = DefDatabase<PawnKindDef>.GetNamedSilentFail(key);
|
||||
if (res == null) res = DefDatabase<ThingDef>.GetNamedSilentFail(key).race.AnyPawnKind;
|
||||
if (res == null) res = DefDatabase<ThingDef>.GetNamedSilentFail(key)?.race?.AnyPawnKind;
|
||||
|
||||
if (res == null) hybridInfo.Remove(key);
|
||||
if (res == null)
|
||||
{
|
||||
Log.Warning($"Could not find pawnKind or race {key}, removing hybrid definition");
|
||||
hybridInfo.Remove(key);
|
||||
}
|
||||
} while (res == null && !hybridInfo.EnumerableNullOrEmpty());
|
||||
|
||||
return res;
|
||||
|
|
Loading…
Reference in a new issue