Circumstances:
When running an ideology with all roles removed, the right-click float "verb" menu will fail to open.
Savegame:
Not applicable.
Cause and solution:
The culprit is the RimWorld function:
If the error doesn't immediately leap out at you, the problem is that the routine is scanning for the first spiritual leader role of the pawn's ideology. Upon finding that role, it then verifies whether that role is assigned to any colonist.
However, if you have removed every role from your ideology, the IEnumerable<>.First() function will throw an exception, because it cannot operate against an empty set.
The function should be changed to use FirstOrDefault() instead, and the following line should double-check to be sure that precept_Role is non-null.
This is a vanilla bug, but is exposed by mods, because Achtung! includes a prompt that reports when an exception is encountered while attempting to display the float menu.
jcstryker first discovered this issue: https://github.com/lilwhitemouse/RimWorld-LWM.DeepStorage/issues/110#issuecomment-926989363
Cheers!
When running an ideology with all roles removed, the right-click float "verb" menu will fail to open.
Savegame:
Not applicable.
Cause and solution:
The culprit is the RimWorld function:
Code Select
// H:\RimWorld13\RimWorldWin64_Data\Managed\Assembly-CSharp.dll
// Assembly-CSharp, Version=1.3.7922.19870, Culture=neutral, PublicKeyToken=null
// Global type: <Module>
// Architecture: AnyCPU (64-bit preferred)
// Runtime: v4.0.30319
// Hash algorithm: SHA1
// RimWorld.RitualBehaviorWorker_Conversion
public override string CanStartRitualNow(TargetInfo target, Precept_Ritual ritual, Pawn selectedPawn = null, Dictionary<string, Pawn> forcedForRole = null)
{
Precept_Role precept_Role = ritual.ideo.RolesListForReading.First((Precept_Role r) => r.def == PreceptDefOf.IdeoRole_Moralist);
if (precept_Role.ChosenPawnSingle() == null)
{
return "CantStartRitualRoleNotAssigned".Translate(precept_Role.LabelCap);
}
bool flag = false;
foreach (Pawn item in target.Map.mapPawns.FreeColonistsAndPrisonersSpawned)
{
if (ValidateConvertee(item, precept_Role.ChosenPawnSingle(), throwMessages: false))
{
flag = true;
break;
}
}
if (!flag)
{
return "CantStartRitualNoConvertee".Translate(precept_Role.ChosenPawnSingle().Ideo.name);
}
return base.CanStartRitualNow(target, ritual, selectedPawn, forcedForRole);
}
If the error doesn't immediately leap out at you, the problem is that the routine is scanning for the first spiritual leader role of the pawn's ideology. Upon finding that role, it then verifies whether that role is assigned to any colonist.
However, if you have removed every role from your ideology, the IEnumerable<>.First() function will throw an exception, because it cannot operate against an empty set.
The function should be changed to use FirstOrDefault() instead, and the following line should double-check to be sure that precept_Role is non-null.
This is a vanilla bug, but is exposed by mods, because Achtung! includes a prompt that reports when an exception is encountered while attempting to display the float menu.
jcstryker first discovered this issue: https://github.com/lilwhitemouse/RimWorld-LWM.DeepStorage/issues/110#issuecomment-926989363
Cheers!