示例#1
0
        static void GetFace(bool inc, TI.IElementArray ea, int fi, int index, out string s0, out string s1, out string s2)
        {
            if (ea == null)
            {
                s0 = s1 = s2 = "";
                return;
            }

            TI.Field f0 = ea[index + 0, fi], f1 = ea[index + 1, fi], f2 = ea[index + 2, fi];
            var      ft = f0.FieldType;

            switch (ft)
            {
            case TI.FieldType.ShortInteger:
                s0 = ((f0 as TI.ShortInteger).Value + (inc ? 1 : 0)).ToString();
                s1 = ((f1 as TI.ShortInteger).Value + (inc ? 1 : 0)).ToString();
                s2 = ((f2 as TI.ShortInteger).Value + (inc ? 1 : 0)).ToString();
                break;

            case TI.FieldType.LongInteger:
                s0 = ((f0 as TI.LongInteger).Value + (inc ? 1 : 0)).ToString();
                s1 = ((f1 as TI.LongInteger).Value + (inc ? 1 : 0)).ToString();
                s2 = ((f2 as TI.LongInteger).Value + (inc ? 1 : 0)).ToString();
                break;

            default: throw new Debug.Exceptions.UnreachableException(ft);
            }
        }
示例#2
0
        public static ScriptBlock[] FromBlock(TI.IBlock block)
        {
            TI.IElementArray ea    = block.GetElements();
            ScriptBlock[]    value = new ScriptBlock[ea.Count];

            hs_scripts_block hs;

            for (int x = 0; x < value.Length; x++)
            {
                hs = (hs_scripts_block)ea.GetElement(x);
                var v = value[x] = new ScriptBlock();

                v.Name       = hs.Name.ToString();
                v.ScriptType = (short)hs.ScriptType.Value;
                v.ReturnType = (short)hs.ReturnType.Value;
                Blam.DatumIndex index = hs.RootExpressionIndex.Value;
                v.NodeOffset = index.Index;

                if (v.Name == TagInterface.StringId.kEncryptedResult)
                {
                    v.Name = (hs.Name as TagInterface.StringId).Handle.ToUInt32().ToString("X8");
                }
            }

            return(value);
        }
示例#3
0
        /// <param name="fi">field index</param>
        public void WriteFace(bool inc, TI.IElementArray ea, int fi, int index)
        {
            string s0, s1, s2;

            GetFace(inc, ea, fi, index, out s0, out s1, out s2);

            m_stream.WriteLine("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}", s0, s1, s2);
        }
示例#4
0
        /// <param name="fi">field index</param>
        /// <param name="fi_t">field index</param>
        /// <param name="fi_n">field index</param>
        public void WriteFace(bool inc, TI.IElementArray ea, int fi, TI.IElementArray ea_t, int fi_t, TI.IElementArray ea_n, int fi_n, int index)
        {
            const string k_v_vt_vn = "f {0}/{1}/{2} {3}/{4}/{5} {6}/{7}/{8}";
            string       fmt       = k_v_vt_vn;

            string sv0, sv1, sv2, svt0, svt1, svt2, svn0, svn1, svn2;

            GetFace(inc, ea, fi, index, out sv0, out sv1, out sv2);
            GetFace(inc, ea_t, fi_t, index, out svt0, out svt1, out svt2);
            GetFace(inc, ea_n, fi_n, index, out svn0, out svn1, out svn2);

            m_stream.WriteLine(fmt, sv0, sv1, sv2, svt0, svt1, svt2, svn0, svn1, svn2);
        }
示例#5
0
        public static GlobalsBlock[] FromBlock(TI.IBlock block)
        {
            TI.IElementArray ea    = block.GetElements();
            GlobalsBlock[]   value = new GlobalsBlock[ea.Count];

            hs_globals_block hs;

            for (int x = 0; x < value.Length; x++)
            {
                hs = (hs_globals_block)ea.GetElement(x);
                var v = value[x] = new GlobalsBlock();

                v.Name = hs.Name.Value;
                v.Type = (short)hs.Type.Value;
                Blam.DatumIndex index = hs.InitExpressionIndex.Value;
                v.NodeOffset = index.Index;

                // We have to dynamically caluclate the node counts as
                // some globals are set at runtime, ie '(* 20 seconds)'
                v.NodeCount = -1;
            }

            return(value);
        }