main cult

This commit is contained in:
EnefFlow
2024-01-27 15:19:52 +03:00
committed by Aviu00
parent 6310813ce6
commit 4fab8188f0
429 changed files with 12281 additions and 9 deletions

View File

@@ -0,0 +1,34 @@
namespace Content.Shared.White.Cult.Systems;
/// <summary>
/// Thats need for chat perms update
/// </summary>
public sealed class CultistSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CultistComponent, ComponentStartup>(OnInit);
SubscribeLocalEvent<CultistComponent, ComponentShutdown>(OnRemove);
}
private void OnInit(EntityUid uid, CultistComponent component, ComponentStartup args)
{
RaiseLocalEvent(new EventCultistComponentState(true));
}
private void OnRemove(EntityUid uid, CultistComponent component, ComponentShutdown args)
{
RaiseLocalEvent(new EventCultistComponentState(false));
}
}
public sealed class EventCultistComponentState
{
public bool Created { get; }
public EventCultistComponentState(bool state)
{
Created = state;
}
}

View File

@@ -0,0 +1,55 @@
using Robust.Shared.Random;
namespace Content.Shared.White.Cult.Systems;
/// <summary>
/// Words generator for whisper
/// </summary>
public sealed class CultistWordGeneratorManager
{
private const string Vowels = "aeiou";
private const string Consonants = "bcdfghjklmnpqrstvwxyz";
[Dependency] private readonly IRobustRandom _random = default!;
public string GenerateText(string text)
{
var content = text.Split(' ');
var wordsAmount = content.Length;
if (wordsAmount <= 0)
return "";
for (var i = 0; i < wordsAmount; i++)
{
content[i] = GenerateWord(content[i].Length) + " ";
}
return string.Join("", content);
}
private string GenerateWord(int length)
{
if (length <= 0)
throw new ArgumentException("Word length must be greater than zero.");
var word = "";
for (var i = 0; i < length; i++)
{
var isVowel = (i % 2 == 0); // Alternate between vowels and consonants
var randomChar = GetRandomChar(isVowel ? Vowels : Consonants);
word += randomChar;
}
return word;
}
private char GetRandomChar(string characters)
{
var index = _random.Next(characters.Length);
return characters[index];
}
}