예제 #1
0
        public static IEnumerable <Act.Status> RestockAll(this Creature agent)
        {
            Dictionary <string, ResourceAmount> aggregatedResources = new Dictionary <string, ResourceAmount>();

            foreach (var resource in agent.Inventory.Resources)
            {
                if (resource.MarkedForUse)
                {
                    continue;
                }
                resource.MarkedForRestock = true;

                if (!aggregatedResources.ContainsKey(resource.Resource))
                {
                    aggregatedResources[resource.Resource] = new ResourceAmount(resource.Resource, 0);
                }
                aggregatedResources[resource.Resource].NumResources++;
            }

            foreach (var resource in aggregatedResources)
            {
                var task = new StockResourceTask(resource.Value.CloneResource())
                {
                    Priority = Task.PriorityType.Medium
                };

                if (task.IsFeasible(agent) == Task.Feasibility.Feasible && !agent.AI.Tasks.Contains(task))
                {
                    agent.AI.AssignTask(task);
                }
            }
            yield return(Act.Status.Success);
        }
예제 #2
0
        public static void RestockAllImmediately(this Creature agent, bool allowMarkedForUse = false)
        {
            Dictionary <string, ResourceAmount> aggregatedResources = new Dictionary <string, ResourceAmount>();

            foreach (var resource in agent.Inventory.Resources)
            {
                if (allowMarkedForUse || !resource.MarkedForUse)
                {
                    resource.MarkedForRestock = true;

                    if (!aggregatedResources.ContainsKey(resource.Resource))
                    {
                        aggregatedResources[resource.Resource] = new ResourceAmount(resource.Resource, 0);
                    }
                    aggregatedResources[resource.Resource].NumResources++;
                }
            }

            foreach (var resource in aggregatedResources)
            {
                var task = new StockResourceTask(resource.Value.CloneResource())
                {
                    Priority = Task.PriorityType.Medium
                };

                if (!agent.AI.Tasks.Contains(task))
                {
                    agent.AI.AssignTask(task);
                }
            }
        }
예제 #3
0
        public static IEnumerable <Act.Status> RestockAll(this Creature agent)
        {
            Dictionary <string, ResourceAmount> aggregatedResources = new Dictionary <string, ResourceAmount>();

            foreach (var resource in agent.Inventory.Resources)
            {
                if (!resource.MarkedForRestock || agent.AI.GatherManager.StockOrders.Count == 0)
                {
                    resource.MarkedForRestock = true;

                    if (!aggregatedResources.ContainsKey(resource.Resource))
                    {
                        aggregatedResources[resource.Resource] = new ResourceAmount(resource.Resource, 0);
                    }
                    aggregatedResources[resource.Resource].NumResources++;
                }
            }

            foreach (var resource in aggregatedResources)
            {
                var task = new StockResourceTask(resource.Value);
                if (!agent.AI.Tasks.Contains(task))
                {
                    agent.AI.AssignTask(task);
                }
            }
            yield return(Act.Status.Success);
        }
예제 #4
0
        public static void RestockAllImmediately(this Creature agent)
        {
            Dictionary <string, ResourceAmount> aggregatedResources = new Dictionary <string, ResourceAmount>();

            foreach (var resource in agent.Inventory.Resources)
            {
                if (!resource.MarkedForRestock || agent.AI.GatherManager.StockOrders.Count == 0)
                {
                    if (!resource.MarkedForUse)
                    {
                        resource.MarkedForRestock = true;

                        if (!aggregatedResources.ContainsKey(resource.Resource))
                        {
                            aggregatedResources[resource.Resource] = new ResourceAmount(resource.Resource, 0);
                        }
                        aggregatedResources[resource.Resource].NumResources++;
                    }
                }
            }

            foreach (var resource in aggregatedResources)
            {
                var task = new StockResourceTask(resource.Value)
                {
                    Priority = Task.PriorityType.High
                };

                if (!agent.AI.Tasks.Contains(task))
                {
                    agent.AI.AssignTask(task);
                }
            }
        }
예제 #5
0
        public static void AssignRestockAllTasks(this Creature agent, TaskPriority Priority, bool IgnoreMarks)
        {
            var aggregatedResources = new Dictionary <string, ResourceTypeAmount>();

            foreach (var resource in agent.Inventory.Resources)
            {
                if (!IgnoreMarks && resource.MarkedForUse)
                {
                    continue;
                }

                resource.MarkedForRestock = true;
                var task = new StockResourceTask(resource.Resource)
                {
                    Priority = Priority
                };
                if (task.IsFeasible(agent) == Feasibility.Feasible && !agent.AI.Tasks.Contains(task))
                {
                    agent.AI.AssignTask(task);
                }
            }
        }