This commit is contained in:
2025-09-25 14:42:35 +08:00
parent 94e1e2cd0c
commit 866c84df7f
4 changed files with 60 additions and 39 deletions

Binary file not shown.

View File

@@ -551,10 +551,14 @@
</verbProperties> </verbProperties>
<comps> <comps>
<li Class="ArachnaeSwarm.CompProperties_AbilityAddExtraExp"> <li Class="ArachnaeSwarm.CompProperties_AbilityAddExtraExp">
<skillChanges>
<li>
<skill>Medicine</skill> <skill>Medicine</skill>
<passionGained>Major</passionGained> <passionGained>Major</passionGained>
<xpGainAmount>350000</xpGainAmount> <xpGainAmount>350000</xpGainAmount>
</li> </li>
</skillChanges>
</li>
<li Class="CompProperties_AbilityGiveHediff"> <li Class="CompProperties_AbilityGiveHediff">
<compClass>CompAbilityEffect_GiveHediff</compClass> <compClass>CompAbilityEffect_GiveHediff</compClass>
<hediffDef>ARA_Myrmecocystus_Production_Medicine</hediffDef> <hediffDef>ARA_Myrmecocystus_Production_Medicine</hediffDef>
@@ -669,15 +673,19 @@
<severity>1</severity> <severity>1</severity>
</li> </li>
<li Class="ArachnaeSwarm.CompProperties_AbilityAddExtraExp"> <li Class="ArachnaeSwarm.CompProperties_AbilityAddExtraExp">
<skillChanges>
<li>
<skill>Melee</skill> <skill>Melee</skill>
<passionGained>Major</passionGained> <passionGained>Major</passionGained>
<xpGainAmount>350000</xpGainAmount> <xpGainAmount>350000</xpGainAmount>
</li> </li>
<li Class="ArachnaeSwarm.CompProperties_AbilityAddExtraExp"> <li>
<skill>Shooting</skill> <skill>Shooting</skill>
<passionGained>None</passionGained> <passionGained>None</passionGained>
<xpGainAmount>-350000</xpGainAmount> <xpGainAmount>-350000</xpGainAmount>
</li> </li>
</skillChanges>
</li>
<li Class="ArachnaeSwarm.CompProperties_AbilityResearchPrereq"> <li Class="ArachnaeSwarm.CompProperties_AbilityResearchPrereq">
<requiredResearch>ARA_Technology_4CLO</requiredResearch> <requiredResearch>ARA_Technology_4CLO</requiredResearch>
<failMessage>需要科技 节点CLO-4"追猎种" 以解锁进化</failMessage> <failMessage>需要科技 节点CLO-4"追猎种" 以解锁进化</failMessage>

View File

@@ -1,6 +1,6 @@
using Verse; using Verse;
using RimWorld; using RimWorld;
using System.Linq; using System.Collections.Generic;
namespace ArachnaeSwarm namespace ArachnaeSwarm
{ {
@@ -13,29 +13,34 @@ namespace ArachnaeSwarm
base.Apply(target, dest); base.Apply(target, dest);
Pawn user = parent.pawn; Pawn user = parent.pawn;
if (user == null) return; if (user == null || user.skills == null) return;
// 遍历并应用所有技能变更
foreach (var change in Props.skillChanges)
{
if (change.skill == null) continue;
// 1. 技能经验增益 // 1. 技能经验增益
int levelBefore = user.skills.GetSkill(Props.skill).GetLevel(); int levelBefore = user.skills.GetSkill(change.skill).GetLevel();
user.skills.Learn(Props.skill, Props.xpGainAmount, direct: true); user.skills.Learn(change.skill, change.xpGainAmount, direct: true);
int levelAfter = user.skills.GetSkill(Props.skill).GetLevel(); int levelAfter = user.skills.GetSkill(change.skill).GetLevel();
// 2. 热情设置 // 2. 热情设置
SkillRecord targetSkillRecord = user.skills.GetSkill(Props.skill); SkillRecord targetSkillRecord = user.skills.GetSkill(change.skill);
if (targetSkillRecord != null && !targetSkillRecord.TotallyDisabled) if (targetSkillRecord != null && !targetSkillRecord.TotallyDisabled)
{ {
if (targetSkillRecord.passion != Props.passionGained) if (targetSkillRecord.passion != change.passionGained)
{ {
targetSkillRecord.passion = Props.passionGained; targetSkillRecord.passion = change.passionGained;
} }
} }
// 发送通知 // 发送通知 (为每个技能变更发送一次)
if (PawnUtility.ShouldSendNotificationAbout(user)) if (PawnUtility.ShouldSendNotificationAbout(user))
{ {
Messages.Message("AbilitySkillChanged".Translate( Messages.Message("AbilitySkillChanged".Translate(
user.LabelShort, user.LabelShort,
Props.skill.LabelCap, change.skill.LabelCap,
levelBefore, levelBefore,
levelAfter, levelAfter,
user.Named("USER")), user.Named("USER")),
@@ -43,6 +48,7 @@ namespace ArachnaeSwarm
MessageTypeDefOf.PositiveEvent); MessageTypeDefOf.PositiveEvent);
} }
} }
}
public override bool Valid(LocalTargetInfo target, bool throwMessages = false) public override bool Valid(LocalTargetInfo target, bool throwMessages = false)
{ {
@@ -53,5 +59,4 @@ namespace ArachnaeSwarm
return base.Valid(target, throwMessages); return base.Valid(target, throwMessages);
} }
} }
} }

View File

@@ -1,13 +1,21 @@
using Verse; using Verse;
using RimWorld; using RimWorld;
using System.Collections.Generic;
namespace ArachnaeSwarm namespace ArachnaeSwarm
{ {
public class CompProperties_AbilityAddExtraExp : CompProperties_AbilityEffect // 定义一个类来封装单次技能的变更
public class SkillChange
{ {
public SkillDef skill; public SkillDef skill;
public Passion passionGained = Passion.Major; // 可配置获得的热情等级,默认为大火 public Passion passionGained = Passion.None;
public float xpGainAmount = 50000f; public float xpGainAmount;
}
// 修改 CompProperties 来使用 SkillChange 列表
public class CompProperties_AbilityAddExtraExp : CompProperties_AbilityEffect
{
public List<SkillChange> skillChanges = new List<SkillChange>();
public CompProperties_AbilityAddExtraExp() public CompProperties_AbilityAddExtraExp()
{ {