Пример #1
0
        public void ApplyXmlData(List <XElement> modifers)
        {
            XElement Part = modifers.Find(m => m.Name == "Part");
            PartData data = _designer.CraftScript.Data.Assembly.Parts.ToList().Find(part => part.Id == int.Parse(Part.Attribute("id").Value));
            List <PartConnection> oldConns = data.PartConnections;
            List <AttachPoint>    oldAPs   = data.AttachPoints;

            modifers.Remove(Part);
            modifers.ForEach(m => Part.Descendants().Append(m));

            _partDataConstructor.Invoke(data, new object[] { Part, data.PartScript.CraftScript.Data.XmlVersion, data.PartType });

            data.SetP("PartConnections", oldConns);
            data.SetP("AttachPoints", oldAPs);

            ISymmetrySlice oldSlice = data.PartScript.SymmetrySlice;

            UnityEngine.Object.Destroy(data.PartScript.GameObject);
            CraftBuilder.CallS("CreatePartGameObjects", new PartData[1] {
                data
            }, Game.Instance.Designer.CraftScript);

            data.PartScript.SymmetrySlice = oldSlice;
            Symmmetry.CallS("SynchronizeParts", data.PartScript, true);

            _selectorManager.ignoreNextStructureChangedEvent = true;
            Game.Instance.Designer.CraftScript.RaiseDesignerCraftStructureChangedEvent();
        }