コード例 #1
0
        public void DeleteGenerator(Generator gen)
        {
            //removing generator from 'ready' and 'results' arrays
            ChangeGenerator(gen);

            //manually resetting all dependent generators ready stae
            for (int g = 0; g < list.Length; g++)
            {
                if (list[g].IsDependentFrom(gen))
                {
                    ChangeGenerator(list[g]);
                }
            }

            //clearing if it is output gen
            //if (gen is IOutput)
            //	foreach (MapMagic.Chunk chunk in MapMagic.instance.terrains.Objects())
            //		(gen as IOutput).Clear(chunk);

            //removing group members if it is group
                        #if UNITY_EDITOR
            if (gen is Group &&
                UnityEditor.EditorUtility.DisplayDialog("Remove Containing Generators", "Do you want to remove a contaning generators as well?", "Remove Generators", "Remove Group Only"))
            {
                Group group = gen as Group;
                group.Populate();
                for (int g = group.generators.Count - 1; g >= 0; g--)
                {
                    MapMagic.instance.gens.DeleteGenerator(group.generators[g]);
                }
            }
                        #endif

            //unlinking and removing it's reference in inputs and outputs
            //for (int g=0; g<list.Length; g++)
            //	foreach (Generator.Input input in list[g].Inputs())
            //		if (input.linkGen == gen) input.Unlink();
            UnlinkGenerator(gen);

            //removing from output generators list
            //if (gen is IOutput)
            //	Extensions.ArrayRemove(ref outputs, gen);

            //removing from array
            ArrayTools.Remove(ref list, gen);

            //if it is preview - applying splats
            if (gen is PreviewOutput)
            {
                SplatOutput splatOut = GetGenerator <SplatOutput>();
                if (splatOut != null)
                {
                    ChangeGenerator(splatOut);
                }
                else
                {
                    foreach (MapMagic.Chunk chunk in MapMagic.instance.terrains.Objects())
                    {
                        chunk.ClearSplats();
                    }
                }
            }
        }
コード例 #2
0
        public void DeleteGenerator(Generator gen)
        {
            //removing generator from 'ready' and 'results' arrays
            ChangeGenerator(gen);

            //manually resetting all dependent generators ready stae
            for (int g = 0; g < list.Length; g++)
            {
                if (list[g].IsDependentFrom(gen))
                {
                    ChangeGenerator(list[g]);
                }
            }

            //clearing if it is output gen
            //if (gen is IOutput)
            //	foreach (Chunk chunk in MapMagic.instance.terrains.Objects())
            //		(gen as IOutput).Clear(chunk);

            //removing group members if it is group
                        #if UNITY_EDITOR
            if (gen is Group)
            {
                int dialogResult = UnityEditor.EditorUtility.DisplayDialogComplex("Remove Containing Generators", "Do you want to remove a contaning generators as well?", "Remove Generators", "Remove Group Only", "Cancel");
                if (dialogResult == 2)
                {
                    return;                          //cancel
                }
                if (dialogResult == 0)               //generators
                {
                    Group group = gen as Group;
                    group.Populate(this);
                    for (int g = group.generators.Count - 1; g >= 0; g--)
                    {
                        DeleteGenerator(group.generators[g]);
                    }
                }
            }
                        #endif

            //unlinking and removing it's reference in inputs and outputs
            //for (int g=0; g<list.Length; g++)
            //	foreach (Generator.Input input in list[g].Inputs())
            //		if (input.linkGen == gen) input.Unlink();
            UnlinkGenerator(gen);

            //removing from output generators list
            //if (gen is IOutput)
            //	Extensions.ArrayRemove(ref outputs, gen);

            //removing from array
            ArrayTools.Remove(ref list, gen);

            //removing from preview
            if (MapMagic.instance.previewGenerator == gen)
            {
                MapMagic.instance.previewGenerator = null; MapMagic.instance.previewOutput = null;
            }

            //force regenerate if it was an output
            if (gen is Generator.IOutput)
            {
                MapMagic.instance.ForceGenerate();
            }
        }