Esempio n. 1
0
        public override bool PEGI()
        {
            var tmpVals = Values.current;

            Values.current = targ.TryGetValues(tmpVals);

            browsedBranch = Mathf.Min(browsedBranch, branches.Count - 1);

            bool changed = base.PEGI();

            if (!showDebug)
            {
                if (!isCalledFromAnotherBranch)
                {
                    path = "Cnds";
                }
                else
                {
                    path += "->" + NameForPEGI;
                }

                if (browsedBranch == -1)
                {
                    path.nl();

                    if (pegi.Click("Logic: " + type + (type == ConditionBranchType.AND ? " (ALL should be true)" : " (At least one should be true)")
                                   + (Values.current != null ? (TestFor(Values.current) ? "True" : "false") : " ")
                                   ,
                                   (type == ConditionBranchType.AND ? "All conditions and sub branches should be true" :
                                    "At least one condition or sub branch should be true")
                                   ))
                    {
                        type = (type == ConditionBranchType.AND ? ConditionBranchType.OR : ConditionBranchType.AND);
                    }

                    conds.edit_List(ref browsedCondition, true);

                    changed |= "Sub Conditions".edit_List(branches, ref browsedBranch, true);
                }
                else
                {
                    isCalledFromAnotherBranch = true;
                    var sub = branches[browsedBranch];
                    if (sub.browsedBranch == -1 && icon.Exit.Click())
                    {
                        browsedBranch = -1;
                    }
                    else
                    {
                        changed |= sub.PEGI();
                    }
                    isCalledFromAnotherBranch = false;
                }
            }
            pegi.newLine();

            Values.current = tmpVals;

            return(changed);
        }
Esempio n. 2
0
        public virtual bool Inspect()
        {
            if (!_name.IsNullOrEmpty())
            {
                _name.nl(PEGI_Styles.ListLabel);
            }

            var before = ConditionLogic.inspectedTarget;

            ConditionLogic.inspectedTarget = Values.global;

            var changed = false;



            if (_browsedBranch == -1)
            {
                var cnt = CountForInspector();

                if (cnt > 1)
                {
                    if (_type.ToString().Click((_type == ConditionBranchType.And
                        ? "All conditions and sub branches should be true"
                        : "At least one condition OR sub branch should be true")))
                    {
                        _type = (_type == ConditionBranchType.And ? ConditionBranchType.Or : ConditionBranchType.And);
                    }
                }

                if (cnt > 0)
                {
                    (CheckConditions(ConditionLogic.inspectedTarget) ? icon.Active : icon.InActive).nl();
                }

                var newC = "Conditions".edit_List(ref _conditions, ref _browsedCondition, ref changed);
                if (newC != null)
                {
                    newC.TriggerIndexes = TriggerGroup.TryGetLastUsedTrigger();
                }
            }

            pegi.line(Color.black);

            if (_branches.Count == 0 && "Create Sub Branch".Click().nl())
            {
                _branches.Add(new ConditionBranch());
            }

            if (_branches.Count > 0)
            {
                "Sub Branches".edit_List(ref _branches, ref _browsedBranch).changes(ref changed);
            }

            ConditionLogic.inspectedTarget = before;

            return(changed);
        }
Esempio n. 3
0
        public virtual void Decode(string tg, CfgData data)
        {
            switch (tg)
            {
            case "t":     _type = (ConditionBranchType)data.ToInt(0); break;

            case "wb":    data.ToList(out _branches); break;

            case "v":     data.ToList(out _conditions); break;

            case "insB":  _browsedBranch = data.ToInt(0); break;

            case "ic":    _browsedCondition = data.ToInt(0); break;
            }
        }
Esempio n. 4
0
        public override bool Decode(string tg, string data)
        {
            switch (tg)
            {
            case "t":     _type = (ConditionBranchType)data.ToInt(); break;

            case "wb":    data.Decode_List(out _branches); break;

            case "v":     data.Decode_List(out _conditions); break;

            case "insB":  _browsedBranch = data.ToInt(); break;

            case "ic":    _browsedCondition = data.ToInt(); break;

            default:      return(false);
            }
            return(true);
        }
Esempio n. 5
0
        public override bool Decode(string subtag, string data)
        {
            switch (subtag)
            {
            case "t": type = (ConditionBranchType)data.ToInt(); break;

            case "d": description = data; break;

            case "tag": data.DecodeInto(out targ); break;

            case "wb": data.DecodeInto(out branches); break;

            case "v": data.DecodeInto(out conds); break;

            case "insB": browsedBranch = data.ToInt(); break;

            case "ic": browsedCondition = data.ToInt(); break;

            default: return(false);
            }
            return(true);
        }