Rimworld Mod教程 清单Recipe篇 第二讲:工作台建筑

本讲以fueled stove【炉灶(燃料)】与machining table【机械加工台】为例,讲解工作台的制作

首先看到Core\Defs\ThingDefs_Buildings\Buildings_Production.xml,第125行至149行,关于BenchBase的定义。这是绝大多数工作台def的父对象

 <ThingDef Name="BenchBase" ParentName="BuildingBase" Abstract="True">

    <canOverlapZones>false</canOverlapZones>

    <minifiedDef>MinifiedThing</minifiedDef>

    <terrainAffordanceNeeded>Medium</terrainAffordanceNeeded>

    <thingCategories>

      <li>BuildingsProduction</li>

    </thingCategories>

    <statBases>

      <Mass>20</Mass>

    </statBases>

    <interactionCellIcon>DiningChair</interactionCellIcon>

    <comps>

      <li Class="CompProperties_ReportWorkSpeed">

        <workSpeedStat>WorkTableWorkSpeedFactor</workSpeedStat>

      </li>

    </comps>

    <placeWorkers>

      <li>PlaceWorker_ReportWorkSpeedPenalties</li>

    </placeWorkers>

    <building>

      <buildingTags>

        <li>Production</li>

      </buildingTags>

    </building>

  </ThingDef>

我们重点看到几个部分

interactionCellIcon指的是

的图标,填一个ThingDef,你填椅子这里就是椅子的样子,你填沙发就是沙发

Comp中CompProperties_ReportWorkSpeed是用于报告一些工作速度的影响因素,比如户外、恶劣温度、没电等等,注意这个只能用于报告,不能用于决定,也就是说这些因素实际影响的代码不在这个comp里

PlaceWorker_ReportWorkSpeedPenalties与上面的comp类似

总而言之,当你需要创造一个工作台时,直接以BenchBase作为父对象就不会有太大问题。

往下走,先看到578行至654行的机械加工台  

<ThingDef ParentName="BenchBase">

    <defName>TableMachining</defName>

    <label>machining table</label>

    <description>A work station for assembling machinery like guns and ammunition, or breaking down dead mechanoids.</description>

    <thingClass>Building_WorkTable</thingClass>

    <graphicData>

      <texPath>Things/Building/Production/TableMachining</texPath>

      <graphicClass>Graphic_Multi</graphicClass>

      <drawSize>(3.5,1.5)</drawSize>

      <damageData>

        <cornerTL>Damage/Corner</cornerTL>

        <cornerTR>Damage/Corner</cornerTR>

        <cornerBL>Damage/Corner</cornerBL>

        <cornerBR>Damage/Corner</cornerBR>

      </damageData>

    </graphicData>

    <castEdgeShadows>true</castEdgeShadows>

    <staticSunShadowHeight>0.20</staticSunShadowHeight>

    <costList>

      <Steel>150</Steel>

      <ComponentIndustrial>5</ComponentIndustrial>

    </costList>

    <altitudeLayer>Building</altitudeLayer>

    <fillPercent>0.5</fillPercent>

    <useHitPoints>True</useHitPoints>

    <statBases>

      <WorkToBuild>3000</WorkToBuild>

      <MaxHitPoints>180</MaxHitPoints>

      <Flammability>1.0</Flammability>

      <Cleanliness>-2</Cleanliness>

    </statBases>

    <size>(3,1)</size>

    <designationCategory>Production</designationCategory>

    <uiOrder>2520</uiOrder>

    <passability>PassThroughOnly</passability>

    <pathCost>50</pathCost>

    <hasInteractionCell>True</hasInteractionCell>

    <interactionCellOffset>(0,0,-1)</interactionCellOffset>

    <surfaceType>Item</surfaceType>

    <constructionSkillPrerequisite>4</constructionSkillPrerequisite>

    <recipes>

      <li>ButcherCorpseMechanoid</li>

    </recipes>

    <inspectorTabs>

      <li>ITab_Bills</li>

    </inspectorTabs>

    <comps>

      <li Class="CompProperties_Power">

        <compClass>CompPowerTrader</compClass>

        <shortCircuitInRain>true</shortCircuitInRain>

        <basePowerConsumption>350</basePowerConsumption>

      </li>

      <li Class="CompProperties_Flickable"/>

      <li Class="CompProperties_Glower">

        <glowRadius>5</glowRadius>

        <glowColor>(73,123,138,0)</glowColor>

      </li>

      <li Class="CompProperties_AffectedByFacilities">

        <linkableFacilities>

          <li>ToolCabinet</li>

        </linkableFacilities>

      </li>

      <li Class="CompProperties_Breakdownable"/>

    </comps>

    <building>

      <spawnedConceptLearnOpportunity>BillsTab</spawnedConceptLearnOpportunity>

    </building>

    <constructEffect>ConstructMetal</constructEffect>

    <researchPrerequisites>

      <li>Machining</li>

    </researchPrerequisites>

    <designationHotKey>Misc7</designationHotKey>

    <placeWorkers>

      <li>PlaceWorker_ShowFacilitiesConnections</li>

      <li>PlaceWorker_PreventInteractionSpotOverlap</li>

    </placeWorkers>

  </ThingDef>

我们仅分析与工作台相关部分

thingClass:这是xml与C#连接的部分,工作台使用Building_WorkTable

designationCategory:影响的是这个建筑存在于哪个栏内,Production就是“生产”

hasInteractionCell:是否存在互动点,也就是上文提到那个椅子图标,如果这个填false的话,小人只需要触碰到工作台即可。

interactionCellOffset:如果存在互动点的话,使用这个来修改互动点相对于建筑物中心的位置,格式为(x,0,y),这个互动点会随着建筑物的旋转而旋转。

surfaceType:默认为None,床头柜、矮柜、所有的物品架、工作台为Item,能拿来吃饭的桌子填Eat

recipes:填工作台自带的清单,注意这里不是填什么就只有什么,在使用recipeMaker时或recipeDef时也可以往工作台里增添清单。

inspectorTabs指选中后左侧出现的按钮,ITab_Bills指的是

这个按钮

接下来看一下comps:

CompProperties_Power:耗电,其中class使用的是CompPowerTrader,结合其他数据,决定了机械加工台耗电为350W,并且会在雨中短路。注意,具备像这样的comp的机器,在断电时会完全无法工作,然而,这也有例外,在裁缝台(电力)中,有这样一行:

<building>

      <spawnedConceptLearnOpportunity>BillsTab</spawnedConceptLearnOpportunity>

      <unpoweredWorkTableWorkSpeedFactor>0.5</unpoweredWorkTableWorkSpeedFactor>

      <paintable>true</paintable>

</building>

当出现unpoweredWorkTableWorkSpeedFactor的大于0的数据时,断电的工作台工作效率会乘该值,而不是直接无法工作。

CompProperties_Flickable:指的是这个东西

CompProperties_Glower:该comp可以使Thing发光,并且是否发光会受到许多其他comp控制,比如电力相关,开关相关,燃料相关。

CompProperties_AffectedByFacilities:这使得机械加工台可以与工作柜连接并受到其提供的加成。

CompProperties_Breakdownable:使得机械加工台会损坏,需要使用零部件维修才能继续工作。

placeWorkers中有两项:

PlaceWorker_ShowFacilitiesConnections带来与工作站连接的预览,是视觉效果。

PlaceWorker_PreventInteractionSpotOverlap是渲染互动点的预览。

综上可以看出,thingClass改为Building_WorkTable,inspectorTabs的添加,使得Thing真正成为了工作台,在辅助互动点的设置与recipe的添加,并使用电力进行限制,再进行其他次要数据的调整,机械加工台便完成了。

炉灶也是大同小异,在748行至837行

 <ThingDef ParentName="BenchBase">

    <defName>FueledStove</defName>

    <label>fueled stove</label>

    <description>A wood-fueled stove with an attached countertop for preparing meals.</description>

    <thingClass>Building_WorkTable_HeatPush</thingClass>

    <drawerType>MapMeshAndRealTime</drawerType>

    <graphicData>

      <texPath>Things/Building/Production/TableStoveFueled</texPath>

      <graphicClass>Graphic_Multi</graphicClass>

      <drawSize>(3.5,1.5)</drawSize>

      <damageData>

        <cornerTL>Damage/Corner</cornerTL>

        <cornerTR>Damage/Corner</cornerTR>

        <cornerBL>Damage/Corner</cornerBL>

        <cornerBR>Damage/Corner</cornerBR>

      </damageData>

    </graphicData>

    <castEdgeShadows>true</castEdgeShadows>

    <staticSunShadowHeight>0.20</staticSunShadowHeight>

    <constructEffect>ConstructMetal</constructEffect>

    <costList>

      <Steel>80</Steel>

    </costList>

    <altitudeLayer>Building</altitudeLayer>

    <fillPercent>0.5</fillPercent>

    <useHitPoints>True</useHitPoints>

    <statBases>

      <WorkToBuild>2000</WorkToBuild>

      <MaxHitPoints>180</MaxHitPoints>

      <Flammability>1.0</Flammability>

    </statBases>

    <size>(3,1)</size>

    <designationCategory>Production</designationCategory>

    <uiOrder>2120</uiOrder>

    <passability>PassThroughOnly</passability>

    <pathCost>50</pathCost>

    <hasInteractionCell>True</hasInteractionCell>

    <interactionCellOffset>(0,0,-1)</interactionCellOffset>

    <surfaceType>Item</surfaceType>

    <recipes>

      <li>CookMealSimple</li>

      <li>CookMealFine</li>

      <li>CookMealFine_Veg</li>

      <li>CookMealFine_Meat</li>

      <li>CookMealLavish</li>

      <li>CookMealLavish_Veg</li>

      <li>CookMealLavish_Meat</li>

      <li>CookMealSurvival</li>

      <li>CookMealSimpleBulk</li>

      <li>CookMealFineBulk</li>

      <li>CookMealFineBulk_Veg</li>

      <li>CookMealFineBulk_Meat</li>

      <li>CookMealLavishBulk</li>

      <li>CookMealLavishBulk_Veg</li>

      <li>CookMealLavishBulk_Meat</li>

      <li>CookMealSurvivalBulk</li>

      <li>Make_Pemmican</li>

      <li>Make_PemmicanBulk</li>

      <li MayRequire="Ludeon.RimWorld.Biotech">Make_BabyFood</li>

      <li MayRequire="Ludeon.RimWorld.Biotech">Make_BabyFoodBulk</li>

    </recipes>

    <inspectorTabs>

      <li>ITab_Bills</li>

    </inspectorTabs>

    <comps>

      <li Class="CompProperties_Refuelable">

        <fuelConsumptionRate>160.0</fuelConsumptionRate>

        <fuelCapacity>50.0</fuelCapacity>

        <fuelFilter>

          <thingDefs>

            <li>WoodLog</li>

          </thingDefs>

        </fuelFilter>

        <consumeFuelOnlyWhenUsed>true</consumeFuelOnlyWhenUsed>

        <showAllowAutoRefuelToggle>true</showAllowAutoRefuelToggle>

      </li>

      <li Class="CompProperties_HeatPusher">

        <compClass>CompHeatPusherPowered</compClass>

        <heatPerSecond>4</heatPerSecond>

      </li>

    </comps>

    <placeWorkers>

      <li>PlaceWorker_PreventInteractionSpotOverlap</li>

    </placeWorkers>

    <building>

      <isMealSource>true</isMealSource>

      <spawnedConceptLearnOpportunity>BillsTab</spawnedConceptLearnOpportunity>

      <heatPerTickWhileWorking>0.10</heatPerTickWhileWorking>

    </building>

  </ThingDef>

需要指出其中一些不同:thingClass填Building_WorkTable_HeatPush,同时building下有一个heatPerTickWhileWorking,使得工作台在被使用,进行清单时会持续产热,使房间内温度升高。当然了,你也可以填负值,也就是吸热。

Comp中:

CompProperties_Refuelable即燃料机制,consumeFuelOnlyWhenUsed使得工作台只有在进行清单时才会消耗燃料,而不是像篝火那样持续消耗。

CompProperties_HeatPusher也是产热,但与Building_WorkTable_HeatPush代码中的产热机制不同,这个comp是只要有燃料就会一直产热。当然这里的产热不会影响燃料消耗。

不止为何,在我撰写本文之时,该comp无论如何都不生效,即使我把他的数值改到非常高,他也不会产热,无论该工作台是否工作。

building.isMealSource:建筑可以被作为食物来源,仅与“缺少食物源:你缺少把生食加工成烹饪食品的方式。建造一个炉灶、篝火,或者营养膏合成机。(不能放置在监狱房中,否则殖民者将无法使用它)”这条提示有关。

  • 21
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这是一个错误提示,意思是“配方以致命错误终止:spawn latexmk enoent”。其中,“latexmk”是一个用于编译LaTeX文档的工具,而“enoent”则表示找不到该工具。这个错误可能是由于缺少latexmk或者路径设置不正确等原因造成的。需要检查环境变量和软件安装情况,以解决这个问题。 ### 回答2: 该错误消息通常出现在TeX文档的编译过程中,提示latexmk命令没有找到。这意味着计算机无法找到所需的程序文件或路径,这可能是由于以下几个原因导致的。 首先,可能是由于latexmk程序没有正确安装。检查是否正确安装了TeX发行版和相应的LaTeX包。如果没有,请重新安装最新版本的TeX发行版,并确保将其添加到系统Path路径中。 其次,可能是由于系统的Path路径设置不正确导致的。需要在环境变量中手动添加TeX软件所在的路径,或使用类似于TeXstudio这样的集成开发环境,这些开发环境会自动设置正确的路径。 另外,可能是由于计算机上已有的防病毒软件或安全软件阻止了LaTeX程序的正常运行。在这种情况下,可以考虑暂时关闭这些程序并重新运行处理过程。 最后,可能是系统缺少特定的依赖项,如Perl,导致无法运行latexmk。在这种情况下,需要安装所需的依赖项并重试处理过程。 总之,要解决这个问题,需要检查和调整Path路径设置、安装或重新安装缺少的依赖项,或关闭可能干扰LaTeX程序运行的安全软件。 ### 回答3: 这个错误是在运行latexmk时出现的。通常这种情况下出现这个错误的原因是因为latexmk所需要的文件或工具没有安装或者没有配置正确。 首先,检查一下latexmk是否安装在系统中。如果没有安装,需要安装latexmk。通常在Linux和Mac系统中可以通过命令行安装,而在Windows系统中可以查找有关latexmk的安装程序进行安装。 其次,如果latexmk已经安装,那么检查一下系统中是否安装了所有latexmk所需要的工具和库文件。例如,texlive, texmaker, MikTeX等。 最后,如果以上两步都没有解决问题,那么可能是环境变量没有配置正确所导致的,可以检查一下PATH系统环境变量是否包含了latexmk所在的目录。 总结来说,在遇到这个错误的情况下,最好的解决方式是检查环境配置问题,确保latexmk所需要的依赖文件和环境都是正确的。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值