Ejemplo n.º 1
0
        public KeyValuePair <int, MegaloScriptObjectFilter> CreateObjectFilter(string codeName,
                                                                               int labelStringIndex)
        {
            var filter = new MegaloScriptObjectFilter {
                CodeName         = codeName,
                LabelStringIndex = labelStringIndex
            };

            ObjectFilters.Add(filter);
            return(new KeyValuePair <int, MegaloScriptObjectFilter>(ObjectFilters.Count - 1, filter));
        }
        void DecompileObjectFilterName(MegaloScriptObjectFilter filter, int filterIndex)
        {
            var sb = new System.Text.StringBuilder();

            sb.Append("ObjectFilter");

            if (!filter.HasParameters)
            {
                sb.Append(filterIndex);
            }
            else
            {
                bool prefix_underscore = true;

                if (filter.HasObjectTypeIndex)
                {
                    string obj_type = Model.ToIndexName(Proto.MegaloScriptValueIndexTarget.ObjectType, filter.ObjectTypeIndex);

                    if (prefix_underscore)
                    {
                        sb.Append('_');
                    }
                    sb.Append(obj_type);
                    prefix_underscore = true;
                }
                if (filter.HasTeam)
                {
                    string team_name = Proto.MegaloScriptEnum.ToMemberName(Database,
                                                                           Database.TeamDesignatorValueType, filter.Team);

                    if (prefix_underscore)
                    {
                        sb.Append('_');
                    }
                    sb.Append(team_name);
                    prefix_underscore = true;
                }
                if (filter.HasNumeric)
                {
                    if (prefix_underscore)
                    {
                        sb.Append('_');
                    }
                    sb.Append(filter.Numeric.ToString());
                    prefix_underscore = true;
                }
            }

            filter.CodeName = sb.ToString();
        }