暂存
This commit is contained in:
Binary file not shown.
@@ -14,36 +14,7 @@
|
|||||||
<Wildness>0.3</Wildness>
|
<Wildness>0.3</Wildness>
|
||||||
</statBases>
|
</statBases>
|
||||||
<uiIconScale>1.1</uiIconScale>
|
<uiIconScale>1.1</uiIconScale>
|
||||||
<comps>
|
|
||||||
<li Class="ArachnaeSwarm.CompProperties_InstantTrain">
|
|
||||||
<trainables>
|
|
||||||
<li>ARA_Sowing</li>
|
|
||||||
<li>ARA_PlantCutting</li>
|
|
||||||
</trainables>
|
|
||||||
</li>
|
|
||||||
<li Class="ArachnaeSwarm.CompProperties_AnimalWorkSettings">
|
|
||||||
<!-- 定义技能等级 -->
|
|
||||||
<skillLevels>
|
|
||||||
<li>
|
|
||||||
<skill>Plants</skill>
|
|
||||||
<level>10</level>
|
|
||||||
<disableDecay>true</disableDecay>
|
|
||||||
</li>
|
|
||||||
</skillLevels>
|
|
||||||
<!-- 定义训练项与工作类型的映射 -->
|
|
||||||
<workTypeMap>
|
|
||||||
<li>
|
|
||||||
<trainable>ARA_Sowing</trainable>
|
|
||||||
<workType>Growing</workType>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<trainable>ARA_PlantCutting</trainable>
|
|
||||||
<workType>PlantCutting</workType>
|
|
||||||
</li>
|
|
||||||
</workTypeMap>
|
|
||||||
</li>
|
|
||||||
<li Class="ArachnaeSwarm.CompProperties_NoTrainingDecay" />
|
|
||||||
</comps>
|
|
||||||
<tools>
|
<tools>
|
||||||
<li>
|
<li>
|
||||||
<label>head claw</label>
|
<label>head claw</label>
|
||||||
|
|||||||
@@ -5,40 +5,25 @@ using RimWorld;
|
|||||||
|
|
||||||
namespace ArachnaeSwarm
|
namespace ArachnaeSwarm
|
||||||
{
|
{
|
||||||
// 确保 WorkGiverDefOf 被正确初始化
|
|
||||||
[DefOf]
|
|
||||||
public static class WorkGiverDefOf
|
|
||||||
{
|
|
||||||
public static WorkGiverDef Harvest;
|
|
||||||
public static WorkGiverDef GrowerSow;
|
|
||||||
|
|
||||||
static WorkGiverDefOf()
|
|
||||||
{
|
|
||||||
DefOfHelper.EnsureInitializedInCtor(typeof(WorkGiverDefOf));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class JobGiver_Grower : ThinkNode_JobGiver
|
public class JobGiver_Grower : ThinkNode_JobGiver
|
||||||
{
|
{
|
||||||
private static WorkGiver_GrowerHarvest _workGiverHarvest;
|
private WorkGiver_GrowerHarvest _workGiverHarvest;
|
||||||
private static WorkGiver_GrowerSow _workGiverSow;
|
private WorkGiver_GrowerSow _workGiverSow;
|
||||||
|
|
||||||
static JobGiver_Grower()
|
|
||||||
{
|
|
||||||
// 确保在访问 WorkGiverDefOf 之前,它已经被初始化
|
|
||||||
// 尽管 [DefOf] 会自动处理,但显式调用可以避免某些加载时序问题
|
|
||||||
DefOfHelper.EnsureInitializedInCtor(typeof(WorkGiverDefOf));
|
|
||||||
_workGiverHarvest = WorkGiverDefOf.Harvest.Worker as WorkGiver_GrowerHarvest;
|
|
||||||
_workGiverSow = WorkGiverDefOf.GrowerSow.Worker as WorkGiver_GrowerSow;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Job TryGiveJob(Pawn pawn)
|
protected override Job TryGiveJob(Pawn pawn)
|
||||||
{
|
{
|
||||||
|
// 懒加载 WorkGiver 实例,确保 DefOf 已被初始化
|
||||||
|
if (_workGiverHarvest == null)
|
||||||
|
{
|
||||||
|
_workGiverHarvest = WorkGiverDefOf.GrowerHarvest.Worker as WorkGiver_GrowerHarvest;
|
||||||
|
_workGiverSow = WorkGiverDefOf.GrowerSow.Worker as WorkGiver_GrowerSow;
|
||||||
|
|
||||||
if (_workGiverHarvest == null || _workGiverSow == null)
|
if (_workGiverHarvest == null || _workGiverSow == null)
|
||||||
{
|
{
|
||||||
Log.ErrorOnce("JobGiver_Grower could not find vanilla Grower WorkGivers.", 123457);
|
Log.ErrorOnce("JobGiver_Grower: Failed to get WorkGiver_GrowerHarvest or WorkGiver_GrowerSow. DefOfs might not be initialized or DefNames are incorrect.", 123457);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 1. 优先收获
|
// 1. 优先收获
|
||||||
Thing bestHarvestable = FindClosestThing(pawn, _workGiverHarvest);
|
Thing bestHarvestable = FindClosestThing(pawn, _workGiverHarvest);
|
||||||
@@ -97,3 +82,16 @@ namespace ArachnaeSwarm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 确保 WorkGiverDefOf 被正确初始化,放在命名空间顶层
|
||||||
|
[DefOf]
|
||||||
|
public static class WorkGiverDefOf
|
||||||
|
{
|
||||||
|
public static WorkGiverDef GrowerHarvest;
|
||||||
|
public static WorkGiverDef GrowerSow;
|
||||||
|
|
||||||
|
static WorkGiverDefOf()
|
||||||
|
{
|
||||||
|
DefOfHelper.EnsureInitializedInCtor(typeof(WorkGiverDefOf));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,6 @@ namespace ArachnaeSwarm
|
|||||||
public static class ARA_TrainableDefOf
|
public static class ARA_TrainableDefOf
|
||||||
{
|
{
|
||||||
public static TrainableDef ARA_Sowing;
|
public static TrainableDef ARA_Sowing;
|
||||||
public static TrainableDef ARA_PlantCutting;
|
|
||||||
|
|
||||||
static ARA_TrainableDefOf()
|
static ARA_TrainableDefOf()
|
||||||
{
|
{
|
||||||
@@ -32,12 +31,8 @@ namespace ArachnaeSwarm
|
|||||||
bool canSow = pawn.training.HasLearned(ARA_TrainableDefOf.ARA_Sowing) &&
|
bool canSow = pawn.training.HasLearned(ARA_TrainableDefOf.ARA_Sowing) &&
|
||||||
pawn.training.GetWanted(ARA_TrainableDefOf.ARA_Sowing);
|
pawn.training.GetWanted(ARA_TrainableDefOf.ARA_Sowing);
|
||||||
|
|
||||||
// 检查动物是否学会并被允许执行“植物切割”工作
|
// 现在只需要检查播种技能,因为切割功能已合并
|
||||||
bool canCut = pawn.training.HasLearned(ARA_TrainableDefOf.ARA_PlantCutting) &&
|
return canSow;
|
||||||
pawn.training.GetWanted(ARA_TrainableDefOf.ARA_PlantCutting);
|
|
||||||
|
|
||||||
// 只要满足其中任何一个条件,就返回 true
|
|
||||||
return canSow || canCut;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user