public override void ProcessObjects(ListReader <MyDefinitionId> objects)
        {
            var allEntities = MyEntities.GetEntities();

            m_tmpSubtypes.Clear();
            foreach (var obj in objects)
            {
                m_tmpSubtypes.Add(obj.SubtypeId);
            }


            // Find floating objects in all objects
            foreach (var entity in allEntities)
            {
                MyFloatingObject floatingObject = entity as MyFloatingObject;
                if (floatingObject == null)
                {
                    continue;
                }

                // Check if not manipulated (in hand)
                if (MyManipulationTool.IsEntityManipulated(entity))
                {
                    continue;
                }

                MyDefinitionId defId = floatingObject.Item.Content.GetObjectId();

                // Check if they are marked as removable in Decay.sbc script file.
                if (m_tmpSubtypes.Contains(defId.SubtypeId))
                {
                    MyFloatingObjects.RemoveFloatingObject(floatingObject, true);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Evaluates parent/child relationships in a top-level result set.
 /// </summary>
 /// <typeparam name="T">The type of object that is returned.</typeparam>
 /// <param name="previous">The previous reader.</param>
 /// <param name="id">An optional function that selects the ID from the object.</param>
 /// <param name="parentId">An optional function that selects the ParentID from the object.</param>
 /// <param name="into">A function that assigns the parent to the child.</param>
 /// <returns>A reader that reads a Results objects with children.</returns>
 public static ListReader <T> SelfReferencing <T>(this ListReader <T> previous,
                                                  Func <T, Object> id       = null,
                                                  Func <T, Object> parentId = null,
                                                  Action <T, T> into        = null)
 {
     return(new SelfReferencingListReader <T>(previous, id, parentId, into));
 }
Beispiel #3
0
        public static MyWeatherEffectDefinition GetRandomWeatherFromList(List <string> listedWeather = null, string lastWeather = null)
        {
            if (listedWeather == null || listedWeather.Count == 0)
            {
                return(GetRandomWeather(new List <string> {
                    lastWeather
                }));
            }

            ListReader <MyWeatherEffectDefinition> weatherDefinitions = MyDefinitionManager.Static.GetWeatherDefinitions();
            var newWeatherList = new List <MyWeatherEffectDefinition>();

            foreach (var weatherName in listedWeather)
            {
                if (weatherName.Equals(lastWeather))
                {
                    continue;
                }
                var def = GetWeatherDefinition(weatherName);
                if (def == null)
                {
                    continue;
                }
                newWeatherList.Add(def);
            }

            return(newWeatherList.Count == 0 ? GetWeatherDefinition("Clear") : newWeatherList[new Random().Next(newWeatherList.Count)]);
        }
        internal static void PrepareCullQuery(MyCullQuery cullQuery, ListReader <MyShadowmapQuery> shadowmapQueries, bool updateEnvironmentMap)
        {
            cullQuery.AddMainViewPass(new MyViewport(MyRender11.ViewportResolution), MyGBuffer.Main);

            foreach (var shadowmapQuery in shadowmapQueries)
            {
                bool isCascade = shadowmapQuery.QueryType == MyFrustumEnum.ShadowCascade;
                var  matrix    = shadowmapQuery.ProjectionInfo.WorldToProjection;
                cullQuery.AddDepthPass(ref matrix, shadowmapQuery.ProjectionInfo.CurrentLocalToProjection, shadowmapQuery.Viewport, shadowmapQuery.DepthBuffer, isCascade, ToString(shadowmapQuery.QueryType));

                if (isCascade)
                {
                    var smallCulling = new MyCullingSmallObjects
                    {
                        ProjectionDir    = shadowmapQuery.ProjectionDir,
                        ProjectionFactor = shadowmapQuery.ProjectionFactor,
                        SkipThreshold    = MyRenderProxy.Settings.ShadowCascadeSmallSkipThresholds[shadowmapQuery.CascadeIndex]
                    };
                    cullQuery.FrustumCullQueries[cullQuery.Size - 1].SmallObjects = smallCulling;
                    cullQuery.FrustumCullQueries[cullQuery.Size - 1].CascadeIndex = shadowmapQuery.CascadeIndex;
                }

                cullQuery.FrustumCullQueries[cullQuery.Size - 1].Type    = shadowmapQuery.QueryType;
                cullQuery.FrustumCullQueries[cullQuery.Size - 1].Ignored = shadowmapQuery.IgnoredEntities;
            }

            if (updateEnvironmentMap)
            {
                MyEnvironmentProbe.UpdateEnvironmentProbes(cullQuery);
            }
        }
Beispiel #5
0
        static LispReader()
        {
            _macros['"'] = new StringReader();
            _macros[';'] = new CommentReader();
            _macros['\''] = new WrappingReader(QUOTE);
            _macros['@'] = new WrappingReader(DEREF);//new DerefReader();
            _macros['^'] = new WrappingReader(META);
            _macros['`'] = new SyntaxQuoteReader();
            _macros['~'] = new UnquoteReader();
            _macros['('] = new ListReader();
            _macros[')'] = new UnmatchedDelimiterReader();
            _macros['['] = new VectorReader();
            _macros[']'] = new UnmatchedDelimiterReader();
            _macros['{'] = new MapReader();
            _macros['}'] = new UnmatchedDelimiterReader();
            ////	macros['|'] = new ArgVectorReader();
            _macros['\\'] = new CharacterReader();
            _macros['%'] = new ArgReader();
            _macros['#'] = new DispatchReader();

            _dispatchMacros['^'] = new MetaReader();
            _dispatchMacros['\''] = new VarReader();
            _dispatchMacros['"'] = new RegexReader();
            _dispatchMacros['('] = new FnReader();
            _dispatchMacros['{'] = new SetReader();
            _dispatchMacros['='] = new EvalReader();
            _dispatchMacros['!'] = new CommentReader();
            _dispatchMacros['<'] = new UnreadableReader();
            _dispatchMacros['_'] = new DiscardReader();
        }
Beispiel #6
0
        /// <param name="args">Recipient grid, recipient block, message</param>
        private static void ProgrammableBlock_SendMessage(MyFunctionalBlock block, ListReader <Ingame.TerminalActionParameter> args)
        {
            if (args.Count != 3)
            {
                Logger.DebugLog("Wrong number of arguments, expected 3, got " + args.Count, Logger.severity.WARNING);
                if (MyAPIGateway.Session.Player != null)
                {
                    block.AppendCustomInfo("Failed to send message:\nWrong number of arguments, expected 3, got " + args.Count + '\n');
                }
                return;
            }

            string[] stringArgs = new string[3];
            for (int i = 0; i < 3; i++)
            {
                if (args[i].TypeCode != TypeCode.String)
                {
                    Logger.DebugLog("TerminalActionParameter #" + i + " is of wrong type, expected String, got " + args[i].TypeCode, Logger.severity.WARNING);
                    if (MyAPIGateway.Session.Player != null)
                    {
                        block.AppendCustomInfo("Failed to send message:\nTerminalActionParameter #" + i + " is of wrong type, expected String, got " + args[i].TypeCode + '\n');
                    }
                    return;
                }

                stringArgs[i] = (string)args[i].Value;
            }

            int count = Message.CreateAndSendMessage(block.EntityId, stringArgs[0], stringArgs[1], stringArgs[2]);

            if (MyAPIGateway.Session.Player != null)
            {
                (block as IMyTerminalBlock).AppendCustomInfo("Sent message to " + count + " block" + (count == 1 ? "" : "s"));
            }
        }
Beispiel #7
0
        public static MyPhysicalItemDefinition GetItemDefinition(MyDefinitionId itemId)
        {
            if (_allItems.Count == 0)
            {
                _allItems = MyDefinitionManager.Static.GetPhysicalItemDefinitions();
            }

            MyPhysicalItemDefinition item = null;

            if (_cachedItemDefinitions.TryGetValue(itemId, out item))
            {
                return(item);
            }

            foreach (var itemdef in _allItems)
            {
                if (itemdef.Id == itemId)
                {
                    item = itemdef;
                    _cachedItemDefinitions.Add(itemId, item);
                    break;
                }
            }

            return(item);
        }
Beispiel #8
0
 public static ListReader <T1> ThenChildren <T1, T2>(
     this ListReader <T1> previous,
     RecordReader <T2> recordReader,
     Action <T1, List <T2> > into = null)
 {
     return(previous.ThenChildren(recordReader.GroupByAuto <T1, object>(), null, into));
 }
        private ListReader<ITerminalAction> GetActions(ListReader<MyTerminalBlock> blocks, out bool genericType)
        {
            try
            {
                bool allFunctional = true;
                foreach (var block in blocks)
                {
                    allFunctional &= block is MyFunctionalBlock;
                    tmpBlockDefinitions.Add(block.BlockDefinition.Id);
                }

                if (tmpBlockDefinitions.Count == 1)
                {
                    genericType = false;
                    return GetValidActions(blocks.ItemAt(0).GetType());
                }
                else if (tmpBlockDefinitions.Count == 0 || !allFunctional)
                {
                    genericType = true;
                    return ListReader<ITerminalAction>.Empty;
                }
                else
                {
                    genericType = true;
                    return GetValidActions(typeof(MyFunctionalBlock));
                }
            }
            finally
            {
                tmpBlockDefinitions.Clear();
            }
        }
Beispiel #10
0
        public void Clear(string planetName)
        {
            var planets = MyEntities.GetEntities().OfType <MyPlanet>().ToList();
            ListReader <MyWeatherEffectDefinition> weatherDefinitions = MyDefinitionManager.Static.GetWeatherDefinitions();
            var weatherDef = weatherDefinitions.FirstOrDefault(x => x.Id.SubtypeName.Equals("Clear"));

            if (planets.Count == 0)
            {
                Context.Respond("No Planet Found");
                return;
            }

            var count = 0;

            foreach (var planet in planets)
            {
                if (planet.Name != planetName)
                {
                    continue;
                }
                count++;
                WeatherGenerator.SetWeatherOnPlanet(planet, weatherDef);
            }

            Context.Respond($"Clearing up the weather on {count} planets");
        }
Beispiel #11
0
        /// <param name="args">EntityIds as long</param>
        private static void TextPanel_DisplayEntities(MyFunctionalBlock block, ListReader <Ingame.TerminalActionParameter> args)
        {
            s_detectedIds.Clear();

            for (int i = 0; i < args.Count; i++)
            {
                if (args[i].TypeCode != TypeCode.Int64)
                {
                    Logger.DebugLog("TerminalActionParameter # " + i + " is of wrong type, expected Int64, got " + args[i].TypeCode, Logger.severity.WARNING);
                    if (MyAPIGateway.Session.Player != null)
                    {
                        block.AppendCustomInfo("Failed to display entities:\nTerminalActionParameter #" + i + " is of wrong type, expected Int64 (AKA long), got " + args[i].TypeCode + '\n');
                    }
                    return;
                }
                s_detectedIds.Add((long)args[i].Value);
            }

            TextPanel panel;

            if (!Registrar.TryGetValue(block.EntityId, out panel))
            {
                Logger.AlwaysLog("Text panel not found in registrar: " + block.EntityId, Logger.severity.ERROR);
                return;
            }

            Logger.DebugLog("Found text panel with id: " + block.EntityId);

            panel.Display(s_detectedIds);
        }
        public override void ProcessObjects(ListReader<MyDefinitionId> objects)
        {
            var allEntities = MyEntities.GetEntities();

            m_tmpSubtypes.Clear();
            foreach (var obj in objects)
                m_tmpSubtypes.Add(obj.SubtypeId);


            // Find floating objects in all objects
            foreach (var entity in allEntities)
            {

                MyFloatingObject floatingObject = entity as MyFloatingObject;
                if(floatingObject == null)
                    continue;

                // Check if not manipulated (in hand)
                if (MyManipulationTool.IsEntityManipulated(entity))
                    continue;

                MyDefinitionId defId = floatingObject.Item.Content.GetObjectId();

                // Check if they are marked as removable in Decay.sbc script file.
                if (m_tmpSubtypes.Contains(defId.SubtypeId))
                {
                    MyFloatingObjects.RemoveFloatingObject(floatingObject, true);
                }

            }
        }
Beispiel #13
0
        private ListReader <ITerminalAction> GetActions(ListReader <MyTerminalBlock> blocks, out bool genericType)
        {
            try
            {
                bool allFunctional = true;
                foreach (var block in blocks)
                {
                    allFunctional &= block is MyFunctionalBlock;
                    tmpBlockTypes.Add(block.GetType());
                }

                if (tmpBlockTypes.Count == 1)
                {
                    genericType = false;
                    return(GetValidActions(blocks.ItemAt(0).GetType()));
                }
                else if (tmpBlockTypes.Count == 0 || !allFunctional)
                {
                    genericType = true;
                    return(ListReader <ITerminalAction> .Empty);
                }
                else
                {
                    genericType = true;
                    return(GetValidActions(typeof(MyFunctionalBlock)));
                }
            }
            finally
            {
                tmpBlockTypes.Clear();
            }
        }
        private async void LoadDataButton_Click(object sender, RoutedEventArgs e)
        {
            ShowMessage("Looking for file...");

            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add(".csv");

            StorageFile file = await openPicker.PickSingleFileAsync();

            if (file != null)
            {
                ShowMessage("Selected file: " + file.Name);

                string text = await Windows.Storage.FileIO.ReadTextAsync(file);

                ShowMessage("Got text: " + text.Substring(0, 30) + "...");

                var RawData = CSVTextParser.ParseText(text);

                var Data = ListReader.ReadLists(RawData);

                App.ApplicationData = Data;

                if (App.ApplicationData != null)
                {
                    ShowMessage("Data found in file:");
                    ShowMessage(App.ApplicationData.Categories.Count.ToString() + " Categories");
                    ShowMessage(App.ApplicationData.ImageFiles.Count.ToString() + " ImageFiles");
                    ShowMessage("");
                    for (int i = 0; i < 10; i++)
                    {
                        if (i < App.ApplicationData.ImageFiles.Count)
                        {
                            ShowMessage("File " + i.ToString() + ":");
                            ShowMessage("   FileName: " + App.ApplicationData.ImageFiles[i].FileName);
                            //ShowMessage("   Path: " + App.ApplicationData.ImageFiles[i].Path);
                            ShowMessage("   No of marks: " + App.ApplicationData.ImageFiles[i].Marks.Count.ToString());

                            string Marks = "";
                            for (int j = 0; j < App.ApplicationData.ImageFiles[i].Marks.Count; j++)
                            {
                                if (App.ApplicationData.ImageFiles[i].Marks[j] == 'x')
                                {
                                    Marks += App.ApplicationData.Categories[j].Name + ", ";
                                }
                            }
                            ShowMessage("   Marks: " + Marks);
                            ShowMessage("");
                        }
                    }
                }
            }
            else
            {
                ShowMessage("No file selected!");
            }
        }
Beispiel #15
0
        /// <summary>
        /// Reads the list of page table items whose head is stored at the page index provided.
        /// The data read from persistent storage is merges with the data already in memory
        /// using the following protocol:
        ///     if the in memory data has the "IsDirty" flag set then we keep the in memory data
        ///     else we over-write the in-memory data with the data from disk
        /// </summary>
        /// <param name="stream">data file to read from</param>
        /// <param name="pageIdx">index of the first physical page storing the list</param>
        /// <returns>returns the index of the first physical page we read data from</returns>
        public int ReadPageTableData(FileStreamWrapper stream, int pageIdx)
        {
            List <PageTableItem> itemList    = null;
            List <int>           pageIdxList = null;

            // create reader
            ListReader <PageTableItem> reader = new ListReader <PageTableItem>();

            reader.ReadList(stream, pageIdx, out itemList, out pageIdxList);

            // merge with current data
            for (int idx = 0; idx < this.pageTable.Count && idx < itemList.Count; idx++)
            {
                if (!this.pageTable[idx].IsDirty)
                {
                    this.pageTable[idx] = itemList[idx];
                }
            }

            // add the missing ones
            if (this.pageTable.Count < itemList.Count)
            {
                this.pageTable.AddRange(
                    itemList.GetRange(
                        this.pageTable.Count,
                        (itemList.Count - this.pageTable.Count)));
            }

            // update page index
            this.pageTableStoragePages = pageIdxList;

            // return index of the first page
            return(this.pageTableStoragePages[0]);
        }
Beispiel #16
0
        public void ListReaderIsFilled()
        {
            ListReader MyReader = new ListReader(FileLocation);
            string     MyOutput = MyReader.OutputList();

            Assert.True(MyOutput != "");
        }
Beispiel #17
0
        /// <summary>
        /// Reads the list of index items whose head is stored at the page index provided.
        /// The data read from persistent storage is merges with the data already in memory
        /// using the following protocol:
        ///     if the in memory data has the "IsDirty" flag set then we keep the in memory data
        ///     else we over-write the in-memory data with the data from disk
        /// </summary>
        /// <param name="stream">data file to read from</param>
        /// <param name="pageIdx">index of the first physical page storing the list</param>
        /// <returns>returns the index of the first physical page we read data from</returns>
        public int ReadIndexData(FileStreamWrapper stream, int pageIdx)
        {
            List <IndexItem <T> > itemList    = null;
            List <int>            pageIdxList = null;

            // create reader
            ListReader <IndexItem <T> > reader = new ListReader <IndexItem <T> >();

            reader.ReadList(stream, pageIdx, out itemList, out pageIdxList);

            // merge with current data
            for (int idx = 0; idx < itemList.Count; idx++)
            {
                var item = itemList[idx];

                IndexItem <T> indexEntry = null;
                if (this.indexMap.TryGetValue(item.ResourceId, out indexEntry))
                {
                    if (null == indexEntry ||
                        indexEntry.IsDirty)
                    {
                        continue;
                    }
                }

                this.indexMap[item.ResourceId] = item;
            }

            // update page index
            this.indexStoragePages = pageIdxList;

            // return index of the first page
            return(this.indexStoragePages[0]);
        }
Beispiel #18
0
 float GetO2TankFill(List <IMyGasTank> airTanks)
 {
     o2TanksCount = 0;
     //get percent in tanks
     o2TanksFill = 0;
     foreach (IMyGasTank de in airTanks)
     {
         de.Components.TryGet <MyResourceSinkComponent>(out sink);
         list  = sink.AcceptedResources;
         hasO2 = false;
         for (int j = 0; j < list.Count; ++j)
         {
             hasO2 = list[j].SubtypeId.ToString() == "Oxygen";
             if (hasO2)
             {
                 break;
             }
         }
         if (hasO2)
         {
             o2TanksFill += de.FilledRatio * 100;
             ++o2TanksCount;
         }
     }
     if (o2TanksCount == 0)
     {
         return(-1);
     }
     o2TanksFill /= o2TanksCount;
     return(o2TanksFill);
 }
        private ListReader<ITerminalAction> GetActions(ListReader<MyTerminalBlock> blocks, out bool genericType)
        {
            try
            {
                bool allFunctional = true;
                foreach (var block in blocks)
                {
                    allFunctional &= block is MyFunctionalBlock;
                    tmpBlockTypes.Add(block.GetType());
                }

                if (tmpBlockTypes.Count == 1)
                {
                    genericType = false;
                    return GetValidActions(blocks.ItemAt(0).GetType(), blocks);
                }
                else if (tmpBlockTypes.Count == 0 || !allFunctional)
                {
                    genericType = true;
                    return ListReader<ITerminalAction>.Empty;
                }
                else
                {
                    genericType = true;
                    var commonType = FindBaseClass(tmpBlockTypes.ToArray<Type>(), typeof(MyFunctionalBlock));
                    return GetValidActions(commonType, blocks);
                }
            }
            finally
            {
                tmpBlockTypes.Clear();
            }
        }
Beispiel #20
0
        public List <T[]> GetParamList2 <T>(object key)
        {
            List <Object>  input  = (List <Object>)GetParam(key);
            ListReader <T> reader = new ListReader <T>();

            return(reader.read2(input));
        }
Beispiel #21
0
        static LispReader()
        {
            _macros['"']  = new StringReader();
            _macros[';']  = new CommentReader();
            _macros['\''] = new WrappingReader(QUOTE);
            _macros['@']  = new WrappingReader(DEREF);//new DerefReader();
            _macros['^']  = new WrappingReader(META);
            _macros['`']  = new SyntaxQuoteReader();
            _macros['~']  = new UnquoteReader();
            _macros['(']  = new ListReader();
            _macros[')']  = new UnmatchedDelimiterReader();
            _macros['[']  = new VectorReader();
            _macros[']']  = new UnmatchedDelimiterReader();
            _macros['{']  = new MapReader();
            _macros['}']  = new UnmatchedDelimiterReader();
            ////	macros['|'] = new ArgVectorReader();
            _macros['\\'] = new CharacterReader();
            _macros['%']  = new ArgReader();
            _macros['#']  = new DispatchReader();


            _dispatchMacros['^']  = new MetaReader();
            _dispatchMacros['\''] = new VarReader();
            _dispatchMacros['"']  = new RegexReader();
            _dispatchMacros['(']  = new FnReader();
            _dispatchMacros['{']  = new SetReader();
            _dispatchMacros['=']  = new EvalReader();
            _dispatchMacros['!']  = new CommentReader();
            _dispatchMacros['<']  = new UnreadableReader();
            _dispatchMacros['_']  = new DiscardReader();
        }
 protected override void OnHook()
 {
     Debug.Assert(MyMultiplayer.Static != null, "Should not get here without multiplayer");
     Block.SyncType.PropertyChanged += Notify;
     Block.OnClose += (entity) => RaiseDestroyed();
     m_properties   = Block.SyncType.Properties;
 }
 public MyTerminalBlockData(MySyncedBlock block, Action<MyTerminalBlockData> propertyDirty)
 {
     Block = block;
     Block.SyncType.PropertyChanged += Notify;
     m_properties = Block.SyncType.Properties;
     m_propertyDirty = propertyDirty;
 }
Beispiel #24
0
        private ListReader <ITerminalAction> GetValidActions(Type blockType, ListReader <MyTerminalBlock> blocks)
        {
            var allActions   = MyTerminalControlFactory.GetActions(blockType);
            var validActions = new List <ITerminalAction>();

            foreach (var action in allActions)
            {
                if (action.IsValidForGroups())
                {
                    bool found = false;
                    foreach (var block in blocks)
                    {
                        if (action.IsEnabled(block))
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        validActions.Add(action);
                    }
                }
            }
            return(validActions);
        }
 public MyTerminalBlockData(MySyncedBlock block, Action <MyTerminalBlockData> propertyDirty)
 {
     Block = block;
     Block.SyncType.PropertyChanged += Notify;
     m_properties    = Block.SyncType.Properties;
     m_propertyDirty = propertyDirty;
 }
        public override void ProcessObjects(ListReader<MyDefinitionId> objects)
        {
            var allEntities = MyEntities.GetEntities();

            m_tmpSubtypes.Clear();
            foreach (var obj in objects)
                m_tmpSubtypes.Add(obj.SubtypeId);

            foreach (var entity in allEntities)
            {
                if (!(entity is MyCubeGrid))
                    continue;

                var cubeGrid = entity as MyCubeGrid;
                if (cubeGrid.BlocksCount != 1)
                    continue;

                if (cubeGrid.IsStatic)
                    continue;

                if (MyManipulationTool.IsEntityManipulated(entity))
                    continue;

                var blocks = cubeGrid.CubeBlocks;
                var block = blocks.First();

                if (m_tmpSubtypes.Contains(block.BlockDefinition.Id.SubtypeId))
                {
                    entity.SyncObject.SendCloseRequest();
                }
            }
        }
        /// <summary>
        /// Splits the specified input into a list of <see cref="ExpressionToken" /> values.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        /// <exception cref="System.NotSupportedException"></exception>
        public ExpressionToken[] Tokenize(string input)
        {
            _currentTokens = new List<ExpressionToken>();
            ExpressionToken lastExpToken = null;

            var reader = new ListReader<RawToken>(new RawTokenizer().Tokenize(input));

            while (!reader.IsEnd)
            {
                var curRawToken = reader.Read();
                switch (curRawToken.TokenType)
                {
                    case RawTokenType.WhiteSpace:
                        // generially ends previous token outside other special scopes
                        lastExpToken = null;
                        break;
                    case RawTokenType.Literal:
                        if (lastExpToken == null || lastExpToken.TokenType != ExpressionTokenType.Value)
                        {
                            lastExpToken = new ExpressionToken { TokenType = ExpressionTokenType.Value };
                            _currentTokens.Add(lastExpToken);
                        }
                        lastExpToken.Append(curRawToken);
                        break;
                    case RawTokenType.Symbol:
                        // first do operator match by checking the prev op
                        // and see if combined with current token would still match a known operator
                        if (KnownOperators.IsKnown(curRawToken.Value))
                        {
                            if (lastExpToken != null && lastExpToken.TokenType == ExpressionTokenType.Operator)
                            {
                                var testOpValue = lastExpToken.Value + curRawToken.Value;
                                if (KnownOperators.IsKnown(testOpValue))
                                {
                                    // just append it
                                    lastExpToken.Append(curRawToken);
                                    continue;
                                }
                            }
                            // start new one
                            lastExpToken = new ExpressionToken { TokenType = ExpressionTokenType.Operator };
                            _currentTokens.Add(lastExpToken);
                            lastExpToken.Append(curRawToken);
                        }
                        else
                        {
                            lastExpToken = HandleNonOperatorSymbolToken(reader, lastExpToken, curRawToken);
                        }
                        break;
                    default:
                        // should never happen
                        throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "Unsupported token type {0} at position {1}.", curRawToken.TokenType, curRawToken.Position));
                }
            }

            MassageTokens(_currentTokens);

            return _currentTokens.ToArray();
        }
Beispiel #28
0
 public MyEffectBank(ListReader <MyAudioEffect> effects, XAudio2 engine)
 {
     foreach (var effect in effects)
     {
         m_effects[effect.EffectId] = effect;
     }
     m_engine = engine;
 }
Beispiel #29
0
 /// <summary>
 /// Extends the reader by reading another set of records that are children of the previous results.
 /// </summary>
 /// <typeparam name="T1">The type of objects in the first set of results.</typeparam>
 /// <typeparam name="T2">The type of objects in the second set of results.</typeparam>
 /// <typeparam name="TId">The type of the ID value.</typeparam>
 /// <param name="previous">The previous reader.</param>
 /// <param name="recordReader">The mapping that defines the layout of the records in each row.</param>
 /// <param name="id">An optional function that extracts an ID from the object. Use when this row is a parent in a parent-child relationship.</param>
 /// <param name="into">A function that assigns the children to their parent.</param>
 /// <returns>A reader that reads a list of objects and their children.</returns>
 public static ListReader <T1> ThenChildren <T1, T2, TId>(
     this ListReader <T1> previous,
     RecordReader <T2> recordReader,
     Func <T1, TId> id,
     Action <T1, List <T2> > into = null)
 {
     return(previous.ThenChildren(recordReader.GroupByAuto <T1, TId>(), id, into));
 }
Beispiel #30
0
 public static ListReader <TRoot> ThenChildren <TRoot, TParent, TChild>(
     this ListReader <TRoot> previous,
     IChildRecordReader <TChild> recordReader,
     Func <TRoot, IEnumerable <TParent> > parents,
     Action <TParent, List <TChild> > into = null)
 {
     return(previous.ThenChildren(recordReader, parents, (Func <TParent, object>)null, into));
 }
 public void Add(string material, ListReader <MaterialEdit> edit)
 {
     if (!_builders.TryGetValue(material, out var list))
     {
         _builders[material] = list = PoolManager.Get <List <ListReader <MaterialEdit> > >();
     }
     list.Add(edit);
 }
Beispiel #32
0
        /// <summary>
        /// Evaluates the specified input expression.
        /// </summary>
        /// <param name="input">The input expression (infix).</param>
        /// <param name="coerseToBoolean">if set to <c>true</c> then the result will be coersed to boolean true/false if possible.
        /// Anything not "false", "0", or "" is considered true.</param>
        /// <returns></returns>
        /// <exception cref="NotSupportedException">Unbalanced expression.</exception>
        /// <exception cref="System.NotSupportedException"></exception>
        public ExpressionToken Evaluate(string input, bool coerseToBoolean = false)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return(coerseToBoolean ? ExpressionToken.False : new ExpressionToken(input));
            }

            var tokens = new InfixToPostfixTokenizer().Tokenize(input);
            var reader = new ListReader <ExpressionToken>(tokens);

            // from https://en.wikipedia.org/wiki/Reverse_Polish_notation
            _stack = new Stack <ExpressionToken>();
            while (!reader.IsEnd)
            {
                var tk = reader.Read();
                switch (tk.TokenType)
                {
                case ExpressionTokenType.Value:
                case ExpressionTokenType.DoubleQuoted:
                case ExpressionTokenType.SingleQuoted:
                case ExpressionTokenType.Field:
                    _stack.Push(tk);
                    break;

                case ExpressionTokenType.Operator:
                    HandleOperator(tk.OperatorType);
                    break;

                case ExpressionTokenType.Function:
                    HandleFunction(tk.Value);
                    break;
                }
            }

            if (_stack.Count == 1)
            {
                var res = _stack.Pop();
                if (coerseToBoolean)
                {
                    if (IsFalse(res.Value))
                    {
                        return(ExpressionToken.False);
                    }
                    return(ExpressionToken.True);
                }
                return(res);

                //if (res.IsNumeric())
                //{
                //    return res;
                //}
                //else if (IsTrue(res.Value))
                //{
                //    return ExpressionToken.True;
                //}
            }
            throw new NotSupportedException("Unbalanced expression.");
        }
Beispiel #33
0
 public static ListReader <TRoot> ThenChildren <TRoot, TParent, TChild, TId>(
     this ListReader <TRoot> previous,
     RecordReader <TChild> recordReader,
     Func <TRoot, IEnumerable <TParent> > parents,
     Func <TParent, TId> id,
     Action <TParent, List <TChild> > into = null)
 {
     return(previous.ThenChildren(recordReader.GroupByAuto <TParent, TId>(), parents, id, into));
 }
        public void Apply(MyTerminalBlock block, ListReader <TerminalActionParameter> parameters)
        {
            var b = (TBlock)block;

            if (Enabled(b))
            {
                m_actionWithParameters(b, parameters);
            }
        }
Beispiel #35
0
        /// <summary>
        /// Execute an existing command, and translate the result set. This method supports auto-open.
        /// The Connection property of the command should be initialized before calling this method.
        /// </summary>
        /// <param name="command">The command to execute.</param>
        /// <param name="withGraph">The object graph to use to deserialize the object or null to use the default graph.</param>
        /// <param name="commandBehavior">The behavior of the command when executed.</param>
        /// <typeparam name="T">The type of object to return in the result set.</typeparam>
        /// <returns>A data reader with the results.</returns>
        public static IList <T> Query <T>(
            this IDbCommand command,
            Type withGraph = null,
            CommandBehavior commandBehavior = CommandBehavior.Default)
        {
            var queryReader = new ListReader <T>(Graph.GetOneToOne <T>(withGraph));

            return(command.Query(queryReader, commandBehavior));
        }
Beispiel #36
0
        private void DoInit()
        {
            _planets.Clear();
            _planets.UnionWith(MyEntities.GetEntities().OfType <MyPlanet>().Where(x => x.HasAtmosphere));
            Log.Info($"Fount {_planets.Count} with atmosphere to work with this plugin");
            ListReader <MyWeatherEffectDefinition> weatherDefinitions = MyDefinitionManager.Static.GetWeatherDefinitions();

            Log.Info($"{weatherDefinitions.Count} weather definitions found on server");
        }
        static void Test(string text, params string[] expectedLines)
        {
            var lines = new ListReader(text)
            {
                ThrowExceptionOnNoEol = true
            };

            Assert.IsTrue(expectedLines.SequenceEqual(lines.Select(n => n.Text)));
        }
		internal ContentTypeReader[] LoadAssetReaders()
        {			
			// Dummy variables required for it to work on iDevices ** DO NOT DELETE ** 
			// This forces the classes not to be optimized out when deploying to iDevices
			ListReader<Char> hCharListReader = new ListReader<Char>();
			ListReader<Rectangle> hRectangleListReader = new ListReader<Rectangle>();
			ListReader<Vector3> hVector3ListReader = new ListReader<Vector3>();
			ListReader<StringReader> hStringListReader = new ListReader<StringReader>();
			SpriteFontReader hSpriteFontReader = new SpriteFontReader();
			Texture2DReader hTexture2DReader = new Texture2DReader();
			CharReader hCharReader = new CharReader();
			RectangleReader hRectangleReader = new RectangleReader();
			StringReader hStringReader = new StringReader();
			Vector3Reader hVector3Reader = new Vector3Reader();
			CurveReader hCurveReader = new CurveReader();
			
            int numberOfReaders;
			
            // The first content byte i read tells me the number of content readers in this XNB file
            numberOfReaders = _reader.Read7BitEncodedInt();
            contentReaders = new ContentTypeReader[numberOfReaders];
		
            // For each reader in the file, we read out the length of the string which contains the type of the reader,
            // then we read out the string. Finally we instantiate an instance of that reader using reflection
            for (int i = 0; i < numberOfReaders; i++)
            {
                // This string tells us what reader we need to decode the following data
                // string readerTypeString = reader.ReadString();
				string originalReaderTypeString = _reader.ReadString();
 
				// Need to resolve namespace differences
				string readerTypeString = originalReaderTypeString;
								
				readerTypeString = PrepareType(readerTypeString);

				Type l_readerType = Type.GetType(readerTypeString);
				
            	if(l_readerType !=null)
					contentReaders[i] = (ContentTypeReader)Activator.CreateInstance(l_readerType,true);
            	else
					throw new ContentLoadException("Could not find matching content reader of type " + originalReaderTypeString + " (" + readerTypeString + ")");
				
				// I think the next 4 bytes refer to the "Version" of the type reader,
                // although it always seems to be zero
                int typeReaderVersion = _reader.ReadInt32();
            }

            return contentReaders;
        }
Beispiel #39
0
        static EdnReader()
        {
            _macros['"'] = new StringReader();
            _macros[';'] = new CommentReader();
            _macros['^'] = new MetaReader();
            _macros['('] = new ListReader();
            _macros[')'] = new UnmatchedDelimiterReader();
            _macros['['] = new VectorReader();
            _macros[']'] = new UnmatchedDelimiterReader();
            _macros['{'] = new MapReader();
            _macros['}'] = new UnmatchedDelimiterReader();
            _macros['\\'] = new CharacterReader();
            _macros['#'] = new DispatchReader();

            _dispatchMacros['^'] = new MetaReader();
            //_dispatchMacros['"'] = new RegexReader();
            _dispatchMacros['{'] = new SetReader();
            _dispatchMacros['<'] = new UnreadableReader();
            _dispatchMacros['_'] = new DiscardReader();
        }
        ExpressionToken HandleNonOperatorSymbolToken(ListReader<RawToken> reader, ExpressionToken lastExpToken, RawToken curRawToken)
        {
            switch (curRawToken.Value)
            {
                case ",":
                    lastExpToken = new ExpressionToken { TokenType = ExpressionTokenType.Comma };
                    _currentTokens.Add(lastExpToken);
                    lastExpToken.Append(curRawToken);
                    break;
                case "(":
                    // if last one is string make it a function
                    if (lastExpToken != null && lastExpToken.TokenType == ExpressionTokenType.Value)
                    {
                        lastExpToken.TokenType = ExpressionTokenType.Function;
                    }

                    lastExpToken = new ExpressionToken { TokenType = ExpressionTokenType.OpenParenthesis };
                    _currentTokens.Add(lastExpToken);
                    lastExpToken.Append(curRawToken);
                    break;
                case ")":
                    lastExpToken = new ExpressionToken { TokenType = ExpressionTokenType.CloseParenthesis };
                    _currentTokens.Add(lastExpToken);
                    lastExpToken.Append(curRawToken);
                    break;
                case "{":
                    // read until end of }
                    lastExpToken = ReadToLiteralAs(reader, "}", ExpressionTokenType.Field);
                    break;
                case "\"":
                    // read until end of "
                    lastExpToken = ReadToLiteralAs(reader, "\"", ExpressionTokenType.DoubleQuoted);
                    break;
                case "'":
                    // read until end of '
                    lastExpToken = ReadToLiteralAs(reader, "'", ExpressionTokenType.SingleQuoted);
                    break;
            }

            return lastExpToken;
        }
 private ListReader<ITerminalAction> GetValidActions(Type blockType, ListReader<MyTerminalBlock> blocks )
 {
     var allActions = MyTerminalControlFactory.GetActions(blockType);
     var validActions = new List<ITerminalAction>();
     foreach (var action in allActions)
     {
         if (action.IsValidForGroups())
         {
             bool found=false;
             foreach (var block in blocks)
                 if (action.IsEnabled(block))
                 {
                     found = true;
                     break;
                 }
             if (found)
                 validActions.Add(action);
         }
     }
     return validActions;
 }
        /// <summary>
        /// Reads the list of data items whose head is stored at the page index provided.
        /// </summary>
        /// <param name="stream">data file to read from</param>
        /// <param name="pageIdx">index of the first physical page storing the list</param>
        /// <returns>returns the index of the first physical page we read data from</returns>
        public int ReadTransactionTableData(FileStreamWrapper stream, int pageIdx)
        {
            List<TransItem> itemList = null;
            List<int> pageIdxList = null;

            // create reader
            ListReader<TransItem> reader = new ListReader<TransItem>();
            reader.ReadList(stream, pageIdx, out itemList, out pageIdxList);

            // clear the current data
            this.contextTable.Clear();

            foreach (TransItem item in itemList)
            {
                this.contextTable.Add(item.Transaction, item);
            }

            // update page index
            this.contextTableStoragePages = pageIdxList;

            // return index of the first page
            return this.contextTableStoragePages[0];
        }
Beispiel #43
0
        /// <summary>
        /// Evaluates the specified input as an infix expression.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        /// <exception cref="System.NotSupportedException"></exception>
        public ExpressionToken EvaluateInfix(string input)
        {
            var tokens = new InfixToPostfixTokenizer().Tokenize(input);
            var reader = new ListReader<ExpressionToken>(tokens);

            // from https://en.wikipedia.org/wiki/Reverse_Polish_notation
            _stack = new Stack<ExpressionToken>();
            while (!reader.IsEnd)
            {
                var tk = reader.Read();
                switch (tk.TokenType)
                {
                    case ExpressionTokenType.Value:
                    case ExpressionTokenType.DoubleQuoted:
                    case ExpressionTokenType.SingleQuoted:
                    case ExpressionTokenType.Field:
                        _stack.Push(tk);
                        break;
                    case ExpressionTokenType.Operator:
                        HandleOperator(tk.OperatorType);
                        break;
                    case ExpressionTokenType.Function:
                        HandleFunction(tk.Value);
                        break;
                }
            }

            if (_stack.Count > 1)
            {
                throw new NotSupportedException("Unbalanced expression.");
            }
            else if (_stack.Count == 1)
            {
                return _stack.Pop();
            }
            return new ExpressionToken("0");
        }
Beispiel #44
0
        /// <summary>
        /// Reads the list of data items whose head is stored at the page index provided.
        /// </summary>
        /// <param name="stream">data file to read from</param>
        /// <param name="pageIdx">index of the first physical page storing the list</param>
        /// <returns>returns the index of the first physical page we read data from</returns>
        public int ReadPageManagerData(FileStreamWrapper stream, int pageIdx)
        {
            List<int> itemList = null;
            List<int> pageIdxList = null;

            // create reader
            ListReader<int> reader = new ListReader<int>();
            reader.ReadList(stream, pageIdx, out itemList, out pageIdxList);

            // merge with current data
            this.SetFreePages(itemList);

            // update page index
            this.managerStoragePages = pageIdxList;

            return this.managerStoragePages[0];
        }
Beispiel #45
0
        public void LoadData(MyAudioInitParams initParams, ListReader<MySoundData> sounds, ListReader<MyAudioEffect> effects)
        {
            MyLog.Default.WriteLine("MyAudio.LoadData - START");
            MyLog.Default.IncreaseIndent();
            m_initParams = initParams;
            m_sounds = sounds;
            m_effects = effects;
            m_canPlay = true;
            try
            {
                if (sounds.Count > 0)
                {
                    Init();
                }
                else
                {
                    MyLog.Default.WriteLine("Unable to load audio data. Game continues, but without sound", LoggingOptions.AUDIO);
                    m_canPlay = false;
                }
            }
            catch (Exception ex)
            {
                MyLog.Default.WriteLine("Exception during loading audio engine. Game continues, but without sound. Details: " + ex.ToString(), LoggingOptions.AUDIO);
                MyLog.Default.WriteLine("Device ID: " + m_deviceDetails.DeviceID, LoggingOptions.AUDIO);
                MyLog.Default.WriteLine("Device name: " + m_deviceDetails.DisplayName, LoggingOptions.AUDIO);
                MyLog.Default.WriteLine("Device role: " + m_deviceDetails.Role, LoggingOptions.AUDIO);
                MyLog.Default.WriteLine("Output format: " + m_deviceDetails.OutputFormat, LoggingOptions.AUDIO);

                //  This exception is the only way I can know if we can play sound (e.g. if computer doesn't have sound card).
                //  I didn't find other ways of checking it.
                m_canPlay = false;
            }

            if (m_initParams.SimulateNoSoundCard)
                m_canPlay = false;

            if (m_canPlay)
            {
                m_cueBank = new MyCueBank(m_audioEngine, sounds);
                m_cueBank.UseSameSoundLimiter = m_useSameSoundLimiter;
                m_cueBank.SetSameSoundLimiter();
                m_cueBank.DisablePooling = initParams.DisablePooling;
                m_effectBank = new MyEffectBank(effects, m_audioEngine);
                m_3Dsounds = new List<IMy3DSoundEmitter>();
                m_listener = new Listener();
                m_listener.SetDefaultValues();
                m_helperEmitter = new Emitter();
                m_helperEmitter.SetDefaultValues();

                m_musicOn = true;
                m_gameSoundsOn = true;
           
                m_musicAllowed = true;

                if ((m_musicCue != null) && m_musicCue.IsPlaying)
                {
                    // restarts music cue
                    m_musicCue = PlaySound(m_musicCue.CueEnum);
                    if (m_musicCue != null)
                    {
                        m_musicCue.SetOutputVoices(m_musicAudioVoiceDesc);
                        m_musicAudioVoice.SetVolume(m_volumeMusic);
                    }

                    UpdateMusic(0);
                }
                else
                {
                    m_musicState = MyMusicState.Stopped;
                }
                m_loopMusic = true;

                m_transitionForward = false;
                m_timeFromTransitionStart = 0;

                m_soundInstancesTotal2D = 0;
                m_soundInstancesTotal3D = 0;
            }

            MyLog.Default.DecreaseIndent();
            MyLog.Default.WriteLine("MyAudio.LoadData - END");
        }
        ExpressionToken ReadToLiteralAs(ListReader<RawToken> reader, string literalValue, ExpressionTokenType tokenType)
        {
            ExpressionToken lastExpToken = new ExpressionToken { TokenType = tokenType };
            _currentTokens.Add(lastExpToken);
            while (!reader.IsEnd)
            {
                var next = reader.Read();
                if (next.TokenType == RawTokenType.Symbol && next.Value == literalValue)
                {
                    break;
                }
                lastExpToken.Append(next);
            }

            return lastExpToken;
        }
 private ITerminalAction FindAction(ListReader<ITerminalAction> actions, string name)
 {
     foreach (var item in actions)
     {
         if (item.Id == name)
             return item;
     }
     return null;
 }
        void GetWorldMods(ListReader<MyObjectBuilder_Checkpoint.ModItem> mods)
        {
            m_worldLocalMods.Clear();
            m_worldWorkshopMods.Clear();

            foreach (var mod in mods)
            {
                if (mod.PublishedFileId == 0)
                    m_worldLocalMods.Add(mod.Name);
                else
                    m_worldWorkshopMods.Add(mod.PublishedFileId);
            }
        }
 private MyTerminalBlock FirstFunctional(ListReader<MyTerminalBlock> blocks, MyEntity owner, long playerID)
 {
     foreach (var block in blocks)
     {
         if (block.IsFunctional && (block.HasPlayerAccess(playerID) || block.HasPlayerAccess((owner as MyTerminalBlock).OwnerId)))
             return block;
     }
     return null;
 }
 private static void OnRunApplied(MyProgrammableBlock programmableBlock, ListReader<TerminalActionParameter> parameters)
 {
     string argument = null;
     var firstParameter = parameters.FirstOrDefault();
     if (!firstParameter.IsEmpty && firstParameter.TypeCode == TypeCode.String)
         argument = firstParameter.Value as string;
     programmableBlock.Run(argument);
 }
 private static void OnAction(MyRemoteControl block, ListReader<TerminalActionParameter> paramteres)
 {
     var firstParameter = paramteres.FirstOrDefault();
     if (!firstParameter.IsEmpty)
     {
         block.ChangeDirection((Base6Directions.Direction)firstParameter.Value);
     }
 }
        static void MassageTokens(List<ExpressionToken> tokens)
        {
            // do final token parsing based on contexts and cleanup

            var reader = new ListReader<ExpressionToken>(tokens);
            while (!reader.IsEnd)
            {
                var tk = reader.Read();

                if (tk.TokenType == ExpressionTokenType.Operator)
                {
                    // special detection for operators depending on where it is :(
                    DetermineOperatorType(reader, tk);
                }

                tk.Freeze();
            }
        }
 public MyEffectBank(ListReader<MyAudioEffect> effects, XAudio2 engine)
 {
     foreach (var effect in effects)
         m_effects[effect.EffectId] = effect;
     m_engine = engine;
 }
 private static void DetermineOperatorType(ListReader<ExpressionToken> reader, ExpressionToken tk)
 {
     tk.OperatorType = KnownOperators.TryMap(tk.Value);
     switch (tk.OperatorType)
     {
         case OperatorType.PreDecrement:
         case OperatorType.PreIncrement:
             // detect if it's really post ++ -- versions 
             var prev = reader.Position > 1 ? reader.Peek(-2) : null;
             if (prev != null && prev.TokenType == ExpressionTokenType.Value)
             {
                 if (tk.OperatorType == OperatorType.PreIncrement)
                 {
                     tk.OperatorType = OperatorType.PostIncrement;
                 }
                 else
                 {
                     tk.OperatorType = OperatorType.PostDecrement;
                 }
             }
             break;
         case OperatorType.Addition:
         case OperatorType.Subtraction:
             // detect if unary + -
             prev = reader.Position > 1 ? reader.Peek(-2) : null;
             if (prev == null ||
                 (prev.TokenType == ExpressionTokenType.Operator &&
                 prev.OperatorType != OperatorType.PostDecrement &&
                 prev.OperatorType != OperatorType.PostIncrement))
             {
                 if (tk.OperatorType == OperatorType.Addition)
                 {
                     tk.OperatorType = OperatorType.UnaryPlus;
                 }
                 else
                 {
                     tk.OperatorType = OperatorType.UnaryMinus;
                 }
             }
             break;
         case OperatorType.None:
             throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "Operator {0} is not supported.", tk.Value));
     }
 }
Beispiel #55
0
 void IMyAudio.ReloadData(ListReader<MySoundData> sounds, ListReader<MyAudioEffect> effects) { }
Beispiel #56
0
 public void ReloadData(ListReader<MySoundData> sounds, ListReader<MyAudioEffect> effects)
 {
     UnloadData();
     LoadData(m_initParams, sounds, effects);
 }
 private void RemoveTypesFromChanges(ListReader<MyDefinitionId> types)
 {
     foreach(var resourceType in types)
     {
         int existingCount;
         if (m_changedTypes.TryGetValue(resourceType, out existingCount))
             m_changedTypes[resourceType] = existingCount - 1;
     }
 }
 internal ContentTypeReader[] LoadAssetReaders()
 {
   if (ContentTypeReaderManager.falseflag)
   {
     ByteReader byteReader = new ByteReader();
     SByteReader sbyteReader = new SByteReader();
     DateTimeReader dateTimeReader = new DateTimeReader();
     DecimalReader decimalReader = new DecimalReader();
     BoundingSphereReader boundingSphereReader = new BoundingSphereReader();
     BoundingFrustumReader boundingFrustumReader = new BoundingFrustumReader();
     RayReader rayReader = new RayReader();
     ListReader<char> listReader1 = new ListReader<char>();
     ListReader<Rectangle> listReader2 = new ListReader<Rectangle>();
     ArrayReader<Rectangle> arrayReader1 = new ArrayReader<Rectangle>();
     ListReader<Vector3> listReader3 = new ListReader<Vector3>();
     ListReader<StringReader> listReader4 = new ListReader<StringReader>();
     ListReader<int> listReader5 = new ListReader<int>();
     SpriteFontReader spriteFontReader = new SpriteFontReader();
     Texture2DReader texture2Dreader = new Texture2DReader();
     CharReader charReader = new CharReader();
     RectangleReader rectangleReader = new RectangleReader();
     StringReader stringReader = new StringReader();
     Vector2Reader vector2Reader = new Vector2Reader();
     Vector3Reader vector3Reader = new Vector3Reader();
     Vector4Reader vector4Reader = new Vector4Reader();
     CurveReader curveReader = new CurveReader();
     IndexBufferReader indexBufferReader = new IndexBufferReader();
     BoundingBoxReader boundingBoxReader = new BoundingBoxReader();
     MatrixReader matrixReader = new MatrixReader();
     BasicEffectReader basicEffectReader = new BasicEffectReader();
     VertexBufferReader vertexBufferReader = new VertexBufferReader();
     AlphaTestEffectReader testEffectReader = new AlphaTestEffectReader();
     EnumReader<SpriteEffects> enumReader1 = new EnumReader<SpriteEffects>();
     ArrayReader<float> arrayReader2 = new ArrayReader<float>();
     ArrayReader<Vector2> arrayReader3 = new ArrayReader<Vector2>();
     ListReader<Vector2> listReader6 = new ListReader<Vector2>();
     ArrayReader<Matrix> arrayReader4 = new ArrayReader<Matrix>();
     EnumReader<Blend> enumReader2 = new EnumReader<Blend>();
     NullableReader<Rectangle> nullableReader = new NullableReader<Rectangle>();
     EffectMaterialReader effectMaterialReader = new EffectMaterialReader();
     ExternalReferenceReader externalReferenceReader = new ExternalReferenceReader();
   }
   int length = this._reader.Read7BitEncodedInt();
   this.contentReaders = new ContentTypeReader[length];
   for (int index = 0; index < length; ++index)
   {
     string str = this._reader.ReadString();
     Func<ContentTypeReader> func;
     if (ContentTypeReaderManager.typeCreators.TryGetValue(str, out func))
     {
       this.contentReaders[index] = func();
     }
     else
     {
       string typeName = ContentTypeReaderManager.PrepareType(str);
       Type type = Type.GetType(typeName);
       if (type != (Type) null)
       {
         try
         {
           this.contentReaders[index] = ContentExtensions.GetDefaultConstructor(type).Invoke((object[]) null) as ContentTypeReader;
         }
         catch (TargetInvocationException ex)
         {
           throw new InvalidOperationException("Failed to get default constructor for ContentTypeReader. To work around, add a creation function to ContentTypeReaderManager.AddTypeCreator() with the following failed type string: " + str);
         }
       }
       else
         throw new ContentLoadException("Could not find matching content reader of type " + str + " (" + typeName + ")");
     }
     this._reader.ReadInt32();
   }
   return this.contentReaders;
 }
Beispiel #59
0
 public static void LoadData(MyAudioInitParams initParams, ListReader<MySoundData> sounds, ListReader<MyAudioEffect> effects)
 {
     Static = initParams.Instance;
     OnSoundError = initParams.OnSoundError;
     Static.LoadData(initParams, sounds, effects);
 }
Beispiel #60
0
 //GR: Use Reload data on uload Session in order to load only GUI relate cues (about 56 where all cues are about 602)
 //This saves 300 MB of memory when exiting to main menu
 public static void ReloadData(ListReader<MySoundData> sounds, ListReader<MyAudioEffect> effects)
 {
     Static.ReloadData(sounds, effects);
 }