using System.Linq; using Content.Server.GameTicking; using Content.Server.GameTicking.Rules.Components; using Content.Server.Speech.Components; using Content.Server._White.AspectsSystem.Aspects.Components; using Content.Server._White.AspectsSystem.Base; using Content.Server.GameTicking.Components; using Content.Shared.Mind.Components; using Robust.Shared.Random; using Content.Server._White.Accent.BomzhAccent; namespace Content.Server._White.AspectsSystem.Aspects; public sealed class RandomAccentAspect : AspectSystem { [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly ChatHelper _chatHelper = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(HandleLateJoin); } protected override void Started(EntityUid uid, RandomAccentAspectComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) { base.Started(uid, component, gameRule, args); var query = EntityQueryEnumerator(); while (query.MoveNext(out var ent, out _)) { ApplyRandomAccent(ent); } } private void HandleLateJoin(PlayerSpawnCompleteEvent ev) { var query = EntityQueryEnumerator(); while (query.MoveNext(out var ruleEntity, out _, out var gameRule)) { if (!GameTicker.IsGameRuleAdded(ruleEntity, gameRule)) continue; if (!ev.LateJoin) return; var mob = ev.Mob; ApplyRandomAccent(mob); _chatHelper.SendAspectDescription(mob, Loc.GetString("random-accent-aspect-desc")); } } #region Helpers // TODO: Move this to prototypes. private enum AccentType { Stuttering, Spanish, Slurred, Scrambled, Pirate, Russian, OwO, Lizard, Backwards, Bark, Anxiety, Moth, French, Gnome, Bomzh, Frontallisp } private void ApplyRandomAccent(EntityUid uid) { var allAccents = Enum.GetValues(typeof(AccentType)).Cast().ToList(); var randomIndex = _random.Next(allAccents.Count); var selectedAccent = allAccents[randomIndex]; ApplyAccent(uid, selectedAccent); } private void ApplyAccent(EntityUid uid, AccentType accentType) { switch (accentType) { case AccentType.Stuttering: EntityManager.EnsureComponent(uid); break; case AccentType.Spanish: EntityManager.EnsureComponent(uid); break; case AccentType.Slurred: EntityManager.EnsureComponent(uid); break; case AccentType.Scrambled: EntityManager.EnsureComponent(uid); break; case AccentType.Pirate: EntityManager.EnsureComponent(uid); break; case AccentType.Russian: // Untranslated EntityManager.EnsureComponent(uid); break; case AccentType.OwO: EntityManager.EnsureComponent(uid); break; case AccentType.Lizard: EntityManager.EnsureComponent(uid); break; /* Not funny case AccentType.Backwards: EntityManager.EnsureComponent(uid); break; */ case AccentType.Bark: EntityManager.EnsureComponent(uid); break; case AccentType.Anxiety: var stutter = EntityManager.EnsureComponent(uid); stutter.MatchRandomProb = 0.2f; stutter.FourRandomProb = 0f; stutter.ThreeRandomProb = 0.3f; stutter.CutRandomProb = 0f; break; case AccentType.Moth: EntityManager.EnsureComponent(uid); break; case AccentType.French: // Untranslated EntityManager.EnsureComponent(uid); break; case AccentType.Gnome: EntityManager.EnsureComponent(uid); break; case AccentType.Bomzh: EntityManager.EnsureComponent(uid); break; case AccentType.Frontallisp: EntityManager.EnsureComponent(uid); break; } } #endregion }