Exemple #1
0
        public static float calculateTaskCost(TileNode v, ToolPrerequisite t)
        {
            float pathCost = StarAI.PathFindingCore.Utilities.calculatePathCost(v) * pathCostMultiplier;
            float toolCost = calculateToolCostMultiplier(t);

            return(pathCost + toolCost);
        }
Exemple #2
0
        public TaskMetaData(string Name, LocationPrerequisite LocationPrereque, StaminaPrerequisite StaminaPrerequisite = null, ToolPrerequisite ToolPrerequisite = null, InventoryFullPrerequisite InventoryFull = null, BedTimePrerequisite bedTimePrereq = null, ItemPrerequisite ItemPrereque = null)
        {
            this.name = Name;
            this.staminaPrerequisite   = StaminaPrerequisite;
            this.toolPrerequisite      = ToolPrerequisite;
            this.inventoryPrerequisite = InventoryFull;
            this.pathsToTake           = new List <List <TileNode> >();
            this.bedTimePrerequisite   = bedTimePrereq;

            this.itemPrerequisite     = ItemPrereque;
            this.locationPrerequisite = LocationPrereque;
            //Make sure to set values correctly incase of null
            setUpLocationPrerequsiteIfNull();
            setUpStaminaPrerequisiteIfNull();
            setUpToolPrerequisiteIfNull();
            setUpInventoryPrerequisiteIfNull();
            setUpBedTimeIfNull();
            setUpItemPrerequisiteIfNull();
            this.prerequisitesList = new List <TaskPrerequisites.GenericPrerequisite>();
            this.prerequisitesList.Add(this.staminaPrerequisite);
            this.prerequisitesList.Add(this.toolPrerequisite);
            this.prerequisitesList.Add(this.inventoryPrerequisite);
            this.prerequisitesList.Add(this.bedTimePrerequisite);
            this.prerequisitesList.Add(this.itemPrerequisite);
        }
        public static KeyValuePair <int, List <TileNode> > calculateTaskCost(TileNode v, ToolPrerequisite t, bool unknownPath)
        {
            //if(unknownPath) PathFindingLogic.delay = 18;
            // else PathFindingLogic.delay = 0;
            List <TileNode> idealPath = StarAI.PathFindingCore.Utilities.getIdealPath(v);
            int             costCalculation;

            if (idealPath.Count == 0)
            {
                costCalculation = Int32.MaxValue;
            }
            else
            {
                costCalculation = idealPath.Count;
            }

            if (costCalculation == Int32.MaxValue)
            {
                return(new KeyValuePair <int, List <TileNode> >(Int32.MaxValue, new List <TileNode>()));
            }

            float pathCost = costCalculation * pathCostMultiplier;
            float toolCost = calculateToolCostMultiplier(t);

            return(new KeyValuePair <int, List <TileNode> >(((int)pathCost + (int)toolCost), idealPath));
        }
        public static KeyValuePair <int, List <List <TileNode> > > calculateTaskCost(List <List <TileNode> > v, ToolPrerequisite t, bool unknownPath)
        {
            //if (unknownPath) PathFindingLogic.delay = 18;
            //else PathFindingLogic.delay = 0;
            float totalCalculation             = 0;
            List <List <TileNode> > idealPaths = new List <List <TileNode> >();

            foreach (var path in v)
            {
                ModCore.CoreMonitor.Log("HMMM" + path.ElementAt(0).thisLocation.name.ToString());
                ModCore.CoreMonitor.Log("HMMM" + path.ElementAt(0).tileLocation.ToString());
                List <TileNode> idealPath       = StarAI.PathFindingCore.Utilities.getIdealPath(path);
                int             costCalculation = 0;

                if (idealPath.Count == 0)
                {
                    costCalculation = Int32.MaxValue;
                }
                else
                {
                    costCalculation = idealPath.Count;
                }

                //There was an error somewhere and now this won't work!!!!
                if (costCalculation == Int32.MaxValue)
                {
                    return(new KeyValuePair <int, List <List <TileNode> > >(Int32.MaxValue, new List <List <TileNode> >()));
                }

                float pathCost = costCalculation * pathCostMultiplier;

                ModCore.CoreMonitor.Log("I THINK THIS IS MY PATH COST: " + costCalculation);
                float toolCost = calculateToolCostMultiplier(t);
                totalCalculation += toolCost + pathCost;
                idealPaths.Add(idealPath);
            }
            return(new KeyValuePair <int, List <List <TileNode> > >((int)totalCalculation, idealPaths));
        }