Exemple #1
0
        //===============================================================================\\

        public static float GetIncrementWeapon(Thing weapon, INano nanoObj)
        {
            float hp = IsAdvancedResearchComplete()
                                ? HP_WEAPON_PER_YEAR
                                : (HP_WEAPON_PER_YEAR * LOW_TIER_WEAPONS);

            return(nanoObj.RareTicksPerYear() / hp);
        }
Exemple #2
0
        //===============================================================================\\

        private TickData getTickData(int thingID, INano nanoObj)
        {
            TickData data = null;

            if (!this.TickTracker.TryGetValue(thingID, out data))
            {
                data = nanoObj.GenerateTickData();
                this.TickTracker.Add(thingID, data);
            }
            return(data);
        }
Exemple #3
0
        //===============================================================================\\
        //===============================================================================\\
        //===============================================================================\\

        public static float GetIncrementApparel(Apparel apparel, INano nanoObj)
        {
            float hp = IsAdvancedResearchComplete()
                                ? HP_APPAREL_PER_YEAR
                                : (HP_APPAREL_PER_YEAR * LOW_TIER_APPAREL);

            float wearPerDay = 0;

            if (apparel.def != null)
            {
                if (apparel.def.apparel != null)
                {
                    wearPerDay = apparel.def.apparel.wearPerDay;
                }
            }

            return(nanoObj.RareTicksPerYear() / (hp + (60f * wearPerDay)));
        }
Exemple #4
0
        //===============================================================================\\

        public void ProcessTick(List <Apparel> apparel, List <Thing> weapons, INano nanoObject)
        {
            // Stat Defs for UI
            bool isAdvancedComplete = IsAdvancedResearchComplete();
            bool isWeaponsComplete  = IsWeaponResearchComplete();

            this.StatModApparel.value = isAdvancedComplete
                                ? 100
                                : (100 * LOW_TIER_APPAREL);

            if (isWeaponsComplete)
            {
                this.StatModWeapons.value = isAdvancedComplete
                                        ? 100
                                        : (100 * LOW_TIER_WEAPONS);
            }
            else
            {
                this.StatModWeapons.value = 0;
            }

            // Apparel / Weapons

            int powerApparelCount = 0;
            int powerWeaponsCount = 0;
            int tickFuel          = 0;

            if (this.CmpPowerTrader.PowerOn && this.CmpRefuelable.HasFuel)
            {
                foreach (Apparel a in apparel)
                {
                    if (a.HitPoints < a.MaxHitPoints)
                    {
                        ++powerApparelCount;
                        TickData data = this.getTickData(a.thingIDNumber, nanoObject);
                        if (data.AddHP(NanoRepair.GetIncrementApparel(a, nanoObject)))
                        {
                            a.HitPoints = a.HitPoints + 1;
                            ++tickFuel;
                            if (a.HitPoints >= a.MaxHitPoints)
                            {
                                this.TickTracker.Remove(a.thingIDNumber);
                                --powerApparelCount;
                            }
                        }
                    }

                    if (a.WornByCorpse && a.HitPoints >= (a.MaxHitPoints * 0.98))
                    {
                        FieldInfo info = a.GetType().GetField("wornByCorpseInt", BindingFlags.Instance | BindingFlags.NonPublic);
                        info.SetValue(a, false);
                    }
                }

                if (isWeaponsComplete)
                {
                    foreach (Thing w in weapons)
                    {
                        if (w != null && w.def != null && (w.def.IsRangedWeapon || w.def.IsMeleeWeapon))
                        {
                            if (w.HitPoints < w.MaxHitPoints)
                            {
                                ++powerWeaponsCount;
                                TickData wData = this.getTickData(w.thingIDNumber, nanoObject);
                                if (wData.AddHP(NanoRepair.GetIncrementWeapon(w, nanoObject)))
                                {
                                    w.HitPoints = w.HitPoints + 1;
                                    ++tickFuel;
                                    if (w.HitPoints >= w.MaxHitPoints)
                                    {
                                        this.TickTracker.Remove(w.thingIDNumber);
                                        --powerWeaponsCount;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (powerApparelCount == 0 && powerWeaponsCount == 0)
            {
                this.CmpPowerTrader.PowerOutput = -(this.CmpPowerTrader.Props.basePowerConsumption * 0.1f);
            }
            else
            {
                float factor = this.CmpPowerTrader.Props.basePowerConsumption * (isAdvancedComplete ? 1.0f : LOW_TIER_POWER);
                this.CmpPowerTrader.PowerOutput = -(factor * (powerApparelCount + (2 * powerWeaponsCount)));
            }

            if (tickFuel > 0)
            {
                this.CmpRefuelable.ConsumeFuel(FUEL_RATE * tickFuel);
            }
        }