main cult
This commit is contained in:
34
Content.Shared/_White/Cult/Systems/CultistSystem.cs
Normal file
34
Content.Shared/_White/Cult/Systems/CultistSystem.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user