From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:23:40 +0000 (+1000) Subject: Fix tippy speech time (#36616) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=a436032963c1c382deb10f14a38c3a1fb52c60a0;p=space-station-14.git Fix tippy speech time (#36616) --- diff --git a/Content.Server/Tips/TipsSystem.cs b/Content.Server/Tips/TipsSystem.cs index 2f7edd45d6..effbb7ba87 100644 --- a/Content.Server/Tips/TipsSystem.cs +++ b/Content.Server/Tips/TipsSystem.cs @@ -35,6 +35,16 @@ public sealed class TipsSystem : EntitySystem private string _tipsDataset = ""; private float _tipTippyChance; + /// + /// Always adds this time to a speech message. This is so really short message stay around for a bit. + /// + private const float SpeechBuffer = 3f; + + /// + /// Expected reading speed. + /// + private const float Wpm = 180f; + [ViewVariables(VVAccess.ReadWrite)] private TimeSpan _nextTipTime = TimeSpan.Zero; @@ -127,6 +137,8 @@ public sealed class TipsSystem : EntitySystem 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]); @@ -183,6 +195,12 @@ public sealed class TipsSystem : EntitySystem _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(_tipsDataset, out var tips)) @@ -194,7 +212,7 @@ public sealed class TipsSystem : EntitySystem if (_random.Prob(_tipTippyChance)) { var ev = new TippyEvent(msg); - ev.SpeakTime = 1 + tip.Length * 0.05f; + ev.SpeakTime = GetSpeechTime(msg); RaiseNetworkEvent(ev); } else { diff --git a/Content.Shared/Tips/TippyEvent.cs b/Content.Shared/Tips/TippyEvent.cs index 4370e9c822..e5dc0b7f35 100644 --- a/Content.Shared/Tips/TippyEvent.cs +++ b/Content.Shared/Tips/TippyEvent.cs @@ -13,6 +13,8 @@ public sealed class TippyEvent : EntityEventArgs 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;