コード例 #1
0
        /// <summary>
        /// Use this only when parsing.
        /// </summary>
        public Script GetScript(int offset)
        {
            if (!_initializing)
            {
                throw new Exception("Error: Not initializing.");
            }

            if (offset < 0)
            {
                return(null);
            }

            MovesetEntry e = GetEntry(offset);

            if (e is Script)
            {
                return(e as Script);
            }
            else if (e is Event)
            {
                return(((Event)e)._script);
            }

            return(null);
        }
コード例 #2
0
ファイル: Parameter.cs プロジェクト: 0000duck/brawltools
        internal void LinkScript()
        {
            MovesetEntry e     = _root.GetEntry(RawOffset);
            bool         exist = e != null && e is Event;

            _offsetInfo = _root.GetScriptLocation(RawOffset);

            Script a;

            if (_offsetInfo.list == ListValue.Null && !exist)
            {
                _root.SubRoutines.Add(a = Parse <Script>(RawOffset));
            }
            else if (_offsetInfo.list != ListValue.References)
            {
                a = _root.GetScript(_offsetInfo);
            }
            else
            {
                if (_externalEntry == null && _offsetInfo.index >= 0 && _offsetInfo.index < _root.ReferenceList.Count)
                {
                    _externalEntry = _root.ReferenceList[_offsetInfo.index];
                    _externalEntry.References.Add(this);
                }
                return;
            }

            if (a == null)
            {
                a = GetScript();
            }

            if (a != null)
            {
                a._actionRefs.Add(this);
            }
            else
            {
                throw new Exception("Script not found.");
            }

            _script = a;
        }
コード例 #3
0
        /// <summary>
        /// Use this only when parsing.
        /// </summary>
        internal ScriptOffsetInfo GetScriptLocation(int offset)
        {
            if (!_initializing)
            {
                throw new Exception("Error: Not initializing.");
            }

            //Create new offset info
            ScriptOffsetInfo info = new ScriptOffsetInfo();

            //Check if the offset is legit
            if (offset <= 0)
            {
                return(info);
            }

            info.list = ListValue.Actions;

            //Search action offsets
            for (info.type = 0; (int)info.type < 2; info.type++)
            {
                if ((info.index = _scriptOffsets[(int)info.list][(int)info.type].IndexOf(offset)) != -1)
                {
                    return(info);
                }
            }

            info.list++;

            //Search subaction offsets
            for (info.type = 0; (int)info.type < 4; info.type++)
            {
                if ((info.index = _scriptOffsets[(int)info.list][(int)info.type].IndexOf(offset)) != -1)
                {
                    return(info);
                }
            }

            info.type = TypeValue.None;
            info.list++;

            //Search subroutine offsets
            if ((info.index = _scriptOffsets[(int)info.list][0].IndexOf(offset)) != -1)
            {
                return(info);
            }

            info.list++;

            //Search reference entry offsets
            MovesetEntry e = GetEntry(offset);

            if (e is ExternalEntry && e != null)
            {
                info.index = e.Index;
                return(info);
            }

            //Set values to null
            info.list++;
            info.type  = TypeValue.None;
            info.index = -1;

            //Continue searching dataCommon
            if (_dataCommon != null)
            {
                info.list++;

                //Search screen tint offsets
                if ((info.index = _scriptOffsets[3][0].IndexOf(offset)) != -1)
                {
                    return(info);
                }

                info.list++;

                //Search flash overlay offsets
                if ((info.index = _scriptOffsets[4][0].IndexOf(offset)) != -1)
                {
                    return(info);
                }

                info.list = ListValue.Null;
            }
            return(info);
        }