Vanilla-Expanded / VanillaExpandedFramework

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

[Feature Request] [PipeNet] New Comp allowing a resource processor to use multiple source pipelines #55

Closed databobek closed 4 months ago

databobek commented 1 year ago

I think it would be cool to have a PipeNet Comp that would allow us to create refineries taking multiple resources as input. The XML could look something like this:

image

that would allow to make for more interesting pipes, for example refinery taking both Chemfuel and Helixien Gas to produce some raw plastics.

KylianB commented 1 year ago

Added a new comp (WIP, but already working).

<li Class="PipeSystem.CompProperties_AdvancedResourceProcessor">
  <showBufferInfo>false</showBufferInfo>
  <notWorkingKey>VCHE_CantRefine</notWorkingKey>
  <progressBarOffset>(0, 0, -0.65)</progressBarOffset>
  <showResultItem>true</showResultItem>
  <processes>
    <li>VCHE_ProcessChemfuel</li>
  </processes>
  <soundAmbient>VCHE_RefineryAmbient</soundAmbient>
</li>

And the new def:

<PipeSystem.ProcessDef>
  <defName>VCHE_ProcessChemfuel</defName>
  <label>Make chemfuel</label>
  <ingredients>
    <li>
      <pipeNet>VCHE_DeepchemNet</pipeNet>
      <thing>VCHE_Deepchem</thing>
      <countNeeded>1</countNeeded>
    </li>
  </ingredients>
  <!-- Result: -->
  <ticks>30000</ticks>
  <pipeNet>VCHE_ChemfuelNet</pipeNet>
  <thing>Chemfuel</thing>
  <count>3</count>
  <destroyIngredientsDirectly>true</destroyIngredientsDirectly>
</PipeSystem.ProcessDef>

For now there is no wiki page for it (things may change, be added…). More info on the usable tags can be found in CompProperties_AdvancedResourceProcessor.cs and ProcessDef.cs.

I will let this thread open for suggestion and report on how it works!

databobek commented 1 year ago

I’ll check it out tonight and let you know, madlad!

On Thu, 7 Sep 2023 at 17:42, Kylian Balde @.***> wrote:

Added a new comp (WIP, but already working).

  • false VCHE_CantRefine (0, 0, -0.65) true
  • VCHE_ProcessChemfuel
  • VCHE_RefineryAmbient

    And the new def:

    VCHE_ProcessChemfuel
  • VCHE_DeepchemNet VCHE_Deepchem 1
  • 30000 VCHE_ChemfuelNet Chemfuel 3 true
    For now there is no wiki page for it (things may change, be added…). More info on the usable tags can be found in CompProperties_AdvancedResourceProcessor.cs and ProcessDef.cs . I will let this thread open for suggestion and report on how it works! — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you authored the thread.Message ID: ***@***.*** com>
    databobek commented 1 year ago

    Aawww -- downloaded from main

    Exception in ConfigErrors() of VCEPU_PrometheumRefinery: System.NullReferenceException: Object reference not set to an instance of an object
      at PipeSystem.CompProperties_AdvancedResourceProcessor+<ConfigErrors>d__11.MoveNext () [0x000fa] in <246c58623a5141fe9a9a92932c2c3248>:0 
      at Verse.ThingDef+<ConfigErrors>d__352.MoveNext () [0x00e09] in <95de19971c5d40878d8742747904cdcd>:0 
      at Verse.DefDatabase`1[T].ErrorCheckAllDefs () [0x0006b] in <95de19971c5d40878d8742747904cdcd>:0 
    UnityEngine.StackTraceUtility:ExtractStackTrace ()
    Verse.Log:Error (string)
    Verse.DefDatabase`1<Verse.ThingDef>:ErrorCheckAllDefs ()
    System.Reflection.MonoMethod:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo)
    System.Reflection.MethodBase:Invoke (object,object[])
    Verse.GenGeneric:InvokeStaticMethodOnGenericType (System.Type,System.Type,string)
    Verse.PlayDataLoader/<>c:<DoPlayLoad>b__4_1 (System.Type)
    System.Threading.Tasks.Parallel/<>c__DisplayClass31_0`2<System.Type, object>:<ForEachWorker>b__0 (int)
    System.Threading.Tasks.Parallel/<>c__DisplayClass17_0`1<object>:<ForWorker>b__1 ()
    System.Threading.Tasks.Task:InnerInvoke ()
    System.Threading.Tasks.Task:InnerInvokeWithArg (System.Threading.Tasks.Task)
    System.Threading.Tasks.Task/<>c__DisplayClass178_0:<ExecuteSelfReplicating>b__0 (object)
    System.Threading.Tasks.Task:InnerInvoke ()
    System.Threading.Tasks.Task:Execute ()
    System.Threading.Tasks.Task:ExecutionContextCallback (object)
    System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
    System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
    System.Threading.Tasks.Task:ExecuteWithThreadLocal (System.Threading.Tasks.Task&)
    System.Threading.Tasks.Task:ExecuteEntry (bool)
    System.Threading.Tasks.Task:System.Threading.IThreadPoolWorkItem.ExecuteWorkItem ()
    System.Threading.ThreadPoolWorkQueue:Dispatch ()
    System.Threading._ThreadPoolWaitCallback:PerformWaitCallback ()
    
       <li Class="PipeSystem.CompProperties_AdvancedResourceProcessor">
            <showBufferInfo>false</showBufferInfo>
            <notWorkingKey>VCEPU_CantRefinePrometheum</notWorkingKey>
            <progressBarOffset>(0, 0, -0.65)</progressBarOffset>
            <showResultItem>true</showResultItem>
            <processes>
              <li>VCHEPU_RefineIntoPrometheum</li>
            </processes>
            <soundAmbient>VCHE_RefineryAmbient</soundAmbient>
          </li>
    
    <PipeSystem.ProcessDef>
        <defName>VCHEPU_RefineIntoPrometheum</defName>
        <label>Make Prometheum</label>
        <ingredients>
          <li>
            <pipeNet>VHGE_HelixienNet</pipeNet>
            <thing>VHGE_Helixien</thing>
            <countNeeded>10</countNeeded>
          </li>
          <li>
            <pipeNet>VCHE_ChemfuelNet</pipeNet>
            <thing>Chemfuel</thing>
            <countNeeded>5</countNeeded>
          </li>
        </ingredients>
        <!-- Result: -->
        <ticks>15000</ticks>
        <pipeNet>VCEPU_PrometheumNet</pipeNet>
        <thing>Prometheum</thing>
        <count>3</count>
        <destroyIngredientsDirectly>true</destroyIngredientsDirectly>
      </PipeSystem.ProcessDef>

    image

    KylianB commented 1 year ago

    Can you please share a full log?

    databobek commented 1 year ago

    https://gist.github.com/HugsLibRecordKeeper/291acea04544bc6225efed887cf57f77

    here you go friend

    KylianB commented 1 year ago

    Thank you, could you try to add to your def:

    <inspectorTabs>
      <li>PipeSystem.ITab_Processor</li>
    </inspectorTabs>

    Also make sure you have the needed comp resource, the new processor doesn't act as one. In your case, you seem to need:

    <li Class="PipeSystem.CompProperties_Resource">
      <pipeNet>VCHE_ChemfuelNet</pipeNet>
    </li>
    <li Class="PipeSystem.CompProperties_Resource">
      <pipeNet>VHGE_HelixienNet</pipeNet>
    </li>
    databobek commented 1 year ago

    This is so cool man!

    I'll change my Defs to use the new system and let you know how it works in some time.

    databobek commented 1 year ago

    First thoughts: Would be cool if I am building a refinery connecting to many pipelines that it would highlihgt all connectable pipes on map (not only output pipe and power conduits.

    I really dig that it shows what it is producing instead of the giant progress bar. Maybe optionally also allow to show the source resources?

    The ongoing process label in the process inspector tab could use a bit more space. image

    Not sure how that happens: image If you have an ongoing process and remove the bill, it goes into negatives :)

    databobek commented 1 year ago

    Not sure if process def accepts research requirement but that would be awesome as well :)

    databobek commented 1 year ago

    Doesn't seem i can use this to drop things on the ground? Cause i get a config error without result pipe system

    databobek commented 1 year ago

    When result tank/network is full, the production should stop I think, but it just drops on the ground

    KylianB commented 1 year ago

    First thoughts: Would be cool if I am building a refinery connecting to many pipelines that it would highlihgt all connectable pipes on map (not only output pipe and power conduits.

    I really dig that it shows what it is producing instead of the giant progress bar. Maybe optionally also allow to show the source resources?

    The ongoing process label in the process inspector tab could use a bit more space. image

    Not sure how that happens: image If you have an ongoing process and remove the bill, it goes into negatives :)

    Will try to reproduce and fix, thank you. Same thing for the UI issue.

    Not sure if process def accepts research requirement but that would be awesome as well :)

    Not yet, but I can add it

    Doesn't seem i can use this to drop things on the ground? Cause i get a config error without result pipe system

    It should be possible when having only <thing>Prometheum</thing> in your processed def (and no <pipeNet>VCEPU_PrometheumNet</pipeNet>)

    When result tank/network is full, the production should stop I think, but it just drops on the ground

    It's planned to be a processor option, somewhere in the UI. By default, it won't spawn if the net is full, but the player will also be able to make it spawn on ground when the net is full.

    Thank you for all the feedback!

    databobek commented 1 year ago

    somewhere in the UI

    I like

    Should be possible

    doesn't work for me image image

    https://gist.github.com/HugsLibRecordKeeper/9b713e957e632e934f7faa93dc5926be

    databobek commented 1 year ago

    image seems that they still check for hauling jobs even if piped? spams the logs a bit with many refineries :)

    databobek commented 1 year ago

    After the recent changes: image Log spam is still there ( i guess for debug?)

    image

    still goes into negative (not a big issue tbh) [reproduce by: add process (x10), process starts, reduce count to x0, process ends, process count now is x -1) Happens also when removing and readding the process

    Production setting on the ground/ or not correctly chooses pipe or ground vs pipe or stop ✓ I'd rename the setting to "Continue production when net full" cause now it kinda implies pipe or ground IMO.

    The list of processes doesn't choose the first available process image In this case, the refinery was connected to everything required for "Make Dye from Waste", but the first process was already started, which makes it impossible to have fallback pipelines :)

    You can have refineries with mixed manual/piped input!! ✓ image

    If i configure like this: image It will just take the "steel" from the net, which doesn't really make sense. Maybe skip the "thing" entirely if pipenet is defined?

    KylianB commented 1 year ago

    Going to fix the above issues, thank you! For the ingredients, this is the intended behaviour. If the processor can take from the net it will do so, if it can't, pawns will try to fill it using a map item. When used together as a single ingredient, they are intended to represent the same thing.

    databobek commented 1 year ago

    I already remade both my pipeline mods to fit into this :) it's great work Kylian

    databobek commented 12 months ago

    Would be cool if the process clearly showed whether it's started or not + how much time each process takes :)

    databobek commented 11 months ago

    image ultra super based

    databobek commented 11 months ago

    image guess this should be hidden behind dev mode? :)

    databobek commented 11 months ago

    I've used this extensively over the past weeks and there seem to be no outstanding issues.

    Hopefully this month I will release a mod that uses it so we'll get more testers :)

    Only outstanding things imo is:

    databobek commented 8 months ago

    Seems that if I have a networked item and a manual item in a process definition, after reloading a save they need to be refilled (progress doesn't fall though).

    databobek commented 8 months ago

    image image The label is not used

    databobek commented 8 months ago

    When wastepack container is full, the next processes continue as normal without filling the wastepack container anymore

    databobek commented 8 months ago

    When there are no processes available, it goes into red error when pressing the "add process" button.

    When you have the resource specified as ingredient image it tries to find the texture by name and fails (because these are multi-folders, not graphic2d)

    KylianB commented 8 months ago

    Seems that if I have a networked item and a manual item in a process definition, after reloading a save they need to be refilled (progress doesn't fall though).

    Should be fixed

    The label is not used

    It's used inside the process tab, when it's the current process

    When wastepack container is full, the next processes continue as normal without filling the wastepack container anymore

    It's the default behaviour (copying vanilla), but it can be modified with <stopWhenWastepackFull>true</stopWhenWastepackFull> (on the CompProperties_AdvancedResourceProcessor)

    When there are no processes available, it goes into red error when pressing the "add process" button.

    Should be fixed

    databobek commented 7 months ago

    image Shows "Contents: Nothing" when waster container is set and waste % only shows when process is working

    databobek commented 7 months ago

    It seems that the refineries cannot be cleared of waste image even though rechargers can

    databobek commented 7 months ago

    stop when wastepack full doesn't seem to stop processing when waste is at 100%, might be linked to the double waste container thing?

    disregard, it was a patch issue