Skip to content

Commit

Permalink
[AI] Add editing of Desires & Motivations; Make skill list collapseable
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Aug 2, 2023
1 parent a37a15e commit 3b1b771
Showing 1 changed file with 98 additions and 40 deletions.
138 changes: 98 additions & 40 deletions AI_CheatTools/CheatToolsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static class CheatToolsWindowInit
private static HSceneFlagCtrl _hScene;
private static string _gameTimeText;
private static KeyValuePair<object, string>[] _openInInspectorButtons;
private static bool _expandDesires, _expandSkills;

public static void Initialize()
{
Expand Down Expand Up @@ -283,65 +284,122 @@ private static void DrawSingleGirlCheats(AgentActor currentAdvGirl)

if (currentAdvGirl.ChaControl != null && currentAdvGirl.ChaControl.fileGameInfo != null)
{
GUILayout.Label("Status");

GUILayout.BeginHorizontal();
GUILayout.BeginVertical(GUI.skin.box);
{
GUILayout.Label($"Love phase: {currentAdvGirl.ChaControl.fileGameInfo.phase + 1} / 4");
if (GUILayout.Button("-1")) currentAdvGirl.SetPhase(Mathf.Max(0, currentAdvGirl.ChaControl.fileGameInfo.phase - 1));
if (GUILayout.Button("+1")) currentAdvGirl.SetPhase(Mathf.Min(3, currentAdvGirl.ChaControl.fileGameInfo.phase + 1));
}
GUILayout.EndHorizontal();
GUILayout.Label("Status");

GUILayout.BeginHorizontal();
{
var sickness = AIProject.Definitions.Sickness.TagTable.FirstOrDefault(x => x.Value == currentAdvGirl.AgentData.SickState.ID).Key;
GUILayout.Label($"Sickness: {sickness ?? "None"}", GUILayout.ExpandWidth(true));
if (GUILayout.Button("Heal", GUILayout.ExpandWidth(false)) && currentAdvGirl.AgentData.SickState.ID > -1)
GUILayout.BeginHorizontal();
{
GUILayout.Label($"Love phase: {currentAdvGirl.ChaControl.fileGameInfo.phase + 1} / 4");
if (GUILayout.Button("-1")) currentAdvGirl.SetPhase(Mathf.Max(0, currentAdvGirl.ChaControl.fileGameInfo.phase - 1));
if (GUILayout.Button("+1")) currentAdvGirl.SetPhase(Mathf.Min(3, currentAdvGirl.ChaControl.fileGameInfo.phase + 1));
}
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
{
var sickness = AIProject.Definitions.Sickness.TagTable.FirstOrDefault(x => x.Value == currentAdvGirl.AgentData.SickState.ID).Key;
GUILayout.Label($"Sickness: {sickness ?? "None"}", GUILayout.ExpandWidth(true));
if (GUILayout.Button("Heal", GUILayout.ExpandWidth(false)) && currentAdvGirl.AgentData.SickState.ID > -1)
{
currentAdvGirl.HealSickBySleep();
currentAdvGirl.AgentData.SickState.OverwritableID = -1;
currentAdvGirl.AgentData.WeaknessMotivation = 0;
}
}
GUILayout.EndHorizontal();

foreach (Status.Type statusValue in Enum.GetValues(typeof(Status.Type)))
{
currentAdvGirl.HealSickBySleep();
currentAdvGirl.AgentData.SickState.OverwritableID = -1;
currentAdvGirl.AgentData.WeaknessMotivation = 0;
if (currentAdvGirl.AgentData.StatsTable.ContainsKey((int)statusValue))
{
GUILayout.BeginHorizontal();
{
var status = Mathf.RoundToInt(currentAdvGirl.AgentData.StatsTable[(int)statusValue]);
GUILayout.Label(statusValue + ": " + status, GUILayout.Width(120));
var newStatus = Mathf.RoundToInt(GUILayout.HorizontalSlider(status, 0, (int)statusValue == 5 ? 150 : 100));
if (newStatus != status)
currentAdvGirl.AgentData.StatsTable[(int)statusValue] = newStatus;
}
GUILayout.EndHorizontal();
}
}
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();

foreach (Status.Type statusValue in Enum.GetValues(typeof(Status.Type)))
GUILayout.BeginVertical(GUI.skin.box);
{
if (currentAdvGirl.AgentData.StatsTable.ContainsKey((int)statusValue))
_expandDesires = GUILayout.Toggle(_expandDesires, " Desires & Motivations");
if (_expandDesires)
{
GUILayout.BeginHorizontal();
foreach (Desire.Type typeValue in Enum.GetValues(typeof(Desire.Type)))
{
var status = Mathf.RoundToInt(currentAdvGirl.AgentData.StatsTable[(int)statusValue]);
GUILayout.Label(statusValue + ": " + status, GUILayout.Width(120));
var newStatus = Mathf.RoundToInt(GUILayout.HorizontalSlider(status, 0, (int)statusValue == 5 ? 150 : 100));
if (newStatus != status)
currentAdvGirl.AgentData.StatsTable[(int)statusValue] = newStatus;
var desireKey = Desire.GetDesireKey(typeValue);
var desire = currentAdvGirl.GetDesire(desireKey);
var motivation = currentAdvGirl.GetMotivation(desireKey);
if (desire.HasValue || motivation.HasValue)
{
GUILayout.BeginHorizontal();
{
GUILayout.Label(typeValue + ": ", GUILayout.ExpandWidth(true));
GUI.changed = false;

if (desire.HasValue)
{
var textFieldDesire = GUILayout.TextField($"{desire.Value:F2}", GUILayout.Width(60));
if (GUI.changed && float.TryParse(textFieldDesire, out var newDesire) && Mathf.Abs(newDesire - desire.Value) >= 0.01f)
currentAdvGirl.SetDesire(desireKey, newDesire);
GUI.changed = false;
}
else
{
GUILayout.Label("---", GUILayout.Width(60));
}

if (motivation.HasValue)
{
var textFieldMotivation = GUILayout.TextField($"{motivation.Value:F2}", GUILayout.Width(60));
if (GUI.changed && float.TryParse(textFieldMotivation, out var newMotivation) && Mathf.Abs(newMotivation - motivation.Value) >= 0.01f)
currentAdvGirl.SetMotivation(desireKey, newMotivation);
GUI.changed = false;
}
else
{
GUILayout.Label("---", GUILayout.Width(60));
}
}
GUILayout.EndHorizontal();
}
}
GUILayout.EndHorizontal();
}
}
GUILayout.Space(6);
GUILayout.EndVertical();

GUILayout.Label("Flavor skills");
foreach (FlavorSkill.Type typeValue in Enum.GetValues(typeof(FlavorSkill.Type)))
GUILayout.BeginVertical(GUI.skin.box);
{
if (currentAdvGirl.ChaControl.fileGameInfo.flavorState.ContainsKey((int)typeValue))
_expandSkills = GUILayout.Toggle(_expandSkills, " Flavor skills");
if (_expandSkills)
{
GUILayout.BeginHorizontal();
foreach (FlavorSkill.Type typeValue in Enum.GetValues(typeof(FlavorSkill.Type)))
{
GUILayout.Label(typeValue + ": ", GUILayout.Width(120));
GUI.changed = false;
var flavorSkill = currentAdvGirl.GetFlavorSkill(typeValue);
var textField = GUILayout.TextField(flavorSkill.ToString());
if (GUI.changed && int.TryParse(textField, out var newSkill) && newSkill != flavorSkill)
currentAdvGirl.SetFlavorSkill(typeValue, newSkill);
GUI.changed = false;
if (currentAdvGirl.ChaControl.fileGameInfo.flavorState.ContainsKey((int)typeValue))
{
GUILayout.BeginHorizontal();
{
GUILayout.Label(typeValue + ": ", GUILayout.Width(120));
GUI.changed = false;
var flavorSkill = currentAdvGirl.GetFlavorSkill(typeValue);
var textField = GUILayout.TextField(flavorSkill.ToString());
if (GUI.changed && int.TryParse(textField, out var newSkill) && newSkill != flavorSkill)
currentAdvGirl.SetFlavorSkill(typeValue, newSkill);
GUI.changed = false;
}
GUILayout.EndHorizontal();
}
}
GUILayout.EndHorizontal();
}
}
GUILayout.Space(6);
GUILayout.EndVertical();
}

if (currentAdvGirl.AgentData.TalkMotivation >= currentAdvGirl.AgentData.StatsTable[5])
Expand Down

0 comments on commit 3b1b771

Please sign in to comment.