Example #1
0
        public static float getCuMWorth(this Backstory bs, bool includeSkillGainWorth = true)
        {
            if (bs == null)
            {
                return(0);
            }
            float total = 0, BC = QOLMod.getBaseCost();

            if (includeSkillGainWorth)
            {
                foreach (KeyValuePair <SkillDef, int> p in bs.skillGainsResolved)
                {
                    total += BC * (float)p.Value;
                }
            }
            WorkTags           disabledWorkTags = bs.workDisables;
            List <WorkTypeDef> allDefsListForReading = DefDatabase <WorkTypeDef> .AllDefsListForReading;

            foreach (WorkTypeDef wtd in allDefsListForReading)
            {
                if ((wtd.workTags & disabledWorkTags) != WorkTags.None)
                {
                    total += -2 * BC;
                }
            }
            return(total);
        }
Example #2
0
 public static float getCuMWorth(this SkillRecord sr)
 {
     if (sr == null || sr.TotallyDisabled)
     {
         return(0);
     }
     return(sr.Level * QOLMod.getBaseCost() + sr.passion.getCuMWorth());
 }
Example #3
0
 public static float getCuMWorth(this Trait t, bool removal = false)
 {
     if (t == null)
     {
         return(0);
     }
     return(QOLMod.getTraitCost(t, removal) * QOLMod.getBaseCost());
 }
Example #4
0
        public static float getCuMWorth(this Passion p)
        {
            switch (p)
            {
            case Passion.None: return(0);

            case Passion.Minor: return(QOLMod.getBaseCost() * 2);

            case Passion.Major: return(QOLMod.getBaseCost() * 3);
            }
            Log.Error("Unknown Passion type while calculation upgrade cost!");
            return(0);
        }
Example #5
0
        public static float getCuMWorth(this Pawn p)
        {
            if (p == null)
            {
                return(0);
            }
            float points = 0, BC = QOLMod.getBaseCost();;

            points += getCuMWorth(p.records);
            foreach (Trait t in p.story.traits.allTraits)
            {
                points += t.getCuMWorth();
            }
            foreach (Backstory bs in p.story.AllBackstories)
            {
                points += bs.getCuMWorth(false);
            }
            foreach (SkillRecord sr in p.skills.skills)
            {
                points += sr.getCuMWorth();
            }
            return(points);
        }
        protected void settlementChanged(Settlement settlement)
        {
            if (settlement == null)
            {
                return;
            }

            //grab items for trade stock from settlement
            stock = new ThingOwner <Thing>(this);
            foreach (StockGenerator generator in TraderKind.stockGenerators)
            {
                IEnumerable <Thing> things = generator.GenerateThings(settlement.Tile);
                foreach (Thing t in things)
                {
                    GiveSoldThingToTrader(t, t.stackCount, null);
                }
            }
            //grab name from settlement
            if (settlement != null)
            {
                this.settlementName = settlement.TraderName;
            }
            else
            {
                this.settlementName = "unknown";
            }
            //A non null list of pawns from the settlement that we evaluate as workforce
            List <Pawn> pawnsToInspect = new List <Pawn>();

            pawnsToInspect.AddRange(settlement.Map.mapPawns.FreeColonistsSpawned);

            //grab the highest skill levels from the pawns in the settlement for each skill.
            maxSkillLevels = new List <SkillLevel>();
            foreach (SkillDef skillDef in DefDatabase <SkillDef> .AllDefsListForReading)
            {
                SkillLevel skr = buildDefaultMaxSkillLevel(skillDef);
                maxSkillLevels.Add(skr);
                foreach (Pawn p in pawnsToInspect)
                {
                    skr.level = Math.Max(skr.level, p.skills.GetSkill(skillDef).Level);
                }
            }

            //Names from the workers
            this.pawnNames = (from Pawn p in pawnsToInspect select p.Name.ToStringFull).ToList();

            //collect the CuM points for the pawns and add them to the pool
            float BC     = QOLMod.getBaseCost();
            float points = 0;

            foreach (Pawn p in pawnsToInspect)
            {
                points += p.getCuMWorth();
            }
            Current.Game.GetComponent <QOLModGameComponent>().pooledPoints += points * QOLMod.getCumPointRemnantsToPoolConversionFactor();

            foreach (Action <Settlement> a in onSettlementChanged)
            {
                a(settlement);
            }
        }