Can fuel consumption be disabled with flick?

Started by OmegaSerris, November 10, 2018, 05:27:06 PM

Previous topic - Next topic

OmegaSerris

Hey there! :)

I'm playing through a tundra tribal run and wood gathering for heat has gotten a bit tiresome. I had already disabled electricity research to keep from being tempted so regular heaters are not an option. I had some chemfuel stocked up from self tamed boomalopes I couldn't bring myself to take behind the barn so I thought, why not throw together a kerosene heater to rid myself of all the campfires?

It worked out pretty well, through I'm still trying to balance it. I based it (shamelessly copied and pasted) on the campfire, electric heater, and chemfuel generator (with some tweaks here and there) and here it is:

  <ThingDef ParentName="BuildingBase">
    <defName>Heater_Chemfuel</defName>
    <label>chemfuel heater</label>
    <thingClass>Building_WorkTable</thingClass>
    <description>An device that converts chemfuel into heat. Can explode if damaged.</description>   
    <category>Building</category>
    <graphicData>
      <texPath>Things/Building/Misc/TempControl/Heater</texPath>
      <graphicClass>Graphic_Single</graphicClass>
      <shadowData>
        <volume>(0.5,0.3,0.7)</volume>
        <offset>(0,0,-0.15)</offset>
      </shadowData>
      <damageData>
        <rect>(0.234375,0,0.515625,0.984375)</rect>
        <cornerTL>Damage/Corner</cornerTL>
        <cornerTR>Damage/Corner</cornerTR>
        <cornerBL>Damage/Corner</cornerBL>
        <cornerBR>Damage/Corner</cornerBR>
      </damageData>
    </graphicData>
    <!-- <uiIconPath>Things/Building/Misc/Tempcontrol/Heater</uiIconPath> -->
    <minifiedDef>MinifiedThing</minifiedDef>
    <altitudeLayer>Building</altitudeLayer>
    <passability>PassThroughOnly</passability>
    <pathCost>40</pathCost>
    <blockWind>true</blockWind>
    <rotatable>false</rotatable>
    <!-- <fillPercent>0.4</fillPercent> -->
    <thingCategories>
      <li>BuildingsTemperature</li>
    </thingCategories>
    <constructEffect>ConstructMetal</constructEffect>
    <tickerType>Normal</tickerType>
    <drawerType>RealtimeOnly</drawerType>
    <statBases>
      <WorkToBuild>1000</WorkToBuild>
      <MaxHitPoints>100</MaxHitPoints>
      <Mass>6</Mass>
      <Flammability>1</Flammability>
    </statBases>
    <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
    <selectable>true</selectable>
    <costList>
      <Steel>50</Steel>
      <ComponentIndustrial>1</ComponentIndustrial>
    </costList>
    <leaveResourcesWhenKilled>false</leaveResourcesWhenKilled>
    <placeWorkers>
      <li>PlaceWorker_Heater</li>
    </placeWorkers>
    <drawPlaceWorkersWhileSelected>true</drawPlaceWorkersWhileSelected>
    <comps>
      <li Class="CompProperties_Refuelable">
        <fuelConsumptionRate>2.5</fuelConsumptionRate>
        <fuelCapacity>10.0</fuelCapacity>
        <fuelConsumptionPerTickInRain>0.0006</fuelConsumptionPerTickInRain>
        <fuelFilter>
          <thingDefs>
            <li>Chemfuel</li>
         </thingDefs>
        </fuelFilter>
        <initialFuelPercent>0</initialFuelPercent>
      </li>
      <li Class="CompProperties_Glower">
        <glowRadius>3</glowRadius>
        <glowColor>(255,150,100,0)</glowColor>
      </li>
      <li Class="CompProperties_Flickable" />
      <!-- <li Class="CompProperties_Flickable"> -->
        <!-- <commandTexture>UI/Commands/Vent</commandTexture> -->
        <!-- <commandLabelKey>CommandDesignateOpenCloseVentLabel</commandLabelKey> -->
        <!-- <commandDescKey>CommandDesignateOpenCloseVentDesc</commandDescKey> -->
      <!-- </li> -->
      <li Class="CompProperties_HeatPusher">
        <compClass>CompHeatPusherPowered</compClass>
        <heatPerSecond>32</heatPerSecond>
        <heatPushMaxTemperature>28</heatPushMaxTemperature>
      </li>
      <li Class="CompProperties_FireOverlay">
        <fireSize>0.2</fireSize>
        <!-- <offset>(0,0,0.2)</offset> -->
      </li>
      <li Class="CompProperties_Breakdownable"/>
      <li Class="CompProperties_Explosive">
        <explosiveRadius>0</explosiveRadius>
        <explosiveExpandPerFuel>0.35</explosiveExpandPerFuel>
        <explosiveDamageType>Flame</explosiveDamageType>
        <startWickHitPointsPercent>0.333</startWickHitPointsPercent>
        <preExplosionSpawnThingDef>Filth_Fuel</preExplosionSpawnThingDef>
        <preExplosionSpawnChance>1</preExplosionSpawnChance>
        <wickTicks>
          <min>30</min>
          <max>30</max>
        </wickTicks>
      </li>
    </comps>
    <researchPrerequisites>
      <li>ComplexFurniture</li>
    </researchPrerequisites>
    <designationCategory>Temperature</designationCategory>
    <constructionSkillPrerequisite>3</constructionSkillPrerequisite>
  </ThingDef>

Please don't mind the comments, just things I was poking around with.

TL;DR: The one thing I can't seem to figure out is how to stop it from burning fuel while flicked off. The heat generation stops, but fuel continues to tick down. Am I missing something or is this something built deeper into the code that would require some C# (which is further than I really want to go :P)?

Bonus points if you know how to turn off the FireOverlay when flicked off. It's a neat effect to make it unique from the electric one, but I've just been telling myself it's a pilot light that has to stay lit. ;D

AileTheAlien

I believe the fuel consumption / flicking can't be changed in XML alone; I was trying to do something similar earlier this year.

OmegaSerris

Well, that's kinda dumb. :P But if that's the case then ah well... I'll just uninstall them and stash them somewhere for the warmer seasons. Thanks though!

Oh, and if anyone comes across this and wants the idea you're welcome to use it. :D

LWM

It really seems to me like it should work as you have written it.  I'm not sure why it doesn't, TBH.

Have you considered making it a "Building" instead of a "Building_Worktable"?  Also, even if it's turned "off" it will still burn fuel if it's in the rain, because you have set <fuelConsumptionPerTickInRain>0.0006</fuelConsumptionPerTickInRain>.

--LWM

LWM

Ah.  Nope.  I believe I have solved your problem.

Make your kerosene burner flickable BEFORE you make it burn fuel.  Right now the code checks if it's flickable once - when it loads the burning fuel comp.

You'll still lose fuel in the rain.

BTW, the Glowable comp checks much more often whether it's flickable - it probably shouldn't, actually, as there's a performance hit.  The fire overlay?  That WOULD take C#.  Very simple C# (with Harmony), but C#.  How much do you want it gone?

Also, BTW, the campfire is probably a building_workbench because you can cook on it.  You might go with "Building"...unless you're cooking on the kerosene heater....which actually isn't completely unreasonable, if it's crazy slow?  Maybe?

Hope that helps....and this is actually a really cool little mod idea - I like it!

--LWM