Ejemplo n.º 1
0
        public static void PowerIV()
        {
            CompProperties_Battery new_cap = DefDatabase <ThingDef> .GetNamed("Battery", true).GetCompProperties <CompProperties_Battery>();

            new_cap.storedEnergyMax = 1500f;
            new_cap.efficiency      = 1.25f;
        }
Ejemplo n.º 2
0
        public override string CompInspectStringExtra()
        {
            string devString = $"Stored: {StoredEnergy:F1} / {MaxStoredEnergy:F0}, pulling from {PullBatteriesCount} ({ReasonNoPull})";

            // Don't display the extra inspector info that the battery gives. It just clutters the inspector.
            // Optional, from props.
            if (!DoInspectorInfo)
            {
                if (Prefs.DevMode)
                {
                    return(devString);
                }
                return(null);
            }

            CompProperties_Battery p = this.Props;
            string text = devString + '\n' + "PowerBatteryStored".Translate() + ": " + StoredEnergy.ToString("F0") + " / " + MaxStoredEnergy.ToString("F0") + " Wd";

            text += "\n" + "PowerBatteryEfficiency".Translate() + ": " + (p.efficiency * 100f).ToString("F0") + "%";
            if (this.StoredEnergy > 0f)
            {
                text += "\n" + "SelfDischarging".Translate() + ": " + 5f.ToString("F0") + " W";
            }
            return(text + "\n" + GetBaseInspectString());
        }
Ejemplo n.º 3
0
        public override void PostExposeData()
        {
            base.PostExposeData();
            Scribe_Values.Look <float>(ref this.chargeEfficiency, "chargeEfficiency", 0f, false);
            CompProperties_Battery props = this.Props;

            if (StoredEnergy > props.storedEnergyMax)
            {
                SetStoredEnergyPct(1);
            }
        }
Ejemplo n.º 4
0
        static bool Prefix(CompPowerBattery __instance, ref float __result)
        {
            if (__instance is CompGreedyBattery gb)
            {
                if (__instance.parent.IsBrokenDown())
                {
                    __result = 0f;
                    return(false);
                }

                CompProperties_Battery props = __instance.Props;
                __result = (gb.realMax - __instance.StoredEnergy) / props.efficiency;
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        public override string CompInspectStringExtra()
        {
            CompProperties_Battery props = this.Props;
            string text = string.Concat(new string[]
            {
                "PowerBatteryStored".Translate(),
                ": ",
                StoredEnergy.ToString("F0"),
                " / ",
                props.storedEnergyMax.ToString("F0"),
                " Wd"
            });
            string text2 = text;

            text = string.Concat(new string[]
            {
                text2,
                "\n",
                "PowerBatteryEfficiency".Translate(),
                ": ",
                (chargeEfficiency * 100f).ToString("F0"),
                "%"
            });
            if (StoredEnergy > 0f)
            {
                text2 = text;
                text  = string.Concat(new string[]
                {
                    text2,
                    "\n",
                    "SelfDischarging".Translate(),
                    ": ",
                    5f.ToString("F0"),
                    " W"
                });
            }
            if (PowerNet == null)
            {
                return(text + "\n" + "PowerNotConnected".Translate());
            }
            string value  = (this.PowerNet.CurrentEnergyGainRate() / CompPower.WattsToWattDaysPerTick).ToString("F0");
            string value2 = this.PowerNet.CurrentStoredEnergy().ToString("F0");

            return(text + "\n" + "PowerConnectedRateStored".Translate(value, value2));
        }
Ejemplo n.º 6
0
        static public PowerType powerTypeFor(ThingDef def)
        {
            CompProperties_Battery powerBattery = def.GetCompProperties <CompProperties_Battery>();

            if (powerBattery != null)
            {
                return(PowerType.Storage);
            }

            CompProperties_Power power = def.GetCompProperties <CompProperties_Power>();

            if (power != null)
            {
                return(power.basePowerConsumption > 0 ? PowerType.Consumer : PowerType.Producer);
            }

            return(PowerType.None);
        }