暂存
This commit is contained in:
Binary file not shown.
@@ -93,11 +93,17 @@
|
||||
<li>Foods</li>
|
||||
</categories>
|
||||
</fuelFilter>
|
||||
<fuelCapacity>10.0</fuelCapacity>
|
||||
<fuelCapacity>2.0</fuelCapacity>
|
||||
<targetFuelLevelConfigurable>false</targetFuelLevelConfigurable>
|
||||
<fuelGizmoLabel>营养</fuelGizmoLabel>
|
||||
<outOfFuelMessage>没有营养</outOfFuelMessage>
|
||||
</li>
|
||||
|
||||
<li Class="CompProperties_AffectedByFacilities">
|
||||
<linkableFacilities>
|
||||
<li>ARA_NutrientNetworkTower</li>
|
||||
</linkableFacilities>
|
||||
</li>
|
||||
</comps>
|
||||
</ThingDef>
|
||||
|
||||
|
||||
@@ -12,4 +12,15 @@
|
||||
<showIfUndefined>false</showIfUndefined>
|
||||
</StatDef>
|
||||
|
||||
<StatDef>
|
||||
<defName>NutrientTransmissionEfficiency</defName>
|
||||
<label>生物质传输效率</label>
|
||||
<description>减少无线传输生物质时的燃料消耗。最终消耗量将乘以 (1 - 效率)。</description>
|
||||
<category>Building</category>
|
||||
<defaultBaseValue>0</defaultBaseValue>
|
||||
<minValue>0</minValue>
|
||||
<toStringStyle>PercentZero</toStringStyle>
|
||||
<displayPriorityInCategory>8000</displayPriorityInCategory>
|
||||
</StatDef>
|
||||
|
||||
</Defs>
|
||||
@@ -1,29 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Defs>
|
||||
|
||||
<!-- 1. 加成建筑 "孵化加速器" -->
|
||||
<ThingDef ParentName="BuildingBase">
|
||||
<defName>ARA_IncubationAccelerator</defName>
|
||||
<label>孵化加速器</label>
|
||||
<description>一个辅助性的生物机械装置,当放置在大型孵化池旁边时,可以加速其内部的孵化过程。</description>
|
||||
<defName>ARA_NutrientNetworkTower</defName>
|
||||
<label>阿拉克涅营养供给塔</label>
|
||||
<description>一个中央营养供给设施。它可以自动为链接到的、需要营养的建筑补充燃料。它本身需要被手动填充大量的生物质。</description>
|
||||
<size>(3,3)</size>
|
||||
<graphicData>
|
||||
<texPath>Things/Building/Misc/ToolCabinet</texPath>
|
||||
<texPath>ArachnaeSwarm/Building/ARA_ResearchBench</texPath>
|
||||
<graphicClass>Graphic_Multi</graphicClass>
|
||||
<shadowData>
|
||||
<volume>(0.7, 0.4, 0.7)</volume>
|
||||
<offset>(0,0,-0.1)</offset>
|
||||
</shadowData>
|
||||
<shaderType>CutoutComplex</shaderType>
|
||||
<drawSize>(3,4.5)</drawSize>
|
||||
</graphicData>
|
||||
<size>(1,1)</size>
|
||||
<altitudeLayer>Building</altitudeLayer>
|
||||
<passability>PassThroughOnly</passability>
|
||||
<pathCost>70</pathCost>
|
||||
<tickerType>Rare</tickerType>
|
||||
<fillPercent>0.5</fillPercent>
|
||||
<statBases>
|
||||
<MaxHitPoints>300</MaxHitPoints>
|
||||
<WorkToBuild>3000</WorkToBuild>
|
||||
<Mass>20</Mass>
|
||||
<Flammability>0.5</Flammability>
|
||||
</statBases>
|
||||
<costList>
|
||||
<ARA_Carapace>50</ARA_Carapace>
|
||||
</costList>
|
||||
<comps>
|
||||
<!-- 使用原版的 CompFacility -->
|
||||
<li Class="CompProperties_Facility">
|
||||
<statOffsets>
|
||||
<!-- 提供我们自定义的孵化速度加成 -->
|
||||
<ARA_IncubationSpeedFactor>0.60</ARA_IncubationSpeedFactor>
|
||||
</statOffsets>
|
||||
<!-- 供能核心组件 -->
|
||||
<li Class="ArachnaeSwarm.CompProperties_NutrientProvider">
|
||||
<linkableBuildings>
|
||||
<!-- 这里列出所有可以被供能的建筑的 defName -->
|
||||
<!-- 您之后可以手动添加,例如: -->
|
||||
<li>ARA_BioforgeIncubator</li>
|
||||
<li>ARA_BioforgeIncubator_Thing</li>
|
||||
<li>ARA_JellyVat</li>
|
||||
<li>ARA_GrowthVat</li>
|
||||
<li>ARA_MorphableResearchBench</li>
|
||||
</linkableBuildings>
|
||||
<maxDistance>80</maxDistance> <!-- 供能范围 -->
|
||||
</li>
|
||||
|
||||
<!-- 自身的燃料库 -->
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition">
|
||||
<fuelCapacity>1000.0</fuelCapacity>
|
||||
<fuelFilter>
|
||||
<categories>
|
||||
<li>Foods</li>
|
||||
<li>Corpses</li>
|
||||
</categories>
|
||||
</fuelFilter>
|
||||
<fuelGizmoLabel>生物质</fuelGizmoLabel>
|
||||
<showAllowAutoRefuelToggle>true</showAllowAutoRefuelToggle>
|
||||
<targetFuelLevelConfigurable>true</targetFuelLevelConfigurable>
|
||||
</li>
|
||||
|
||||
<!-- 开关 -->
|
||||
<li Class="CompProperties_Flickable"/>
|
||||
|
||||
<!-- 接收增效器的加成 -->
|
||||
<li Class="CompProperties_AffectedByFacilities">
|
||||
<linkableFacilities>
|
||||
<li>ARA_GrowthVat</li>
|
||||
</linkableFacilities>
|
||||
</li>
|
||||
</comps>
|
||||
<designationCategory>ARA_Buildings</designationCategory>
|
||||
</ThingDef>
|
||||
|
||||
<!-- 3. 主建筑 "生物孵化池" -->
|
||||
@@ -79,7 +121,7 @@
|
||||
<productionQueueLimit>3</productionQueueLimit>
|
||||
<minNutritionToStart>1.0</minNutritionToStart>
|
||||
<whitelist>
|
||||
<li>ArachnaeNode_Race_WeaponSmith</li> <!-- 示例:允许普通殖民者操作 -->
|
||||
<li>ArachnaeNode_Race_WeaponSmith</li> <!-- 示例:允许普通殖民者操作 -->
|
||||
</whitelist>
|
||||
|
||||
<!-- 质量系统设置 -->
|
||||
@@ -146,7 +188,8 @@
|
||||
<!-- c. 原版的设施链接接收组件 -->
|
||||
<li Class="CompProperties_AffectedByFacilities">
|
||||
<linkableFacilities>
|
||||
<li>ARA_IncubationAccelerator</li>
|
||||
<li>ARA_NutrientNetworkTower</li>
|
||||
<li>ARA_GrowthVat</li>
|
||||
</linkableFacilities>
|
||||
</li>
|
||||
</comps>
|
||||
@@ -242,7 +285,8 @@
|
||||
<!-- c. 原版的设施链接接收组件 -->
|
||||
<li Class="CompProperties_AffectedByFacilities">
|
||||
<linkableFacilities>
|
||||
<li>ARA_IncubationAccelerator</li>
|
||||
<li>ARA_NutrientNetworkTower</li>
|
||||
<li>ARA_GrowthVat</li>
|
||||
</linkableFacilities>
|
||||
</li>
|
||||
|
||||
@@ -250,7 +294,7 @@
|
||||
</ThingDef>
|
||||
|
||||
<ThingDef ParentName="BuildingBase">
|
||||
<defName>ARA_JellyVat</defName> <!-- defName is changed to reflect its purpose -->
|
||||
<defName>ARA_JellyVat</defName> <!-- defName is changed to reflect its purpose -->
|
||||
<label>生物质酿造池</label>
|
||||
<description>一个活体虫族器官,通过分别消化植物和肉类物质,来缓慢培育出营养丰富的阿拉克涅虫蜜。需要同时填充素食和肉类才能工作。</description>
|
||||
<thingClass>Building</thingClass>
|
||||
@@ -300,7 +344,7 @@
|
||||
|
||||
<li Class="ArachnaeSwarm.CompProperties_MultiFuelSpawner">
|
||||
<spawnIntervalRange>
|
||||
<min>120000</min> <!-- 2天 -->
|
||||
<min>120000</min> <!-- 2天 -->
|
||||
<max>120000</max>
|
||||
</spawnIntervalRange>
|
||||
<products>
|
||||
@@ -325,7 +369,13 @@
|
||||
<fuelConsumptionRate>12.5</fuelConsumptionRate>
|
||||
<consumeFuelOnlyWhenUsed>true</consumeFuelOnlyWhenUsed>
|
||||
</li>
|
||||
|
||||
|
||||
<li Class="CompProperties_AffectedByFacilities">
|
||||
<linkableFacilities>
|
||||
<li>ARA_NutrientNetworkTower</li>
|
||||
</linkableFacilities>
|
||||
</li>
|
||||
|
||||
<!-- 燃料槽 2: 肉类 -->
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition_WithKey">
|
||||
<saveKeysPrefix>meat_vat</saveKeysPrefix>
|
||||
@@ -343,4 +393,107 @@
|
||||
</comps>
|
||||
|
||||
</ThingDef>
|
||||
|
||||
<ThingDef ParentName="BuildingBase">
|
||||
<defName>ARA_GrowthVat</defName>
|
||||
<label>阿拉克涅捕获茧</label>
|
||||
<description>用来存放猎物的茧。</description>
|
||||
<thingClass>ArachnaeSwarm.Building_NutrientVat</thingClass>
|
||||
<containedPawnsSelectable>true</containedPawnsSelectable>
|
||||
<tickerType>Normal</tickerType>
|
||||
<graphicData>
|
||||
<texPath>ArachnaeSwarm/Building/ARA_GrowthVat</texPath>
|
||||
<graphicClass>Graphic_Single</graphicClass>
|
||||
<shaderType>CutoutComplex</shaderType>
|
||||
<drawSize>(2.5,2.5)</drawSize>
|
||||
<shadowData>
|
||||
<volume>(0.85, 0.3, 1.7)</volume>
|
||||
</shadowData>
|
||||
</graphicData>
|
||||
<castEdgeShadows>true</castEdgeShadows>
|
||||
<defaultPlacingRot>North</defaultPlacingRot>
|
||||
<size>(1,2)</size>
|
||||
<statBases>
|
||||
<MaxHitPoints>500</MaxHitPoints>
|
||||
<WorkToBuild>8000</WorkToBuild>
|
||||
<Mass>30</Mass>
|
||||
<Flammability>0.5</Flammability>
|
||||
</statBases>
|
||||
<costList>
|
||||
<Steel>150</Steel>
|
||||
<ComponentIndustrial>4</ComponentIndustrial>
|
||||
</costList>
|
||||
<altitudeLayer>Building</altitudeLayer>
|
||||
<passability>PassThroughOnly</passability>
|
||||
<pathCost>42</pathCost>
|
||||
<blockWind>true</blockWind>
|
||||
<drawerType>MapMeshAndRealTime</drawerType>
|
||||
<fillPercent>0.5</fillPercent>
|
||||
<canOverlapZones>false</canOverlapZones>
|
||||
<designationCategory>ARA_Buildings</designationCategory>
|
||||
<uiOrder>2200</uiOrder>
|
||||
<hasInteractionCell>true</hasInteractionCell>
|
||||
<interactionCellOffset>(0,0,-1)</interactionCellOffset>
|
||||
<rotatable>false</rotatable>
|
||||
<inspectorTabs>
|
||||
<li>ITab_BiosculpterNutritionStorage</li>
|
||||
<li>ITab_Genes</li>
|
||||
</inspectorTabs>
|
||||
<researchPrerequisites>
|
||||
<li>GrowthVats</li>
|
||||
</researchPrerequisites>
|
||||
<building>
|
||||
<ai_chillDestination>false</ai_chillDestination>
|
||||
<haulToContainerDuration>120</haulToContainerDuration>
|
||||
<workTableRoomRole>Laboratory</workTableRoomRole>
|
||||
</building>
|
||||
<constructionSkillPrerequisite>4</constructionSkillPrerequisite>
|
||||
<!-- ... 其他建筑属性 ... -->
|
||||
<comps>
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition">
|
||||
<fuelCapacity>100.0</fuelCapacity>
|
||||
<fuelFilter>
|
||||
<categories>
|
||||
<li>Foods</li>
|
||||
</categories>
|
||||
</fuelFilter>
|
||||
<fuelGizmoLabel>生物质</fuelGizmoLabel>
|
||||
<showAllowAutoRefuelToggle>true</showAllowAutoRefuelToggle>
|
||||
<targetFuelLevelConfigurable>true</targetFuelLevelConfigurable>
|
||||
</li>
|
||||
<li Class="ArachnaeSwarm.CompProperties_GrowthVatBooster">
|
||||
<linkableBuildings>
|
||||
<li>ARA_NutrientNetworkTower</li>
|
||||
</linkableBuildings>
|
||||
<statOffset>
|
||||
<stat>NutrientTransmissionEfficiency</stat>
|
||||
<value>0.05</value>
|
||||
</statOffset>
|
||||
</li>
|
||||
<li Class="ArachnaeSwarm.CompProperties_GrowthVatBooster">
|
||||
<linkableBuildings>
|
||||
<li>ARA_BioforgeIncubator</li>
|
||||
<li>ARA_BioforgeIncubator_Thing</li>
|
||||
</linkableBuildings>
|
||||
<statOffset>
|
||||
<stat>ARA_IncubationSpeedFactor</stat>
|
||||
<value>0.1</value>
|
||||
</statOffset>
|
||||
</li>
|
||||
<li Class="CompProperties_AffectedByFacilities">
|
||||
<linkableFacilities>
|
||||
<li>ARA_NutrientNetworkTower</li>
|
||||
</linkableFacilities>
|
||||
</li>
|
||||
</comps>
|
||||
<modExtensions>
|
||||
<li Class="ArachnaeSwarm.DefModExtension_NutrientVat">
|
||||
<!-- 在这里配置您的顶部贴图 -->
|
||||
<topGraphicPath>ArachnaeSwarm/Building/ARA_GrowthVatTop</topGraphicPath>
|
||||
<!-- 如果是单张贴图,使用 Graphic_Single -->
|
||||
<graphicClass>Graphic_Single</graphicClass>
|
||||
</li>
|
||||
</modExtensions>
|
||||
</ThingDef>
|
||||
|
||||
</Defs>
|
||||
@@ -65,82 +65,4 @@
|
||||
</comps>
|
||||
</ThingDef>
|
||||
|
||||
<ThingDef ParentName="BuildingBase">
|
||||
<defName>ARA_GrowthVat</defName>
|
||||
<label>阿拉克涅捕获茧</label>
|
||||
<description>用来存放猎物的茧。</description>
|
||||
<thingClass>ArachnaeSwarm.Building_NutrientVat</thingClass>
|
||||
<containedPawnsSelectable>true</containedPawnsSelectable>
|
||||
<tickerType>Normal</tickerType>
|
||||
<graphicData>
|
||||
<texPath>ArachnaeSwarm/Building/ARA_GrowthVat</texPath>
|
||||
<graphicClass>Graphic_Single</graphicClass>
|
||||
<shaderType>CutoutComplex</shaderType>
|
||||
<drawSize>(2.5,2.5)</drawSize>
|
||||
<shadowData>
|
||||
<volume>(0.85, 0.3, 1.7)</volume>
|
||||
</shadowData>
|
||||
</graphicData>
|
||||
<castEdgeShadows>true</castEdgeShadows>
|
||||
<defaultPlacingRot>North</defaultPlacingRot>
|
||||
<size>(1,2)</size>
|
||||
<statBases>
|
||||
<MaxHitPoints>500</MaxHitPoints>
|
||||
<WorkToBuild>8000</WorkToBuild>
|
||||
<Mass>30</Mass>
|
||||
<Flammability>0.5</Flammability>
|
||||
</statBases>
|
||||
<costList>
|
||||
<Steel>150</Steel>
|
||||
<ComponentIndustrial>4</ComponentIndustrial>
|
||||
</costList>
|
||||
<altitudeLayer>Building</altitudeLayer>
|
||||
<passability>PassThroughOnly</passability>
|
||||
<pathCost>42</pathCost>
|
||||
<blockWind>true</blockWind>
|
||||
<drawerType>MapMeshAndRealTime</drawerType>
|
||||
<fillPercent>0.5</fillPercent>
|
||||
<canOverlapZones>false</canOverlapZones>
|
||||
<designationCategory>ARA_Buildings</designationCategory>
|
||||
<uiOrder>2200</uiOrder>
|
||||
<hasInteractionCell>true</hasInteractionCell>
|
||||
<interactionCellOffset>(0,0,-1)</interactionCellOffset>
|
||||
<rotatable>false</rotatable>
|
||||
<inspectorTabs>
|
||||
<li>ITab_BiosculpterNutritionStorage</li>
|
||||
<li>ITab_Genes</li>
|
||||
</inspectorTabs>
|
||||
<researchPrerequisites>
|
||||
<li>GrowthVats</li>
|
||||
</researchPrerequisites>
|
||||
<building>
|
||||
<ai_chillDestination>false</ai_chillDestination>
|
||||
<haulToContainerDuration>120</haulToContainerDuration>
|
||||
<workTableRoomRole>Laboratory</workTableRoomRole>
|
||||
</building>
|
||||
<constructionSkillPrerequisite>4</constructionSkillPrerequisite>
|
||||
<!-- ... 其他建筑属性 ... -->
|
||||
<comps>
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition">
|
||||
<fuelCapacity>100.0</fuelCapacity>
|
||||
<fuelFilter>
|
||||
<categories>
|
||||
<li>Foods</li>
|
||||
</categories>
|
||||
</fuelFilter>
|
||||
<fuelGizmoLabel>生物质</fuelGizmoLabel>
|
||||
<showAllowAutoRefuelToggle>true</showAllowAutoRefuelToggle>
|
||||
<targetFuelLevelConfigurable>true</targetFuelLevelConfigurable>
|
||||
</li>
|
||||
</comps>
|
||||
<modExtensions>
|
||||
<li Class="ArachnaeSwarm.DefModExtension_NutrientVat">
|
||||
<!-- 在这里配置您的顶部贴图 -->
|
||||
<topGraphicPath>ArachnaeSwarm/Building/ARA_GrowthVatTop</topGraphicPath>
|
||||
<!-- 如果是单张贴图,使用 Graphic_Single -->
|
||||
<graphicClass>Graphic_Single</graphicClass>
|
||||
</li>
|
||||
</modExtensions>
|
||||
</ThingDef>
|
||||
|
||||
</Defs>
|
||||
134
Nutrient_Network_Design.md
Normal file
134
Nutrient_Network_Design.md
Normal file
@@ -0,0 +1,134 @@
|
||||
# 中央营养供给网络设计文档 (v2)
|
||||
|
||||
## 1. 概述
|
||||
|
||||
为了解决需要手动为大量建筑补充营养(燃料)的繁琐操作,本项目旨在设计并实现一个“中央营养供给网络”。该网络由一个或多个“中央供能塔”组成,它们能够自动、无线地为地图上所有需要营养的建筑进行补给。此外,系统还支持通过辅助建筑来提升供能塔的燃料传输效率。
|
||||
|
||||
## 2. 设计目标
|
||||
|
||||
* **自动化**: 消除手动为每个建筑“加油”的需求。
|
||||
* **策略性**: 引入效率加成建筑,鼓励玩家进行更优化的基地布局。
|
||||
* **可扩展性**: 系统应支持多个供能塔、消费者和增效器建筑。
|
||||
* **性能友好**: 设计应考虑到性能,避免在游戏后期造成明显的卡顿。
|
||||
* **用户友好**: 玩家应能轻松理解网络的工作状态,并对其进行基本控制。
|
||||
|
||||
## 3. 系统架构
|
||||
|
||||
本系统采用**去中心化**的设计。每个“中央供能塔”都是一个独立的网络节点。同时,它也作为一个可以被其他设施影响的单位,以接收效率加成。
|
||||
|
||||
### 3.1. 主要组件与建筑
|
||||
|
||||
#### a. `CompNutrientNetworkFeeder` (供能塔核心组件)
|
||||
|
||||
* **职责**:
|
||||
1. **扫描与链接**: 定期扫描地图,查找所有在范围内的消费者建筑,并维护一个持久化的 `linkedConsumers` 列表。
|
||||
2. **计算效率**: 检查自身 `Stat`,获取由“增效器”提供的 `NutrientTransmissionEfficiency` 总加成。
|
||||
3. **分配与供能**: 从 `linkedConsumers` 列表中选择目标,计算需要补充的燃料量 `X`。根据效率加成,从自身燃料库中扣除 `X * (1 - EfficiencyBonus)` 的燃料。
|
||||
4. **冲突避免**: 使用一个临时标记 `isBeingFueledNow` 来防止多个供能塔同时为一个目标补充。
|
||||
5. **视觉效果**: 借鉴原版 `CompFacility`,在选中供能塔时,持续绘制到所有已连接消费者的连接线。
|
||||
* **依附于**: 中央供能塔 (`Building_NutrientTower`)。
|
||||
|
||||
#### b. `CompRefuelableNutrition` (修改现有组件)
|
||||
|
||||
* **职责**:
|
||||
1. **接收燃料**: 增加一个新的公共方法 `ReceiveFuelFromNetwork(float amount)`。
|
||||
2. **状态标记**: 增加一个临时的 `bool isBeingFueledNow` 字段。
|
||||
|
||||
#### c. “营养网络增效器” (新建筑)
|
||||
* **`ThingDef`**: 一个新的建筑,例如 `ARA_NutrientNetworkBooster`。
|
||||
* **`comps`**:
|
||||
* 拥有 `<li Class="CompProperties_Facility">`。
|
||||
* 在 `statOffsets` 中提供一个新的 `StatDef` 加成:`<NutrientTransmissionEfficiency>0.1</NutrientTransmissionEfficiency>`。
|
||||
|
||||
#### d. “中央供能塔” (修改)
|
||||
* **`comps`**:
|
||||
* 除了原计划的组件,新增 `<li Class="CompProperties_AffectedByFacilities">`,使其可以链接到“增效器”。
|
||||
|
||||
### 3.2. 工作流程 (Mermaid)
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
subgraph "增效器 (Booster)"
|
||||
C(Building_Booster)
|
||||
C -- 提供加成 --> B
|
||||
end
|
||||
|
||||
subgraph "中央供能塔 (Provider)"
|
||||
B(Building_NutrientTower)
|
||||
B -- 拥有 --> B1[CompAffectedByFacilities]
|
||||
B -- 拥有 --> B2[CompNutrientNetworkFeeder]
|
||||
end
|
||||
|
||||
subgraph "消费者建筑 (Consumer)"
|
||||
A(Building_Existing)
|
||||
end
|
||||
|
||||
B2 -- 1. 扫描并连接 --> A
|
||||
B2 -- 2. 选中时绘制连接线 --> A
|
||||
C -- "statOffsets" --> B1
|
||||
B2 -- 3. 从B1读取效率加成 --> B1
|
||||
B2 -- 4. 根据效率进行供能 --> A
|
||||
```
|
||||
|
||||
## 4. 实现细节与挑战
|
||||
|
||||
* **自定义StatDef**: 需要在XML中创建一个新的 `StatDef`,名为 `NutrientTransmissionEfficiency`。
|
||||
* **性能优化**: 保持合理的扫描间隔。
|
||||
* **范围限制**: 供能塔的服务范围和增效器的影响范围都应是可配置的。
|
||||
* **视觉反馈**:
|
||||
* 供能塔 -> 消费者:绘制连接线,颜色可根据消费者燃料状态变化。
|
||||
* 增效器 -> 供能塔:使用原版的 `CompFacility` 机制,在选中增效器时会自动显示其影响的供能塔。
|
||||
|
||||
## 5. XML 定义 (示例)
|
||||
|
||||
#### a. 新的 StatDef
|
||||
```xml
|
||||
<StatDef>
|
||||
<defName>NutrientTransmissionEfficiency</defName>
|
||||
<label>nutrient transmission efficiency</label>
|
||||
<description>Reduces the amount of fuel consumed when transfering nutrients wirelessly. The final cost is multiplied by (1 - efficiency).</description>
|
||||
<category>Building</category>
|
||||
<defaultBaseValue>0</defaultBaseValue>
|
||||
<minValue>0</minValue>
|
||||
<toStringStyle>PercentZero</toStringStyle>
|
||||
</StatDef>
|
||||
```
|
||||
|
||||
#### b. 增效器 ThingDef
|
||||
```xml
|
||||
<ThingDef ParentName="BuildingBase">
|
||||
<defName>ARA_NutrientNetworkBooster</defName>
|
||||
<!-- ...其他属性... -->
|
||||
<comps>
|
||||
<li Class="CompProperties_Facility">
|
||||
<linkableBuildings>
|
||||
<li>ARA_NutrientNetworkTower</li>
|
||||
</linkableBuildings>
|
||||
<statOffsets>
|
||||
<NutrientTransmissionEfficiency>0.1</NutrientTransmissionEfficiency>
|
||||
</statOffsets>
|
||||
</li>
|
||||
</comps>
|
||||
</ThingDef>
|
||||
```
|
||||
|
||||
#### c. 供能塔 ThingDef
|
||||
```xml
|
||||
<ThingDef ParentName="BuildingBase">
|
||||
<defName>ARA_NutrientNetworkTower</defName>
|
||||
<!-- ...其他属性... -->
|
||||
<comps>
|
||||
<li Class="CompProperties_RefuelableNutrition">...</li>
|
||||
<li Class="ArachnaeSwarm.CompProperties_NutrientNetworkFeeder">...</li>
|
||||
<li Class="CompProperties_AffectedByFacilities">
|
||||
<linkableFacilities>
|
||||
<li>ARA_NutrientNetworkBooster</li>
|
||||
</linkableFacilities>
|
||||
</li>
|
||||
<!-- ...Flickable, Breakdownable, Power... -->
|
||||
</comps>
|
||||
</ThingDef>
|
||||
```
|
||||
|
||||
---
|
||||
这份文档现在包含了我们所有的设计决策,形成了一个完整且强大的功能蓝图。
|
||||
@@ -121,6 +121,9 @@
|
||||
<Compile Include="Building_Comps\WULA_MutiFuelSpawner\CompRefuelableWithKey.cs" />
|
||||
<Compile Include="Building_Comps\WULA_MutiFuelSpawner\IFuelSource.cs" />
|
||||
<Compile Include="Building_Comps\WULA_MutiFuelSpawner\Patch_CompRefuelableWithKey.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientNetwork\CompFacility_GrowthVatBooster.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientNetwork\CompNutrientProvider.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientNetwork\CompProperties_NutrientProvider.cs" />
|
||||
<Compile Include="Hediffs\ARA_ConfigurableMutant\Hediff_ConfigurableMutant.cs" />
|
||||
<Compile Include="Hediffs\ARA_ConfigurableMutant\Hediff_NecroticVirus_Configurable.cs" />
|
||||
<Compile Include="Hediffs\ARA_ConfigurableMutant\HediffComp_NecroticTransformation.cs" />
|
||||
|
||||
@@ -68,6 +68,11 @@ namespace ArachnaeSwarm
|
||||
Messages.Message("MessageRefueled".Translate(parent.LabelShort, totalNutritionGained.ToString("0.##"), Props.fuelGizmoLabel), parent, MessageTypeDefOf.PositiveEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public void ReceiveFuel(float amount)
|
||||
{
|
||||
base.Refuel(amount);
|
||||
}
|
||||
|
||||
public override string CompInspectStringExtra()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompProperties_GrowthVatBooster : CompProperties_Facility
|
||||
{
|
||||
public StatModifier statOffset; // 从XML读取
|
||||
|
||||
public CompProperties_GrowthVatBooster()
|
||||
{
|
||||
compClass = typeof(CompFacility_GrowthVatBooster);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompFacility_GrowthVatBooster : CompFacility
|
||||
{
|
||||
private new CompProperties_GrowthVatBooster Props => (CompProperties_GrowthVatBooster)props;
|
||||
|
||||
private List<StatModifier> cachedStatOffsets = new List<StatModifier>();
|
||||
private bool lastHadPawn = false;
|
||||
|
||||
private Building_NutrientVat Vat => parent as Building_NutrientVat;
|
||||
|
||||
public override List<StatModifier> StatOffsets
|
||||
{
|
||||
get
|
||||
{
|
||||
// Building_Enterable 使用 innerContainer 存放 Pawn
|
||||
bool hasPawn = Vat != null && Vat.innerContainer.Any;
|
||||
if (cachedStatOffsets.Count == 0 || hasPawn != lastHadPawn)
|
||||
{
|
||||
cachedStatOffsets.Clear();
|
||||
if (hasPawn && Props.statOffset != null)
|
||||
{
|
||||
cachedStatOffsets.Add(Props.statOffset);
|
||||
}
|
||||
lastHadPawn = hasPawn;
|
||||
}
|
||||
return cachedStatOffsets;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompNutrientProvider : CompFacility
|
||||
{
|
||||
private CompRefuelableNutrition selfRefuelable;
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
selfRefuelable = parent.GetComp<CompRefuelableNutrition>();
|
||||
}
|
||||
|
||||
public override void CompTickRare()
|
||||
{
|
||||
base.CompTickRare();
|
||||
|
||||
if (selfRefuelable == null || !selfRefuelable.HasFuel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 找到最需要燃料的已连接建筑
|
||||
var targetBuilding = LinkedBuildings
|
||||
.Select(b => new { Building = b, Comp = (b as ThingWithComps)?.GetComp<CompRefuelableNutrition>() })
|
||||
.Where(x => x.Comp != null && x.Comp.Fuel < x.Comp.TargetFuelLevel)
|
||||
.OrderBy(x => x.Comp.Fuel / x.Comp.Props.fuelCapacity) // 按燃料百分比排序
|
||||
.FirstOrDefault();
|
||||
|
||||
if (targetBuilding != null)
|
||||
{
|
||||
var consumerComp = targetBuilding.Comp;
|
||||
float fuelNeeded = consumerComp.TargetFuelLevel - consumerComp.Fuel;
|
||||
float fuelToTransfer = Mathf.Min(fuelNeeded, selfRefuelable.Fuel);
|
||||
|
||||
// 计算效率加成,并设置上限为 10%
|
||||
float efficiency = Mathf.Clamp(parent.GetStatValue(StatDef.Named("NutrientTransmissionEfficiency")), 0f, 0.1f);
|
||||
float finalCost = fuelToTransfer * (1 - efficiency);
|
||||
|
||||
selfRefuelable.ConsumeFuel(finalCost);
|
||||
consumerComp.ReceiveFuel(fuelToTransfer);
|
||||
|
||||
// 可以在这里添加一个 Mote 来显示传输效果
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using RimWorld;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompProperties_NutrientProvider : CompProperties_Facility
|
||||
{
|
||||
public CompProperties_NutrientProvider()
|
||||
{
|
||||
compClass = typeof(CompNutrientProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user