44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using Verse;
|
|
|
|
namespace ArachnaeSwarm
|
|
{
|
|
public class HediffCompProperties_HiveMindMaster : HediffCompProperties
|
|
{
|
|
public int scanIntervalTicks = 60; // Default to 1 second
|
|
|
|
public HediffCompProperties_HiveMindMaster()
|
|
{
|
|
this.compClass = typeof(HediffComp_HiveMindMaster);
|
|
}
|
|
}
|
|
|
|
public class HediffComp_HiveMindMaster : HediffComp
|
|
{
|
|
private Hediff_HiveMindMaster parentHediff;
|
|
|
|
private HediffCompProperties_HiveMindMaster Props => (HediffCompProperties_HiveMindMaster)this.props;
|
|
|
|
public override void CompPostMake()
|
|
{
|
|
base.CompPostMake();
|
|
parentHediff = (Hediff_HiveMindMaster)this.parent;
|
|
// Immediately try to bind drones when the hediff is first applied.
|
|
parentHediff.TryBindAllAvailableDrones();
|
|
}
|
|
|
|
public override void CompPostTick(ref float severityAdjustment)
|
|
{
|
|
base.CompPostTick(ref severityAdjustment);
|
|
|
|
// Periodically check for new unbound drones based on XML value.
|
|
if (Find.TickManager.TicksGame % Props.scanIntervalTicks == 0)
|
|
{
|
|
if (parentHediff == null)
|
|
{
|
|
parentHediff = (Hediff_HiveMindMaster)this.parent;
|
|
}
|
|
parentHediff.TryBindAllAvailableDrones();
|
|
}
|
|
}
|
|
}
|
|
} |