Example #1
0
 private void LoadRoutines(IEnumerable <RoutineModel> data3)
 {
     foreach (RoutineModel item in data3)
     {
         item.DatabaseName = name;
         Routines.Add(item);
     }
 }
Example #2
0
        public static void LoadCharities()
        {
            charityDatabase.AppendCharity("Programming");
            charityDatabase.AppendCharity("Is");
            charityDatabase.AppendCharity("Fun");

            Routines.Add(new CharitySelection(charityDatabase));
            Routines.Add(new CharityDonation(charityDatabase));
            Routines.Add(new Callback());
        }
Example #3
0
 void PrepareLateRoutineBuilders()
 {
     // builders for routines (again, in case any were added during compilation, e.g. by a PROPSPEC)
     foreach (var routine in Context.ZEnvironment.Routines)
     {
         Debug.Assert(routine.Name != null);
         if (!Routines.ContainsKey(routine.Name))
         {
             Routines.Add(routine.Name, Game.DefineRoutine(
                              routine.Name.Text,
                              routine.Name == Context.ZEnvironment.EntryRoutineName,
                              (routine.Flags & RoutineFlags.CleanStack) != 0));
         }
     }
 }
Example #4
0
        void PrepareEarlyRoutineBuilders()
        {
            // builders for routines
            if (Context.ZEnvironment.EntryRoutineName == null)
            {
                Context.ZEnvironment.EntryRoutineName = Context.GetStdAtom(StdAtom.GO);
            }

            foreach (var routine in Context.ZEnvironment.Routines)
            {
                Debug.Assert(routine.Name != null);

                Routines.Add(routine.Name, Game.DefineRoutine(
                                 routine.Name.Text,
                                 routine.Name == Context.ZEnvironment.EntryRoutineName,
                                 (routine.Flags & RoutineFlags.CleanStack) != 0));
            }
        }
Example #5
0
        /// <summary>
        /// Parses a header. Sets parser state accordingly.
        /// </summary>
        /// <remarks>
        /// A header is in the following format
        /// [headerName, param1, param2, ...]
        ///
        /// So for example
        /// [objects]
        ///
        /// Or more complex
        /// [routine,_Routine1,1,true]
        /// </remarks>
        /// <param name="line">The header line</param>
        private void ParseHeaders(string line)
        {
            _currentHeading = line
                              .Trim('[', ']')
                              .Split(',')
                              .Select(x => x.Trim())
                              .ToArray();

            Validate("A heading must have at least one value in it",
                     () => _currentHeading.Length > 0);

            _state = _currentHeading[0] switch
            {
                "objects" => ParserState.Objects,
                "positions" => ParserState.Positions,
                "variables" => ParserState.Variables,
                "text" => ParserState.Text,
                "routine" => ParserState.Routines,
                _ => ParserState.Invalid
            };

            Validate($"Current heading produced invalid state {line}",
                     () => _state != ParserState.Invalid);

            // Check if we are a new routine, if so populate current routine
            if (_state == ParserState.Routines)
            {
                if (_currentRoutine != null)
                {
                    _currentRoutine.EndLineNumber = _lineNo - 1;
                }

                // Routine is in format [routine,ROUTINE_NAME,1,ACTIVE_ON_START]
                _currentRoutine = new ScripterRoutine
                {
                    Name = _currentHeading[1],
                    GlobalRoutineSpeed    = int.Parse(_currentHeading[2]),
                    GlobalRoutinePriority = bool.Parse(_currentHeading[3]),
                    LineNumber            = _lineNo,
                };
                Routines.Add(_currentRoutine);
            }
        }
Example #6
0
        async Task ExecuteLoadRoutinesCommand()
        {
            IsBusy = true;

            try
            {
                Routines.Clear();
                var items = await _routineService.GetItemsAsync(true);

                foreach (var item in items)
                {
                    Routines.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #7
0
 public void Add(Routine routine)
 {
     routine.Id = Routines.GetNewId();
     Routines.Add(routine);
     SortRoutines();
 }
Example #8
0
 protected virtual void TrackRoutine()
 {
     Routines.Add(this);
 }