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

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()
{