示例#1
0
        /// <summary>
        /// Dumps a fighters script in it's entirety as text for use in version diffing.
        /// </summary>
        /// <returns></returns>
        public string Serialize()
        {
            StringBuilder sb = new StringBuilder();

            foreach (uint u in MotionTable)
            {
                string label = "";
                AnimationHashPairs.TryGetValue(u, out label);
                if (string.IsNullOrEmpty(label))
                {
                    label = $"{u:X8}";
                }

                sb.Append(String.Format($"\n\n{MotionTable.IndexOf(u):X}: [{label}]"));
                ACMDScript c1 = null, c2 = null,
                           c3 = null, c4 = null;

                if (Main.EventLists.ContainsKey(u))
                {
                    c1 = Main.EventLists[u];
                }
                if (GFX.EventLists.ContainsKey(u))
                {
                    c2 = GFX.EventLists[u];
                }
                if (SFX.EventLists.ContainsKey(u))
                {
                    c3 = SFX.EventLists[u];
                }
                if (Expression.EventLists.ContainsKey(u))
                {
                    c4 = Expression.EventLists[u];
                }

                sb.Append("\n\tGame:{");
                if (c1 != null)
                {
                    foreach (ACMDCommand cmd in c1)
                    {
                        sb.Append(String.Format("\n\t\t{0}", cmd.ToString()));
                    }
                }
                else
                {
                    sb.Append("\n\t\tEmpty");
                }
                sb.Append("\n\t}");

                sb.Append("\n\tGFX:{");
                if (c2 != null)
                {
                    foreach (ACMDCommand cmd in c2)
                    {
                        sb.Append(String.Format("\n\t\t{0}", cmd.ToString()));
                    }
                }
                else
                {
                    sb.Append("\n\t\tEmpty");
                }
                sb.Append("\n\t}");

                sb.Append("\n\tSFX:{");
                if (c3 != null)
                {
                    foreach (ACMDCommand cmd in c3)
                    {
                        sb.Append(String.Format("\n\t\t{0}", cmd.ToString()));
                    }
                }
                else
                {
                    sb.Append("\n\t\tEmpty");
                }
                sb.Append("\n\t}");

                sb.Append("\n\tExpression:{");
                if (c4 != null)
                {
                    foreach (ACMDCommand cmd in c4)
                    {
                        sb.Append(String.Format("\n\t\t{0}", cmd.ToString()));
                    }
                }
                else
                {
                    sb.Append("\n\t\tEmpty");
                }
                sb.Append("\n\t}");
            }
            return(sb.ToString());
        }