public ListFilterMenuAction(string actionID, ActionPath actionPath, IListFilterDataSource dataSource, IResourceResolver resourceResolver)
     : base(actionID, actionPath, resourceResolver)
 {
     Platform.CheckForNullReference(dataSource, "dataSource");
     _dataSource = dataSource;
 }
Exemple #2
0
 public ContextMenuAction(string actionID, ActionPath path, ClickActionFlags flags, IResourceResolver resourceResolver)
     : base(actionID, path, flags, resourceResolver)
 {
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="actionID">The logical action ID.</param>
        /// <param name="maxRows">The maximum number of rows that the user can select.</param>
        /// <param name="maxColumns">The maximum number of columns that the user can select.</param>
        /// <param name="callback">A <see cref="SetLayoutCallback"/> delegate that will be called when the user selects a layout size.</param>
        /// <param name="path">The action path.</param>
        /// <param name="resourceResolver">A resource resolver that will be used to resolve icons associated with this action.</param>
        public LayoutChangerAction(string actionID, int maxRows, int maxColumns, SetLayoutCallback callback, ActionPath path, IResourceResolver resourceResolver)
            : base(actionID, path, resourceResolver)
        {
            Platform.CheckForNullReference(callback, "callback");

            base.Label         = path.LastSegment.LocalizedText;
            _setLayoutCallback = callback;
            _maxRows           = maxRows;
            _maxColumns        = maxColumns;
        }
Exemple #4
0
 public override void AICallback(ActionPath result, MoveSuggestor ms, int tested, int all)
 {
     base.AICallback(result, ms, tested, all);
     MakeAction(result.actions[0].Action);
 }
 public ActionPlaceholder(string actionId, ActionPath path, IResourceResolver resourceResolver)
     : base(actionId, path, ClickActionFlags.None, resourceResolver)
 {
 }
Exemple #6
0
    private IEnumerator GOAP_Planning(List <Action.State> wanted, PlanImportance importance) // only gives one option
    {
        if (wanted.Count == 0)
        {
            wanted.Add(new Action.State(concedeTag, 100));
        }

        List <ActionPath> succeeded = new List <ActionPath>();
        List <ActionPath> aps       = new List <ActionPath>();
        ActionPath        ap;

        List <ActionPath> newActions = new List <ActionPath>();

        List <ActionsBranchable> actionsByWant;
        ActionsBranchable        branchable;

        List <BranchTemporaryEntry> possible = new List <BranchTemporaryEntry>();

        ActionsBranchable actionBranch;
        int  calc = 0, old;
        bool fit, symbiont;

        int wantedChosen = -1;

        foreach (Action.State want in wanted)
        {
            wantedChosen++;
            aps.Clear();
            actionsByWant = GetBranchableActions(new List <Action.State> {
                want
            });
            //its certain that its only one right now
            actionBranch = actionsByWant[0];
            foreach (Action action in actionBranch.actions)
            {
                aps.Add(new ActionPath(action, null));
            }

            while (aps.Count > 0)
            {
                calc++;
                if (calc > intelligence.calcsPerSecond)
                {
                    calc = 0;
                    yield return(null);
                }

                ap = aps[0];
                aps.RemoveAt(0);

                //check if able to execute
                #region Execute Check
                fit      = true;
                symbiont = false;
                foreach (Action action in ap.actions)
                {
                    if (action.requirements.Count == 0)
                    {
                        symbiont = true;
                    }
                    foreach (Action.State requirement in action.requirements)
                    {
                        symbiont = false;
                        foreach (AState aState in states)
                        {
                            if (requirement.state == aState.state)
                            {
                                symbiont = true;
                                if (requirement.amount > aState.amount)
                                {
                                    fit = false;
                                    break;
                                }
                            }
                        }
                        if (!fit || !symbiont)
                        {
                            break;
                        }
                    }
                    if (!fit)
                    {
                        break;
                    }
                }

                if (fit && symbiont)
                {
                    succeeded.Add(ap);
                    continue;
                }
                #endregion

                //foreach action get branches
                newActions.Clear();
                fit = true;
                foreach (Action oldAction in ap.actions)
                {
                    actionsByWant = GetBranchableActions(oldAction.requirements);
                    if (actionsByWant.Count == 0)
                    {
                        continue;
                    }

                    possible.Clear();
                    foreach (Action a in actionsByWant[0].actions)
                    {
                        possible.Add(new BranchTemporaryEntry(null, a));
                    }

                    for (int i = 1; i < actionsByWant.Count; i++)
                    {
                        branchable = actionsByWant[i];
                        old        = possible.Count - 1;
                        //multiply all excisting with each of this list
                        for (int _old = old; _old > -1; _old--)
                        {
                            foreach (Action a in branchable.actions)
                            {
                                possible.Add(new BranchTemporaryEntry(possible[_old], a));
                            }
                        }

                        //remove all the old ones
                        for (int _i = old; _i > 0; _i--)
                        {
                            possible.RemoveAt(_i);
                        }
                    }

                    for (int p = possible.Count - 1; p > -1; p--)
                    {
                        if (possible[p].actions.Count < actionsByWant.Count)
                        {
                            possible.RemoveAt(p);
                        }
                    }

                    if (possible.Count == 0)
                    {
                        fit = false;
                        break;
                    }

                    //add actions to temp list
                    foreach (BranchTemporaryEntry bte in possible)
                    {
                        //remove functions that are executed multiple times
                        for (int i = bte.actions.Count - 1; i > -1; i--)
                        {
                            for (int _i = bte.actions.Count - 1; _i > -1; _i--)
                            {
                                if (i == _i)
                                {
                                    continue;
                                }
                                if (bte.actions[i] == bte.actions[_i])
                                {
                                    bte.actions.RemoveAt(i);
                                }
                            }
                        }

                        newActions.Add(new ActionPath(bte.actions, ap));
                    }
                }

                if (!fit)
                {
                    continue;
                }

                foreach (ActionPath aP in newActions)
                {
                    aps.Add(aP);
                }
            }

            //if it continues the loop, the current one has not been solved
            if (succeeded.Count == 0)
            {
                continue;
            }
            succeeded.Sort();
            int choice = Mathf.RoundToInt(Mathf.Lerp(0, succeeded.Count - 1, (float)intelligence.value / 100));

            #region Debug

            /*
             * //temporary debug
             * foreach (ActionPath e in succeeded)
             * {
             *  string s = "";
             *  ActionPath _e = e;
             *  while (true)
             *  {
             *      foreach (Action a in _e.actions)
             *          s += a.name + " ";
             *      if (!(_e.parent != null))
             *          break;
             *      _e = _e.parent;
             *  }
             *
             *  print(s);
             * }
             */
            #endregion

            //convert action path into a planning
            Plan newPlan = new Plan();
            newPlan.goal = wanted[wantedChosen].state;
            ActionPath current = succeeded[choice];
            while (true)
            {
                foreach (Action action in current.actions)
                {
                    newPlan.parts.Add(action);
                }
                if (!(current.parent != null))
                {
                    break;
                }
                current = current.parent;
            }

            InsertPlan(newPlan, importance);
            StartPlan();
            yield break;
        }

        //a man without a plan
    }