/// <summary>
        /// Get bitmask representation of stripping options from preset.
        /// </summary>
        /// <param name="preset">Stripping preset.</param>
        /// <returns>
        /// Bitmask representation of preset.
        /// </returns>
        public static int GetPresetOptions(StrippingPreset preset)
        {
            switch (preset)
            {
            case StrippingPreset.StripRuntime:
                return(StripFlag.STRIP_TILE_SYSTEM | StripFlag.STRIP_CHUNK_MAP | StripFlag.STRIP_TILE_DATA | StripFlag.STRIP_BRUSH_REFS | StripFlag.STRIP_EMPTY_CHUNKS | StripFlag.STRIP_COMBINED_EMPTY | StripFlag.STRIP_PLOP_COMPONENTS);

            case StrippingPreset.KeepSystemComponent:
                return(StripFlag.STRIP_CHUNK_MAP | StripFlag.STRIP_TILE_DATA | StripFlag.STRIP_BRUSH_REFS | StripFlag.STRIP_EMPTY_CHUNKS | StripFlag.STRIP_COMBINED_EMPTY | StripFlag.STRIP_PLOP_COMPONENTS);

            case StrippingPreset.NoStripping:
                return(0);

            case StrippingPreset.RuntimeAccess:
                return(StripFlag.STRIP_BRUSH_REFS | StripFlag.STRIP_EMPTY_CHUNKS | StripFlag.STRIP_COMBINED_EMPTY);

            case StrippingPreset.RuntimePainting:
                return(StripFlag.STRIP_EMPTY_CHUNKS | StripFlag.STRIP_COMBINED_EMPTY);

            case StrippingPreset.StripEverything:
                return(0xFFFF);

            default:
                return(0x0000);
            }
        }
Exemple #2
0
        private void DrawStrippingSection()
        {
            // "Stripping Preset"
            using (var content = ControlContent.Basic(
                       TileLang.ParticularText("Property", "Stripping Preset"),
                       TileLang.Text("Custom level of stripping can be applied to tile system upon build.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyStrippingPreset, content);
            }

            // "Stripping Preset Toggles"
            if (!this.propertyStrippingPreset.hasMultipleDifferentValues)
            {
                var             targetSystems = this.targets.Cast <TileSystem>().ToArray();
                int             mixedMask     = RotorzEditorGUI.GetMixedStrippingOptionsMask(targetSystems);
                StrippingPreset preset        = targetSystems[0].StrippingPreset;
                int             options       = targetSystems[0].StrippingOptions & ~mixedMask;

                EditorGUI.showMixedValue = this.propertyStrippingOptionMask.hasMultipleDifferentValues;
                int diff = RotorzEditorGUI.StrippingOptions(preset, options, mixedMask);

                if (diff != 0 && preset == StrippingPreset.Custom)
                {
                    int addBits    = diff & ~options;
                    int removeBits = diff & options;

                    Undo.RecordObjects(this.targets, TileLang.ParticularText("Action", "Modify Stripping Options"));
                    foreach (var tileSystem in targetSystems)
                    {
                        tileSystem.StrippingOptions = (tileSystem.StrippingOptions & ~removeBits) | addBits;
                        EditorUtility.SetDirty(tileSystem);
                    }
                }
                EditorGUI.showMixedValue = false;
            }

            GUILayout.Space(5);
        }