示例#1
0
        internal static void ResolveStudioObjects(ExtensibleSaveFormat.PluginData extendedData, ResolveType resolveType)
        {
            Dictionary <int, ObjectInfo> ObjectList = StudioObjectSearch.FindObjectInfo(StudioObjectSearch.SearchType.All);

            //Resolve all patterns for objects
            if (extendedData != null && extendedData.data.ContainsKey("patternInfo"))
            {
                List <StudioPatternResolveInfo> extPatternInfo;

                if (resolveType == ResolveType.Save)
                {
                    extPatternInfo = ((List <byte[]>)extendedData.data["patternInfo"]).Select(x => StudioPatternResolveInfo.Deserialize(x)).ToList();
                }
                else
                {
                    extPatternInfo = ((object[])extendedData.data["patternInfo"]).Select(x => StudioPatternResolveInfo.Deserialize((byte[])x)).ToList();
                }

                foreach (StudioPatternResolveInfo extPatternResolve in extPatternInfo)
                {
                    ResolveStudioObjectPattern(extPatternResolve, ObjectList[extPatternResolve.DicKey], resolveType);
                }
            }

            //Resolve every item with extended data
            if (extendedData != null && extendedData.data.ContainsKey("itemInfo"))
            {
                List <StudioResolveInfo> extInfo;

                if (resolveType == ResolveType.Save)
                {
                    extInfo = ((List <byte[]>)extendedData.data["itemInfo"]).Select(x => StudioResolveInfo.Deserialize(x)).ToList();
                }
                else
                {
                    extInfo = ((object[])extendedData.data["itemInfo"]).Select(x => StudioResolveInfo.Deserialize((byte[])x)).ToList();
                }

                foreach (StudioResolveInfo extResolve in extInfo)
                {
                    ResolveStudioObject(extResolve, ObjectList[extResolve.DicKey], resolveType);
                    ObjectList.Remove(extResolve.DicKey);
                }
            }

            //Resolve every item without extended data in case of hard mods
            if (resolveType == ResolveType.Load)
            {
                foreach (ObjectInfo OI in ObjectList.Where(x => x.Value is OIItemInfo || x.Value is OILightInfo || x.Value is OICharInfo).Select(x => x.Value))
                {
                    ResolveStudioObject(OI);
                }
            }
        }
            internal static void ExtendedSceneImport(string path)
            {
                PluginData ExtendedData = ExtendedSave.GetSceneExtendedDataById(UARExtID);
                Dictionary <int, ObjectInfo> ObjectList = FindObjectInfo(SearchType.All);

                Dictionary <int, int> ItemImportOrder = FindObjectInfoOrder(SearchType.Import, typeof(OIItemInfo));

                //Resolve patterns on items
                if (ExtendedData != null && ExtendedData.data.ContainsKey("patternInfo"))
                {
                    List <StudioPatternResolveInfo> extPatternInfo = ((object[])ExtendedData.data["patternInfo"]).Select(x => StudioPatternResolveInfo.Deserialize((byte[])x)).ToList();

                    foreach (StudioPatternResolveInfo extPatternResolve in extPatternInfo)
                    {
                        int NewDicKey = ItemImportOrder.Where(x => x.Value == extPatternResolve.ObjectOrder).Select(x => x.Key).FirstOrDefault();
                        if (ObjectList[NewDicKey] is OIItemInfo Item)
                        {
                            ResolveStudioObjectPattern(extPatternResolve, Item);
                        }
                    }
                }

                if (ExtendedData != null && ExtendedData.data.ContainsKey("itemInfo"))
                {
                    List <StudioResolveInfo> extInfo          = ((object[])ExtendedData.data["itemInfo"]).Select(x => StudioResolveInfo.Deserialize((byte[])x)).ToList();
                    Dictionary <int, int>    LightImportOrder = FindObjectInfoOrder(SearchType.Import, typeof(OILightInfo));
                    Dictionary <int, int>    CharImportOrder  = FindObjectInfoOrder(SearchType.Import, typeof(OICharInfo));

                    //Match objects from the StudioResolveInfo to objects in the scene based on the item order that was generated and saved to the scene data
                    foreach (StudioResolveInfo extResolve in extInfo)
                    {
                        int NewDicKey = ItemImportOrder.Where(x => x.Value == extResolve.ObjectOrder).Select(x => x.Key).FirstOrDefault();
                        if (ObjectList[NewDicKey] is OIItemInfo Item)
                        {
                            ResolveStudioObject(extResolve, Item);
                            ObjectList.Remove(NewDicKey);
                        }
                        else
                        {
                            NewDicKey = LightImportOrder.Where(x => x.Value == extResolve.ObjectOrder).Select(x => x.Key).FirstOrDefault();
                            if (ObjectList[NewDicKey] is OILightInfo Light)
                            {
                                ResolveStudioObject(extResolve, Light);
                                ObjectList.Remove(NewDicKey);
                            }
                            else
                            {
                                NewDicKey = CharImportOrder.Where(x => x.Value == extResolve.ObjectOrder).Select(x => x.Key).FirstOrDefault();
                                if (ObjectList[NewDicKey] is OICharInfo CharInfo)
                                {
                                    ResolveStudioObject(extResolve, CharInfo);
                                    ObjectList.Remove(NewDicKey);
                                }
                            }
                        }
                    }
                }

                //Resolve every item without extended data in case of hard mods
                foreach (ObjectInfo OI in ObjectList.Where(x => x.Value is OIItemInfo || x.Value is OILightInfo).Select(x => x.Value))
                {
                    if (OI is OIItemInfo Item)
                    {
                        ResolveStudioObject(Item);
                    }
                    else if (OI is OILightInfo Light)
                    {
                        ResolveStudioObject(Light);
                    }
                }

                //Maps and filters are not imported
                //UniversalAutoResolver.ResolveStudioMap(extData);
            }