diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index e6f8894..9b6b97f 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/1.6/1.6/Defs/PawnKindDef/ARA_PawnKinds.xml b/1.6/1.6/Defs/PawnKindDef/ARA_PawnKinds.xml index 1bf30e4..6870aa5 100644 --- a/1.6/1.6/Defs/PawnKindDef/ARA_PawnKinds.xml +++ b/1.6/1.6/Defs/PawnKindDef/ARA_PawnKinds.xml @@ -182,9 +182,6 @@ 8.0 - -
  • ARA_HiveMindWorker
  • -
    ArachnaeBase_Race_Slavey diff --git a/1.6/1.6/Defs/ThingDef_Races/ARA_RaceBaseSwarm.xml b/1.6/1.6/Defs/ThingDef_Races/ARA_RaceBaseSwarm.xml index dd9ee0e..78f1411 100644 --- a/1.6/1.6/Defs/ThingDef_Races/ARA_RaceBaseSwarm.xml +++ b/1.6/1.6/Defs/ThingDef_Races/ARA_RaceBaseSwarm.xml @@ -61,6 +61,15 @@ DeathActionWorker_Vanish --> + +
  • + +
  • ARA_HiveMindWorker
  • + + 1.0 + false + +
    ArachnaeBase_Race_Slavey @@ -85,7 +94,7 @@ true - true + true @@ -107,7 +116,7 @@ true - true + true @@ -135,11 +144,11 @@ true - true + true - + ArachnaeBase_Race_Acid 阿拉克涅辅虫之一,智力低下,一般被作为活体炮弹打出,击中敌人后若是还没散架,就会继续依靠带酸液的颚撕咬敌军。 @@ -164,7 +173,7 @@
  • - 4400 + 4400 寿命 这种特殊的阿拉克涅辅虫从出生起就走在死亡的道路上了——它们的寿命就是如此短暂。 true @@ -202,7 +211,7 @@ true
  • - true + true
    diff --git a/Source/ArachnaeSwarm/ARA_CompHediffGiver/CompHediffGiver.cs b/Source/ArachnaeSwarm/ARA_CompHediffGiver/CompHediffGiver.cs new file mode 100644 index 0000000..4436cf0 --- /dev/null +++ b/Source/ArachnaeSwarm/ARA_CompHediffGiver/CompHediffGiver.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using Verse; +using RimWorld; + +namespace ArachnaeSwarm +{ + public class CompHediffGiver : ThingComp + { + public CompProperties_HediffGiver Props => (CompProperties_HediffGiver)this.props; + + public override void PostSpawnSetup(bool respawningAfterLoad) + { + base.PostSpawnSetup(respawningAfterLoad); + + // 只有当thing是pawn时才添加hediff + if (this.parent is Pawn pawn) + { + AddHediffsToPawn(pawn); + } + } + + private void AddHediffsToPawn(Pawn pawn) + { + // 检查是否有hediff列表 + if (Props.hediffs == null || Props.hediffs.Count == 0) + return; + + // 检查概率 + if (Props.addChance < 1.0f && Rand.Value > Props.addChance) + return; + + // 为每个hediff添加到pawn + foreach (HediffDef hediffDef in Props.hediffs) + { + // 检查是否允许重复添加 + if (!Props.allowDuplicates && pawn.health.hediffSet.HasHediff(hediffDef)) + continue; + + // 添加hediff + pawn.health.AddHediff(hediffDef); + } + } + } +} \ No newline at end of file diff --git a/Source/ArachnaeSwarm/ARA_CompHediffGiver/CompProperties_HediffGiver.cs b/Source/ArachnaeSwarm/ARA_CompHediffGiver/CompProperties_HediffGiver.cs new file mode 100644 index 0000000..470c230 --- /dev/null +++ b/Source/ArachnaeSwarm/ARA_CompHediffGiver/CompProperties_HediffGiver.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using Verse; + +namespace ArachnaeSwarm +{ + public class CompProperties_HediffGiver : CompProperties + { + // 要添加的hediff列表 + public List hediffs; + + // 添加hediff的概率(0-1之间) + public float addChance = 1.0f; + + // 是否允许重复添加相同的hediff + public bool allowDuplicates = false; + + public CompProperties_HediffGiver() + { + this.compClass = typeof(CompHediffGiver); + } + } +} \ No newline at end of file diff --git a/Source/ArachnaeSwarm/ARA_TrainingWork/JobClean/JobGiver_Cleaner.cs b/Source/ArachnaeSwarm/ARA_TrainingWork/JobClean/JobGiver_Cleaner.cs index f99aedb..3c1aa2a 100644 --- a/Source/ArachnaeSwarm/ARA_TrainingWork/JobClean/JobGiver_Cleaner.cs +++ b/Source/ArachnaeSwarm/ARA_TrainingWork/JobClean/JobGiver_Cleaner.cs @@ -36,12 +36,15 @@ namespace ArachnaeSwarm if (filthJob != null) return filthJob; } - // If no filth, find the closest snow/sand to clear - IntVec3 closestSnowCell = _workGiver.FindClosestSnow(pawn); - if (closestSnowCell.IsValid) + // If no filth, check if there's any snow to clear at all before searching + if (pawn.Map.areaManager.SnowOrSandClear.TrueCount > 0) { - Job snowJob = _workGiver.JobOnCell(pawn, closestSnowCell); - if (snowJob != null) return snowJob; + IntVec3 closestSnowCell = _workGiver.FindClosestSnow(pawn); + if (closestSnowCell.IsValid) + { + Job snowJob = _workGiver.JobOnCell(pawn, closestSnowCell); + if (snowJob != null) return snowJob; + } } return null; diff --git a/Source/ArachnaeSwarm/ARA_TrainingWork/JobClean/WorkGiver_ArachnaeClean.cs b/Source/ArachnaeSwarm/ARA_TrainingWork/JobClean/WorkGiver_ArachnaeClean.cs index ddfb1c6..c80fc1d 100644 --- a/Source/ArachnaeSwarm/ARA_TrainingWork/JobClean/WorkGiver_ArachnaeClean.cs +++ b/Source/ArachnaeSwarm/ARA_TrainingWork/JobClean/WorkGiver_ArachnaeClean.cs @@ -62,14 +62,31 @@ namespace ArachnaeSwarm public IntVec3 FindClosestSnow(Pawn pawn) { - return CellFinder.RandomClosewalkCellNear(pawn.Position, pawn.Map, 100, - c => HasJobOnCell(pawn, c) && pawn.CanReach(c, PathEndMode.Touch, Danger.Deadly)); + IntVec3 bestCell = IntVec3.Invalid; + float bestDistSq = float.MaxValue; + + // Efficiently iterate through the designated snow clear area + foreach (IntVec3 cell in pawn.Map.areaManager.SnowOrSandClear.ActiveCells) + { + // Check for a valid job on the cell first + if (HasJobOnCell(pawn, cell)) + { + float distSq = pawn.Position.DistanceToSquared(cell); + if (distSq < bestDistSq && pawn.CanReach(cell, PathEndMode.Touch, Danger.Deadly)) + { + bestDistSq = distSq; + bestCell = cell; + } + } + } + return bestCell; } public override bool HasJobOnCell(Pawn pawn, IntVec3 c, bool forced = false) { + // The check for SnowOrSandClear area is implicitly handled by the caller (FindClosestSnow) + // We only need to check the snow depth and reservation status. if (pawn.Map.snowGrid.GetDepth(c) < 0.2f) return false; - if (!pawn.Map.areaManager.SnowOrSandClear[c]) return false; // Must be in the clear zone if (!pawn.CanReserve(c, 1, -1, null, forced)) return false; return true; } diff --git a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj index 4532ea1..e0e4d06 100644 --- a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj +++ b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj @@ -85,6 +85,8 @@ + +