private IPowerConsumer[] GetConsumers(Wire initialWire, List <Wire> wires) { List <Wire> connectedWires = initialWire.GetConnectedWires(); connectedWires.Remove(initialWire); List <IPowerConsumer> result = new List <IPowerConsumer>(); wires.Add(initialWire); foreach (var connectedWire in connectedWires) { if (wires.Contains(connectedWire)) { continue; } wires.Add(connectedWire); IPowerConsumer[] consumers = GetConsumers(connectedWire, wires); result.AddRange(consumers); } List <IPowerSpreader> connectors = initialWire.GetConnectors(); foreach (var connector in connectors) { IPowerConsumer connectedDevice = connector.GetConnectedDevice(); if (connectedDevice != null) { result.Add(connectedDevice); } } return(result.ToArray()); }
private void RenderConsumer(Listing_Standard list, IPowerConsumer consumer) { var section = list.BeginSection(ConsumerHeight); DrawIcon(section, 32); DrawLabel(section, consumer); if (!consumer.Essential && SelPawn.Faction == Faction.OfPlayer) { var enableWhileDrafted = consumer.EnableWhileDrafted; var enableWhileNotDrafted = consumer.EnabledWhileNotDrafted; var enableInCombat = consumer.EnabledInCombat; var enableOutOfCombat = consumer.EnabledOutOfCombat; section.CheckboxLabeled("Cyberization.ITab.Power.WhileDrafted".Translate(), ref enableWhileDrafted); section.CheckboxLabeled("Cyberization.ITab.Power.WhileNotDrafted".Translate(), ref enableWhileNotDrafted); section.CheckboxLabeled("Cyberization.ITab.Power.InCombat".Translate(), ref enableInCombat); section.CheckboxLabeled("Cyberization.ITab.Power.OutOfCombat".Translate(), ref enableOutOfCombat); consumer.EnableWhileDrafted = enableWhileDrafted; consumer.EnabledWhileNotDrafted = enableWhileNotDrafted; consumer.EnabledInCombat = enableInCombat; consumer.EnabledOutOfCombat = enableOutOfCombat; } else { section.Label("Cyberization.ITab.Power.CantDisable".Translate()); } DrawPowerSlider(section, consumer); list.EndSection(section); list.Gap(); }
private static int GetSorting(IPowerConsumer consumer) { var ordering = consumer.Tags .Select(tag => PartOrdering.FirstIndexOf(a => a == tag)) .ToList(); return((!ordering.NullOrEmpty() ? ordering.First() : 100) * consumer.Priority); }
public override void ExposeData() { base.ExposeData(); if (Scribe.mode == LoadSaveMode.PostLoadInit) { _consumer = comps.OfType <IPowerConsumer>().First(); } }
private void SendPowerTo(IPowerConsumer consumer, float amount) { if (_powerStored >= amount) { consumer.SendPower(amount); _powerStored -= amount; } }
public static void TurnOnPower(this IPowerConsumer consumer) { UnityEngine.Debug.Log("turning on consumer"); if (!consumer.HasPower) { consumer.HasPower = true; consumer.RefreshVisualization(); consumer.OnPowerChanged(); } }
public static void RefreshVisualization(this IPowerConsumer c) { if (c is IVariablePowerConsumer) { (c as IVariablePowerConsumer).RefreshVisualization(); } else if (c.PowerViz.PowerActive != null) { c.PowerViz.PowerActive.gameObject.SetActive((!(c.FaultedPercentage > 0f)) && c.IsOn); } }
public static void EmergencyShutdown(this IPowerConsumer c) { if (c.HasPower) { c.HasPower = false; c.OnPowerChanged(); } if (c.IsOn) { c.IsOn = false; c.OnEmergencyShutdown(); } c.RefreshVisualization(); }
/// <summary> /// Event called when a new module is mounted at a module mount. /// </summary> /// <param name="moduleMount"></param> protected override void OnModuleMounted(Module module) { PowerPlant newPowerPlant = module == null ? null : module.transform.GetComponent <PowerPlant>(); if (newPowerPlant != null) { mountedPowerPlant = newPowerPlant; hasPowerPlant = true; } IPowerConsumer powerConsumer = module.GetComponent <IPowerConsumer>(); if (powerConsumer != null) { powerConsumer.Power = this; } }
/// <summary> /// Event called when a new module is mounted at a module mount. /// </summary> /// <param name="moduleMount"></param> protected override void OnModuleMounted(Module module) { PowerPlant newPowerPlant = module == null ? null : module.transform.GetComponent <PowerPlant>(); if (newPowerPlant != null) { powerPlant = newPowerPlant; if (fillStorageOnPowerPlantLoaded) { for (int i = 0; i < poweredSubsystems.Count; ++i) { poweredSubsystems[i].currentStorageValue = poweredSubsystems[i].storageCapacity; } } } IPowerConsumer powerConsumer = module.GetComponent <IPowerConsumer>(); if (powerConsumer != null) { powerConsumer.Power = this; } }
public static int ConsumptionInPowerUnits(this IPowerConsumer c) { return(Math.Max(1, Mathf.RoundToInt(c.WattsConsumed / ElectricityConstants.WattsPerBlock))); }
public override void PostMake() { base.PostMake(); _consumer = comps.OfType <IPowerConsumer>().First(); }
public void Add(IPowerConsumer powerConsumer) { }
private static void DrawPowerSlider(Listing_Standard section, IPowerConsumer consumer) { consumer.RateWanted = Mathf.RoundToInt(section.Slider(Mathf.RoundToInt(consumer.RateWanted), consumer.MinRate, consumer.MaxRate)); section.Gap(); }