Ludeon Forums

RimWorld => Bugs => Topic started by: Swikan on December 20, 2021, 08:44:28 PM

Title: [1.3.3200] "Work to build" incorrectly calculated on some structures
Post by: Swikan on December 20, 2021, 08:44:28 PM
I noticed the "Work to build" on the marble wall blueprint seems to be off. (See attachment) According to my research any wall should start off with the work value of 3. Then that value should be multiplied by the material's work to build factor (here: x5.5) and finally, the work to build offset should be added (3). So: 3 * 5.5 + 3 = 19.5

A final work to build value of 15 like in the attachment doesn't seem to make any sense at all. Other Stone Walls are also affected by this as well as some other walls with high Work to build values.

To reproduce: Build a marble wall in non-godmode to create a blueprint. Select blueprint. Click the info button on the blueprint. Hover over the Work to build value. Calculate.
Title: Re: [1.3.3200] "Work to build" incorrectly calculated on some structures
Post by: Ark on December 21, 2021, 04:31:49 AM
The stats you see in the game are beautified values. If you dig into the defs, you'll find that:

<defName>Wall</defName>
  <statBases>
    <WorkToBuild>135</WorkToBuild>

<ThingDef ParentName="ResourceBase" Name="StoneBlocksBase" Abstract="True">
  <stuffProps>
    <statOffsets>
      <WorkToBuild>140</WorkToBuild>
    <statFactors>
      <WorkToBuild>6.0</WorkToBuild>

<ThingDef ParentName="StoneBlocksBase">
  <defName>BlocksMarble</defName>
  <stuffProps>
    <statFactors>
      <WorkToBuild>5.5</WorkToBuild>

And if you dig into the code, you'll find ToStringWorkAmount:
using UnityEngine;

public static string ToStringWorkAmount (this float workAmount)
{
return Mathf.CeilToInt (workAmount / 60f).ToString ();
}

135 divided by 60 and rounded up is 3.
Using the actual values, 135*5.5+140=882.5. 882.5/60=14.7083333... rounds up to 15.
Title: Re: [1.3.3200] "Work to build" incorrectly calculated on some structures
Post by: Swikan on December 21, 2021, 05:32:01 AM
Ah, that makes sense now.  :) I guess this is not a bug after all. Still kind of strange displayed work amounts get strictly rounded up though. But I guess it's to avoid 0s, which would make even less sense.