Skip to content

Commit

Permalink
* ensure other job-givers refer to mom as Dr Ramirez
Browse files Browse the repository at this point in the history
* test of alternate job graph patching
* test of job prediction parameter loading
* fixed instance of job view node click zone not fully covering secondary job giver click zone
* unified research test logic for easier integration
  • Loading branch information
BeauchesneFieldDay committed Sep 5, 2024
1 parent 7ca2357 commit 202f2c5
Show file tree
Hide file tree
Showing 30 changed files with 5,612 additions and 5,076 deletions.
13 changes: 13 additions & 0 deletions Assets/Resources/Research/AltJobGraphPatch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"kelp-welcome": {
"m_CashReward": 1500
},
"displaced-reef": {
"m_PrerequisiteJobs": [
"kelp-welcome"
]
}
"ScienceTweaks": {
"m_BaseExperiencePerLevel": [25, 50, 100]
}
}
7 changes: 7 additions & 0 deletions Assets/Resources/Research/AltJobGraphPatch.json.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Assets/Resources/Research/JobPredictionCoefficients.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target job,constant,job a,job a co.,job b,job b co.,job c,job c co.,completed tasks co.,completed jobs co.,completed jobs w/ exp > 2 co.,completed jobs w/ model > 2 co.,completed jobs w/ argue > 2 co.,visited biomes co.,session count co.,total playtime co.
displaced-reef,-0.1,kelp-welcome,1,kelp-welcome,0,kelp-welcome,0,0,0,0,0,0,0,0,0
8 changes: 6 additions & 2 deletions Assets/_Code/Data/ContentPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ private class PatchRecord {

#region Apply

static public bool IsPatched() {
return s_AppliedPatch.Assets.Count > 0;
}

static public void Apply(string json) {
Undo();

Expand Down Expand Up @@ -94,7 +98,7 @@ static private void ApplyChanges(PatchRecord record, string json) {
assetField.SetValue(asset, patchedValue);
MarkChanged(asset);

Log.Debug("[ContentPatcher] Patching field '{0}' on asset '{1}'...", fieldKv.Key, assetName);
Log.Msg("[ContentPatcher] Patching field '{0}' on asset '{1}'...", fieldKv.Key, assetName);
}
}

Expand Down Expand Up @@ -335,7 +339,7 @@ static private void MarkChanged(object obj) {
[UnityEditor.InitializeOnLoadMethod]
static private void EditorInitialize() {
EditorApplication.playModeStateChanged += (s) => {
if (s == PlayModeStateChange.ExitingEditMode) {
if (s == PlayModeStateChange.ExitingPlayMode) {
Undo();
}
};
Expand Down
2 changes: 2 additions & 0 deletions Assets/_Code/Scripting/Config/ScriptCharacterDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private struct PortraitDef : IKeyValuePair<StringHash32, Sprite>

[SerializeField] private TextId m_NameId = default;
[SerializeField] private TextId m_ShortNameId = default;
[SerializeField] private TextId m_FormalShortNameId = default;
[SerializeField, AutoEnum] private ScriptActorTypeFlags m_Flags = 0;

[Header("Colors")]
Expand All @@ -53,6 +54,7 @@ private struct PortraitDef : IKeyValuePair<StringHash32, Sprite>

[LeafLookup("Name")] public TextId NameId() { return m_NameId; }
[LeafLookup("ShortName")] public TextId ShortNameId() { return m_ShortNameId.IsEmpty ? m_NameId : m_ShortNameId; }
[LeafLookup("FormalShortName")] public TextId FormalShortNameId() { return m_FormalShortNameId.IsEmpty ? ShortNameId() : m_FormalShortNameId; }
public ScriptActorTypeFlags Flags() { return m_Flags; }

public ColorPalette4? NamePaletteOverride() { return m_OverrideNamePalette ? m_NameColor : new ColorPalette4?(); }
Expand Down
18 changes: 18 additions & 0 deletions Assets/_Code/Scripting/ScriptingService.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private void InitParsers()
m_TagEventParser.AddReplace("nameof", ReplaceNameOf);
m_TagEventParser.AddReplace("pluralnameof", ReplacePluralNameOf);
m_TagEventParser.AddReplace("fullnameof", ReplaceFullNameOf);
m_TagEventParser.AddReplace("formalnameof", ReplaceFormalShortNameOf);
m_TagEventParser.AddReplace("item-count", ReplaceItemCount);
m_TagEventParser.AddReplace('|', "{wait 0.25}");

Expand Down Expand Up @@ -300,6 +301,23 @@ static private string ReplaceFullNameOf(TagData inTag, object inContext)
return ReplaceNameOf(inTag, inContext);
}

static private string ReplaceFormalShortNameOf(TagData inTag, object inContext)
{
if (inTag.Data.StartsWith('@')) {
StringHash32 characterId = inTag.Data.Substring(1);
return Loc.Find(Assets.Character(characterId).FormalShortNameId());
}

ScriptableObject obj = Assets.Find(Script.ParseArg<StringHash32>(inTag.Data, inContext));

ScriptCharacterDef charDef = obj as ScriptCharacterDef;
if (!charDef.IsReferenceNull()) {
return Loc.Find(charDef.FormalShortNameId());
}

return ReplaceNameOf(inTag, inContext);
}

static private readonly char[] ChoiceSplitChars = new char[] { '|' };

#endregion // Replace Callbacks
Expand Down
6 changes: 6 additions & 0 deletions Assets/_Code/Services/State/StateMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,12 @@ public void OnLoad(Action inAction, int priority)
}
}

public void RegisterLoadDependency(AsyncHandle handle) {
if (IsLoadingScene()) {
m_LoadBlockers.PushBack(handle);
}
}

private void ProcessCallbackQueue() {
m_OnLoadQueue.Sort((a, b) => b.Priority - a.Priority);
while(m_OnLoadQueue.TryPopFront(out var action)) {
Expand Down
8 changes: 7 additions & 1 deletion Assets/_Code/_Editor/LocEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,13 @@ static private bool AnyAreLocPackage(string[] assetNames) {

static public void Export(params LeafExport.CustomRule[] customRules) {
LeafExport.CustomRule[] rules = customRules;
ArrayUtils.Add(ref rules, new LeafExport.CustomRule(typeof(LocPackage), (p) => LocPackage.GatherStrings((LocPackage) p)));
ArrayUtils.Add(ref rules, new LeafExport.CustomRule(typeof(LocPackage), (p) => {
if (p.name != "ES-Loc") {
return LocPackage.GatherStrings((LocPackage) p);
} else {
return Array.Empty<KeyValuePair<StringHash32, string>>();
}
}));
ArrayUtils.Add(ref rules, new LeafExport.CustomRule(typeof(IHasLocalizationKeys), (p) => ((IHasLocalizationKeys) p).GetStrings()));
IMethodCache methodCache = Leaf.LeafUtils.CreateMethodCache(typeof(IScriptComponent));
methodCache.LoadStatic();
Expand Down
4 changes: 2 additions & 2 deletions Assets/_Content/Maps/ArcticStation/Interior/Job.Arctic.leaf
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ $choice .action.cancel.currentJob; Nope.
#JobRecommendationHandler(jobAtNotVisitedStation1, jobLocation != "ArcticStation")
@repeat 1
{@$JobGiverId} I can't recommend this one for you yet, Ollie.
I know that {nameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
I know that {formalnameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
{nameof $local:jobId}, I believe it's called.

#JobRecommendationHandler(jobAtNotVisitedStation2, jobLocation != "ArcticStation")
@repeat 1
{@$JobGiverId} Hmm, I wouldn't suggest you try this one yet.
But I know {nameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
But I know {formalnameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
I'd recommend you head there and give {nameof $local:jobId} a try.
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ $choice .action.cancel; No thanks.
#JobRecommendationHandler(jobAtNotVisitedStation1, jobLocation != "ArcticStation")
@repeat 1
{@$JobGiverId} I can't recommend this one for you yet, Ollie.
I know that {nameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
I know that {formalnameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
{nameof $local:jobId}, I believe it's called.

#JobRecommendationHandler(jobAtNotVisitedStation2, jobLocation != "ArcticStation")
@repeat 1
{@$JobGiverId} Hmm, I wouldn't suggest you try this one yet.
But I know {nameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
But I know {formalnameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
I'd recommend you head there and give {nameof $local:jobId} a try.
4 changes: 2 additions & 2 deletions Assets/_Content/Maps/BayouStation/Interior/Job.Bayou.leaf
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ $choice .action.cancel; No thanks.
#JobRecommendationHandler(jobAtNotVisitedStation1, jobLocation != "BayouStation")
@repeat 1
{@$JobGiverId} I can't recommend this one for you yet, Ollie.
I know that {nameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
I know that {formalnameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
{nameof $local:jobId}, I believe it's called.

#JobRecommendationHandler(jobAtNotVisitedStation2, jobLocation != "BayouStation")
@repeat 1
{@$JobGiverId} Hmm, I wouldn't suggest you try this one yet.
But I know {nameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
But I know {formalnameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
I'd recommend you head there and give {nameof $local:jobId} a try.
4 changes: 2 additions & 2 deletions Assets/_Content/Maps/BayouStation/Interior/Job_Alt.Bayou.leaf
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ $choice .action.cancel; No thanks.
#JobRecommendationHandler(jobAtNotVisitedStation1, jobLocation != "BayouStation")
@repeat 1
{@$JobGiverId} I can't recommend this one for you yet, Ollie.
I know that {nameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
I know that {formalnameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
{nameof $local:jobId}, I believe it's called.

#JobRecommendationHandler(jobAtNotVisitedStation2, jobLocation != "BayouStation")
@repeat 1
{@$JobGiverId} Hmm, I wouldn't suggest you try this one yet.
But I know {nameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
But I know {formalnameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
I'd recommend you head there and give {nameof $local:jobId} a try.
4 changes: 2 additions & 2 deletions Assets/_Content/Maps/CoralStation/Interior/Job.Coral.leaf
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ $choice .action.cancel; No thanks.
#JobRecommendationHandler(jobAtNotVisitedStation1, jobLocation != "CoralStation")
@repeat 1
{@$JobGiverId} I can't recommend this one for you yet, O.
I know that {nameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
I know that {formalnameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
{nameof $local:jobId}, I believe it's called.

#JobRecommendationHandler(jobAtNotVisitedStation2, jobLocation != "CoralStation")
@repeat 1
{@$JobGiverId} Hmm, I wouldn't suggest you try this one yet.
But I know {nameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
But I know {formalnameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
I'd recommend you head there and give {nameof $local:jobId} a try.
4 changes: 2 additions & 2 deletions Assets/_Content/Maps/KelpStation/Interior/Job.Kelp.leaf
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ $endif
#JobRecommendationHandler(jobAtNotVisitedStation1, jobLocation != "KelpStation")
@repeat 1
{@$JobGiverId} I can't recommend this one for you yet, Olivia.
I know that {nameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
I know that {formalnameof $local:jobPoster} has a job over at the {nameof $local:jobLocation}.
{nameof $local:jobId}, I believe it's called.

#JobRecommendationHandler(jobAtNotVisitedStation2, jobLocation != "KelpStation")
@repeat 1
{@$JobGiverId} Hmm, I wouldn't suggest you try this one yet.
But I know {nameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
But I know {formalnameof $local:jobPoster} has a job at the {nameof $local:jobLocation}.
I'd recommend you head there and give {nameof $local:jobId} a try.
8 changes: 4 additions & 4 deletions Assets/_Content/Story/Characters/drKelp.asset
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ MonoBehaviour:
m_ShortNameId:
m_Source: char.drKelp.name.short
m_HashValue: 2026474644
m_FormalShortNameId:
m_Source: char.drKelp.name.formal
m_HashValue: 2780727721
m_Flags: 0
m_OverrideNamePalette: 0
m_NameColor:
Expand Down Expand Up @@ -47,13 +50,10 @@ MonoBehaviour:
Highlight:
serializedVersion: 2
rgba: 4288716960
m_OverrideHistoryColor: 0
m_HistoryColor:
serializedVersion: 2
rgba: 4294967295
m_DefaultPortrait: {fileID: 21300000, guid: c831c5c135c49922d9b1c79eeee5e737, type: 3}
m_Portraits: []
m_DefaultTypeSFX:
m_Source: text_type_npc
m_HashValue: 1929723363
m_TextToSpeechPitch: 1
m_JobGiverQuotes: []
3 changes: 3 additions & 0 deletions Assets/_Content/Text/ES/ES-Loc.aqloc
Original file line number Diff line number Diff line change
Expand Up @@ -15042,6 +15042,9 @@ Mami, la Investigadora de Algas Marinas
:: char.drKelp.name.short
Mami

:: char.drKelp.name.formal
Dra. Ramírez

:: char.profCoral.name
Profesor Cempaka, Investigador de corales

Expand Down
2 changes: 1 addition & 1 deletion Assets/_Content/Text/ES/SpanishLanguage.asset

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Assets/_Content/Text/EnglishLanguage.asset

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Assets/_Content/Text/characters.aqloc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Mom
Professor Cempaka, The Coral Researcher

:: profCoral.name.short
Professor Cempaka
Prof. Cempaka

:: profBayou.name
Dr. Harper, The Bayou Researcher
Expand Down Expand Up @@ -96,3 +96,6 @@ Mack
:: mack.name.short
Mack

:: drKelp.name.formal
Dr. Ramírez

64 changes: 64 additions & 0 deletions Assets/_Modules/Analytics/AlternateJobGraphFeature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#if (UNITY_EDITOR && !IGNORE_UNITY_EDITOR) || DEVELOPMENT_BUILD
#define DEVELOPMENT
#endif

// comment out this define to disable the AB test
#define ANALYTICS_ABTEST_ALTJOBGRAPH

using System;
using BeauUtil;
using Aqua.Profile;
using System.Collections.Generic;
using UnityEngine;
using BeauUtil.Debugger;
using BeauRoutine;
using System.Collections;

namespace Aqua.Analytics {
static public class AlternateJobGraphFeature {
private const string PatchFilePath = "Research/AltJobGraphPatch";

public enum Status {
Invalid,
Inactive,
Active
}

static public Status GetStatus(SaveData saveData) {
#if ANALYTICS_ABTEST_ALTJOBGRAPH
return ResearchTests.IsABC(saveData, 2) ? Status.Active : Status.Inactive;
#else
return Status.Invalid;
#endif // ANALYTICS_ABTEST_ALTJOBGRAPH
}

static public void TryApplyPatch() {
#if ANALYTICS_ABTEST_ALTJOBGRAPH
if (GetStatus(Save.Current) != Status.Active) {
ContentPatcher.Undo();
return;
}

if (ContentPatcher.IsPatched()) {
return;
}

TextAsset patchFile = Resources.Load<TextAsset>(PatchFilePath);
ContentPatcher.Apply(patchFile.text);
Resources.UnloadAsset(patchFile);
#endif // ANALYTICS_ABTEST_ALTJOBGRAPH
}

static public string GetModifiedBranchName(string branchName, Status active) {
switch (active) {
case Status.Invalid:
default:
return branchName;
case Status.Inactive:
return branchName + "-original-job-graph";
case Status.Active:
return branchName + "-alt-job-graph";
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/_Modules/Analytics/AlternateJobGraphFeature.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 202f2c5

Please sign in to comment.