When I detour Zone_Growing.GetGizmos(), the allow sowing button disappears. Even when I use the exact code from decompiled source, the button is not there: vanilla code (using Zhentar's ILSpy):
I investigated whether Zone_Growing.GetGizmos() should return the allow sowing button and it does;
I commented out the Zone_Growing.GetGizmos() detour and detoured Zone_Growing.SetPlantDefToGrow() with this:
Which gave this:
Searching RimWorld's language translations for "allow sowing" gives:
But searching for CommandAllowSow or allow sowing in Core/Defs or decompiled Assembly-CSharp.dll gives nothing.
Interestingly when you analyse Zone_Growing.allowSow with ILSpy and expand Read By or Assigned By, it does list RimWorld.Zone_Growing.GetGizmos(), but when you look at RimWorld.Zone_Growing.GetGizmos(), it doesn't use Zone_Growing.allowSow as far as I can tell.
I tried JetBrains dotPeek, which gave this:
Telerik JustDecompile, which gave this XD:
ILSpy Version 2.4
Is the decompiler just missing the code for the button or is the button magicked in somewhere else?
Code Select
[DebuggerHidden]
public override IEnumerable<Gizmo> GetGizmos()
{
IEnumerator<Gizmo> enumerator = base.GetGizmos().GetEnumerator();
while (enumerator.MoveNext())
{
Gizmo current = enumerator.Current;
yield return current;
}
yield return PlantToGrowSettableUtility.SetPlantToGrowCommand(this);
yield break;
}
I investigated whether Zone_Growing.GetGizmos() should return the allow sowing button and it does;
I commented out the Zone_Growing.GetGizmos() detour and detoured Zone_Growing.SetPlantDefToGrow() with this:
Code Select
public void SetPlantDefToGrow(ThingDef plantDef)
{
plantDefToGrow = plantDef;
MethodInfo method = GetType().GetMethod("GetGizmos", BindingFlags.Instance | BindingFlags.Public);
if (method != null)
{
foreach (Gizmo g in (IEnumerable<Gizmo>)method.Invoke(this, null))
{
if (g == null)
{
Log.Message("Test: gizmo was null");
continue;
}
if (g.ToString() != null)
{
Log.Message("ToString: " + g.ToString());
}
if (g.GetType() != null)
{
Log.Message("GetType: " + g.GetType());
}
}
}
else
{
Log.Message("Test: can't get method");
}
Log.Message("Test: Only SetPlantToGrowCommand");
Command_SetPlantToGrow but = PlantToGrowSettableUtility.SetPlantToGrowCommand(this);
if (but.ToString() != null)
{
Log.Message("ToString: " + but.ToString());
}
if (but.GetType() != null)
{
Log.Message("GetType: " + but.GetType());
}
}
Which gave this:
Code Select
ToString: Command(label=Rename, defaultDesc=Rename this zone.)
GetType: Verse.Command_Action
ToString: Command(label=Hide, defaultDesc=Hide/unhide this zone.)
GetType: Verse.Command_Toggle
ToString: Command(label=Delete, defaultDesc=Delete this zone.)
GetType: Verse.Command_Action
ToString: Command(label=Plant: rice plant, defaultDesc=Determine which plant should be sown here.)
GetType: Verse.Command_SetPlantToGrow
ToString: Command(label=Allow sowing, defaultDesc=When disabled, colonists will never sow plants in this zone. They will still harvest.)
GetType: Verse.Command_Toggle
Test: Only SetPlantToGrowCommand
ToString: Command(label=Plant: rice plant, defaultDesc=Determine which plant should be sown here.)
GetType: Verse.Command_SetPlantToGrow
Searching RimWorld's language translations for "allow sowing" gives:
Code Select
<CommandAllowSow>Allow sowing</CommandAllowSow>
<CommandAllowSowDesc>When disabled, colonists will never sow plants in this zone. They will still harvest.</CommandAllowSowDesc>
But searching for CommandAllowSow or allow sowing in Core/Defs or decompiled Assembly-CSharp.dll gives nothing.
Interestingly when you analyse Zone_Growing.allowSow with ILSpy and expand Read By or Assigned By, it does list RimWorld.Zone_Growing.GetGizmos(), but when you look at RimWorld.Zone_Growing.GetGizmos(), it doesn't use Zone_Growing.allowSow as far as I can tell.
I tried JetBrains dotPeek, which gave this:
Code Select
[DebuggerHidden]
public override IEnumerable<Gizmo> GetGizmos()
{
// ISSUE: object of a compiler-generated type is created
// ISSUE: variable of a compiler-generated type
Zone_Growing.\u003CGetGizmos\u003Ec__IteratorAC gizmosCIteratorAc = new Zone_Growing.\u003CGetGizmos\u003Ec__IteratorAC()
{
\u003C\u003Ef__this = this
};
// ISSUE: reference to a compiler-generated field
gizmosCIteratorAc.\u0024PC = -2;
return (IEnumerable<Gizmo>) gizmosCIteratorAc;
}
Telerik JustDecompile, which gave this XD:
Code Select
[DebuggerHidden]
public override IEnumerable<Gizmo> GetGizmos()
{
Zone_Growing.<GetGizmos>c__IteratorAC variable = null;
return variable;
}
ILSpy Version 2.4
Code Select
[DebuggerHidden]
public override IEnumerable<Gizmo> GetGizmos()
{
Zone_Growing.<GetGizmos>c__IteratorAC <GetGizmos>c__IteratorAC = new Zone_Growing.<GetGizmos>c__IteratorAC();
<GetGizmos>c__IteratorAC.<>f__this = this;
Zone_Growing.<GetGizmos>c__IteratorAC expr_0E = <GetGizmos>c__IteratorAC;
expr_0E.$PC = -2;
return expr_0E;
}
Is the decompiler just missing the code for the button or is the button magicked in somewhere else?