Skip to content

Commit

Permalink
additional articles in generated sentences
Browse files Browse the repository at this point in the history
  • Loading branch information
levimhuillet committed May 23, 2024
1 parent e497e0c commit f167ed7
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 16 deletions.
27 changes: 24 additions & 3 deletions Assets/_Code/Data/Bestiary/Facts/Behavior/BFConsume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using ScriptableBake;
using UnityEngine;
using UnityEngine.Serialization;
using static UnityEngine.ParticleSystem;

namespace Aqua
{
Expand Down Expand Up @@ -35,6 +36,10 @@ private BFConsume() : base(BFTypeId.Consume) { }
static public readonly TextId MascNoun = "words.masculineNoun";
static public readonly TextId FemNoun = "words.feminineNoun";

static public readonly TextId OfArticle = "words.articles.of";
static public readonly TextId ByArticle = "words.articles.by";
static public readonly TextId PorArticle = "words.articles.por";


static public void Configure()
{
Expand All @@ -58,18 +63,34 @@ static private IEnumerable<BFFragment> GenerateFragments(BFBase inFact, BFDiscov
if (!bIsLight)
{
yield return BFFragment.CreateAmount(BestiaryUtils.FormatPropertyRate(fact.Amount, fact.Property));
if (Services.Loc.IsCurrentLanguageGendered())
{
yield return BFFragment.CreateLocWord(BestiaryFactFragmentType.Article, OfArticle);
}
}
if (Services.Loc.IsCurrentLanguageGendered()) {
// yield return BFFragment.CreateGenderedLocNoun(BestiaryUtils.Property(fact.Property).ShortLabelId(), BestiaryUtils.Property(fact.Property).GenderId());
// Turns out we don't need gendered articles on water properties
yield return BFFragment.CreateLocNoun(BestiaryUtils.Property(fact.Property).ShortLabelId());
// Turns out we don't need gendered articles on water properties except for light
if (bIsLight) {
yield return BFFragment.CreateGenderedLocNoun(BestiaryUtils.Property(fact.Property).ShortLabelId(), BestiaryUtils.Property(fact.Property).GenderId(), true);
}
else {
yield return BFFragment.CreateLocNoun(BestiaryUtils.Property(fact.Property).ShortLabelId());
}
}
else {
yield return BFFragment.CreateLocNoun(BestiaryUtils.Property(fact.Property).ShortLabelId());
}
if (bIsLight)
{
// TODO: add gendered light
if (Services.Loc.IsCurrentLanguageGendered())
{
yield return BFFragment.CreateLocWord(BestiaryFactFragmentType.Article, PorArticle);
}
if (Services.Loc.IsCurrentLanguageGendered())
{
yield return BFFragment.CreateLocWord(BestiaryFactFragmentType.Article, ByArticle);
}
yield return BFFragment.CreateAmount(BestiaryUtils.FormatPropertyRate(fact.Amount, fact.Property));
}
}
Expand Down
11 changes: 11 additions & 0 deletions Assets/_Code/Data/Bestiary/Facts/Behavior/BFEat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ private BFEat() : base(BFTypeId.Eat) { }
static public readonly TextId CatchDisabledSentence = "factFormat.catch.disabled";
static public readonly TextId EatSentenceStressed = "factFormat.eat.stressed";
static public readonly TextId EatRateSentenceStressed = "factFormat.eat.stressed.rate";
static public readonly TextId OfArticle = "words.articles.of";
static public readonly TextId ByArticle = "words.articles.by";


static public void Configure()
{
Expand All @@ -55,6 +58,10 @@ static private IEnumerable<BFFragment> GenerateFragments(BFBase inFact, BFDiscov
if (BFType.HasRate(inFlags))
{
yield return BFFragment.CreateAmount(BestiaryUtils.FormatMassRate(fact.Amount));
if (Services.Loc.IsCurrentLanguageGendered())
{
yield return BFFragment.CreateLocWord(BestiaryFactFragmentType.Article, OfArticle);
}
}

if (Services.Loc.IsCurrentLanguageGendered() && !BFType.HasRate(inFlags)) {
Expand Down Expand Up @@ -85,6 +92,10 @@ static private IEnumerable<BFFragment> GenerateFragments(BFBase inFact, BFDiscov
if (BFType.HasRate(inFlags))
{
yield return BFFragment.CreateAmount(BestiaryUtils.FormatMassRate(fact.Amount));
if (Services.Loc.IsCurrentLanguageGendered())
{
yield return BFFragment.CreateLocWord(BestiaryFactFragmentType.Article, OfArticle);
}
}
if (Services.Loc.IsCurrentLanguageGendered() && !BFType.HasRate(inFlags))
{
Expand Down
3 changes: 3 additions & 0 deletions Assets/_Code/Data/Bestiary/Facts/Behavior/BFGrow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ private BFGrow() : base(BFTypeId.Grow) { }
static private readonly TextId GrowSentence = "factFormat.grow";
static private readonly TextId GrowSentenceStressed = "factFormat.grow.stressed";

static public readonly TextId OfArticle = "words.articles.of";
static public readonly TextId ByArticle = "words.articles.by";

static public void Configure()
{
BFType.DefineAttributes(BFTypeId.Grow, BFShapeId.Behavior, BFFlags.IsBehavior | BFFlags.SelfTarget, BFDiscoveredFlags.All, CompareStressedPair);
Expand Down
8 changes: 8 additions & 0 deletions Assets/_Code/Data/Bestiary/Facts/Behavior/BFProduce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using BeauUtil;
using ScriptableBake;
using UnityEngine;
using static UnityEngine.ParticleSystem;

namespace Aqua {
[CreateAssetMenu(menuName = "Aqualab Content/Fact/Produce")]
Expand All @@ -23,6 +24,9 @@ private BFProduce() : base(BFTypeId.Produce) { }
static private readonly TextId ProduceSentence = "factFormat.produce";
static private readonly TextId ProduceSentenceStressed = "factFormat.produce.stressed";

static public readonly TextId OfArticle = "words.articles.of";
static public readonly TextId ByArticle = "words.articles.by";

static public void Configure()
{
BFType.DefineAttributes(BFTypeId.Produce, BFShapeId.Behavior, BFFlags.IsBehavior | BFFlags.HasRate, BFDiscoveredFlags.All, Compare);
Expand All @@ -43,6 +47,10 @@ static private IEnumerable<BFFragment> GenerateFragments(BFBase inFact, BFDiscov
}
yield return BFFragment.CreateLocVerb(ProduceVerb);
yield return BFFragment.CreateAmount(BestiaryUtils.FormatPropertyRate(fact.Amount, fact.Property));
if (Services.Loc.IsCurrentLanguageGendered())
{
yield return BFFragment.CreateLocWord(BestiaryFactFragmentType.Article, OfArticle);
}

if (Services.Loc.IsCurrentLanguageGendered())
{
Expand Down
8 changes: 8 additions & 0 deletions Assets/_Code/Data/Bestiary/Facts/Behavior/BFReproduce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using BeauUtil;
using ScriptableBake;
using UnityEngine;
using static UnityEngine.ParticleSystem;

namespace Aqua {
[CreateAssetMenu(menuName = "Aqualab Content/Fact/Reproduce")]
Expand All @@ -25,6 +26,9 @@ private BFReproduce() : base(BFTypeId.Reproduce) { }
static private readonly TextId ReproduceSentenceStressed = "factFormat.reproduce.stressed";
static private readonly TextId ReproduceDisabledSentenceStressed = "factFormat.reproduce.stressed.disabled";

static public readonly TextId OfArticle = "words.articles.of";
static public readonly TextId ByArticle = "words.articles.by";

static public void Configure()
{
BFType.DefineAttributes(BFTypeId.Reproduce, BFShapeId.Behavior, BFFlags.IsBehavior | BFFlags.SelfTarget | BFFlags.HasRate, BFDiscoveredFlags.All, CompareStressedPair);
Expand All @@ -51,6 +55,10 @@ static private IEnumerable<BFFragment> GenerateFragments(BFBase inFact, BFDiscov
else
{
yield return BFFragment.CreateLocVerb(ReproduceVerb);
if (Services.Loc.IsCurrentLanguageGendered())
{
yield return BFFragment.CreateLocWord(BestiaryFactFragmentType.Article, ByArticle);
}
yield return BFFragment.CreateAmount(BestiaryUtils.FormatPercentageRate(fact.Amount));
}
}
Expand Down
10 changes: 10 additions & 0 deletions Assets/_Code/Data/Bestiary/Utils/BestiaryFactFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ static public BFFragment CreateWord(BestiaryFactFragmentType inType, StringSlice
};
}

static public BFFragment CreateLocWord(BestiaryFactFragmentType inType, TextId inWord)
{
return new BFFragment()
{
Type = inType,
String = Services.Loc.Localize(inWord, true)
};
}

static public BFFragment CreateLocNoun(TextId inWord)
{
return new BFFragment()
Expand Down Expand Up @@ -109,5 +118,6 @@ public enum BestiaryFactFragmentType : byte
Conjunction,
Condition,
Image,
Article,
}
}
5 changes: 5 additions & 0 deletions Assets/_Code/UI/Bestiary/FactSentenceTweaks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ private struct TextBackgroundColorPair
[SerializeField] private TextBackgroundColorPair m_AmountColor = TextBackgroundColorPair.Default;
[SerializeField] private TextBackgroundColorPair m_ConjunctionColor = TextBackgroundColorPair.Default;
[SerializeField] private TextBackgroundColorPair m_ConditionColor = TextBackgroundColorPair.Default;
[SerializeField] private TextBackgroundColorPair m_ArticleColor = TextBackgroundColorPair.Default;


#endregion // Inspector

Expand Down Expand Up @@ -150,6 +152,9 @@ private TextBackgroundColorPair FragmentColors(in BFFragment inFragment)
case BestiaryFactFragmentType.Condition:
return m_ConditionColor;

case BestiaryFactFragmentType.Article:
return m_ArticleColor;

default:
throw new ArgumentOutOfRangeException("inFragment.Type");
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/_Content/Bestiary/Critters/BlueTang/BlueTang.asset
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ MonoBehaviour:
m_Source: critters.blueTang.commonName.plural
m_HashValue: 1939586421
m_GenderId:
m_Source: words.feminineNoun
m_HashValue: 1829061279
m_Source: words.masculineNoun
m_HashValue: 3526716989
m_DescriptionId:
m_Source: critters.blueTang.description
m_HashValue: 3775591405
Expand Down
4 changes: 2 additions & 2 deletions Assets/_Content/Bestiary/Critters/Diatoms/Diatoms.asset
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ MonoBehaviour:
m_Source:
m_HashValue: 0
m_GenderId:
m_Source: words.feminineNoun.plural
m_HashValue: 2565478825
m_Source: words.feminineNoun
m_HashValue: 1829061279
m_DescriptionId:
m_Source: critters.diatoms.description
m_HashValue: 199990884
Expand Down
4 changes: 2 additions & 2 deletions Assets/_Content/Bestiary/Critters/Fishers/Fishers.asset
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ MonoBehaviour:
m_Source: critters.fishers.commonName.plural
m_HashValue: 4166645665
m_GenderId:
m_Source: words.masculineNoun.plural
m_HashValue: 4241678267
m_Source: words.masculineNoun
m_HashValue: 3526716989
m_DescriptionId:
m_Source: critters.fishers.description
m_HashValue: 91300497
Expand Down
4 changes: 2 additions & 2 deletions Assets/_Content/Bestiary/Critters/SeaStar/SeaStar.asset
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ MonoBehaviour:
m_Source:
m_HashValue: 0
m_GenderId:
m_Source: words.feminineNoun
m_HashValue: 1829061279
m_Source: words.masculineNoun
m_HashValue: 3526716989
m_DescriptionId:
m_Source: critters.seaStar.description
m_HashValue: 486231416
Expand Down
3 changes: 3 additions & 0 deletions Assets/_Content/Bestiary/FactSentenceTweaks.asset
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ MonoBehaviour:
m_ConditionColor:
Text: {r: 0.007843138, g: 0.3137255, b: 0.2901961, a: 1}
Background: {r: 0.31646922, g: 0.4716981, b: 0.3048238, a: 0}
m_ArticleColor:
Text: {r: 0.007843138, g: 0.3137255, b: 0.2901961, a: 1}
Background: {r: 0.36862746, g: 0.36862746, b: 0.36862746, a: 0}
13 changes: 11 additions & 2 deletions Assets/_Content/Text/ES/ES-Loc.aqloc
Original file line number Diff line number Diff line change
Expand Up @@ -16275,6 +16275,15 @@ Ha estado en bicicleta
:: words.stressed
Estresado

:: words.articles.of
de

:: words.articles.by
un

:: words.articles.por
por

:: fact.whenStressed.label
Al estresarse

Expand Down Expand Up @@ -16353,10 +16362,10 @@ Esta información requiere una {h}clave privada{/h} para descifrarse.
{critter-name}{0}{/critter-name} consume {1} de {property-name}{2}{/property-name} cuando se estresa.

:: factFormat.reduce
{critter-name}{0}{/critter-name} reduce {property-name}{2}{/property-name} por {1}.
{critter-name}{0}{/critter-name} reduce {property-name}{2}{/property-name} por un {1}.

:: factFormat.reduce.stressed
{critter-name}{0}{/critter-name} reduce {property-name}{2}{/property-name} por {1} cuando se estresa.
{critter-name}{0}{/critter-name} reduce {property-name}{2}{/property-name} por un {1} cuando se estresa.

:: factFormat.reproduce
{critter-name}{0}{/critter-name} se reproduce por un {1}.
Expand Down
2 changes: 1 addition & 1 deletion Assets/_Content/Text/ES/SpanishLanguage.asset

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Assets/_Content/Text/facts.aqloc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ The
:: words.feminineNoun.plural
The

:: words.articles.of
of

:: words.articles.by
by

:: words.articles.por
by

# basePath fact

:: whenStressed.label
Expand Down
7 changes: 5 additions & 2 deletions Assets/_Content/WaterProperties/Light.asset
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ MonoBehaviour:
m_ShortLabelId:
m_Source:
m_HashValue: 0
m_GenderId:
m_Source: words.feminineNoun
m_HashValue: 1829061279
m_Icon: {fileID: 21300000, guid: 589d491a260711b44aabb4326740b9dd, type: 3}
m_HiResIconPath:
m_Palette:
Expand All @@ -36,9 +39,8 @@ MonoBehaviour:
serializedVersion: 2
rgba: 4288716960
m_Units: '%'
m_RateUnits:
m_SignificantDigits: 2
m_AdjustFormat:
m_Format:
m_EnvironmentFactFormat:
m_Source: properties.light.sentence
m_HashValue: 968429913
Expand All @@ -57,3 +59,4 @@ MonoBehaviour:
m_MinValue: 0
m_MaxValue: 100
m_DefaultValue: 70
m_ValueScale: 1

0 comments on commit f167ed7

Please sign in to comment.