Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnemotechnician committed Jun 27, 2024
1 parent 6adc50d commit d9d74de
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
14 changes: 12 additions & 2 deletions Content.Shared/Language/ObfuscationMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ namespace Content.Shared.Language;
[ImplicitDataDefinitionForInheritors]
public abstract partial class ObfuscationMethod
{
public static readonly ObfuscationMethod Default = new ReplacementObfuscation();
/// <summary>
/// The fallback obfuscation method, replaces the message with the string "&lt;?&gt;".
/// </summary>
public static readonly ObfuscationMethod Default = new ReplacementObfuscation
{
Replacement = new List<string> { "<?>" }
};

/// <summary>
/// Obfuscates the provided message and writes the result into the provided StringBuilder.
/// Implementations should use the context's pseudo-random number generator and provide stable obfuscations.
/// </summary>
internal abstract void Obfuscate(StringBuilder builder, string message, SharedLanguageSystem context);

/// <summary>
Expand Down Expand Up @@ -36,7 +46,7 @@ public partial class ReplacementObfuscation : ObfuscationMethod

internal override void Obfuscate(StringBuilder builder, string message, SharedLanguageSystem context)
{
var idx = context.PseudoRandomNumber(0, 0, Replacement.Count - 1);
var idx = context.PseudoRandomNumber(message.GetHashCode(), 0, Replacement.Count - 1);
builder.Append(Replacement[idx]);
}
}
Expand Down
20 changes: 10 additions & 10 deletions Resources/Prototypes/Entities/Objects/Devices/translators.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- type: entity
abstract: true
id: TranslatorUnpowered
parent: [ BaseItem ]
parent: BaseItem
name: translator
description: Translates speech.
components:
Expand Down Expand Up @@ -36,7 +36,7 @@
- type: entity
abstract: true
id: TranslatorEmpty
parent: [ Translator ]
parent: Translator
suffix: Empty
components:
- type: ItemSlots
Expand All @@ -49,7 +49,7 @@
id: CanilunztTranslator
parent: [ TranslatorEmpty ]
name: Canilunzt translator
description: Translates speech between Canilunzt and Galactic Common.
description: Translates speech between Canilunzt and Galactic Common, allowing your local yeepers to communicate with the locals and vice versa!
components:
- type: HandheldTranslator
spoken:
Expand All @@ -66,7 +66,7 @@
id: BubblishTranslator
parent: [ TranslatorEmpty ]
name: Bubblish translator
description: Translates speech between Bubblish and Galactic Common.
description: Translates speech between Bubblish and Galactic Common, helping communicate with slimes and slime people.
components:
- type: HandheldTranslator
spoken:
Expand All @@ -83,7 +83,7 @@
id: NekomimeticTranslator
parent: [ TranslatorEmpty ]
name: Nekomimetic translator
description: Translates speech between Nekomimetic and Galactic Common. Why would you want that?
description: Translates speech between Nekomimetic and Galactic Common, enabling you to communicate with your pet cats.
components:
- type: HandheldTranslator
spoken:
Expand All @@ -100,7 +100,7 @@
id: DraconicTranslator
parent: [ TranslatorEmpty ]
name: Draconic translator
description: Translates speech between Draconic and Galactic Common.
description: Translates speech between Draconic and Galactic Common, making it easier to understand your local Uniathi.
components:
- type: HandheldTranslator
spoken:
Expand Down Expand Up @@ -134,7 +134,7 @@
id: RootSpeakTranslator
parent: [ TranslatorEmpty ]
name: RootSpeak translator
description: Translates speech between RootSpeak and Galactic Common. Like a true plant?
description: Translates speech between RootSpeak and Galactic Common. You may now speak for the trees.
components:
- type: HandheldTranslator
spoken:
Expand All @@ -151,7 +151,7 @@
id: MofficTranslator
parent: [ TranslatorEmpty ]
name: Moffic translator
description: Translates speech between Moffic and Galactic Common. Like a true moth... or bug?
description: Translates speech between Moffic and Galactic Common, helping you understand the buzzes of your pet mothroach!
components:
- type: HandheldTranslator
spoken:
Expand All @@ -168,7 +168,7 @@
id: XenoTranslator
parent: [ TranslatorEmpty ]
name: Xeno translator
description: Translates speech between Xeno and Galactic Common. Not sure if that will help.
description: Translates speech between Xeno and Galactic Common. This will probably not help you survive an encounter, though.
components:
- type: HandheldTranslator
spoken:
Expand All @@ -184,7 +184,7 @@
id: AnimalTranslator
parent: [ TranslatorEmpty ]
name: Animal translator
description: Translates all the cutes noises that animals make into a more understandable form!
description: Translates all the cutes noises that most animals make into a more understandable form!
components:
- type: HandheldTranslator
understood:
Expand Down
6 changes: 3 additions & 3 deletions Resources/Prototypes/Language/languages.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# The universal language, assumed if the entity has a UniversalLanguageSpeakerComponent.
# Do not use otherwise. Try to use the respective component instead of this language.
# Do not use otherwise. Making an entity explicitly understand/speak this language will NOT have the desired effect.
- type: language
id: Universal
obfuscation:
!type:ReplacementObfuscation # Should never be used anyway
!type:ReplacementObfuscation
replacement:
- "*incomprehensible*"
- "*incomprehensible*" # Never actually used

# The common galactic tongue.
- type: language
Expand Down

0 comments on commit d9d74de

Please sign in to comment.