This commit is contained in:
2025-09-11 22:45:43 +08:00
parent 6c2527e695
commit 1b3c01d8bc
5 changed files with 48 additions and 8 deletions

Binary file not shown.

View File

@@ -70,7 +70,22 @@
<workSpeedStat>ResearchSpeedFactor</workSpeedStat>
</li>
<li Class="ArachnaeSwarm.CompProperties_Morphable">
<!-- 休息速度增益例如1.0代表200%的速度 -->
<restGainMultiplier>1.0</restGainMultiplier>
<!-- 操作按钮的自定义标签 -->
<gizmoLabel>离开织座</gizmoLabel>
<!-- 操作按钮的自定义描述 -->
<gizmoDesc>使织域种离开织座。</gizmoDesc>
<!--
操作按钮的自定义图标路径。
路径相对于"Textures"文件夹。
例如,如果你的图标在 "YourMod/Textures/UI/Icons/Revert.png",路径就是 "UI/Icons/Revert"。
游戏会自动处理.png扩展名。
-->
<gizmoIconPath>UI/Commands/EggSpew</gizmoIconPath>
</li>
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition">
<fuelFilter>

View File

@@ -223,7 +223,19 @@ namespace ArachnaeSwarm
// 计算将要对 Pawn 造成的伤害
float damageProportion = dinfo.Amount / this.def.statBases.GetStatValueFromList(StatDefOf.MaxHitPoints, 1f);
float pawnDamage = pawn.MaxHitPoints * damageProportion;
DamageInfo pawnDinfo = new DamageInfo(dinfo.Def, pawnDamage, dinfo.ArmorPenetrationInt, dinfo.Angle, dinfo.Instigator, null, dinfo.Weapon, dinfo.Category, dinfo.IntendedTarget);
// 关键修复创建一个新的、干净的DamageInfo不指定hitPart让游戏自动选择有效的部位
DamageInfo pawnDinfo = new DamageInfo(
def: dinfo.Def,
amount: pawnDamage,
armorPenetration: dinfo.ArmorPenetrationInt,
angle: dinfo.Angle,
instigator: dinfo.Instigator,
hitPart: null, // 明确设为null防止继承无效上下文
weapon: dinfo.Weapon,
category: dinfo.Category,
intendedTarget: dinfo.IntendedTarget
);
// 调用统一的转换方法它会处理建筑的移除、Pawn的生成和状态同步
compMorphable.TransformBackToPawn();

View File

@@ -28,13 +28,21 @@ namespace ArachnaeSwarm
{
if (parent.Faction == Faction.OfPlayer && storedPawn != null)
{
yield return new Command_Action
Command_Action command = new Command_Action();
command.defaultLabel = Props.gizmoLabel;
command.defaultDesc = Props.gizmoDesc;
command.action = () => { TransformBackToPawn(); };
if (!Props.gizmoIconPath.NullOrEmpty())
{
defaultLabel = "恢复人形",
defaultDesc = "将此建筑恢复为人形。",
icon = TexCommand.ReleaseAnimals, // TODO: Replace with a proper icon
action = () => { TransformBackToPawn(); }
};
command.icon = ContentFinder<UnityEngine.Texture2D>.Get(Props.gizmoIconPath);
}
else
{
command.icon = TexCommand.ReleaseAnimals; // Fallback icon
}
yield return command;
}
}

View File

@@ -5,7 +5,12 @@ namespace ArachnaeSwarm
{
public class CompProperties_Morphable : CompProperties
{
public float restGainMultiplier = 1f; // Default to 1.0 if not specified in XML
public float restGainMultiplier = 1f;
// Gizmo properties
public string gizmoLabel = "离开织座";
public string gizmoDesc = "使织域种离开织座。";
public string gizmoIconPath;
public CompProperties_Morphable()
{