Exemplo n.º 1
0
        public void Import(CustomObjectImport import)
        {
            DecompressImport(import);

            foreach (var cobj in import.Data.CustomObjects)
            {
                if (!import.IgnoreCustomObjects.Contains(cobj))
                {
                    // Add Custom Model
                    if (cobj.BehaviorProps.Behavior is object)
                    {
                        if (cobj.BehaviorProps.Behavior.IsVanilla)
                        {
                            var behav = import.DestBehaviorBank.GetBehaviorByBankAddress(cobj.BehaviorProps.BehaviorAddress);
                            cobj.BehaviorProps.Behavior = behav.Config;
                        }
                        else if (import.Data.Behaviors.ContainsKey(cobj.BehaviorProps.Behavior))
                        {
                            var behav = import.Data.Behaviors[cobj.BehaviorProps.Behavior];
                            import.DestBehaviorBank.Behaviors.Add(behav);
                            if (behav.Config.CustomAsmLinks.Any())
                            {
                                import.DestCustomAsmBank.Areas.AddRangeIfNotContains(behav.Config.CustomAsmLinks.Select(n => n.CustomAsm).ToArray());
                            }
                            behav.ParseScript();
                        }
                        cobj.BehaviorProps.BehaviorAddress = -1;
                    }

                    // Add Custom Behavior
                    if (cobj.ModelProps.Model is object && import.Data.CustomModels.ContainsKey(cobj.ModelProps.Model) && import.DestModelBanks.ContainsKey(cobj.ModelProps.Model))
                    {
                        var destModelBank = import.DestModelBanks[cobj.ModelProps.Model];
                        destModelBank.Models.Add(import.Data.CustomModels[cobj.ModelProps.Model]);
                        destModelBank.NeedToSave = true;
                    }

                    // Add Custom Object
                    CustomObjects.Add(cobj);
                }
            }
        }
Exemplo n.º 2
0
 public static void DecompressImport(CustomObjectImport import)
 {
     import.Decompress();
 }