summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--SetLetters.cs137
-rw-r--r--TaSTT.shader84
-rw-r--r--TaSTT_menu.asset15
-rw-r--r--TaSTT_params.asset63
-rw-r--r--cell_names.txt42
-rw-r--r--generate_animations.sh31
-rw-r--r--generate_fx.py441
-rw-r--r--group_names.txt12
-rw-r--r--template.anim98
10 files changed, 884 insertions, 42 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7806de3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.meta
+generated
+*.swp
diff --git a/SetLetters.cs b/SetLetters.cs
new file mode 100644
index 0000000..c14fe31
--- /dev/null
+++ b/SetLetters.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+// Expands a list of 4-byte parameters into a longer list of (effectively)
+// 1-byte parameters. The 1-byte parameters are easier to use in an animation
+// layer, since we can write conditions for them.
+[SharedBetweenAnimators]
+public class SetLetters : StateMachineBehaviour
+{
+ Dictionary<string, int> letters_;
+ List<string> cell_parameters_;
+ List<string> group_parameters_;
+
+ int GetLetterFromGroup(int g, int which)
+ {
+ return (((g & (0x000000FF << (which * 8))) >> (which * 8)) & 0x000000FF);
+ }
+
+ // This function is called in 2 contexts:
+ // 1. animator.parameters contains everything we need. Updating params is not
+ // reflected in emulator.
+ // 2. animator.parameters contains nothing we need. Updating params is
+ // reflected in emulator.
+ override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
+ {
+ if (letters_ == null) {
+ letters_ = new Dictionary<string, int>();
+ }
+
+ // I don't know why or how but Unity fucking refuses to save this variable,
+ // so reinitialize it every time, YOLO.
+ cell_parameters_ = new List<string> {
+ "_Letter_Row00_Col00",
+ "_Letter_Row00_Col01",
+ "_Letter_Row00_Col02",
+ "_Letter_Row00_Col03",
+ "_Letter_Row00_Col04",
+ "_Letter_Row00_Col05",
+ "_Letter_Row00_Col06",
+ "_Letter_Row00_Col07",
+ "_Letter_Row00_Col08",
+ "_Letter_Row00_Col09",
+ "_Letter_Row00_Col10",
+ "_Letter_Row00_Col11",
+ "_Letter_Row00_Col12",
+ "_Letter_Row00_Col13",
+ "_Letter_Row01_Col00",
+ "_Letter_Row01_Col01",
+ "_Letter_Row01_Col02",
+ "_Letter_Row01_Col03",
+ "_Letter_Row01_Col04",
+ "_Letter_Row01_Col05",
+ "_Letter_Row01_Col06",
+ "_Letter_Row01_Col07",
+ "_Letter_Row01_Col08",
+ "_Letter_Row01_Col09",
+ "_Letter_Row01_Col10",
+ "_Letter_Row01_Col11",
+ "_Letter_Row01_Col12",
+ "_Letter_Row01_Col13",
+ "_Letter_Row02_Col00",
+ "_Letter_Row02_Col01",
+ "_Letter_Row02_Col02",
+ "_Letter_Row02_Col03",
+ "_Letter_Row02_Col04",
+ "_Letter_Row02_Col05",
+ "_Letter_Row02_Col06",
+ "_Letter_Row02_Col07",
+ "_Letter_Row02_Col08",
+ "_Letter_Row02_Col09",
+ "_Letter_Row02_Col10",
+ "_Letter_Row02_Col11",
+ "_Letter_Row02_Col12",
+ "_Letter_Row02_Col13",
+ };
+ group_parameters_ = new List<string> {
+ "_Letter_Row00_Col00_03",
+ "_Letter_Row00_Col04_07",
+ "_Letter_Row00_Col08_11",
+ "_Letter_Row00_Col12_13",
+ "_Letter_Row01_Col00_03",
+ "_Letter_Row01_Col04_07",
+ "_Letter_Row01_Col08_11",
+ "_Letter_Row01_Col12_13",
+ "_Letter_Row02_Col00_03",
+ "_Letter_Row02_Col04_07",
+ "_Letter_Row02_Col08_11",
+ "_Letter_Row02_Col12_13",
+ };
+
+ bool got_match = false;
+ foreach (var param in animator.parameters) {
+ if (param.name == "_Letter_Row00_Col00_03") {
+ got_match = true;
+ break;
+ }
+ }
+ if (!got_match) {
+ if (!letters_.ContainsKey(cell_parameters_[0])) {
+ return;
+ }
+ foreach (var param in cell_parameters_) {
+ animator.SetInteger(param, letters_[param]);
+ }
+
+ return;
+ }
+
+ int cell_idx = 0;
+ for (int i = 0; i < group_parameters_.Count; i++) {
+ string group_param = group_parameters_[i];
+ int g = animator.GetInteger(group_param);
+
+ string cell_param = cell_parameters_[cell_idx];
+ letters_[cell_param] = GetLetterFromGroup(g, 0);
+ cell_idx += 1;
+
+ cell_param = cell_parameters_[cell_idx];
+ letters_[cell_param] = GetLetterFromGroup(g, 1);
+ cell_idx += 1;
+
+ // If we're on the last group of 4 in a row, we do not look at the cells,
+ // since there are only 14 cells in each row.
+ if (i % 4 != 3) {
+ cell_param = cell_parameters_[cell_idx];
+ letters_[cell_param] = GetLetterFromGroup(g, 2);
+ cell_idx += 1;
+
+ cell_param = cell_parameters_[cell_idx];
+ letters_[cell_param] = GetLetterFromGroup(g, 3);
+ cell_idx += 1;
+ }
+ }
+ }
+}
diff --git a/TaSTT.shader b/TaSTT.shader
index f865026..747eb2f 100644
--- a/TaSTT.shader
+++ b/TaSTT.shader
@@ -4,48 +4,48 @@
{
_MainTex ("Texture", 2D) = "white" {}
// software "engineering" LULW
- _Letter_Row00_Col00("Letter_Row00_Col00", float) = 0
- _Letter_Row00_Col01("Letter_Row00_Col01", float) = 0
- _Letter_Row00_Col02("Letter_Row00_Col02", float) = 0
- _Letter_Row00_Col03("Letter_Row00_Col03", float) = 0
- _Letter_Row00_Col04("Letter_Row00_Col04", float) = 0
- _Letter_Row00_Col05("Letter_Row00_Col05", float) = 0
- _Letter_Row00_Col06("Letter_Row00_Col06", float) = 0
- _Letter_Row00_Col07("Letter_Row00_Col07", float) = 0
- _Letter_Row00_Col08("Letter_Row00_Col08", float) = 0
- _Letter_Row00_Col09("Letter_Row00_Col09", float) = 0
- _Letter_Row00_Col10("Letter_Row00_Col10", float) = 0
- _Letter_Row00_Col11("Letter_Row00_Col11", float) = 0
- _Letter_Row00_Col12("Letter_Row00_Col12", float) = 0
- _Letter_Row00_Col13("Letter_Row00_Col13", float) = 0
- _Letter_Row01_Col00("Letter_Row01_Col00", float) = 0
- _Letter_Row01_Col01("Letter_Row01_Col01", float) = 0
- _Letter_Row01_Col02("Letter_Row01_Col02", float) = 0
- _Letter_Row01_Col03("Letter_Row01_Col03", float) = 0
- _Letter_Row01_Col04("Letter_Row01_Col04", float) = 0
- _Letter_Row01_Col05("Letter_Row01_Col05", float) = 0
- _Letter_Row01_Col06("Letter_Row01_Col06", float) = 0
- _Letter_Row01_Col07("Letter_Row01_Col07", float) = 0
- _Letter_Row01_Col08("Letter_Row01_Col08", float) = 0
- _Letter_Row01_Col09("Letter_Row01_Col09", float) = 0
- _Letter_Row01_Col10("Letter_Row01_Col10", float) = 0
- _Letter_Row01_Col11("Letter_Row01_Col11", float) = 0
- _Letter_Row01_Col12("Letter_Row01_Col12", float) = 0
- _Letter_Row01_Col13("Letter_Row01_Col13", float) = 0
- _Letter_Row02_Col00("Letter_Row02_Col00", float) = 0
- _Letter_Row02_Col01("Letter_Row02_Col01", float) = 0
- _Letter_Row02_Col02("Letter_Row02_Col02", float) = 0
- _Letter_Row02_Col03("Letter_Row02_Col03", float) = 0
- _Letter_Row02_Col04("Letter_Row02_Col04", float) = 0
- _Letter_Row02_Col05("Letter_Row02_Col05", float) = 0
- _Letter_Row02_Col06("Letter_Row02_Col06", float) = 0
- _Letter_Row02_Col07("Letter_Row02_Col07", float) = 0
- _Letter_Row02_Col08("Letter_Row02_Col08", float) = 0
- _Letter_Row02_Col09("Letter_Row02_Col09", float) = 0
- _Letter_Row02_Col10("Letter_Row02_Col10", float) = 0
- _Letter_Row02_Col11("Letter_Row02_Col11", float) = 0
- _Letter_Row02_Col12("Letter_Row02_Col12", float) = 0
- _Letter_Row02_Col13("Letter_Row02_Col13", float) = 0
+ _Letter_Row00_Col00("_Letter_Row00_Col00", float) = 0
+ _Letter_Row00_Col01("_Letter_Row00_Col01", float) = 0
+ _Letter_Row00_Col02("_Letter_Row00_Col02", float) = 0
+ _Letter_Row00_Col03("_Letter_Row00_Col03", float) = 0
+ _Letter_Row00_Col04("_Letter_Row00_Col04", float) = 0
+ _Letter_Row00_Col05("_Letter_Row00_Col05", float) = 0
+ _Letter_Row00_Col06("_Letter_Row00_Col06", float) = 0
+ _Letter_Row00_Col07("_Letter_Row00_Col07", float) = 0
+ _Letter_Row00_Col08("_Letter_Row00_Col08", float) = 0
+ _Letter_Row00_Col09("_Letter_Row00_Col09", float) = 0
+ _Letter_Row00_Col10("_Letter_Row00_Col10", float) = 0
+ _Letter_Row00_Col11("_Letter_Row00_Col11", float) = 0
+ _Letter_Row00_Col12("_Letter_Row00_Col12", float) = 0
+ _Letter_Row00_Col13("_Letter_Row00_Col13", float) = 0
+ _Letter_Row01_Col00("_Letter_Row01_Col00", float) = 0
+ _Letter_Row01_Col01("_Letter_Row01_Col01", float) = 0
+ _Letter_Row01_Col02("_Letter_Row01_Col02", float) = 0
+ _Letter_Row01_Col03("_Letter_Row01_Col03", float) = 0
+ _Letter_Row01_Col04("_Letter_Row01_Col04", float) = 0
+ _Letter_Row01_Col05("_Letter_Row01_Col05", float) = 0
+ _Letter_Row01_Col06("_Letter_Row01_Col06", float) = 0
+ _Letter_Row01_Col07("_Letter_Row01_Col07", float) = 0
+ _Letter_Row01_Col08("_Letter_Row01_Col08", float) = 0
+ _Letter_Row01_Col09("_Letter_Row01_Col09", float) = 0
+ _Letter_Row01_Col10("_Letter_Row01_Col10", float) = 0
+ _Letter_Row01_Col11("_Letter_Row01_Col11", float) = 0
+ _Letter_Row01_Col12("_Letter_Row01_Col12", float) = 0
+ _Letter_Row01_Col13("_Letter_Row01_Col13", float) = 0
+ _Letter_Row02_Col00("_Letter_Row02_Col00", float) = 0
+ _Letter_Row02_Col01("_Letter_Row02_Col01", float) = 0
+ _Letter_Row02_Col02("_Letter_Row02_Col02", float) = 0
+ _Letter_Row02_Col03("_Letter_Row02_Col03", float) = 0
+ _Letter_Row02_Col04("_Letter_Row02_Col04", float) = 0
+ _Letter_Row02_Col05("_Letter_Row02_Col05", float) = 0
+ _Letter_Row02_Col06("_Letter_Row02_Col06", float) = 0
+ _Letter_Row02_Col07("_Letter_Row02_Col07", float) = 0
+ _Letter_Row02_Col08("_Letter_Row02_Col08", float) = 0
+ _Letter_Row02_Col09("_Letter_Row02_Col09", float) = 0
+ _Letter_Row02_Col10("_Letter_Row02_Col10", float) = 0
+ _Letter_Row02_Col11("_Letter_Row02_Col11", float) = 0
+ _Letter_Row02_Col12("_Letter_Row02_Col12", float) = 0
+ _Letter_Row02_Col13("_Letter_Row02_Col13", float) = 0
}
SubShader
{
diff --git a/TaSTT_menu.asset b/TaSTT_menu.asset
new file mode 100644
index 0000000..91e0de6
--- /dev/null
+++ b/TaSTT_menu.asset
@@ -0,0 +1,15 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: -340790334, guid: 67cc4cb7839cd3741b63733d5adf0442, type: 3}
+ m_Name: TaSTT_menu
+ m_EditorClassIdentifier:
+ controls: []
diff --git a/TaSTT_params.asset b/TaSTT_params.asset
new file mode 100644
index 0000000..8809134
--- /dev/null
+++ b/TaSTT_params.asset
@@ -0,0 +1,63 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: -1506855854, guid: 67cc4cb7839cd3741b63733d5adf0442, type: 3}
+ m_Name: TaSTT_params
+ m_EditorClassIdentifier:
+ parameters:
+ - name: _Letter_Row00_Col00_03
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row00_Col04_07
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row00_Col08_11
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row00_Col12_13
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row01_Col00_03
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row01_Col04_07
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row01_Col08_11
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row01_Col12_13
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row02_Col00_03
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row02_Col04_07
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row02_Col08_11
+ valueType: 0
+ saved: 0
+ defaultValue: 0
+ - name: _Letter_Row02_Col12_13
+ valueType: 0
+ saved: 0
+ defaultValue: 0
diff --git a/cell_names.txt b/cell_names.txt
new file mode 100644
index 0000000..f556d3c
--- /dev/null
+++ b/cell_names.txt
@@ -0,0 +1,42 @@
+_Letter_Row00_Col00
+_Letter_Row00_Col01
+_Letter_Row00_Col02
+_Letter_Row00_Col03
+_Letter_Row00_Col04
+_Letter_Row00_Col05
+_Letter_Row00_Col06
+_Letter_Row00_Col07
+_Letter_Row00_Col08
+_Letter_Row00_Col09
+_Letter_Row00_Col10
+_Letter_Row00_Col11
+_Letter_Row00_Col12
+_Letter_Row00_Col13
+_Letter_Row01_Col00
+_Letter_Row01_Col01
+_Letter_Row01_Col02
+_Letter_Row01_Col03
+_Letter_Row01_Col04
+_Letter_Row01_Col05
+_Letter_Row01_Col06
+_Letter_Row01_Col07
+_Letter_Row01_Col08
+_Letter_Row01_Col09
+_Letter_Row01_Col10
+_Letter_Row01_Col11
+_Letter_Row01_Col12
+_Letter_Row01_Col13
+_Letter_Row02_Col00
+_Letter_Row02_Col01
+_Letter_Row02_Col02
+_Letter_Row02_Col03
+_Letter_Row02_Col04
+_Letter_Row02_Col05
+_Letter_Row02_Col06
+_Letter_Row02_Col07
+_Letter_Row02_Col08
+_Letter_Row02_Col09
+_Letter_Row02_Col10
+_Letter_Row02_Col11
+_Letter_Row02_Col12
+_Letter_Row02_Col13
diff --git a/generate_animations.sh b/generate_animations.sh
new file mode 100644
index 0000000..b3e6e78
--- /dev/null
+++ b/generate_animations.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+# One animation per slot, per letter.
+# For upper-lower + a few symbols, this is roughly
+# 3 * 12 * 60 \approx 2000 animations.
+# Hopefully we don't hit some limit, lmao
+
+set -o errexit
+set -o pipefail
+
+[ -d generated/animations ] && rm -rf generated || true
+mkdir -p generated/animations
+
+for row in `seq 0 2`; do
+ ROW_PADDED=$(printf '%02d' $row)
+ for col in `seq 0 13`; do
+ COL_PADDED=$(printf '%02d' $col)
+ LETTER_SHADER_PARAM=_Letter_Row${ROW_PADDED}_Col${COL_PADDED}
+ for letter in `seq 0 60`; do
+ LETTER_PADDED=$(printf '%02d' $letter)
+ ANIM_NAME=${LETTER_SHADER_PARAM}_Letter${LETTER_PADDED}
+ FILENAME=generated/animations/${ANIM_NAME}.anim
+ cat template.anim | \
+ sed \
+ -e "s/%LETTER_VALUE%/$letter/g" \
+ -e "s/%LETTER_SHADER_PARAM%/$LETTER_SHADER_PARAM/g" \
+ -e "s/%ANIMATION_NAME%/$ANIM_NAME/g" \
+ > $FILENAME
+ done
+ done
+done
diff --git a/generate_fx.py b/generate_fx.py
new file mode 100644
index 0000000..a39b618
--- /dev/null
+++ b/generate_fx.py
@@ -0,0 +1,441 @@
+#!/usr/bin/env python3
+
+# Template parameters:
+# 1. %*_U% - the !u! identifier for a block.
+# 2. %*_U2% - the & identifier for a block.
+# 3. %ANIMATOR_PARAMETER_NAME% - the name of an animator parameter.
+# 4. %SET_LETTERS_GUID% - the GUID from SetLetters.cs.meta
+# 5. %SERIALIZED_VERSION% - the value of serializedVersion (usually a small int
+# like 0-5)
+# 6. %DEFAULT_GROUP_VAL% - the default value of the group parameters.
+# 8. %DEFAULT_CELL_VAL% - the default value of the cell parameters.
+# 9. %LAYER_NAME% - the name to use for the current animator layer.
+# 10. %LAYER_STATE_MACHINE_U2% - the U2 to use for the current layer's state machine.
+# 11. %TRANSITION_DST_STATE_U2% - in an animatorstatetransition, this specifies
+# where we're transitioning to.
+# 12. %TRANSITION_THRESHOLD% - the threshold to use when transitioning.
+
+params = {}
+
+class EvilGlobalState:
+ u2_ticker = 0
+state = EvilGlobalState()
+
+def get_u2(class_id, state):
+ state.u2_ticker += 1
+ return class_id + ("%05d" % (state.u2_ticker))
+
+# These !u! and & numbers are, respectively, a class ID and an instance ID.
+# The instance ID begins with the class ID then has a 5-digit suffix.
+params["ANIMATOR_CONTROLLER_U"] = "91"
+params["ANIMATOR_HEADER_U2"] = "9100000" # this is a special value
+
+params["ANIMATOR_STATE_MACHINE_U"] = "1107"
+params["EXPAND_GROUPS_LAYER_U2"] = get_u2("1107", state)
+params["CELL_LAYER_U2"] = get_u2("1107", state)
+
+params["MONO_BEHAVIOUR_U"] = "114"
+params["SET_LETTERS_SCRIPT_U2"] = get_u2("114", state)
+
+params["ANIMATOR_STATE_U"] = "1102"
+params["EXPAND_GROUPS_LAYER_STATE_U2"] = get_u2("1102", state)
+
+params["ANIMATOR_STATE_TRANSITION_U"] = "1101"
+
+# By default, the board shows an empty character in every group/cell.
+# Technically we only have to initialize groups, since SetLetters.cs will use
+# the groups to populate the cells.
+DEFAULT_CHAR=1
+params["DEFAULT_GROUP_VAL"] = str((DEFAULT_CHAR << 24) | (DEFAULT_CHAR << 16) | (DEFAULT_CHAR << 8) | DEFAULT_CHAR)
+params["DEFAULT_CELL_VAL"] = str(DEFAULT_CHAR)
+params["DEFAULT_INT_VAL"] = str(0)
+
+# Get from SetLetters.cs.meta
+with open("SetLetters.cs.meta") as f:
+ guid = None
+ for line in f:
+ if "guid" in line:
+ guid = line.split()[1]
+assert(guid != None)
+params["SET_LETTERS_GUID"]=guid
+
+HEADER="""
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+"""[1:]
+
+# Generates the sed cmd args required to replace all parameters defined in
+# $1, which is an associative array like `params`.
+def replaceMacros(lines, macro_defs):
+ for k,v in macro_defs.items():
+ lines = lines.replace("%" + k + "%", v)
+ return lines
+
+def genHeader():
+ return replaceMacros(HEADER, params)
+print(genHeader())
+
+ANIMATOR_HEADER = """
+--- !u!%ANIMATOR_CONTROLLER_U% &%ANIMATOR_HEADER_U2%
+AnimatorController:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: TaSTT_fx
+ serializedVersion: 5
+"""[1:]
+
+ANIMATOR_PARAMETER_HEADER = """
+ m_AnimatorParameters:
+"""[1:]
+
+ANIMATOR_PARAMETER_INT = """
+ - m_Name: %ANIMATOR_PARAMETER_NAME%
+ m_Type: 3
+ m_DefaultFloat: 0
+ m_DefaultInt: %DEFAULT_INT_VAL%
+ m_DefaultBool: 0
+ m_Controller: {fileID: %ANIMATOR_HEADER_U2%}
+"""[1:]
+
+ANIMATOR_LAYER_HEADER = """
+ m_AnimatorLayers:
+"""[1:]
+
+ANIMATOR_LAYER_EXPAND_GROUPS = """
+ - serializedVersion: 5
+ m_Name: TaSTT_Expand_Groups
+ m_StateMachine: {fileID: %EXPAND_GROUPS_LAYER_U2%}
+ m_Mask: {fileID: 0}
+ m_Motions: []
+ m_Behaviours: []
+ m_BlendingMode: 0
+ m_SyncedLayerIndex: -1
+ m_DefaultWeight: 1
+ m_IKPass: 0
+ m_SyncedLayerAffectsTiming: 0
+ m_Controller: {fileID: %ANIMATOR_HEADER_U2%}
+"""[1:]
+
+ANIMATOR_LAYER_CELL_ANIM = """
+ - serializedVersion: 5
+ m_Name: %LAYER_NAME%
+ m_StateMachine: {fileID: %LAYER_STATE_MACHINE_U2%}
+ m_Mask: {fileID: 0}
+ m_Motions: []
+ m_Behaviours: []
+ m_BlendingMode: 0
+ m_SyncedLayerIndex: -1
+ m_DefaultWeight: 1
+ m_IKPass: 0
+ m_SyncedLayerAffectsTiming: 0
+ m_Controller: {fileID: 9100000}
+"""[1:]
+
+GROUP_NAMES = [
+ "_Letter_Row00_Col00_03",
+ "_Letter_Row00_Col04_07",
+ "_Letter_Row00_Col08_11",
+ "_Letter_Row00_Col12_13",
+ "_Letter_Row01_Col00_03",
+ "_Letter_Row01_Col04_07",
+ "_Letter_Row01_Col08_11",
+ "_Letter_Row01_Col12_13",
+ "_Letter_Row02_Col00_03",
+ "_Letter_Row02_Col04_07",
+ "_Letter_Row02_Col08_11",
+ "_Letter_Row02_Col12_13",
+ ]
+
+CELL_NAMES = [
+ "_Letter_Row00_Col00",
+ "_Letter_Row00_Col01",
+ "_Letter_Row00_Col02",
+ "_Letter_Row00_Col03",
+ "_Letter_Row00_Col04",
+ "_Letter_Row00_Col05",
+ "_Letter_Row00_Col06",
+ "_Letter_Row00_Col07",
+ "_Letter_Row00_Col08",
+ "_Letter_Row00_Col09",
+ "_Letter_Row00_Col10",
+ "_Letter_Row00_Col11",
+ "_Letter_Row00_Col12",
+ "_Letter_Row00_Col13",
+ "_Letter_Row01_Col00",
+ "_Letter_Row01_Col01",
+ "_Letter_Row01_Col02",
+ "_Letter_Row01_Col03",
+ "_Letter_Row01_Col04",
+ "_Letter_Row01_Col05",
+ "_Letter_Row01_Col06",
+ "_Letter_Row01_Col07",
+ "_Letter_Row01_Col08",
+ "_Letter_Row01_Col09",
+ "_Letter_Row01_Col10",
+ "_Letter_Row01_Col11",
+ "_Letter_Row01_Col12",
+ "_Letter_Row01_Col13",
+ "_Letter_Row02_Col00",
+ "_Letter_Row02_Col01",
+ "_Letter_Row02_Col02",
+ "_Letter_Row02_Col03",
+ "_Letter_Row02_Col04",
+ "_Letter_Row02_Col05",
+ "_Letter_Row02_Col06",
+ "_Letter_Row02_Col07",
+ "_Letter_Row02_Col08",
+ "_Letter_Row02_Col09",
+ "_Letter_Row02_Col10",
+ "_Letter_Row02_Col11",
+ "_Letter_Row02_Col12",
+ "_Letter_Row02_Col13",
+ ]
+
+def genAnimator(state):
+ result = replaceMacros(ANIMATOR_HEADER, params)
+ result += ANIMATOR_PARAMETER_HEADER
+ for group_name in GROUP_NAMES:
+ params["ANIMATOR_PARAMETER_NAME"] = group_name
+ params["DEFAULT_INT_VAL"] = params["DEFAULT_GROUP_VAL"]
+ result += replaceMacros(ANIMATOR_PARAMETER_INT, params)
+ for cell_name in CELL_NAMES:
+ params["ANIMATOR_PARAMETER_NAME"] = cell_name
+ params["DEFAULT_INT_VAL"] = params["DEFAULT_CELL_VAL"]
+ result += replaceMacros(ANIMATOR_PARAMETER_INT, params)
+ result += replaceMacros(ANIMATOR_LAYER_HEADER, params)
+ result += replaceMacros(ANIMATOR_LAYER_EXPAND_GROUPS, params)
+ for cell_name in CELL_NAMES:
+ params[cell_name + "_U2"] = get_u2("1102", state)
+ params["LAYER_NAME"] = cell_name
+ params["LAYER_STATE_MACHINE_U2"] = params[cell_name + "_U2"]
+ result += replaceMacros(ANIMATOR_LAYER_CELL_ANIM, params)
+ return result
+print(genAnimator(state))
+
+EXPAND_GROUPS_LAYER = """
+--- !u!%ANIMATOR_STATE_MACHINE_U% &%EXPAND_GROUPS_LAYER_U2%
+AnimatorStateMachine:
+ serializedVersion: 6
+ m_ObjectHideFlags: 1
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: TaSTT_Expand_Groups
+ m_ChildStates:
+ - serializedVersion: 1
+ m_State: {fileID: %EXPAND_GROUPS_LAYER_STATE_U2%}
+ m_Position: {x: 280, y: 90, z: 0}
+ m_ChildStateMachines: []
+ m_AnyStateTransitions: []
+ m_EntryTransitions: []
+ m_StateMachineTransitions: {}
+ m_StateMachineBehaviours: []
+ m_AnyStatePosition: {x: 50, y: 20, z: 0}
+ m_EntryPosition: {x: 50, y: 120, z: 0}
+ m_ExitPosition: {x: 800, y: 120, z: 0}
+ m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
+ m_DefaultState: {fileID: %EXPAND_GROUPS_LAYER_STATE_U2%}
+"""[1:]
+
+EXPAND_GROUPS_LAYER_STATE = """
+--- !u!%ANIMATOR_STATE_U% &%EXPAND_GROUPS_LAYER_STATE_U2%
+AnimatorState:
+ serializedVersion: 6
+ m_ObjectHideFlags: 1
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: SetLetters
+ m_Speed: 1
+ m_CycleOffset: 0
+ m_Transitions: []
+ m_StateMachineBehaviours:
+ - {fileID: %SET_LETTERS_SCRIPT_U2%}
+ m_Position: {x: 50, y: 50, z: 0}
+ m_IKOnFeet: 0
+ m_WriteDefaultValues: 1
+ m_Mirror: 0
+ m_SpeedParameterActive: 0
+ m_MirrorParameterActive: 0
+ m_CycleOffsetParameterActive: 0
+ m_TimeParameterActive: 0
+ m_Motion: {fileID: 0}
+ m_Tag:
+ m_SpeedParameter:
+ m_MirrorParameter:
+ m_CycleOffsetParameter:
+ m_TimeParameter:
+"""[1:]
+
+SET_LETTERS_SCRIPT = """
+--- !u!%MONO_BEHAVIOUR_U% &%SET_LETTERS_SCRIPT_U2%
+MonoBehaviour:
+ m_ObjectHideFlags: 1
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: %SET_LETTERS_GUID%, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+"""[1:]
+
+# Generate the layer that converts our select few 32-bit int parameters into
+# 4x as many int parameters, each containing the letter value for one cell.
+def genExpandGroupsLayer():
+ result = EXPAND_GROUPS_LAYER + EXPAND_GROUPS_LAYER_STATE + SET_LETTERS_SCRIPT
+ result = replaceMacros(result, params)
+ return result
+print(genExpandGroupsLayer())
+
+CELL_LAYER_HEADER="""
+--- !u!%ANIMATOR_STATE_MACHINE_U% &%CELL_LAYER_U2%
+AnimatorStateMachine:
+ serializedVersion: 6
+ m_ObjectHideFlags: 1
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: %LAYER_NAME%
+ m_ChildStates:
+"""[1:]
+
+CELL_LAYER_STATE_HEADER="""
+ - serializedVersion: 1
+ m_State: {fileID: %CELL_LAYER_STATE_U2%}
+ m_Position: {x: 350.6628, y: %STATE_Y%, z: 0}
+"""[1:]
+
+CELL_LAYER_MIDDLE="""
+ m_ChildStateMachines: []
+ m_AnyStateTransitions:
+"""[1:]
+
+CELL_LAYER_TRANSITION_HEADER="""
+ - {fileID: %CELL_LAYER_TRANSITION_U2%}
+"""[1:]
+
+CELL_LAYER_SUFFIX="""
+ m_ChildStateMachines: []
+ m_EntryTransitions: []
+ m_StateMachineTransitions: {}
+ m_StateMachineBehaviours: []
+ m_AnyStatePosition: {x: 50, y: 20, z: 0}
+ m_EntryPosition: {x: 50, y: 120, z: 0}
+ m_ExitPosition: {x: 800, y: 120, z: 0}
+ m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
+ m_DefaultState: {fileID: %CELL_LAYER_DEFAULT_STATE_U2%}
+"""[1:]
+
+CELL_LAYER_STATE = """
+--- !u!%ANIMATOR_STATE_U% &%CELL_LAYER_STATE_U2%
+AnimatorState:
+ serializedVersion: 6
+ m_ObjectHideFlags: 1
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: %ANIMATION_NAME%
+ m_Speed: 1
+ m_CycleOffset: 0
+ m_Transitions: []
+ m_StateMachineBehaviours: []
+ m_Position: {x: 50, y: 50, z: 0}
+ m_IKOnFeet: 0
+ m_WriteDefaultValues: 0
+ m_Mirror: 0
+ m_SpeedParameterActive: 0
+ m_MirrorParameterActive: 0
+ m_CycleOffsetParameterActive: 0
+ m_TimeParameterActive: 0
+ m_Motion: {fileID: 7400000, guid: %CELL_LAYER_STATE_ANIM_GUID%, type: 2}
+ m_Tag:
+ m_SpeedParameter:
+ m_MirrorParameter:
+ m_CycleOffsetParameter:
+ m_TimeParameter:
+"""[1:]
+
+CELL_LAYER_TRANSITION="""
+--- !u!%ANIMATOR_STATE_TRANSITION_U% &%CELL_LAYER_TRANSITION_U2%
+AnimatorStateTransition:
+ m_ObjectHideFlags: 1
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name:
+ m_Conditions:
+ - m_ConditionMode: 6
+ m_ConditionEvent: %LAYER_NAME%
+ m_EventTreshold: %TRANSITION_THRESHOLD%
+ m_DstStateMachine: {fileID: 0}
+ m_DstState: {fileID: %CELL_LAYER_DST_STATE_U2%}
+ m_Solo: 0
+ m_Mute: 0
+ m_IsExit: 0
+ serializedVersion: 3
+ m_TransitionDuration: 0.1
+ m_TransitionOffset: 0
+ m_ExitTime: 0.75
+ m_HasExitTime: 0
+ m_HasFixedDuration: 1
+ m_InterruptionSource: 0
+ m_OrderedInterruption: 1
+ m_CanTransitionToSelf: 1
+"""[1:]
+
+def getAnimationGuid(anim_meta_filename):
+ with open(anim_meta_filename, 'r') as f:
+ for line in f:
+ if "guid" in line:
+ return line.split()[1]
+ return None
+
+def genCellAnimationLayers(state):
+ result = ""
+ for layer in CELL_NAMES:
+ params["CELL_LAYER_U2"] = params[layer + "_U2"]
+ params["CELL_LAYER_U2" + layer] = params["CELL_LAYER_U2"]
+ params["LAYER_NAME"] = layer
+ result += replaceMacros(CELL_LAYER_HEADER, params)
+
+ # Add a state for each animation, i.e. for each character writeable in this slot.
+ for i in range(0,60):
+ params["CELL_LAYER_STATE_U2"] = get_u2(params["ANIMATOR_STATE_U"], state)
+ params["CELL_LAYER_STATE_U2" + layer + ("_Letter%02d" % i)] = params["CELL_LAYER_STATE_U2"]
+ params["STATE_Y"] = str(-190 - i * 40)
+ result += replaceMacros(CELL_LAYER_STATE_HEADER, params)
+
+ result += CELL_LAYER_MIDDLE
+
+ for i in range(0,60):
+ params["CELL_LAYER_TRANSITION_U2"] = get_u2(params["ANIMATOR_STATE_TRANSITION_U"], state)
+ params["CELL_LAYER_TRANSITION_U2" + layer + ("_Letter%02d" % i)] = params["CELL_LAYER_TRANSITION_U2"]
+ result += replaceMacros(CELL_LAYER_TRANSITION_HEADER, params)
+
+ # Set the default layer to the 0th animation.
+ params["CELL_LAYER_DEFAULT_STATE_U2"] = params["CELL_LAYER_STATE_U2" + layer + ("_Letter%02d" % 0)]
+ result += replaceMacros(CELL_LAYER_SUFFIX, params)
+
+ # Done creating the layer header! Phew. Let's make the states next.
+ for i in range(0,60):
+ params["ANIMATION_NAME"] = layer + ("_Letter%02d" % i)
+ params["CELL_LAYER_STATE_U2"] = params["CELL_LAYER_STATE_U2" + layer + ("_Letter%02d" % i)]
+ # Get the GUID of the animation we will play at this state.
+ anim_meta_filename = "generated/animations/" + layer + ("_Letter%02d" % i) + ".anim.meta"
+ params["CELL_LAYER_STATE_ANIM_GUID"] = getAnimationGuid(anim_meta_filename)
+ result += replaceMacros(CELL_LAYER_STATE, params)
+
+ # OK, finally, let's wire up the states.
+ for i in range(0,60):
+ params["CELL_LAYER_TRANSITION_U2"] = params["CELL_LAYER_TRANSITION_U2" + layer + ("_Letter%02d" % i)]
+ params["TRANSITION_THRESHOLD"] = str(i)
+ params["CELL_LAYER_DST_STATE_U2"] = params["CELL_LAYER_STATE_U2" + layer + ("_Letter%02d" % i)]
+ result += replaceMacros(CELL_LAYER_TRANSITION, params)
+
+ return result
+print(genCellAnimationLayers(state))
diff --git a/group_names.txt b/group_names.txt
new file mode 100644
index 0000000..cdf19e0
--- /dev/null
+++ b/group_names.txt
@@ -0,0 +1,12 @@
+_Letter_Row00_Col00_03
+_Letter_Row00_Col04_07
+_Letter_Row00_Col08_11
+_Letter_Row00_Col12_13
+_Letter_Row01_Col00_03
+_Letter_Row01_Col04_07
+_Letter_Row01_Col08_11
+_Letter_Row01_Col12_13
+_Letter_Row02_Col00_03
+_Letter_Row02_Col04_07
+_Letter_Row02_Col08_11
+_Letter_Row02_Col12_13
diff --git a/template.anim b/template.anim
new file mode 100644
index 0000000..ee84cea
--- /dev/null
+++ b/template.anim
@@ -0,0 +1,98 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!74 &7400000
+AnimationClip:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: template
+ serializedVersion: 6
+ m_Legacy: 0
+ m_Compressed: 0
+ m_UseHighQualityCurve: 1
+ m_RotationCurves: []
+ m_CompressedRotationCurves: []
+ m_EulerCurves: []
+ m_PositionCurves: []
+ m_ScaleCurves: []
+ m_FloatCurves:
+ - curve:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: %LETTER_VALUE%
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 136
+ weightedMode: 0
+ inWeight: 0
+ outWeight: 0
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
+ attribute: material.%LETTER_SHADER_PARAM%
+ path: CustomSTT
+ classID: 137
+ script: {fileID: 0}
+ m_PPtrCurves: []
+ m_SampleRate: 60
+ m_WrapMode: 0
+ m_Bounds:
+ m_Center: {x: 0, y: 0, z: 0}
+ m_Extent: {x: 0, y: 0, z: 0}
+ m_ClipBindingConstant:
+ genericBindings:
+ - serializedVersion: 2
+ path: 2794480623
+ attribute: 2284639795
+ script: {fileID: 0}
+ typeID: 137
+ customType: 22
+ isPPtrCurve: 0
+ pptrCurveMapping: []
+ m_AnimationClipSettings:
+ serializedVersion: 2
+ m_AdditiveReferencePoseClip: {fileID: 0}
+ m_AdditiveReferencePoseTime: 0
+ m_StartTime: 0
+ m_StopTime: 0
+ m_OrientationOffsetY: 0
+ m_Level: 0
+ m_CycleOffset: 0
+ m_HasAdditiveReferencePose: 0
+ m_LoopTime: 1
+ m_LoopBlend: 0
+ m_LoopBlendOrientation: 0
+ m_LoopBlendPositionY: 0
+ m_LoopBlendPositionXZ: 0
+ m_KeepOriginalOrientation: 0
+ m_KeepOriginalPositionY: 1
+ m_KeepOriginalPositionXZ: 0
+ m_HeightFromFeet: 0
+ m_Mirror: 0
+ m_EditorCurves:
+ - curve:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: %LETTER_VALUE%
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 136
+ weightedMode: 0
+ inWeight: 0
+ outWeight: 0
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
+ attribute: material.%LETTER_SHADER_PARAM%
+ path: CustomSTT
+ classID: 137
+ script: {fileID: 0}
+ m_EulerEditorCurves: []
+ m_HasGenericRootTransform: 0
+ m_HasMotionFloatCurves: 0
+ m_Events: []