mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-15 03:31:44 +01:00
* maybeAccentuate * accentuate examine nodes * working prototype * random accentuator * fix SingleAccentuator.cs * french, mumble, slurred * mobster, pirate, stutter * remove examine prediction (for one day) * random accents per examine, not per sentence * Revert "random accents per examine, not per sentence" This reverts commit 0dfa644bb760e4b3f760f43db8870f43ea75e64d. * crew manifest * tweak examine reaccentuation chance * alert level announcement * event centcom announcements * tweak accent system signatures * nuke annoucement, tweak manifest chance * accentuation rarer and a bit more messed up * examine tooltips * more centcom announcements * reformat * sophisticated reformatting * less * tweak --------- Co-authored-by: Milon <milonpl.git@proton.me>
67 lines
2.1 KiB
C#
67 lines
2.1 KiB
C#
using Robust.Shared.Random;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Server.Speech.EntitySystems;
|
|
|
|
public static class RandomAccentuator
|
|
{
|
|
private const float DefaultAccentuationChance = 0.25f;
|
|
|
|
private const float DefaultReaccentuationChance = 0.15f;
|
|
|
|
private const float MaxReaccentuations = 4;
|
|
|
|
public static string MaybeAccentuate(string message,
|
|
float chance = DefaultAccentuationChance,
|
|
float reaccentuationChance = DefaultReaccentuationChance)
|
|
{
|
|
var random = IoCManager.Resolve<IRobustRandom>();
|
|
var singleAccentuator = new SingleAccentuator();
|
|
return random.Prob(chance)
|
|
? MaybeAccentuateDirect(message, singleAccentuator, random, reaccentuationChance)
|
|
: message;
|
|
}
|
|
|
|
public static FormattedMessage MaybeAccentuate(FormattedMessage message,
|
|
float chance = DefaultAccentuationChance,
|
|
float reaccentuationChance = DefaultReaccentuationChance)
|
|
{
|
|
var random = IoCManager.Resolve<IRobustRandom>();
|
|
var singleAccentuator = new SingleAccentuator();
|
|
var newMessage = new FormattedMessage();
|
|
|
|
foreach (var node in message)
|
|
{
|
|
if (random.Prob(chance) && node.Name is null && node.Value.TryGetString(out var text) &&
|
|
!string.IsNullOrWhiteSpace(text))
|
|
{
|
|
var accentedText = MaybeAccentuateDirect(text, singleAccentuator, random, reaccentuationChance);
|
|
newMessage.PushTag(new MarkupNode(accentedText));
|
|
}
|
|
else
|
|
{
|
|
newMessage.PushTag(node);
|
|
}
|
|
}
|
|
|
|
return newMessage;
|
|
}
|
|
|
|
private static string MaybeAccentuateDirect(string message,
|
|
SingleAccentuator singleAccentuator,
|
|
IRobustRandom random,
|
|
float reaccentuationChance)
|
|
{
|
|
for (var i = 0; i < MaxReaccentuations; i++)
|
|
{
|
|
if (i > 0 && !random.Prob(reaccentuationChance))
|
|
continue;
|
|
|
|
singleAccentuator.NextSystem();
|
|
message = singleAccentuator.Accentuate(message);
|
|
}
|
|
|
|
return message;
|
|
}
|
|
}
|