private string _tipsDataset = "";
private float _tipTippyChance;
+ /// <summary>
+ /// Always adds this time to a speech message. This is so really short message stay around for a bit.
+ /// </summary>
+ private const float SpeechBuffer = 3f;
+
+ /// <summary>
+ /// Expected reading speed.
+ /// </summary>
+ private const float Wpm = 180f;
+
[ViewVariables(VVAccess.ReadWrite)]
private TimeSpan _nextTipTime = TimeSpan.Zero;
if (args.Length > 3)
ev.SpeakTime = float.Parse(args[3]);
+ else
+ ev.SpeakTime = GetSpeechTime(ev.Msg);
if (args.Length > 4)
ev.SlideTime = float.Parse(args[4]);
_tipTippyChance = value;
}
+ public static float GetSpeechTime(string text)
+ {
+ var wordCount = (float)text.Split().Length;
+ return SpeechBuffer + wordCount * (60f / Wpm);
+ }
+
private void AnnounceRandomTip()
{
if (!_prototype.TryIndex<LocalizedDatasetPrototype>(_tipsDataset, out var tips))
if (_random.Prob(_tipTippyChance))
{
var ev = new TippyEvent(msg);
- ev.SpeakTime = 1 + tip.Length * 0.05f;
+ ev.SpeakTime = GetSpeechTime(msg);
RaiseNetworkEvent(ev);
} else
{
public string Msg;
public string? Proto;
+
+ // TODO: Why are these defaults even here, have the caller specify. This get overriden only most of the time.
public float SpeakTime = 5;
public float SlideTime = 3;
public float WaddleInterval = 0.5f;