void GenerateSwitchGroup(SwitchGroup switchGroup, CodeBuilder classBuilder, int indentLevel, PropertyHash propertyHash)
        {
            classBuilder.AppendLine(indentLevel, $"switch({propertyHash.GenerateHashCode()})");
            classBuilder.AppendLine(indentLevel, "{");

            foreach (var hashGroup in switchGroup)
            {
                classBuilder.AppendLine(indentLevel + 1, $"case {hashGroup.Key}:");
                var subProperties = hashGroup.ToArray();
                if (subProperties.Length != 1)
                {
                    GenerateProperties(subProperties, indentLevel + 2, classBuilder);
                    classBuilder.AppendLine(indentLevel + 2, "break;");
                    continue;
                }
                var property            = subProperties[0];
                var propertyNameBuilder = new StringBuilder();
                propertyNameBuilder.AppendDoubleEscaped(property.JsonName);
                string jsonName = propertyNameBuilder.ToString();
                classBuilder.AppendLine(indentLevel + 2, $"if(!propertyName.EqualsString(\"{jsonName}\"))");
                classBuilder.AppendLine(indentLevel + 2, "{");
                classBuilder.AppendLine(indentLevel + 3, "json = json.SkipProperty();");
                classBuilder.AppendLine(indentLevel + 3, "break;");
                classBuilder.AppendLine(indentLevel + 2, "}");

                var generator = _getGeneratorForType(property.Type);
                generator.GenerateFromJson(classBuilder, indentLevel + 2, property.Type, propertyValue => $"value.{property.CodeName} = {propertyValue};", $"value.{property.CodeName}");

                classBuilder.AppendLine(indentLevel + 2, "break;");
            }

            classBuilder.AppendLine(indentLevel, "}"); // end of switch
        }
Esempio n. 2
0
        void GenerateSwitchGroup(SwitchGroup switchGroup, CodeBuilder classBuilder, int indentLevel, PropertyHash propertyHash, JsonFormat format)
        {
            classBuilder.AppendLine(indentLevel, $"switch({propertyHash.GenerateHashCode()})");
            classBuilder.AppendLine(indentLevel, "{");

            foreach (var hashGroup in switchGroup)
            {
                classBuilder.AppendLine(indentLevel + 1, $"case {hashGroup.Key}:");
                var subProperties = hashGroup.ToArray();
                if (subProperties.Length != 1)
                {
                    GenerateProperties(subProperties, indentLevel + 2, classBuilder, format);
                    classBuilder.AppendLine(indentLevel + 2, "break;");
                    continue;
                }
                var property = subProperties[0];

                if (format == JsonFormat.UTF8)
                {
                    var propertyNameBuilder = new StringBuilder();
                    propertyNameBuilder.AppendEscaped(property.JsonName);
                    string jsonName = propertyNameBuilder.ToString();
                    var    literal  = _literals.GetMatchesLiteral(jsonName);
                    classBuilder.AppendLine(indentLevel + 2, $"if(!propertyName.{literal.CodeName}())");
                }
                else if (format == JsonFormat.String)
                {
                    var propertyNameBuilder = new StringBuilder();
                    propertyNameBuilder.AppendDoubleEscaped(property.JsonName);
                    string jsonName = propertyNameBuilder.ToString();
                    classBuilder.AppendLine(indentLevel + 2, $"if(!propertyName.EqualsString(\"{jsonName}\"))");
                }
                classBuilder.AppendLine(indentLevel + 2, "{");
                classBuilder.AppendLine(indentLevel + 3, "json = json.SkipProperty();");
                classBuilder.AppendLine(indentLevel + 3, "break;");
                classBuilder.AppendLine(indentLevel + 2, "}");

                var generator = _getGeneratorForType(property.Type);
                generator.GenerateFromJson(
                    classBuilder,
                    indentLevel + 2,
                    property.Type,
                    propertyValue => $"value.{property.CodeName} = {propertyValue};",
                    $"value.{property.CodeName}",
                    format);
                if (property.WasSetVariable != null)
                {
                    classBuilder.AppendLine(indentLevel + 2, $"{property.WasSetVariable} = true;");
                }

                classBuilder.AppendLine(indentLevel + 2, "break;");
            }

            // default to handle unmapped properties
            classBuilder.AppendLine(indentLevel + 1, "default:");
            classBuilder.AppendLine(indentLevel + 2, "json = json.SkipProperty();");
            classBuilder.AppendLine(indentLevel + 2, "break;");

            classBuilder.AppendLine(indentLevel, "}"); // end of switch
        }
Esempio n. 3
0
        SwitchGroup GetSwitchGroups(IGrouping <int, JsonPropertyInstance>[] hashes)
        {
            var switchGroup = new SwitchGroup();

            foreach (var grouping in hashes)
            {
                switchGroup.Add(grouping);
            }

            return(switchGroup);
        }
Esempio n. 4
0
    //导入存储信息
    void LoadDataMain()
    {
        SingleScene temp = Global.m_sceneData.GetDataBySceneName(Application.loadedLevelName);

        if (temp != null)
        {
            obj_destroy = temp.obj_destroy;
            pri_switch  = temp.pri_switch;
            LoadLightData(temp.light_data);
        }
    }
Esempio n. 5
0
        private Statement ProcessSwitchStatement(SwitchNode node)
        {
            Expression condition = expressionBuilder.BuildExpression(node.Condition);

            if (condition is MemberExpression)
            {
                condition = expressionBuilder.TransformMemberExpression((MemberExpression)condition);
            }

            SwitchStatement statement = new SwitchStatement(condition);

            foreach (SwitchSectionNode switchSectionNode in node.Cases)
            {
                SwitchGroup group = new SwitchGroup();

                foreach (StatementNode caseNode in switchSectionNode.Labels)
                {
                    if (caseNode is CaseLabelNode)
                    {
                        CaseLabelNode labelNode  = (CaseLabelNode)caseNode;
                        Expression    labelValue = expressionBuilder.BuildExpression(labelNode.Value);

                        if (labelValue is MemberExpression)
                        {
                            labelValue = expressionBuilder.TransformMemberExpression((MemberExpression)labelValue);
                        }

                        group.AddCase(labelValue);
                    }
                    else
                    {
                        Debug.Assert(caseNode is DefaultLabelNode);
                        group.AddDefaultCase();
                    }
                }

                foreach (StatementNode statementNode in switchSectionNode.Statements)
                {
                    Statement childStatement = BuildStatement(statementNode);

                    if (childStatement != null)
                    {
                        group.AddStatement(childStatement);
                    }
                }

                statement.AddSwitchGroup(group);
            }

            return(statement);
        }
Esempio n. 6
0
        public override void EnterSwitchGroup(SwitchGroup switchGroup)
        {
            var statements = switchGroup.Statements.ToList();

            if (statements.Count == 1 && statements[0] is BlockStatement)
            {
                return;
            }
            foreach (var statement in statements)
            {
                statement.Remove();
            }
            switchGroup.AddChild(new BlockStatement(switchGroup.Context, statements));
        }
Esempio n. 7
0
 // Use this for initialization
 void Awake()
 {
     if (!once)
     {
         DontDestroyOnLoad(gameObject);
         once = true;
     }
     else
     {
         Destroy(gameObject);
     }
     m_dialog      = GameObject.FindObjectOfType <DialogManage>();
     m_frag        = GameObject.FindObjectOfType <FragmentSystem>();
     m_ui          = GameObject.FindObjectOfType <UIInterface>();
     m_pubSwitches = GameObject.FindObjectOfType <SwitchGroup>();
     m_sceneData   = GameObject.FindObjectOfType <SceneSaveData>();
 }
        IEnumerable <SwitchGroup> FindSwitchGroups(IGrouping <int, JsonPropertyInstance>[] hashes)
        {
            int last        = 0;
            int gaps        = 0;
            var switchGroup = new SwitchGroup();

            foreach (var grouping in hashes)
            {
                int hash = grouping.Key;
                gaps += hash - last - 1;
                if (gaps > 8)
                {
                    //to many gaps this switch group is finished
                    yield return(switchGroup);

                    switchGroup = new SwitchGroup();
                    gaps        = 0;
                }
                switchGroup.Add(grouping);
            }
            yield return(switchGroup);
        }
Esempio n. 9
0
 public override INode VisitSwitchGroup(SwitchGroup switchGroup)
 {
     return(new SwitchGroup(switchGroup.Context, switchGroup.Children.Select(Visit)));
 }
Esempio n. 10
0
 public virtual void ExitSwitchGroup(SwitchGroup switchGroup)
 {
 }
Esempio n. 11
0
 public virtual void EnterSwitchGroup(SwitchGroup switchGroup)
 {
 }
Esempio n. 12
0
 public virtual T VisitSwitchGroup(SwitchGroup switchGroup)
 {
     return(VisitChildren(switchGroup));
 }
	void OnEnable()
	{
		g = target as SwitchGroup;
		EditorApplication.hierarchyWindowChanged += OnHierarchyChanged;
	}
Esempio n. 14
0
        public static STMGSection ParseSection(byte[] blob)
        {
            using (var reader = new BinaryReader(new MemoryStream(blob)))
            {
                var stmgSection = new STMGSection((uint)blob.Length);
                stmgSection.VolumeThreshold   = reader.ReadSingle();
                stmgSection.MaxVoiceInstances = reader.ReadUInt16();
                stmgSection.StateGroupCount   = reader.ReadUInt32();
                stmgSection.StateGroups       = new StateGroup[stmgSection.StateGroupCount];
                for (var i = 0; i < stmgSection.StateGroupCount; i++)
                {
                    var stateGroup = new StateGroup();
                    stateGroup.Id = reader.ReadUInt32();
                    stateGroup.DefaultTransitionTime     = reader.ReadUInt32();
                    stateGroup.CustomTransitionTimeCount = reader.ReadUInt32();
                    stateGroup.CustomTransitionTimes     = new CustomTransitionTime[stateGroup.CustomTransitionTimeCount];
                    for (var j = 0; j < stateGroup.CustomTransitionTimeCount; j++)
                    {
                        CustomTransitionTime customTransitionTime = default;
                        customTransitionTime.FromStateId    = reader.ReadUInt32();
                        customTransitionTime.ToStateId      = reader.ReadUInt32();
                        customTransitionTime.TransitionTime = reader.ReadUInt32();
                        stateGroup.CustomTransitionTimes[j] = customTransitionTime;
                    }
                    stmgSection.StateGroups[i] = stateGroup;
                }
                stmgSection.ParameterDependentSwitchGroupCount = reader.ReadUInt32();
                stmgSection.ParameterDependentSwitchGroups     = new SwitchGroup[stmgSection.ParameterDependentSwitchGroupCount];
                for (var i = 0; i < stmgSection.ParameterDependentSwitchGroupCount; i++)
                {
                    var switchGroup = new SwitchGroup();
                    switchGroup.Id = reader.ReadUInt32();
                    switchGroup.GameParameterId  = reader.ReadUInt32();
                    switchGroup.Unknown_08       = reader.ReadByte();
                    switchGroup.SwitchPointCount = reader.ReadUInt32();
                    switchGroup.SwitchPoints     = new SwitchPoint[switchGroup.SwitchPointCount];
                    for (var j = 0; j < switchGroup.SwitchPointCount; j++)
                    {
                        SwitchPoint switchPoint = default;
                        switchPoint.X = reader.ReadSingle();
                        switchPoint.Y = reader.ReadUInt32();
                        switchPoint.FollowingCurveShape = reader.ReadUInt32();
                        switchGroup.SwitchPoints[j]     = switchPoint;
                    }
                    stmgSection.ParameterDependentSwitchGroups[i] = switchGroup;
                }
                stmgSection.GameParameterCount = reader.ReadUInt32();
                stmgSection.GameParameters     = new GameParameter[stmgSection.GameParameterCount];
                for (var i = 0; i < stmgSection.GameParameterCount; i++)
                {
                    var gameParameter = new GameParameter();
                    gameParameter.Id                    = reader.ReadUInt32();
                    gameParameter.DefaultValue          = reader.ReadSingle();
                    gameParameter.InterpolationMode     = (GameParameterInterpolationMode)reader.ReadUInt32();
                    gameParameter.InterpolationAttack   = reader.ReadSingle();
                    gameParameter.InterpolationRelease  = reader.ReadSingle();
                    gameParameter.BoundBuiltInParameter = (GameParameterBuiltInParameter)reader.ReadByte();
                    stmgSection.GameParameters[i]       = gameParameter;
                }

                return(stmgSection);
            }
        }