This commit is contained in:
2025-09-01 16:56:48 +08:00
parent e58fac54f8
commit 9ab3300ac6
7 changed files with 66 additions and 21 deletions

Binary file not shown.

View File

@@ -30,6 +30,10 @@
<needCost>4</needCost>
<failMessage>食物不足</failMessage>
</li>
<li Class="ArachnaeSwarm.CompProperties_AbilityBodyPartCheck">
<requiredPart>ARA_Ovary</requiredPart>
<failMessage>卵巢受损或缺失,无法生育</failMessage>
</li>
</comps>
</AbilityDef>
@@ -64,12 +68,12 @@
<shotCount>32</shotCount> <!-- 总共发射5次 -->
<ticksBetweenShots>3</ticksBetweenShots> <!-- 每次发射间隔12 Ticks (0.2秒) -->
</li>
</comps>
<li Class="ArachnaeSwarm.CompProperties_AbilityNeedCost">
<li Class="ArachnaeSwarm.CompProperties_AbilityNeedCost">
<needDef>Food</needDef>
<needCost>0.5</needCost>
<failMessage>食物不足</failMessage>
</li>
</comps>
</AbilityDef>
<ThingDef>

View File

@@ -33,11 +33,7 @@
<isTargetable>true</isTargetable>
<expandHomeArea>false</expandHomeArea>
</building>
<hatchingGraphicData>
<texPath>Things/Building/Natural/Hive</texPath>
<graphicClass>Graphic_Random</graphicClass>
<drawSize>1.6</drawSize>
</hatchingGraphicData>
<comps>
<li Class="CompProperties_Glower">
<glowRadius>6</glowRadius>
@@ -54,10 +50,16 @@
</whitelist>
<delay>300</delay> <!-- 5 seconds -->
<destroyOnSpawn>true</destroyOnSpawn>
<hatchingGraphicData>
<texPath>Things/Building/Natural/Hive</texPath>
<graphicClass>Graphic_Random</graphicClass>
<drawSize>1.6</drawSize>
</hatchingGraphicData>
</li>
<li Class="CompProperties_SpawnEffecterOnDestroy">
<effect>CocoonDestroyed</effect>
</li>
</comps>
</ThingDef>

View File

@@ -76,6 +76,7 @@
<Compile Include="Building_Incubator.cs" />
<Compile Include="Hediffs\Hediff_CurseFlame.cs" />
<Compile Include="CompAbilityEffect_NeedCost.cs" />
<Compile Include="CompAbilityEffect_BodyPartCheck.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -7,25 +7,13 @@ namespace ArachnaeSwarm
{
public CompSpawnPawnFromList SpawnComp => GetComp<CompSpawnPawnFromList>();
public GraphicData hatchingGraphicData;
private Graphic hatchingGraphic;
public override void SpawnSetup(Map map, bool respawningAfterLoad)
{
base.SpawnSetup(map, respawningAfterLoad);
if (hatchingGraphicData != null)
{
hatchingGraphic = hatchingGraphicData.Graphic;
}
}
public override Graphic Graphic
{
get
{
if (SpawnComp != null && SpawnComp.IsHatching && hatchingGraphic != null)
if (SpawnComp != null && SpawnComp.IsHatching && SpawnComp.Props.hatchingGraphicData != null)
{
return hatchingGraphic;
return SpawnComp.Props.hatchingGraphicData.Graphic;
}
return base.Graphic;
}

View File

@@ -0,0 +1,49 @@
using System.Linq;
using RimWorld;
using Verse;
namespace ArachnaeSwarm
{
public class CompProperties_AbilityBodyPartCheck : CompProperties_AbilityEffect
{
public BodyPartDef requiredPart;
public float minimumHealth = 0.8f;
public string failMessage = "Missing or damaged body part.";
public CompProperties_AbilityBodyPartCheck()
{
compClass = typeof(CompAbilityEffect_BodyPartCheck);
}
}
public class CompAbilityEffect_BodyPartCheck : CompAbilityEffect
{
public new CompProperties_AbilityBodyPartCheck Props => (CompProperties_AbilityBodyPartCheck)props;
public override bool GizmoDisabled(out string reason)
{
Pawn caster = parent.pawn;
if (caster != null && caster.health != null && caster.health.hediffSet != null)
{
var part = caster.health.hediffSet.GetNotMissingParts()
.FirstOrDefault(p => p.def == Props.requiredPart);
if (part == null)
{
reason = Props.failMessage;
return true;
}
float partHealth = caster.health.hediffSet.GetPartHealth(part) / part.def.GetMaxHealth(caster);
if (partHealth < Props.minimumHealth)
{
reason = Props.failMessage;
return true;
}
}
reason = null;
return false;
}
}
}

View File

@@ -13,6 +13,7 @@ namespace ArachnaeSwarm
public bool destroyOnSpawn = false;
public IntRange spawnCount = new IntRange(1, 1);
public Type lordJob;
public GraphicData hatchingGraphicData;
public CompProperties_SpawnPawnFromList()
{