public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        BlockBehaviour block = (BlockBehaviour)target;

        if (block.Slot == null || Application.isPlaying)
        {
            return;
        }

        BlockBehaviourEditor.CreateNeighborExlusionUI(block.Slot);
    }
Example #2
0
    private void showEditor(Slot slot, MapBehaviour mapBehaviour)
    {
        if (slot.Collapsed)
        {
            GUILayout.Label("Collapsed: " + slot.Module);
            GUILayout.Space(20f);
            GUILayout.Label("Add exclusion rules:");
            BlockBehaviourEditor.CreateNeighborExlusionUI(slot);
            return;
        }

        GUILayout.Label("Possible modules: " + slot.Modules.Count() + " / " + ModuleData.Current.Count());
        GUILayout.Label("Entropy: " + slot.Modules.Entropy);

        if (GUILayout.Button("Collapse Random"))
        {
            slot.CollapseRandom();
            mapBehaviour.BuildAllSlots();
        }

        var prototypes = new Dictionary <ModulePrototype, List <Module> >();

        foreach (var module in slot.Modules.ToArray())
        {
            var proto = module.Prototype;
            if (!prototypes.ContainsKey(proto))
            {
                prototypes[proto] = new List <Module>();
            }
            prototypes[proto].Add(module);
        }

        foreach (var proto in prototypes.Keys)
        {
            var list = prototypes[proto];

            GUILayout.BeginHorizontal();

            EditorGUILayout.PrefixLabel(proto.gameObject.name + " (" + (100f * list.Sum(module => module.Prototype.Probability) / slot.Modules.Sum(module => module.Prototype.Probability)).ToString("0.0") + "%)");
            foreach (var module in list)
            {
                if (GUILayout.Button("R" + module.Rotation))
                {
                    slot.Collapse(module);
                    mapBehaviour.BuildAllSlots();
                }
            }

            GUILayout.EndHorizontal();
        }
    }
Example #3
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        SlotInspector slotInspector = (SlotInspector)target;
        var           mapBehaviour  = slotInspector.MapBehaviour;
        var           map           = mapBehaviour.Map;

        if (mapBehaviour == null)
        {
            return;
        }

        var position = slotInspector.GetPosition();

        GUILayout.Label("Position: " + position);

        if (!mapBehaviour.Initialized)
        {
            if (GUILayout.Button("Initialize Map"))
            {
                mapBehaviour.Initialize();
            }
            return;
        }

        var slot = map.GetSlot(position, false);

        if (slot == null)
        {
            if (GUILayout.Button("CreateSlot"))
            {
                map.GetSlot(position);
            }
            return;
        }

        if (slot.Collapsed)
        {
            GUILayout.Label("Collapsed: " + slot.Module);
            GUILayout.Space(20f);
            GUILayout.Label("Add exclusion rules:");
            BlockBehaviourEditor.CreateNeighborExlusionUI(slot);
            return;
        }

        GUILayout.Label("Possible modules: " + slot.Modules.Count() + " / " + mapBehaviour.Modules.Count());
        GUILayout.Label("Entropy: " + slot.Modules.Entropy);

        if (GUILayout.Button("Collapse Random"))
        {
            slot.CollapseRandom();
            mapBehaviour.BuildAllSlots();
        }

        var prototypes = new Dictionary <ModulePrototype, List <Module> >();

        foreach (var module in slot.Modules.ToArray())
        {
            var proto = module.Prototype;
            if (!prototypes.ContainsKey(proto))
            {
                prototypes[proto] = new List <Module>();
            }
            prototypes[proto].Add(module);
        }

        foreach (var proto in prototypes.Keys)
        {
            var list = prototypes[proto];

            GUILayout.BeginHorizontal();

            EditorGUILayout.PrefixLabel(proto.gameObject.name + " (" + (100f * list.Sum(module => module.Prototype.Probability) / slot.Modules.Sum(module => module.Prototype.Probability)).ToString("0.0") + "%)");
            foreach (var module in list)
            {
                if (GUILayout.Button("R" + module.Rotation))
                {
                    slot.Collapse(module);
                    mapBehaviour.BuildAllSlots();
                }
            }

            GUILayout.EndHorizontal();
        }
    }
    private void showEditor(Slot slot, MapBehaviour mapBehaviour)
    {
        if (slot.Collapsed)
        {
            GUILayout.Label("Collapsed: " + slot.Module);
            GUILayout.Space(20f);
            GUILayout.Label("Add exclusion rules:");
            BlockBehaviourEditor.CreateNeighborExlusionUI(slot);
            return;
        }

        GUILayout.Label("Possible modules: " + slot.Modules.Count() + " / " + ModuleData.Current.Count());
        GUILayout.Label("Entropy: " + slot.Modules.Entropy);

        if (GUILayout.Button("Collapse Random"))
        {
            slot.CollapseRandom();
            mapBehaviour.BuildAllSlots();
        }

        var prototypes = new Dictionary <ModulePrototype, List <Module> >();

        foreach (var module in slot.Modules.ToArray())
        {
            var proto = module.Prototype;
            if (!prototypes.ContainsKey(proto))
            {
                prototypes[proto] = new List <Module>();
            }
            prototypes[proto].Add(module);
        }

        if (prototypes.Any())
        {
            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Filter: ");
            this.filterString = GUILayout.TextField(this.filterString);
            GUILayout.EndHorizontal();
        }

        int hiddenByFilter = 0;

        foreach (var proto in prototypes.Keys)
        {
            if (this.filterString != "" && !proto.gameObject.name.ToLower().Contains(this.filterString.ToLower()))
            {
                hiddenByFilter++;
                continue;
            }

            var list = prototypes[proto];

            GUILayout.BeginHorizontal();

            EditorGUILayout.PrefixLabel(proto.gameObject.name + " (" + (100f * list.Sum(module => module.Prototype.Probability) / slot.Modules.Sum(module => module.Prototype.Probability)).ToString("0.0") + "%)");
            foreach (var module in list)
            {
                if (GUILayout.Button("R" + module.Rotation))
                {
                    slot.Collapse(module);
                    mapBehaviour.BuildAllSlots();
                }
            }

            GUILayout.EndHorizontal();
        }

        if (hiddenByFilter > 0)
        {
            GUILayout.Label("(+" + hiddenByFilter + " that don't match the filter query)");
        }

        var defaultSlot       = mapBehaviour.Map.GetDefaultSlot(slot.Position.y);
        var removedPrototypes = new List <ModulePrototype>();
        var removedByDefault  = new List <ModulePrototype>();

        foreach (var module in ModuleData.Current)
        {
            if (!prototypes.ContainsKey(module.Prototype))
            {
                prototypes.Add(module.Prototype, null);
                if (defaultSlot != null && !defaultSlot.Modules.Contains(module))
                {
                    removedByDefault.Add(module.Prototype);
                }
                else
                {
                    removedPrototypes.Add(module.Prototype);
                }
            }
        }

        if (removedPrototypes.Any())
        {
            GUILayout.Space(15f);
            GUILayout.Label("Removed modules:");
            foreach (var prototype in removedPrototypes)
            {
                GUILayout.Label(prototype.gameObject.name);
            }
        }
        if (removedByDefault.Any())
        {
            GUILayout.Space(15f);
            GUILayout.Label("Modules always removed at this y coordinate:");
            foreach (var prototype in removedByDefault)
            {
                GUILayout.Label(prototype.gameObject.name);
            }
        }
    }