private void TriggerOn(TriggerPoint point)
 {
     if (this.triggerPoint == point)
     {
         this.Trigger();
     }
 }
Пример #2
0
        public T RunTriggerScript <T>(QueryPiplineContext queryPiplineContext, TriggerPoint triggerPoint, string functionName, T result, params object[] parameters)
        {
            var triggerScripts = queryPiplineContext.TriggerScriptsOfOneServiceType?.Where(t => t.TriggerPoint == (int)triggerPoint).ToList();

            if (triggerScripts != null && triggerScripts.Any())
            {
                foreach (var script in triggerScripts)
                {
                    var dynamicScript = script.ToDynamicScript();
                    dynamicScript.FunctionName = functionName;
                    dynamicScript.ProjectName  = queryPiplineContext.ApplicationCode;
                    dynamicScript.Parameters   = parameters;
                    var executeResult = _scriptEngineProvider.RunScript <T>(dynamicScript);
                    if (!executeResult.IsSuccess && (OnFailurePolicy)script.OnFailurePolicy == OnFailurePolicy.Break)
                    {
                        throw new Exception(executeResult.Message);
                    }
                    else
                    {
                        result = executeResult.Data;
                    }
                }
            }
            return(result);
        }
Пример #3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            hash ^= steps_.GetHashCode();
            if (TriggerPoint.Length != 0)
            {
                hash ^= TriggerPoint.GetHashCode();
            }
            if (Priority != 0)
            {
                hash ^= Priority.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
 public SnapshotPoint?GetTriggerPoint(ITextSnapshot textSnapshot)
 {
     return(TriggerPoint.GetPoint(textSnapshot));
 }
Пример #5
0
    //Scans and retrieves all the objects in the scene with the environment tag
    private List <ObjectSet> ScanScene()
    {
        List <GameObject> envObjects = GameObjectsInScene();

        List <ObjectSet> mazeSet = new List <ObjectSet>();

        foreach (GameObject env in envObjects)
        {
            //Save the objects transform properties into an ObjectSet

            string envName = env.name;

            if (env.tag == "Spawn")
            {
                if (env.GetComponent <SpawnScript>().playerSpawn)
                {
                    envName += "P";
                }
            }
            //Debug.Log (env);
            int state = 0;
            // For antimatter state determines if it is antimatter or matter. 0 = antimatter, 1 = matter
            if (env.tag == "AntiMatter" && env.GetComponent <AntiMatterScript>().isMatter)
            {
                state = 1;
            }
            else if (env.tag == "EField")
            {
                state = env.GetComponent <ElectricFieldScript>().flips;
                // For Magnetic field state refers to whether or not the magnetic field is into our out of page. 0 = into, 1 = out of
            }
            else if (env.tag == "MField" && env.GetComponent <MagneticFieldScript>().direction)
            {
                state = 1;
                // Whether or not the teleporter is activated, 0 = no, 1 = yes
            }
            else if (env.tag == "Teleporter" && env.GetComponent <TeleporterScript>().enabled)
            {
                state = 1;
                // Whether or not the Measurer is measuring momentem or position. 0 for position, 1 for momentum
            }
            else if (env.tag == "Measurer" && env.GetComponent <MeasurerScript>().pORxMeasure)
            {
                state = 1;
                // Whether or not the spawn is a player spawn or not
            }
            else if (env.tag == "Spawn" && env.GetComponent <SpawnScript>().playerSpawn)
            {
                state = 1;
            }
            else if (env.tag == "Walls")
            {
                //Debug.Log (env.GetComponent<WallScript>());
                // The state is twice the value of the energy in the wall. If the wall is even then the wall is verticle, otherwise it is horizontal
                state = 2 * env.GetComponent <WallScript>().energyConsumption;
                //Debug.Log (env.GetComponent<WallScript>().energyConsumption);
                if (env.GetComponent <WallScript>().IsHorizontal())
                {
                    state++;
                }
                //Debug.Log (state);
            }
            else if (env.tag == "Trigger")
            {
                TriggerPoint triggerScript = env.GetComponent <TriggerPoint>();
                TriggerFlags stateFlag     = 0;
                if (triggerScript.levelEnd)
                {
                    stateFlag |= TriggerFlags.LevelEnd;
                }
                else if (triggerScript.convertMatter)
                {
                    stateFlag |= TriggerFlags.MatterConversion;
                }

                state = ((int)stateFlag);
            }
            else if (env.tag == "Gate" && !env.GetComponent <GateScript>().isMatter)
            {
                state = 1;
            }
            // Determining the state of the object, in terms of rotation or what-not

            /*
             * if(env.tag == dg) {
             *
             *
             * } else {
             *
             * }
             */
            mazeSet.Add(new ObjectSet(env.transform.position, env.transform.rotation, env.transform.localScale, envName, state));
        }

        return(mazeSet);
    }
Пример #6
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            var completionSetsCount = completionSets.Count;
            var tokens = classifier.Tokens;

            if (tokens != null)
            {
                // find current token
                var cursorPosition = session.TextView.Caret.Position.BufferPosition;

                var currentTokenIndex = FindCurrentTokenIndex(tokens, cursorPosition.Position);
                if (currentTokenIndex >= 0)
                {
                    // prepare the context
                    var currentToken = classifier.Tokens[currentTokenIndex];
                    var items        = Enumerable.Empty <SimpleDothtmlCompletion>();
                    var context      = GetCompletionContext(session);
                    context.CompletionSession = session;
                    context.CurrentTokenIndex = currentTokenIndex;
                    context.CurrentNode       = parser.Root.FindNodeByPosition(cursorPosition.Position - 1);
                    var combineWithHtmlCompletions = false;
                    int?applicableToStartPosition  = null;

                    TriggerPoint triggerPoint = TriggerPoint.None;
                    if (currentToken.Type == DothtmlTokenType.DirectiveStart)
                    {
                        // directive name completion
                        triggerPoint = TriggerPoint.DirectiveName;
                        items        = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                    }
                    else if (currentToken.Type == DothtmlTokenType.DirectiveValue)
                    {
                        // directive value
                        triggerPoint = TriggerPoint.DirectiveValue;

                        // prepare applicable start position to include value text tag in the intellisense selection to replace
                        applicableToStartPosition = tokens[currentTokenIndex].StartPosition;
                        items = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                    }
                    else if (currentToken.Type == DothtmlTokenType.OpenTag || IsTagName(currentTokenIndex, tokens))
                    {
                        // element name
                        triggerPoint = TriggerPoint.TagName;
                        items        = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                        if (currentToken.Type != DothtmlTokenType.OpenTag)
                        {
                            applicableToStartPosition = tokens[GetTagNameStartTokenIndex(currentTokenIndex, tokens)].StartPosition;
                        }
                        combineWithHtmlCompletions = true;
                    }
                    else if (currentToken.Type == DothtmlTokenType.WhiteSpace || currentToken.Type == DothtmlTokenType.Text)
                    {
                        var previousToken = GetPreviousToken(currentTokenIndex, tokens, new[] { DothtmlTokenType.WhiteSpace });

                        if (context.CurrentNode?.Tokens.All(all => all.Type == DothtmlTokenType.WhiteSpace || (all.Type == DothtmlTokenType.Text && string.IsNullOrWhiteSpace(all.Text))) == true)
                        {
                            session.Dismiss();
                            return;
                        }

                        // prepare applicable start position to include current text tag in the intellisense selection to replace
                        if (currentToken.Type == DothtmlTokenType.Text)
                        {
                            applicableToStartPosition = tokens[currentTokenIndex].StartPosition;
                        }

                        if (context.CurrentNode is DothtmlDirectiveNode && previousToken?.Type == DothtmlTokenType.DirectiveName)
                        {
                            // directive value
                            triggerPoint = TriggerPoint.DirectiveValue;
                            items        = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                        }
                        else if (previousToken?.Type == DothtmlTokenType.OpenBinding)
                        {
                            // binding name
                            triggerPoint = TriggerPoint.BindingName;
                            items        = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                        }
                        else if (context.CurrentNode is DothtmlElementNode || context.CurrentNode is DothtmlAttributeNode)
                        {
                            // attribute name
                            triggerPoint = TriggerPoint.TagAttributeName;
                            items        = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                            combineWithHtmlCompletions = sourceProvider.CompletionProviders.OfType <MainTagAttributeNameCompletionProvider>().Single().CombineWithHtmlCompletions;
                        }
                        else if (previousToken?.Type == DothtmlTokenType.SingleQuote || previousToken?.Type == DothtmlTokenType.DoubleQuote || previousToken?.Type == DothtmlTokenType.Equals)
                        {
                            // attribute value
                            triggerPoint = TriggerPoint.TagAttributeValue;
                            items        = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                            combineWithHtmlCompletions = true;
                        }
                    }
                    else if (currentToken.Type == DothtmlTokenType.SingleQuote || currentToken.Type == DothtmlTokenType.DoubleQuote || currentToken.Type == DothtmlTokenType.Equals)
                    {
                        // attribute value
                        triggerPoint = TriggerPoint.TagAttributeValue;
                        items        = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                        combineWithHtmlCompletions = true;
                    }
                    else if (currentToken.Type == DothtmlTokenType.OpenBinding)
                    {
                        // binding name
                        triggerPoint = TriggerPoint.BindingName;
                        items        = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                    }
                    else if (currentToken.Type == DothtmlTokenType.Colon)
                    {
                        if (context.CurrentNode is DothtmlBindingNode)
                        {
                            // binding value
                            triggerPoint = TriggerPoint.BindingValue;
                            items        = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                        }
                        else
                        {
                            // element name
                            triggerPoint = TriggerPoint.TagName;
                            items        = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                            combineWithHtmlCompletions = true;
                        }
                    }
                    var results = items.OrderBy(v => v.DisplayText).Distinct(CompletionEqualityComparer.Instance).ToList();

                    // handle duplicate sessions (sometimes this method is called twice (e.g. when space key is pressed) so we need to make sure that we'll display only one session
                    lock (activeSessions)
                    {
                        if (activeSessions.Count > 0)
                        {
                            activeSessions.ToList().ForEach(fe => fe.Dismiss());
                        }
                        activeSessions.Add(session);

                        session.Dismissed += (s, a) =>
                        {
                            lock (activeSessions)
                            {
                                activeSessions.Remove((ICompletionSession)s);
                            }
                        };
                        session.Committed += (s, a) =>
                        {
                            lock (activeSessions)
                            {
                                activeSessions.Remove((ICompletionSession)s);
                            }
                        };
                    }

                    if (results.Any())
                    {
                        // show the session
                        var newCompletionSet = new CustomCompletionSet("dotVVM", "dotVVM", FindTokenSpanAtPosition(session, applicableToStartPosition ?? -1), results, null);
                        if (combineWithHtmlCompletions && completionSets.Any())
                        {
                            newCompletionSet = MergeCompletionSets(completionSets, newCompletionSet);
                        }
                        else
                        {
                            completionSets.Clear();
                        }
                        completionSets.Add(newCompletionSet);
                    }
                }
            }
        }