补产奶

This commit is contained in:
2025-09-03 19:54:55 +08:00
parent 9fcaa54f8b
commit 47d5dc9490
5 changed files with 105 additions and 4 deletions

Binary file not shown.

View File

@@ -587,10 +587,10 @@
</generalSettings>
</alienRace>
<comps>
<li Class="CompProperties_Milkable">
<milkDef>ARA_InsectJelly</milkDef>
<milkIntervalDays>0.01</milkIntervalDays>
<milkAmount>14</milkAmount>
<li Class="ArachnaeSwarm.CompProperties_MilkableArachnae">
<milkDef>ARA_InsectJelly</milkDef>
<milkIntervalDays>2</milkIntervalDays>
<milkAmount>14</milkAmount>
</li>
<li Class="ArachnaeSwarm.CompProperties_AutoMechCarrier">
<freeProduction>true</freeProduction>

View File

@@ -84,6 +84,10 @@
<Compile Include="ARA_HiveMind\CompProperties_AbilityBindDrone.cs" />
<Compile Include="JobGiver_MaintainBuildings.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Work\CompMilkableArachnae.cs" />
<Compile Include="Work\CompProperties_MilkableArachnae.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainHarmony.cs" />
<Compile Include="ARA_TrainingWork\ThinkNode_ConditionalAnimalShouldDoGrowingWork.cs" />

View File

@@ -0,0 +1,80 @@
using RimWorld;
using Verse;
using UnityEngine;
namespace ArachnaeSwarm
{
public class CompMilkableArachnae : CompHasGatherableBodyResource
{
protected override int GatherResourcesIntervalDays => Props.milkIntervalDays;
protected override int ResourceAmount => Props.milkAmount;
protected override ThingDef ResourceDef => Props.milkDef;
protected override string SaveKey => "milkFullness";
public CompProperties_MilkableArachnae Props => (CompProperties_MilkableArachnae)props;
protected override bool Active
{
get
{
if (!base.Active)
{
return false;
}
Pawn pawn = parent as Pawn;
if (Props.milkFemaleOnly && pawn != null && pawn.gender != Gender.Female)
{
return false;
}
if (pawn != null && !pawn.ageTracker.CurLifeStage.milkable)
{
return false;
}
if (ModsConfig.AnomalyActive && pawn.IsShambler)
{
return false;
}
return true;
}
}
public override string CompInspectStringExtra()
{
if (!Active)
{
return null;
}
return "MilkFullness".Translate() + ": " + base.Fullness.ToStringPercent();
}
public override void CompTick()
{
base.CompTick();
// 检查是否活跃且fullness已满
if (Active && fullness >= 1.0f)
{
// 检查parent是否是Pawn且在普通地图上
if (parent is Pawn pawn && pawn.Map != null)
{
// 自动生成资源并掉落到地上
int num = ResourceAmount;
while (num > 0)
{
int num2 = Mathf.Clamp(num, 1, ResourceDef.stackLimit);
num -= num2;
Thing thing = ThingMaker.MakeThing(ResourceDef);
thing.stackCount = num2;
GenPlace.TryPlaceThing(thing, pawn.Position, pawn.Map, ThingPlaceMode.Near);
}
// 重置挤奶进度
fullness = 0f;
}
}
}
}
}

View File

@@ -0,0 +1,17 @@
using Verse;
namespace ArachnaeSwarm
{
public class CompProperties_MilkableArachnae : CompProperties
{
public int milkIntervalDays;
public int milkAmount = 1;
public ThingDef milkDef;
public bool milkFemaleOnly = true;
public CompProperties_MilkableArachnae()
{
compClass = typeof(CompMilkableArachnae); // 注意这里是 CompMilkableArachnae
}
}
}