Esempio n. 1
0
        //===============================================================================\\

        public override void TickRare()
        {
            base.TickRare();

            List <Apparel> apparel = new List <Apparel>();
            List <Thing>   weapons = new List <Thing>();

            if (_nano.CmpPowerTrader.PowerOn && _nano.CmpRefuelable.HasFuel)
            {
                foreach (Pawn occupant in new List <Pawn>(this.CurOccupants).Where(x => x != null))
                {
                    if (occupant.apparel != null && occupant.apparel.WornApparel != null)
                    {
                        apparel.AddRange(new List <Apparel>(occupant.apparel.WornApparel).Where(x => x != null && x.def != null));
                    }

                    if (NanoRepair.IsWeaponResearchComplete())
                    {
                        if (occupant.equipment != null && occupant.equipment.GetDirectlyHeldThings() != null)
                        {
                            weapons.AddRange(new List <Thing>(occupant.equipment.GetDirectlyHeldThings()).Where(x =>
                            {
                                return((x != null) &&
                                       (x.def != null) &&
                                       (x.def.IsRangedWeapon || x.def.IsMeleeWeapon));
                            }));
                        }
                    }
                }
            }

            _nano.ProcessTick(apparel, weapons, this);
        }
Esempio n. 2
0
        //===============================================================================\\

        public override void TickRare()
        {
            base.TickRare();

            List <Apparel> apparel = new List <Apparel>();
            List <Thing>   weapons = new List <Thing>();

            if (_nano.CmpPowerTrader.PowerOn && _nano.CmpRefuelable.HasFuel)
            {
                SlotGroup group = base.GetSlotGroup();
                if (group != null && group.HeldThings != null)
                {
                    bool weaponsComplete = NanoRepair.IsWeaponResearchComplete();
                    foreach (Thing thing in group.HeldThings)
                    {
                        if (thing.def != null && thing.def.stackLimit == 1 && !thing.def.Minifiable)
                        {
                            if (thing.def.IsApparel)
                            {
                                apparel.Add((Apparel)thing);
                            }
                            else if (weaponsComplete && (thing.def.IsMeleeWeapon || thing.def.IsRangedWeapon))
                            {
                                weapons.Add(thing);
                            }
                        }
                    }
                }
            }

            _nano.ProcessTick(apparel, weapons, this);
        }
Esempio n. 3
0
 public NanoBed()
 {
     _nano = new NanoRepair();
 }
Esempio n. 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);
            }
        }
Esempio n. 5
0
 public NanoShelf()
 {
     _nano = new NanoRepair();
 }