Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Co-authored-by: Paul <ritter.paul1@googlemail.com>
This commit is contained in:
Pancake
2021-12-21 12:31:20 -08:00
committed by GitHub
parent f4d8ec1b35
commit f334f4a4b9
9 changed files with 160 additions and 1 deletions

View File

@@ -84,6 +84,7 @@ namespace Content.Client.Entry
factory.RegisterClass<SharedGravityGeneratorComponent>();
factory.RegisterClass<SharedAMEControllerComponent>();
prototypes.RegisterIgnore("accent");
prototypes.RegisterIgnore("material");
prototypes.RegisterIgnore("reaction"); //Chemical reactions only needed by server. Reactions checks are server-side.
prototypes.RegisterIgnore("gasReaction");

View File

@@ -317,7 +317,9 @@ namespace Content.Client.Entry
"Udder",
"PneumaticCannon",
"Spreader",
"GrowingKudzu"
"GrowingKudzu",
"MonkeyAccent",
"ReplacementAccent"
};
}
}

View File

@@ -0,0 +1,7 @@
using Robust.Shared.GameObjects;
namespace Content.Server.Speech.Components;
[RegisterComponent]
[ComponentProtoName("MonkeyAccent")]
public sealed class MonkeyAccentComponent : Component {}

View File

@@ -0,0 +1,30 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.ViewVariables;
namespace Content.Server.Speech.Components
{
[Prototype("accent")]
public sealed class ReplacementAccentPrototype : IPrototype
{
[ViewVariables]
[DataField("id", required: true)]
public string ID { get; } = default!;
[DataField("words")]
public string[] Words = default!;
}
/// <summary>
/// Replaces any spoken sentences with a random word.
/// </summary>
[RegisterComponent]
[ComponentProtoName("ReplacementAccent")]
public class ReplacementAccentComponent : Component
{
[DataField("accent", customTypeSerializer: typeof(PrototypeIdSerializer<ReplacementAccentPrototype>), required: true)]
public string Accent = default!;
}
}

View File

@@ -0,0 +1,67 @@
using System.Text;
using Content.Server.Speech.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Random;
namespace Content.Server.Speech.EntitySystems;
public sealed class MonkeyAccentSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
SubscribeLocalEvent<MonkeyAccentComponent, AccentGetEvent>(OnAccent);
}
public string Accentuate(string message)
{
var words = message.Split();
var accentedMessage = new StringBuilder(message.Length + 2);
for (var i = 0; i < words.Length; i++)
{
var word = words[i];
if (_random.NextDouble() >= 0.5)
{
if (word.Length > 1)
{
foreach (var _ in word)
{
accentedMessage.Append('O');
}
if (_random.NextDouble() >= 0.3)
accentedMessage.Append('K');
}
else
accentedMessage.Append('O');
}
else
{
foreach (var _ in word)
{
if (_random.NextDouble() >= 0.8)
accentedMessage.Append('H');
else
accentedMessage.Append('A');
}
}
if (i < words.Length - 1)
accentedMessage.Append(' ');
}
accentedMessage.Append('!');
return accentedMessage.ToString();
}
private void OnAccent(EntityUid uid, MonkeyAccentComponent component, AccentGetEvent args)
{
args.Message = Accentuate(args.Message);
}
}

View File

@@ -0,0 +1,30 @@
using Content.Server.Speech.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.Speech.EntitySystems
{
// TODO: Code in-game languages and make this a language
/// <summary>
/// Replaces any spoken sentences with a random word.
/// </summary>
public class ReplacementAccentSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
SubscribeLocalEvent<ReplacementAccentComponent, AccentGetEvent>(OnAccent);
}
private void OnAccent(EntityUid uid, ReplacementAccentComponent component, AccentGetEvent args)
{
var words = _proto.Index<ReplacementAccentPrototype>(component.Accent).Words;
args.Message = words.Length != 0 ? _random.Pick(words) : "";
}
}
}

View File

@@ -370,6 +370,7 @@
- type: FireVisualizer
sprite: Mobs/Effects/onfire.rsi
normalState: Monkey_burning
- type: MonkeyAccent
- type: entity
name: mouse

View File

@@ -33,6 +33,8 @@
normal: corgi
crit: corgi_dead
dead: corgi_dead
- type: ReplacementAccent
accent: dog
- type: entity
name: Ian
@@ -85,6 +87,8 @@
normal: cat
crit: cat_dead
dead: cat_dead
- type: ReplacementAccent
accent: cat
- type: entity
name: calico cat

View File

@@ -0,0 +1,17 @@
- type: accent
id: cat
words:
- Meow!
- Mow.
- Mrrrow!
- Hhsss!
- Brrow
- type: accent
id: dog
words:
- Bark!
- Bork!
- Woof!
- Arf.
- Grrr.