自动绑定
This commit is contained in:
Binary file not shown.
@@ -9,6 +9,11 @@
|
||||
<isBad>false</isBad>
|
||||
<scenarioCanAdd>false</scenarioCanAdd>
|
||||
<maxSeverity>100</maxSeverity>
|
||||
<comps>
|
||||
<li Class="ArachnaeSwarm.HediffCompProperties_HiveMindMaster">
|
||||
<scanIntervalTicks>3200</scanIntervalTicks>
|
||||
</li>
|
||||
</comps>
|
||||
<stages>
|
||||
<li>
|
||||
<label>连接至 {0} 个虫群工蜂</label>
|
||||
|
||||
@@ -10,5 +10,16 @@
|
||||
<ARA_BindDrone_NoDroneHediff>目标 {0} 没有“ARA_HiveMindDrone”的 hediff。</ARA_BindDrone_NoDroneHediff>
|
||||
<ARA_BindDrone_AlreadyBound>目标 {0} 已绑定到 {1}。</ARA_BindDrone_AlreadyBound>
|
||||
<ARA_BindDrone_NoMasterHediff>施法者 {0} 没有“ARA_HiveMindMaster”的 hediff。</ARA_BindDrone_NoMasterHediff>
|
||||
|
||||
<!-- Possession Ability Keys -->
|
||||
<ARA_MustBeHumanlike>目标必须是类人生物。</ARA_MustBeHumanlike>
|
||||
<ARA_AlreadyPossessed>{0} 已被寄生。</ARA_AlreadyPossessed>
|
||||
<ARA_CannotPossessRace>无法寄生 {0} 种族。</ARA_CannotPossessRace>
|
||||
|
||||
<!-- Hive Mind Tooltips -->
|
||||
<ARA_TipString_LinkedTo>链接至: {0}</ARA_TipString_LinkedTo>
|
||||
<ARA_TipString_NotLinked>未链接至任何女皇种。</ARA_TipString_NotLinked>
|
||||
<ARA_TipString_ControlledDrones>控制的虫族:</ARA_TipString_ControlledDrones>
|
||||
<ARA_TipString_NoDronesBound>尚未绑定任何虫族。</ARA_TipString_NoDronesBound>
|
||||
|
||||
</LanguageData>
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<LanguageData>
|
||||
|
||||
<!-- Possession Ability Keys -->
|
||||
<ARA_MustBeHumanlike>目标必须是类人生物。</ARA_MustBeHumanlike>
|
||||
<ARA_AlreadyPossessed>{0} 已被夺舍。</ARA_AlreadyPossessed>
|
||||
<ARA_CannotPossessRace>无法夺舍 {0} 种族。</ARA_CannotPossessRace>
|
||||
|
||||
</LanguageData>
|
||||
@@ -0,0 +1,44 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,17 @@ namespace ArachnaeSwarm
|
||||
masterHediff?.DeregisterDrone(this.pawn);
|
||||
}
|
||||
}
|
||||
public override string TipStringExtra
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.target is Pawn master && master != null)
|
||||
{
|
||||
return "ARA_TipString_LinkedTo".Translate(master.LabelShortCap);
|
||||
}
|
||||
return "ARA_TipString_NotLinked".Translate();
|
||||
}
|
||||
}
|
||||
// PostTick logic moved to HediffComp_HiveMindDrone
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using Verse;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class Hediff_HiveMindMaster : Hediff
|
||||
public class Hediff_HiveMindMaster : HediffWithComps
|
||||
{
|
||||
private List<Pawn> drones = new List<Pawn>();
|
||||
|
||||
@@ -13,6 +13,30 @@ namespace ArachnaeSwarm
|
||||
|
||||
public override bool ShouldRemove => false;
|
||||
|
||||
public override string TipStringExtra
|
||||
{
|
||||
get
|
||||
{
|
||||
if (drones.NullOrEmpty())
|
||||
{
|
||||
return "\n" + "ARA_TipString_NoDronesBound".Translate().Colorize(ColoredText.SubtleGrayColor);
|
||||
}
|
||||
|
||||
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
|
||||
stringBuilder.AppendLine("\n" + "ARA_TipString_ControlledDrones".Translate().Colorize(ColoredText.TipSectionTitleColor));
|
||||
foreach (var drone in drones)
|
||||
{
|
||||
string backstoryInfo = "";
|
||||
if (drone.story?.TitleShort is string adulthoodTitle && !adulthoodTitle.NullOrEmpty())
|
||||
{
|
||||
backstoryInfo = $" ({adulthoodTitle.Colorize(ColoredText.SubtleGrayColor)})";
|
||||
}
|
||||
stringBuilder.AppendLine($" - {drone.LabelShortCap}{backstoryInfo}");
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExposeData()
|
||||
{
|
||||
base.ExposeData();
|
||||
@@ -57,6 +81,41 @@ namespace ArachnaeSwarm
|
||||
return true;
|
||||
}
|
||||
|
||||
public void TryBindAllAvailableDrones()
|
||||
{
|
||||
if (this.pawn?.Map == null) return;
|
||||
|
||||
// First, clean up any dead, despawned, or destroyed drones from the list.
|
||||
int removedCount = drones.RemoveAll(drone => drone == null || drone.Dead || drone.Destroyed);
|
||||
|
||||
// Find all pawns on the map that could be potential drones
|
||||
List<Pawn> potentialDrones = this.pawn.Map.mapPawns.AllPawnsSpawned
|
||||
.Where(p => p.health.hediffSet.HasHediff(HediffDef.Named("ARA_HiveMindDrone")))
|
||||
.ToList();
|
||||
|
||||
int boundCount = 0;
|
||||
|
||||
foreach (var drone in potentialDrones)
|
||||
{
|
||||
Hediff_HiveMindDrone droneHediff = drone.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_HiveMindDrone")) as Hediff_HiveMindDrone;
|
||||
|
||||
// Check if the drone is unlinked (target is null) and not already in our list
|
||||
if (droneHediff != null && droneHediff.target == null && !drones.Contains(drone))
|
||||
{
|
||||
droneHediff.target = this.pawn; // Set the drone's target to this master
|
||||
drones.Add(drone);
|
||||
Log.Message($"[ArachnaeSwarm] Master {this.pawn.LabelShort} automatically bound drone {drone.LabelShort}.");
|
||||
boundCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Update severity if anything changed (drones were added or removed)
|
||||
if (boundCount > 0 || removedCount > 0)
|
||||
{
|
||||
UpdateSeverity();
|
||||
}
|
||||
}
|
||||
|
||||
public void DeregisterDrone(Pawn drone)
|
||||
{
|
||||
if (drones.Contains(drone))
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
<Compile Include="ARA_HiveMind\Hediff_HiveMindDrone.cs" />
|
||||
<Compile Include="ARA_HiveMind\HediffCompProperties_HiveMindDrone.cs" />
|
||||
<Compile Include="ARA_HiveMind\HediffComp_HiveMindDrone.cs" />
|
||||
<Compile Include="ARA_HiveMind\HediffComp_HiveMindMaster.cs" />
|
||||
<Compile Include="ARA_HiveMind\CompAbilityEffect_BindDrone.cs" />
|
||||
<Compile Include="ARA_HiveMind\CompProperties_AbilityBindDrone.cs" />
|
||||
<Compile Include="ARA_SpawnPawnFromList\JobGiver_MaintainBuildings.cs" />
|
||||
|
||||
Reference in New Issue
Block a user