예제 #1
0
        private void LoadConfiguration()
        {
            if (Controller.Instance.MI == null)
            {
                return;
            }

            foreach (var blockinfo in Controller.Instance.MI.Blocks)
            {
                if (blockinfo.Guid == BB.Guid)
                {
                    XDataHolder bd = blockinfo.BlockData;

                    try { BlockDataLoadEvent(bd); } catch { };

                    LoadConfiguration(bd);

                    foreach (MapperType item in myMapperTypes)
                    {
                        string str    = string.Concat(MapperType.XDATA_PREFIX + item.Key);
                        XData  xDatum = bd.Read(str);
                        if (xDatum != null || !StatMaster.isPaste)
                        {
                            item.DeSerialize((xDatum == null ? item.defaultData : xDatum));
                        }
                    }

                    break;
                }
            }
        }
예제 #2
0
        public override void OnLoad(XDataHolder data)
        {
            base.OnLoad(data);

            Script.DeSerialize(data.Read("bmt-" + Script.Key));
            CheckScript(Script.Value);

            var newPio = data.ReadAll().Where(x => x.Key.StartsWith("bmt-pio")).Select(x =>
            {
                var key = new MExtKey(x.Key.Substring(4), x.Key.Substring(4), KeyCode.None, BlockBehaviour, true);
                key.DeSerialize(x);
                if (!long.TryParse(key.Key.Replace("pio", ""), out long id))
                {
                    return(null);
                }
                return(new KeyValuePair <long, MExtKey>?(new KeyValuePair <long, MExtKey>(id, key)));
            }).Where(x => x != null).ToDictionary(x => x.Value.Key, x => x.Value.Value);

            // merge into old pio because we don't want to replace MExtKey every time
            BlockBehaviour.KeyList.Clear();
            foreach (var kp in newPio)
            {
                if (PIO.ContainsKey(kp.Key))
                {
                    PIO[kp.Key].CopyFrom(kp.Value);
                    BlockBehaviour.KeyList.Add(PIO[kp.Key]);
                }
                else
                {
                    PIO[kp.Key] = kp.Value;
                    BlockBehaviour.KeyList.Add(kp.Value);
                }
            }
        }