Skip to content

Commit

Permalink
Merge branch 'feat/languages' of https://github.com/Mnemotechnician/f…
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxoTrystan committed Dec 18, 2023
2 parents 5c4eff7 + 731f3ee commit 1f2aa4c
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Content.Server/Language/LanguageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void OnInitLanguageSpeaker(EntityUid uid, LanguageSpeakerComponent compo
{
if (string.IsNullOrEmpty(component.CurrentLanguage))
{
component.CurrentLanguage = component.SpokenLanguages.FirstOrDefault(Universal.ID);
component.CurrentLanguage = component.SpokenLanguages.FirstOrDefault(UniversalPrototype);
}
}

Expand Down Expand Up @@ -135,7 +135,7 @@ public bool CanUnderstand(EntityUid listener,
LanguagePrototype language,
LanguageSpeakerComponent? listenerLanguageComp = null)
{
if (language.ID == Universal.ID || HasComp<UniversalLanguageSpeakerComponent>(listener))
if (language.ID == UniversalPrototype || HasComp<UniversalLanguageSpeakerComponent>(listener))
return true;

var listenerLanguages = GetLanguages(listener, listenerLanguageComp)?.UnderstoodLanguages;
Expand Down Expand Up @@ -240,7 +240,7 @@ private static bool IsSentenceEnd(char ch)
RaiseLocalEvent(speaker, ev, true);

if (ev.CurrentLanguage.Length == 0)
ev.CurrentLanguage = comp?.CurrentLanguage ?? Universal.ID; // Fall back to account for admemes like admins possessing a bread
ev.CurrentLanguage = !string.IsNullOrEmpty(comp.CurrentLanguage) ? comp.CurrentLanguage : UniversalPrototype; // Fall back to account for admemes like admins possessing a bread
return ev;
}

Expand Down Expand Up @@ -269,7 +269,7 @@ public void EnsureValidLanguage(EntityUid entity, LanguageSpeakerComponent? comp

if (langs != null && !langs.SpokenLanguages.Contains(comp!.CurrentLanguage, StringComparer.Ordinal))
{
comp.CurrentLanguage = langs.SpokenLanguages.FirstOrDefault(Universal.ID);
comp.CurrentLanguage = langs.SpokenLanguages.FirstOrDefault(UniversalPrototype);
}
}

Expand Down
15 changes: 9 additions & 6 deletions Content.Shared/Language/Systems/SharedLanguageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ namespace Content.Shared.Language.Systems;

public abstract class SharedLanguageSystem : EntitySystem
{
[ValidatePrototypeId<LanguagePrototype>]
public static readonly string GalacticCommonPrototype = "GalacticCommon";
[ValidatePrototypeId<LanguagePrototype>]
public static readonly string UniversalPrototype = "Universal";
public static LanguagePrototype GalacticCommon { get; private set; } = default!;
public static LanguagePrototype Universal { get; private set; } = default!;

[Dependency] private readonly SharedActionsSystem _action = default!;
private static LanguagePrototype? _galacticCommon;
private static LanguagePrototype? _universal;
public static LanguagePrototype GalacticCommon { get => _galacticCommon!; }
public static LanguagePrototype Universal { get => _universal!; }
[Dependency] protected readonly IPrototypeManager _prototype = default!;
[Dependency] protected readonly IRobustRandom _random = default!;
protected ISawmill _sawmill = default!;

public override void Initialize()
{
_galacticCommon = _prototype.Index<LanguagePrototype>("GalacticCommon");
_universal = _prototype.Index<LanguagePrototype>("Universal");
GalacticCommon = _prototype.Index<LanguagePrototype>("GalacticCommon");
Universal = _prototype.Index<LanguagePrototype>("Universal");
_sawmill = Logger.GetSawmill("language");

SubscribeLocalEvent<LanguageSpeakerComponent, MapInitEvent>(OnInit);
Expand Down
41 changes: 41 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
task: SimpleHostileCompound
- type: Puller
needsHands: true
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- Bee
Expand Down Expand Up @@ -221,6 +222,9 @@
- type: EggLayer
eggSpawn:
- id: FoodEgg
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: chicken
- type: LanguageSpeaker
speaks:
- Chicken
Expand Down Expand Up @@ -321,6 +325,9 @@
- type: EggLayer
eggSpawn:
- id: FoodEgg
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: duck
- type: LanguageSpeaker
speaks:
- Duck
Expand Down Expand Up @@ -514,6 +521,7 @@
- type: GuideHelp
guides:
- Chef
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- Cow
Expand Down Expand Up @@ -650,6 +658,7 @@
- type: HTN
rootTask:
task: RuminantHostileCompound
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- Sheep
Expand Down Expand Up @@ -703,6 +712,7 @@
- type: NpcFactionMember
factions:
- Passive
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- Duck
Expand Down Expand Up @@ -762,6 +772,7 @@
rootTask:
task: SimpleHostileCompound
- type: Puller
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- Monkey
Expand Down Expand Up @@ -798,6 +809,9 @@
- type: Inventory
speciesId: kangaroo
templateId: kangaroo
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: kangaroo
- type: LanguageSpeaker
speaks:
- Kangaroo
Expand Down Expand Up @@ -950,6 +964,8 @@
spawned:
- id: FoodMeat
amount: 3
# Frontier - languages mechanic
# - type: MonkeyAccent
- type: LanguageSpeaker
speaks:
- Monkey
Expand Down Expand Up @@ -1084,6 +1100,9 @@
spawned:
- id: FoodMeatRat
amount: 1
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: mouse
- type: LanguageSpeaker
speaks:
- Mouse
Expand Down Expand Up @@ -1588,6 +1607,7 @@
spawned:
- id: FoodMeat
amount: 3
# - type: MonkeyAccent
- type: Puller
- type: CanHostGuardian
- type: NpcFactionMember
Expand All @@ -1610,6 +1630,7 @@
- type: AutoTraitor
giveUplink: false
giveObjectives: false
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- Monkey
Expand Down Expand Up @@ -1728,6 +1749,9 @@
- type: MeleeChemicalInjector
transferAmount: 0.75
solution: melee
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: xeno
- type: LanguageSpeaker
speaks:
- Xeno
Expand Down Expand Up @@ -1984,6 +2008,7 @@
- type: Tag
tags:
- VimPilot
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- Dog
Expand Down Expand Up @@ -2035,6 +2060,9 @@
spawned:
- id: FoodMeat
amount: 2
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: dog
- type: LanguageSpeaker
speaks:
- Dog
Expand Down Expand Up @@ -2189,6 +2217,9 @@
spawned:
- id: FoodMeat
amount: 3
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: cat
- type: LanguageSpeaker
speaks:
- Cat
Expand Down Expand Up @@ -2283,6 +2314,9 @@
spawned:
- id: FoodMeat
amount: 3
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: cat
- type: LanguageSpeaker
speaks:
- Cat
Expand Down Expand Up @@ -2432,6 +2466,7 @@
- type: Tag
tags:
- VimPilot
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- Dog
Expand Down Expand Up @@ -2526,6 +2561,9 @@
spawned:
- id: FoodMeat
amount: 1
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: mouse
- type: LanguageSpeaker
speaks:
- Mouse
Expand Down Expand Up @@ -2635,6 +2673,9 @@
interactSuccessSpawn: EffectHearts
interactSuccessSound:
path: /Audio/Animals/pig_oink.ogg
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: pig
- type: LanguageSpeaker
speaks:
- Pig
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/carp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
- type: HTN
rootTask:
task: DragonCarpCompound
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- GalacticCommon
Expand Down
7 changes: 7 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/pets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@
spawned:
- id: FoodMeat
amount: 3
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: dog
- type: LanguageSpeaker
speaks:
- Dog
Expand Down Expand Up @@ -595,6 +598,9 @@
types:
Piercing: 8
Poison: 8
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: xeno
- type: LanguageSpeaker
speaks:
- Xeno
Expand Down Expand Up @@ -742,6 +748,7 @@
attributes:
proper: true
gender: male
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- Monkey
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
- type: GuideHelp
guides:
- MinorAntagonists
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- Mouse
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/space.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@
- type: MeleeChemicalInjector
solution: melee
transferAmount: 3
# Frontier - languages mechanic
# - type: ReplacementAccent
# accent: xeno
- type: LanguageSpeaker
speaks:
- Xeno
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
- type: Tag
tags:
- CannotSuicide
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- GalacticCommon
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Mobs/Player/guardian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
map: [ "enum.DamageStateVisualLayers.BaseUnshaded" ]
color: "#40a7d7"
shader: unshaded
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- GalacticCommon
Expand Down Expand Up @@ -255,6 +256,7 @@
- type: HTN
rootTask:
task: SimpleHumanoidHostileCompound
# Frontier - languages mechanic
- type: LanguageSpeaker
speaks:
- GalacticCommon
Expand Down

0 comments on commit 1f2aa4c

Please sign in to comment.