Vanilla-Expanded / VanillaExpandedFramework

Vanilla Expanded Framework for RimWorld
Other
69 stars 34 forks source link

How does acceptsNoneAsInput actually work? #103

Open OoyanwoO opened 1 month ago

OoyanwoO commented 1 month ago

According to wiki, if acceptsNoneAsInput = true, input can be empty.

And here is what i done:

  1. Direct change Versatile Assembler's class acceptsNoneAsInput = true from VFEM's factories

Versatile Assembler have 3 inputs btw <numberOfInputs>3</numberOfInputs>

  1. Make a CombinationDef that have include 1 empty input:

    <Defs>
    <ItemProcessor.CombinationDef>
        <defName>VFEM_VersatileAssembler_test</defName>
        <building>VFEM_VersatileAssembler</building>
        <items>
            <li>Steel</li>
        </items>
        <secondItems>
            <li>Cloth</li>
        </secondItems>
        <thirdItems />
        <amount>
            <li>10</li>
            <li>10</li>
                        <li />
        </amount>
        <outputLimitControlled>true</outputLimitControlled>
        <maxTotalOutput>100</maxTotalOutput>
        <result>Hyperweave</result>
        <yield>10</yield>
        <useQualityIncreasing>false</useQualityIncreasing>
        <singleTimeIfNotQualityIncreasing>0.1</singleTimeIfNotQualityIncreasing>
    </ItemProcessor.CombinationDef>
    </Defs>

    The recipe cannot be select. The log:

    System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    [Ref 880D7330]
    at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00029] in <eae584ce26bc40229c1b1aa476bfa589>:0 
    at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
    at ItemProcessor.Command_SetOutputList.ProcessInput (UnityEngine.Event ev) [0x00272] in <d76d864bb4264861abf1ddf56448ff1b>:0 
    at Verse.GizmoGridDrawer.DrawGizmoGrid (System.Collections.Generic.IEnumerable`1[T] gizmos, System.Single startX, Verse.Gizmo& mouseoverGizmo, System.Func`2[T,TResult] customActivatorFunc, System.Func`2[T,TResult] highlightFunc, System.Func`2[T,TResult] lowlightFunc, System.Boolean multipleSelected) [0x007a8] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0 
    at RimWorld.InspectGizmoGrid.DrawInspectGizmoGridFor (System.Collections.Generic.IEnumerable`1[T] selectedObjects, Verse.Gizmo& mouseoverGizmo) [0x001b5] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0  currentSelectable: null 
    (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)
  2. Make a CombinationDef that complete ignore third input:

    <Defs>
    <ItemProcessor.CombinationDef>
        <defName>VFEM_VersatileAssembler_test</defName>
        <building>VFEM_VersatileAssembler</building>
        <items>
            <li>Steel</li>
        </items>
        <secondItems>
            <li>Cloth</li>
        </secondItems>
        <amount>
            <li>10</li>
            <li>10</li>
        </amount>
        <outputLimitControlled>true</outputLimitControlled>
        <maxTotalOutput>100</maxTotalOutput>
        <result>Hyperweave</result>
        <yield>10</yield>
        <useQualityIncreasing>false</useQualityIncreasing>
        <singleTimeIfNotQualityIncreasing>0.1</singleTimeIfNotQualityIncreasing>
    </ItemProcessor.CombinationDef>
    </Defs>

    This can be select, but still error:

    Exception filling window for Verse.FloatMenu: System.NullReferenceException: Object reference not set to an instance of an object
    [Ref 7D584654]
    at ItemProcessor.Command_SetOutputList.TryConfigureIngredientsByOutput (ItemProcessor.CombinationDef element) [0x00505] in <d76d864bb4264861abf1ddf56448ff1b>:0 
    at ItemProcessor.Command_SetOutputList+<>c__DisplayClass4_0.<ProcessInput>b__3 () [0x0001c] in <d76d864bb4264861abf1ddf56448ff1b>:0 
    at Verse.FloatMenuOption.Chosen (System.Boolean colonistOrdering, Verse.FloatMenu floatMenu) [0x00030] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0 
    at Verse.FloatMenuOption.DoGUI (UnityEngine.Rect rect, System.Boolean colonistOrdering, Verse.FloatMenu floatMenu) [0x0053a] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0 
    at Verse.FloatMenu.DoWindowContents (UnityEngine.Rect rect) [0x000fb] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0 
    at Verse.Window.InnerWindowOnGUI (System.Int32 x) [0x001a6] in <f0ac5eb9b52e4cc396c70fc9a4ee15e5>:0  
    (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)
  3. For compare this is the original code and it's working properly.

    <Defs>
    <ItemProcessor.CombinationDef>
        <defName>VFEM_VersatileAssembler_test</defName>
        <building>VFEM_VersatileAssembler</building>
        <items>
            <li>Steel</li>
        </items>
        <secondItems>
            <li>Cloth</li>
        </secondItems>
        <thirdItems>
            <li>WoodLog</li>
        </thirdItems>
        <amount>
            <li>10</li>
            <li>10</li>
            <li>10</li>
        </amount>
        <outputLimitControlled>true</outputLimitControlled>
        <maxTotalOutput>100</maxTotalOutput>
        <result>Hyperweave</result>
        <yield>10</yield>
        <useQualityIncreasing>false</useQualityIncreasing>
        <singleTimeIfNotQualityIncreasing>0.1</singleTimeIfNotQualityIncreasing>
    </ItemProcessor.CombinationDef>
    </Defs>

    image

Do i miss something, or this line is not for this situation?