void ParseDefine(ScopeGroup getter, ScopeGroup scope, DefineNode defineNode)
        {
            IndexedVar var;

            if (!defineNode.Extended)
            {
                var = IndexedVar.AssignVar(VarCollection, scope, defineNode.VariableName, IsGlobal, defineNode);
            }
            else
            {
                var = IndexedVar.AssignVarExt(VarCollection, scope, defineNode.VariableName, IsGlobal, defineNode);
            }

            // Set the defined variable if the variable is defined like "define var = 1"
            Element[] inScopeActions = var.InScope(defineNode.Value != null ? ParseExpression(getter, scope, defineNode.Value) : null);
            if (inScopeActions != null)
            {
                Actions.AddRange(inScopeActions);
            }

            if (defineNode.Type != null)
            {
                var.Type = ParserData.GetDefinedType(defineNode.Type, defineNode.Location);
            }
        }
        public Var[] AssignParameterVariables(ScopeGroup methodScope, ParameterBase[] parameters, IWorkshopTree[] values, Node methodNode)
        {
            Var[] parameterVars = new Var[values.Length];
            for (int i = 0; i < values.Length; i++)
            {
                if (values[i] is Element)
                {
                    // Create a new variable using the parameter.
                    if (!parameters[i].Extended)
                    {
                        parameterVars[i] = IndexedVar.AssignVar(VarCollection, methodScope, parameters[i].Name, IsGlobal, methodNode);
                    }
                    else
                    {
                        parameterVars[i] = IndexedVar.AssignVarExt(VarCollection, methodScope, parameters[i].Name, IsGlobal, methodNode);
                    }

                    ((IndexedVar)parameterVars[i]).Type = ((Element)values[i]).SupportedType?.Type;
                    Actions.AddRange(((IndexedVar)parameterVars[i]).SetVariable((Element)values[i]));
                }
                else if (values[i] is EnumMember)
                {
                    parameterVars[i] = new ElementReferenceVar(parameters[i].Name, methodScope, methodNode, values[i]);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            return(parameterVars);
        }
        private void GetObjects(RulesetNode rulesetNode, string file, TranslateRule globalTranslate, TranslateRule playerTranslate)
        {
            string absolute = new Uri(file).AbsolutePath;

            // Get the defined types
            foreach (var definedType in rulesetNode.DefinedTypes)
            {
                try
                {
                    if (DefinedTypes.Any(type => type.Name == definedType.Name))
                    {
                        throw SyntaxErrorException.NameAlreadyDefined(definedType.Location);
                    }
                    DefinedTypes.Add(DefinedType.GetDefinedType(definedType));
                }
                catch (SyntaxErrorException ex)
                {
                    Diagnostics.Error(ex);
                }
            }

            // Get the user methods.
            for (int i = 0; i < rulesetNode.UserMethods.Length; i++)
            {
                try
                {
                    UserMethods.Add(UserMethod.CreateUserMethod(Root, rulesetNode.UserMethods[i]));
                }
                catch (SyntaxErrorException ex)
                {
                    Diagnostics.Error(ex);
                }
            }

            // Get the rules
            RuleNodes.AddRange(rulesetNode.Rules);

            List <string> importedFiles = new List <string>();

            foreach (ImportObjectNode importObject in rulesetNode.ObjectImports)
            {
                try
                {
                    Importer importer = new Importer(Diagnostics, importedFiles, importObject.File, file, importObject.Location);
                    if (!importer.AlreadyImported)
                    {
                        importedFiles.Add(importer.ResultingPath);
                        switch (importer.FileType)
                        {
                        case ".obj":
                            importer.FileData.Update();
                            string content  = importer.FileData.Content;
                            Model  newModel = Model.ImportObj(content);
                            new ModelVar(importObject.Name, Root, importObject, newModel);
                            break;

                        case ".pathmap":
                            PathMap pathMap = PathMap.ImportFromXML(importer.ResultingPath);
                            new PathMapVar(this, importObject.Name, Root, importObject, pathMap);
                            break;
                        }
                    }
                }
                catch (SyntaxErrorException ex)
                {
                    Diagnostics.Error(ex);
                }
            }

            // Get the variables
            foreach (var definedVar in rulesetNode.DefinedVars)
            {
                try
                {
                    IndexedVar var;

                    if (!definedVar.Extended)
                    {
                        if (definedVar.OverrideID == -1)
                        {
                            var = IndexedVar.AssignVar(VarCollection, Root, definedVar.VariableName, definedVar.IsGlobal, definedVar);
                        }
                        else
                        {
                            var = IndexedVar.AssignVar(
                                VarCollection,
                                Root,
                                definedVar.VariableName,
                                definedVar.IsGlobal,
                                new WorkshopVariable(definedVar.IsGlobal, definedVar.OverrideID, VarCollection.WorkshopNameFromCodeName(definedVar.IsGlobal, definedVar.VariableName)),
                                definedVar
                                );
                        }
                    }
                    else
                    {
                        var = IndexedVar.AssignVarExt(VarCollection, Root, definedVar.VariableName, definedVar.IsGlobal, definedVar);
                    }


                    if (definedVar.Type != null)
                    {
                        var.Type = GetDefinedType(definedVar.Type, definedVar.Location);
                    }
                }
                catch (SyntaxErrorException ex)
                {
                    Diagnostics.Error(ex);
                }
            }
        }