训练台(未完成)

This commit is contained in:
2025-10-08 17:30:33 +08:00
parent 69e673477d
commit 5869706ffb
8 changed files with 403 additions and 100 deletions

View File

@@ -3,28 +3,8 @@
"WorkspaceRootPath": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|d:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\eventsystem\\questnode_root_eventletter.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:eventsystem\\questnode_root_eventletter.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\eventsystem\\dialog_newlayoutdisplay.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:eventsystem\\dialog_newlayoutdisplay.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\eventsystem\\dialog_customdisplay.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:eventsystem\\dialog_customdisplay.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\eventsystem\\effect.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:eventsystem\\effect.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\eventsystem\\compopencustomui.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:eventsystem\\compopencustomui.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\eventsystem\\eventuiconfigdef.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:eventsystem\\eventuiconfigdef.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|d:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\abilities\\ara_queenability\\compabilityeffect_needcost.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:abilities\\ara_queenability\\compabilityeffect_needcost.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
@@ -43,75 +23,15 @@
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "QuestNode_Root_EventLetter.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\QuestNode_Root_EventLetter.cs",
"RelativeDocumentMoniker": "EventSystem\\QuestNode_Root_EventLetter.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\QuestNode_Root_EventLetter.cs",
"RelativeToolTip": "EventSystem\\QuestNode_Root_EventLetter.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAgAAAA3AAAAAAAAAA==",
"Title": "CompAbilityEffect_NeedCost.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\ARA_QueenAbility\\CompAbilityEffect_NeedCost.cs",
"RelativeDocumentMoniker": "Abilities\\ARA_QueenAbility\\CompAbilityEffect_NeedCost.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\ARA_QueenAbility\\CompAbilityEffect_NeedCost.cs",
"RelativeToolTip": "Abilities\\ARA_QueenAbility\\CompAbilityEffect_NeedCost.cs",
"ViewState": "AgIAACUAAAAAAAAAAAAAAEgAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-07T09:56:01.195Z",
"WhenOpened": "2025-10-08T08:23:27.533Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "Dialog_NewLayoutDisplay.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\Dialog_NewLayoutDisplay.cs",
"RelativeDocumentMoniker": "EventSystem\\Dialog_NewLayoutDisplay.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\Dialog_NewLayoutDisplay.cs",
"RelativeToolTip": "EventSystem\\Dialog_NewLayoutDisplay.cs",
"ViewState": "AgIAAAsAAAAAAAAAAAAuwDYAAAARAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-07T09:39:47.15Z"
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "Dialog_CustomDisplay.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\Dialog_CustomDisplay.cs",
"RelativeDocumentMoniker": "EventSystem\\Dialog_CustomDisplay.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\Dialog_CustomDisplay.cs",
"RelativeToolTip": "EventSystem\\Dialog_CustomDisplay.cs",
"ViewState": "AgIAAAsAAAAAAAAAAAAuwBcAAABWAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-07T09:39:43.149Z"
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "Effect.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\Effect.cs",
"RelativeDocumentMoniker": "EventSystem\\Effect.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\Effect.cs",
"RelativeToolTip": "EventSystem\\Effect.cs",
"ViewState": "AgIAAAAAAAAAAAAAAADwvwwAAAA7AAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-07T09:35:57.661Z"
},
{
"$type": "Document",
"DocumentIndex": 5,
"Title": "EventUIConfigDef.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\EventUIConfigDef.cs",
"RelativeDocumentMoniker": "EventSystem\\EventUIConfigDef.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\EventUIConfigDef.cs",
"RelativeToolTip": "EventSystem\\EventUIConfigDef.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAABYAAAAqAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-07T08:37:06.577Z"
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "CompOpenCustomUI.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\CompOpenCustomUI.cs",
"RelativeDocumentMoniker": "EventSystem\\CompOpenCustomUI.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\EventSystem\\CompOpenCustomUI.cs",
"RelativeToolTip": "EventSystem\\CompOpenCustomUI.cs",
"ViewState": "AgIAAAAAAAAAAAAAAADwvxQAAAAtAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-07T08:36:51.993Z"
}
]
}

View File

@@ -1,6 +1,7 @@
using RimWorld;
using RimWorld.Planet;
using Verse;
using System.Text;
namespace ArachnaeSwarm
{
@@ -9,6 +10,8 @@ namespace ArachnaeSwarm
public NeedDef needDef;
public float needCost;
public string failMessage;
public string customLabel; // 自定义显示标签
public bool showProgressBar = true; // 是否显示进度条样式
public CompProperties_AbilityNeedCost()
{
@@ -22,17 +25,10 @@ namespace ArachnaeSwarm
public override bool GizmoDisabled(out string reason)
{
Pawn caster = parent.pawn;
if (caster != null && caster.needs != null)
if (!HasEnoughNeed())
{
if (caster.needs.TryGetNeed(Props.needDef, out Need need))
{
if (need.CurLevel < Props.needCost)
{
reason = Props.failMessage;
return true;
}
}
reason = Props.failMessage ?? "ARA_NeedCost_RequiresAtLeast".Translate(Props.needCost, GetNeedLabel());
return true;
}
reason = null;
return false;
@@ -41,6 +37,103 @@ namespace ArachnaeSwarm
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
{
base.Apply(target, dest);
ConsumeNeed();
}
// 在工具提示中显示消耗信息
public override string ExtraTooltipPart()
{
if (Props.needDef == null)
return null;
StringBuilder stringBuilder = new StringBuilder();
float currentLevel = GetCurrentNeedLevel();
float maxLevel = GetMaxNeedLevel();
bool canCast = HasEnoughNeed();
// 构建显示信息
stringBuilder.AppendLine("ARA_NeedCost_Consumption".Translate(GetNeedLabel()));
stringBuilder.AppendLine();
// 显示消耗和当前值
string costColor = canCast ? "green" : "red";
string costText = "ARA_NeedCost_Cost".Translate(Props.needCost);
stringBuilder.AppendLine($" <color={costColor}>{costText}</color>");
string currentText = "ARA_NeedCost_Current".Translate(currentLevel.ToString("F1"), maxLevel.ToString("F1"));
stringBuilder.AppendLine($" {currentText}");
// 显示进度条(文本模拟)
if (Props.showProgressBar && maxLevel > 0)
{
stringBuilder.AppendLine();
stringBuilder.AppendLine(GetProgressBar(currentLevel, maxLevel, Props.needCost));
}
// 显示状态信息
if (!canCast)
{
stringBuilder.AppendLine();
string insufficientText = "ARA_NeedCost_Insufficient".Translate(GetNeedLabel());
stringBuilder.AppendLine($" <color=red>✗ {insufficientText}</color>");
}
else
{
stringBuilder.AppendLine();
string canCastText = "ARA_NeedCost_CanCast".Translate();
stringBuilder.AppendLine($" <color=green>✓ {canCastText}</color>");
}
return stringBuilder.ToString().TrimEndNewlines();
}
// 文本进度条显示
private string GetProgressBar(float current, float max, float cost)
{
const int barLength = 20;
float fillPercent = current / max;
float costPercent = cost / max;
int fillChars = (int)(barLength * fillPercent);
int costChars = (int)(barLength * costPercent);
StringBuilder bar = new StringBuilder();
bar.Append(" [");
// 已填充部分
for (int i = 0; i < barLength; i++)
{
if (i < fillChars)
{
if (i < costChars)
{
bar.Append("<color=green>█</color>"); // 消耗部分
}
else
{
bar.Append("<color=yellow>█</color>"); // 剩余部分
}
}
else
{
bar.Append("<color=grey>░</color>"); // 未填充部分
}
}
bar.Append("]");
return bar.ToString();
}
// 获取 Need 的显示标签
private string GetNeedLabel()
{
return Props.customLabel ?? Props.needDef.label;
}
// 消耗 Need
private void ConsumeNeed()
{
Pawn caster = parent.pawn;
if (caster != null && caster.needs != null)
{
@@ -50,5 +143,47 @@ namespace ArachnaeSwarm
}
}
}
// 检查是否有足够的 Need 来施放技能
private bool HasEnoughNeed()
{
Pawn caster = parent.pawn;
if (caster != null && caster.needs != null)
{
if (caster.needs.TryGetNeed(Props.needDef, out Need need))
{
return need.CurLevel >= Props.needCost;
}
}
return false;
}
// 获取当前 Need 水平
private float GetCurrentNeedLevel()
{
Pawn caster = parent.pawn;
if (caster != null && caster.needs != null)
{
if (caster.needs.TryGetNeed(Props.needDef, out Need need))
{
return need.CurLevel;
}
}
return 0f;
}
// 获取最大 Need 水平
private float GetMaxNeedLevel()
{
Pawn caster = parent.pawn;
if (caster != null && caster.needs != null)
{
if (caster.needs.TryGetNeed(Props.needDef, out Need need))
{
return need.MaxLevel;
}
}
return 1f;
}
}
}
}