暂存
This commit is contained in:
@@ -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" />
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
49
Source/ArachnaeSwarm/CompAbilityEffect_BodyPartCheck.cs
Normal file
49
Source/ArachnaeSwarm/CompAbilityEffect_BodyPartCheck.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user