コード例 #1
0
        public static string GetDisplayCost(FactorioObject goods)
        {
            var cost = goods.Cost();

            if (float.IsPositiveInfinity(cost))
            {
                return("YAFC analysis: Unable to find a way to fully automate this");
            }

            sb.Clear();

            var    compareCost = cost;
            string costPrefix;

            if (goods is Fluid)
            {
                compareCost = cost * 50;
                costPrefix  = "YAFC cost per 50 units of fluid:";
            }
            else if (goods is Item)
            {
                costPrefix = "YAFC cost per item:";
            }
            else if (goods is Special special && special.isPower)
            {
                costPrefix = "YAFC cost per 1 MW:";
            }
コード例 #2
0
ファイル: Milestones.cs プロジェクト: ShadowGlass0/PyYAFC
        public bool IsAccessibleAtNextMilestone(FactorioObject obj)
        {
            var milestoneMask = milestoneResult[obj] & lockedMask;

            if (milestoneMask == 1)
            {
                return(true);
            }
            if ((milestoneMask & 1) != 0)
            {
                return(false);
            }
            return(((milestoneMask - 1) & (milestoneMask - 2)) == 0); // milestoneMask is a power of 2 + 1
        }
コード例 #3
0
        public FactorioObject GetHighest(FactorioObject target, bool all)
        {
            if (target == null)
            {
                return(null);
            }
            var ms = milestoneResult[target];

            if (!all)
            {
                ms &= lockedMask;
            }
            if (ms == 0)
            {
                return(null);
            }
            var msb = MathUtils.HighestBitSet(ms) - 1;

            return(msb < 0 || msb >= currentMilestones.Length ? null : currentMilestones[msb]);
        }
コード例 #4
0
 public bool IsAccessibleWithCurrentMilesones(FactorioObject obj) => (milestoneResult[obj] & lockedMask) == 1;
コード例 #5
0
ファイル: CostAnalysis.cs プロジェクト: ShadowGlass0/PyYAFC
 private bool ShouldInclude(FactorioObject obj)
 {
     return(onlyCurrentMilestones ? obj.IsAutomatableWithCurrentMilestones() : obj.IsAutomatable());
 }