The assistant explains each thing once, ever; only the twister warning and 'not enough money' come again

What she has said is kept between games (not by the test bots). Loc key list line numbers refreshed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-11-17 16:39:45 +06:00
parent 77f533e390
commit d97f2e844d
3 changed files with 74 additions and 44 deletions

View File

@ -38,11 +38,38 @@ namespace GrassCutter
["asst_ufo"] = "[nervous] Something is coming down out of the sky. [pause] I'm sure it's fine.",
};
// how long before a line may be said again, seconds (the rest: three minutes)
// the few lines she may say again, and how long after, seconds. Everything else she explains once, ever: players got
// tired of hearing how the depot works every four minutes
static readonly Dictionary<string, float> Rest = new Dictionary<string, float>
{
["asst_hello"] = 1e9f, ["asst_drive"] = 1e9f, ["asst_nocash"] = 60f, ["asst_thrown"] = 90f, ["asst_full"] = 240f, ["asst_hopper"] = 240f,
["asst_twister"] = 600f, ["asst_nocash"] = 300f,
};
const string HeardKey = "assistant_heard";
static HashSet<string> s_heard;
static bool s_forgot;
/// <summary>Lines this player has already heard, kept between games.</summary>
static HashSet<string> Heard
{
get
{
if (s_heard == null)
{
s_heard = new HashSet<string>();
// the test bots run on someone's own PC: they neither read nor fill that player's list
if (!CommandLine.Has("-autodemo"))
foreach (var k in PlayerPrefs.GetString(HeardKey, "").Split(',')) if (k.Length > 0) s_heard.Add(k);
}
return s_heard;
}
}
static void MarkHeard(string line)
{
if (s_forgot || Rest.ContainsKey(line) || !Heard.Add(line) || CommandLine.Has("-autodemo")) return;
PlayerPrefs.SetString(HeardKey, string.Join(",", Heard));
PlayerPrefs.Save();
}
const float StaleAfter = 25f;
const int PicW = 300, PicH = 380;
@ -71,7 +98,8 @@ namespace GrassCutter
public static void Say(string line)
{
if (!I || !Lines.ContainsKey(line) || !GameSettings.Tips) return;
if (I._said.TryGetValue(line, out var at) && Time.time - at < (Rest.TryGetValue(line, out var r) ? r : 180f)) return;
if (!s_forgot && !Rest.ContainsKey(line) && Heard.Contains(line)) return;
if (I._said.TryGetValue(line, out var at) && Time.time - at < (Rest.TryGetValue(line, out var r) ? r : 1e9f)) return;
foreach (var q in I._queue) if (q.line == line) return;
// the greeting goes first, whatever was asked before it
if (line == "asst_hello" && I._queue.Count > 0)
@ -89,6 +117,7 @@ namespace GrassCutter
public static void Forget()
{
if (I) I._said.Clear();
s_forgot = true;
}
/// <summary>Stops her mid-sentence (the game is ending, a film starts).</summary>
@ -112,6 +141,7 @@ namespace GrassCutter
// what's no longer news isn't said
if (Time.time - at > StaleAfter) return;
_said[line] = Time.time;
MarkHeard(line);
StartCoroutine(Talk(line));
}