This commit is contained in:
2025-12-13 16:12:11 +08:00
parent d477477043
commit b62a12bc36
3 changed files with 13 additions and 0 deletions

View File

@@ -129,6 +129,7 @@ namespace WulaFallenEmpire.EventSystem.AI.Tools
float baseMaxPoints = StorytellerUtility.DefaultThreatPointsNow(map);
float adjustedMaxPoints = baseMaxPoints * goodwillFactor * 1.5f;
Log.Message($"[WulaAI] send_reinforcement: totalCost={totalCost}, adjustedMaxPoints={adjustedMaxPoints}");
if (totalCost > adjustedMaxPoints)
{
return $"Error: Total cost {totalCost} exceeds limit {adjustedMaxPoints:F0}. Reduce unit count.";

View File

@@ -18,6 +18,7 @@ namespace WulaFallenEmpire.EventSystem.AI.UI
private string _inputText = "";
private bool _isThinking = false;
private Vector2 _scrollPosition = Vector2.zero;
private bool _scrollToBottom = false;
private List<AITool> _tools = new List<AITool>();
private Dictionary<int, Texture2D> _portraits = new Dictionary<int, Texture2D>();
private const int MaxHistoryTokens = 100000;
@@ -472,6 +473,11 @@ When the player requests any form of resources, you MUST follow this multi-turn
_history.Add(("assistant", rawResponse));
}
}
if (!string.IsNullOrEmpty(ParseResponseForDisplay(rawResponse)))
{
_scrollToBottom = true;
}
if (parts.Length > 1)
{
_options.Clear();
@@ -567,6 +573,11 @@ When the player requests any form of resources, you MUST follow this multi-turn
viewHeight += Text.CalcHeight(text, rect.width - 16f) + padding;
}
Rect viewRect = new Rect(0f, 0f, rect.width - 16f, viewHeight);
if (_scrollToBottom)
{
_scrollPosition.y = float.MaxValue;
_scrollToBottom = false;
}
Widgets.BeginScrollView(rect, ref _scrollPosition, viewRect);
float curY = 0f;
for (int i = 0; i < filteredHistory.Count; i++)
@@ -689,6 +700,7 @@ When the player requests any form of resources, you MUST follow this multi-turn
private async void SelectOption(string text)
{
_history.Add(("user", text));
_scrollToBottom = true;
await GenerateResponse();
}