Cut 8b. The Unity project compiles with 0 errors in 6000.3.24f1 batchmode. Packages: manifest.json pins org.gamecult.cultlib at cultlib-unity-v1.0.57 and org.gamecult.caching.unity at caching-unity-v1.2.0, next to the 8a CultMath tag. Aetheria.Shared.Unity references GameCult.CultLib and keeps noEngineReferences. The Database Tools (Assets/Scripts/CultCache/Editor) are deleted in this commit, alongside their five ported drawers in Assets/Scripts/Editor/CultCacheDrawers.cs, each an [CultInspectorDrawer] ICultInspectorDrawer: - InspectableType: popup of the attribute type's [Union] member names, writing the string. - InspectableColor: float3 and float4 through ColorField. - InspectableAnimationCurve: float4[] and BezierCurve through CurveField. - InspectableTemperature: Kelvin, Celsius and Fahrenheit fields over one value. - InspectableSchematicShape: size and cell toggles. The old drawer also drew the item's schematic texture and tinted hull hardpoints, which need the parent document. The tagged Studio hands a drawer only the value, so those wait on the Studio exposing the open record. Unity call sites: - ActionGameManager opens the catalog through AetheriaStores; Cut 10 adds the run and player stores. - Refs resolve through ItemManager.GetData or Get(ref); orbit, planet and belt maps key by CultRecordKey; identity is compared by reference or key. - The PlayerSettings.msgpack reader and writer, which Cut 10 deletes, pass CultDocumentMessagePackSerialization.OptionsFor, since the embedded run reaches CultMath values and refs. Keyboard layouts need no resolver and keep MessagePack's defaults until Cut 10. - The input map uses the nested action to binding shape. - PropertiesPanel reads CultInspectorRangeAttribute. - NameTools loses its legacy name-file writer. - Slime compares serialized settings instead of the deleted SHA1 helper. - FieldDriver drops InspectorHeader. - .gitignore covers the test project's build output. Builds: Aetheria.Shared, AetherDb, Aetheria.Shared.Tests (6/6), Unity batchmode (0 errors). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
93 lines
No EOL
3.4 KiB
C#
93 lines
No EOL
3.4 KiB
C#
using System.Buffers.Text;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text.RegularExpressions;
|
|
using MessagePack;
|
|
using CultMath;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
using Random = CultMath.Random;
|
|
|
|
public class NameTools : EditorWindow
|
|
{
|
|
public int NameGeneratorMinLength = 5;
|
|
public int NameGeneratorMaxLength = 10;
|
|
public int NameGeneratorOrder = 4;
|
|
private int minWordLength = 4;
|
|
private TextAsset nameFile;
|
|
private MarkovNameGenerator _nameGenerator;
|
|
private bool _stripNumberTokens;
|
|
|
|
|
|
// Add menu named "My Window" to the Window menu
|
|
[MenuItem("Window/Aetheria/Name Tools")]
|
|
static void Init()
|
|
{
|
|
// Get existing open window or if none, make a new one:
|
|
NameTools window = (NameTools)EditorWindow.GetWindow(typeof(NameTools));
|
|
window.Show();
|
|
}
|
|
|
|
bool HasNonASCIIChars(string str)
|
|
{
|
|
return (System.Text.Encoding.UTF8.GetByteCount(str) != str.Length);
|
|
}
|
|
|
|
void OnGUI()
|
|
{
|
|
|
|
nameFile = (TextAsset) EditorGUILayout.ObjectField("Name File", nameFile, typeof(TextAsset), false);
|
|
minWordLength = EditorGUILayout.IntField("Minimum File Word Length", minWordLength);
|
|
NameGeneratorMinLength = EditorGUILayout.IntField("Generated Minimum Word Length", NameGeneratorMinLength);
|
|
NameGeneratorMaxLength = EditorGUILayout.IntField("Generated Maximum Word Length", NameGeneratorMaxLength);
|
|
NameGeneratorOrder = EditorGUILayout.IntField("Generator Order", NameGeneratorOrder);
|
|
_stripNumberTokens = GUILayout.Toggle(_stripNumberTokens, "Strip Number Tokens");
|
|
|
|
if (GUILayout.Button("Clean Name File"))
|
|
{
|
|
var lines = nameFile.text.Split('\n');
|
|
using StreamWriter outputFile = new StreamWriter(Path.Combine(Application.dataPath, nameFile.name + ".csv"));
|
|
var names = new HashSet<string>();
|
|
foreach (var line in lines)
|
|
{
|
|
var tokens = line.Split(',', ' ');
|
|
foreach (var t in tokens)
|
|
{
|
|
if (!HasNonASCIIChars(t))
|
|
{
|
|
var s = new string(t.Where(c => char.IsLetter(c) || c == '-' || c == '`' || c == '\'').ToArray()).Trim().Trim('`','-');
|
|
if(s.Length >= minWordLength && !names.Contains(s))
|
|
{
|
|
names.Add(s);
|
|
outputFile.WriteLine(s);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (GUILayout.Button("Process Name File") && nameFile != null)
|
|
{
|
|
var names = new HashSet<string>();
|
|
var lines = nameFile.text.Split('\n');
|
|
foreach (var line in lines)
|
|
{
|
|
foreach(var word in line.ToUpperInvariant().Split(' ', ',', '.', '"'))
|
|
if (word.Length >= minWordLength && !names.Contains(word))
|
|
names.Add(word);
|
|
}
|
|
Debug.Log($"Found {lines.Length} lines, with {names.Count} unique names!");
|
|
var random = new Random(1337);
|
|
_nameGenerator = new MarkovNameGenerator(ref random, names, NameGeneratorOrder, NameGeneratorMinLength, NameGeneratorMaxLength);
|
|
}
|
|
|
|
if (_nameGenerator != null)
|
|
{
|
|
if (GUILayout.Button("Generate Name"))
|
|
{
|
|
Debug.Log(_nameGenerator.NextName);
|
|
}
|
|
}
|
|
}
|
|
} |