Beispiel #1
0
        private void DrawInstructions(MapPropertiesBrush brush, MapProperties properties)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                // HAS INSTRUCTIONS
                _instructionsContent.text = brush.Selection.HasDifferentHasInstructions ? "Instructions (different values)" : "Instructions";

                var hasInstruction         = brush.Selection.HasDifferentHasInstructions ? false : brush.ActiveTileInfo.HasInstructions;
                var selectedHasInstruction = EditorGUILayout.Toggle(_instructionsContent, hasInstruction);

                if (brush.ActiveTileInfo.HasInstructions && !brush.Selection.HasDifferentHasInstructions)
                {
                    // INSTRUCTION OBJECT
                    _targetInstructionsContent.text = brush.Selection.HasDifferentInstructions ? "(different values)" : "";

                    var instruction         = brush.Selection.HasDifferentInstructions ? null : brush.ActiveTileInfo.Instructions;
                    var selectedInstruction = InstructionDrawer.Draw(null, instruction, _targetInstructionsContent);

                    if (instruction != selectedInstruction)
                    {
                        SetInstructions(brush, properties, selectedInstruction);
                    }
                }

                if (!hasInstruction && selectedHasInstruction)
                {
                    AddInstructions(brush, properties);
                }
                if (hasInstruction && !selectedHasInstruction)
                {
                    RemoveInstructions(brush, properties);
                }
            }
        }
        private void DrawInstruction(Rect rect, SerializedProperty property, int index)
        {
            var element     = property.GetArrayElementAtIndex(index);
            var instruction = element.objectReferenceValue as Instruction;

            if (instruction != null)
            {
                var nameRect = new Rect(rect.x, rect.y, rect.width * 0.8f, EditorGUIUtility.singleLineHeight);
                var editRect = new Rect(nameRect.xMax + 5, rect.y, rect.width * 0.2f - 5, nameRect.height);

                using (var changes = new EditorGUI.ChangeCheckScope())
                {
                    instruction.name = EditorGUI.DelayedTextField(nameRect, instruction.name);

                    if (changes.changed)
                    {
                        InstructionDrawer.InstructionSetChanged(instruction.Set);
                    }
                }

                if (GUI.Button(editRect, EditorHelper.EditContent))
                {
                    _toEdit = instruction;
                }
            }
        }
        private void DrawElement(Rect rect, SerializedProperty property, int index)
        {
            var element     = property.GetArrayElementAtIndex(index);
            var instruction = element.objectReferenceValue as Instruction;
            var set         = (target as InstructionSequence).Set;

            element.objectReferenceValue = InstructionDrawer.Draw(rect, set, instruction, _label);
        }
Beispiel #4
0
        private void DrawInstruction(Rect rect, SerializedProperty property, int index)
        {
            var element         = property.GetArrayElementAtIndex(index);
            var instruction     = element.objectReferenceValue as Instruction;
            var indexRect       = new Rect(rect.x, rect.y, rect.width * 0.1f, EditorGUIUtility.singleLineHeight);
            var instructionRect = new Rect(indexRect.xMax + 5, rect.y, rect.width - indexRect.width - 5, indexRect.height);

            EditorGUI.LabelField(indexRect, index.ToString());
            element.objectReferenceValue = InstructionDrawer.Draw(instructionRect, instruction == null ? null : instruction.Set, instruction, _label);
        }
        private void AddInstruction(object data)
        {
            var type = data as Type;
            var set  = target as InstructionSet;

            using (new UndoScope(set))
            {
                var instruction = InstructionDrawer.Create(set, null, type);
                Undo.RegisterCreatedObjectUndo(instruction, "Undo create instruction");
            }
        }
Beispiel #6
0
        private void DrawInstruction(Rect rect, int index)
        {
            var ecosystem   = target as Ecosystem;
            var key         = _updateInstructionKeys[index];
            var instruction = ecosystem.CreatureUpdateInstructions[key];

            var keyRect         = new Rect(rect.x, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
            var instructionRect = new Rect(keyRect.xMax + 5, rect.y, rect.width - keyRect.width - 5, keyRect.height);

            EditorGUI.LabelField(keyRect, key);

            ecosystem.CreatureUpdateInstructions[key] = InstructionDrawer.Draw(instructionRect, instruction == null ? null : instruction.Set, instruction, _updateInstructionLabel);
        }
        private void DrawInstruction(Rect rect, int index)
        {
            var branch      = target as BranchOnString;
            var key         = _branchKeys[index];
            var instruction = branch.Instructions[key];

            var keyRect         = new Rect(rect.x, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
            var instructionRect = new Rect(keyRect.xMax + 5, rect.y, rect.width - keyRect.width - 5, keyRect.height);

            EditorGUI.LabelField(keyRect, key);

            branch.Instructions[key] = InstructionDrawer.Draw(instructionRect, instruction == null ? null : instruction.Set, instruction, _label);
        }
        private void Remove(InstructionSet set, int index)
        {
            using (new UndoScope(set))
            {
                var instruction = set.Instructions[index];
                if (instruction != null)
                {
                    Undo.DestroyObjectImmediate(instruction);
                }

                set.Instructions.RemoveAt(index);

                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(set));
                InstructionDrawer.InstructionSetChanged(set);
            }
        }
        private void DrawRange(Rect rect, int index)
        {
            var branch          = target as BranchOnRange <T>;
            var range           = branch.Instructions[index];
            var min             = index > 0 ? branch.Instructions[index - 1] : null;
            var max             = index < branch.Instructions.Count - 1 ? branch.Instructions[index + 1] : null;
            var valueRect       = new Rect(rect.x, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
            var instructionRect = new Rect(valueRect.xMax + 5, rect.y, rect.width - valueRect.width - 5, valueRect.height);

            var value = DrawRange(valueRect, range.Value, min, max);

            if (!branch.Instructions.Any(other => other.Value.CompareTo(value) == 0))
            {
                range.Value = value;
                branch.Instructions.Sort((first, second) => first.Value.CompareTo(second.Value));
            }

            range.Instruction = InstructionDrawer.Draw(instructionRect, branch.Set, range.Instruction, _label);
        }
Beispiel #10
0
        private void DrawSkill(Rect rect, int index)
        {
            var skill  = _species.Skills[index];
            var inputs = _inputLists[index];

            var labelRect       = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
            var conditionRect   = new Rect(rect.x + 10, labelRect.yMax + 5, rect.width - 10, EditorGUIUtility.singleLineHeight);
            var limitRect       = new Rect(rect.x + 10, conditionRect.yMax + 5, rect.width * 0.75f, EditorGUIUtility.singleLineHeight);
            var limitAmountRect = new Rect(limitRect.xMax + 5, limitRect.y, rect.width - limitRect.width - 15, limitRect.height);
            var instructionRect = new Rect(rect.x + 10, limitRect.yMax + 5, rect.width - 10, EditorGUIUtility.singleLineHeight);
            var inputsRect      = new Rect(rect.x + 10, instructionRect.yMax + 5, rect.width - 10, EditorGUIUtility.singleLineHeight);

            EditorGUI.LabelField(labelRect, skill.Name, EditorStyles.boldLabel);

            using (var changes = new EditorGUI.ChangeCheckScope())
            {
                conditionRect = EditorGUI.PrefixLabel(conditionRect, new GUIContent("Condition"));
                var condition = EditorGUI.DelayedTextField(conditionRect, skill.Condition.Statement);

                if (changes.changed)
                {
                    skill.Condition.Statement = condition;
                    skill.UpdateTriggers();
                }
            }

            var limitIndex = EditorGUI.Popup(limitRect, "Learn Limit", skill.LearnLimit == 0 ? 2 : (skill.LearnLimit == 1 ? 0 : 1), _limits);

            if (limitIndex == 0)
            {
                skill.LearnLimit = 1;
            }
            else if (limitIndex == 1)
            {
                if (skill.LearnLimit == 0 || skill.LearnLimit == 1)
                {
                    skill.LearnLimit = 10;
                }

                skill.LearnLimit = EditorGUI.IntField(limitAmountRect, skill.LearnLimit);
            }
            else if (limitIndex == 2)
            {
                skill.LearnLimit = 0;
            }

            using (var changes = new EditorGUI.ChangeCheckScope())
            {
                instructionRect = EditorGUI.PrefixLabel(instructionRect, new GUIContent("Instruction"));
                skill.Instruction.Instruction = InstructionDrawer.Draw(instructionRect, null, skill.Instruction.Instruction, GUIContent.none);

                if (changes.changed && skill.Instruction.Instruction != null)
                {
                    RefreshInputs(inputs, skill.Instruction);
                }
            }

            for (var i = 0; i < skill.Instruction.Inputs.Count; i++)
            {
                var input     = skill.Instruction.Inputs[i];
                var inputRect = EditorGUI.PrefixLabel(inputsRect, new GUIContent(input.Name));
                VariableValueDrawer.DrawValue(inputRect, input, inputs.Inputs[i].Type, inputs.Inputs[i].ParentType);
                inputsRect.y += EditorGUIUtility.singleLineHeight + 5;
            }
        }