Esempio n. 1
0
        private static Mapping GetMapping(IMyCubeBlock block, byte entityValueId)
        {
            Type type = block.GetType();

            for (int index = _maps.Count - 1; index >= 0; --index)
            {
                Mapping map = _maps[index];
                if (map.BlockType.IsAssignableFrom(type) && map.EntityValueId == entityValueId)
                {
                    return(map);
                }
            }

            return(null);
        }
Esempio n. 2
0
        private static void Load(IMyCubeBlock block, Builder_EntityValues entityValues)
        {
            for (int index = entityValues.valueIds.Length - 1; index >= 0; --index)
            {
                Mapping mapping = GetMapping(block, entityValues.valueIds[index]);
                if (mapping == null)
                {
                    // if the value is obsolete, this is fine
                    Logger.AlwaysLog("No mapping for " + block.GetType().Name + " and " + entityValues.valueIds[index], Logger.severity.WARNING);
                    continue;
                }

                string value = entityValues.values[index];

                if (mapping is SimpleMapping)
                {
                    ApplyMap(block, ((SimpleMapping)mapping).TerminalSyncId, value);
                }
                else
                {
                    foreach (KeyValuePair <ASync.Id, string> pair in ((ComplexMapping)mapping).Enumerate(value))
                    {
                        if (pair.Key != ASync.Id.None)
                        {
                            ApplyMap(block, pair.Key, pair.Value);
                        }
                    }
                }
            }

            Logger.TraceLog("Converted entity ids for " + block.nameWithId());
            _data.Remove(entityValues);
            if (_data.Count == 0)
            {
                Logger.DebugLog("All entity values converted");
                _data = null;
                _maps = null;
            }
        }