public void AddResourceSourceComponent() { MyResourceSourceComponent source = new MyResourceSourceComponent(); MyResourceSourceInfo info = new MyResourceSourceInfo(); info.ResourceTypeId = defId; info.DefinedOutput = maxOutput; source.Init(MyStringHash.GetOrCompute("Battery"), info); source.Enabled = true; source.SetMaxOutput(maxOutput); cockpit.Components.Add(source); }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (CubeGrid.Physics == null) { return; } float maxPowerOutput = SolarComponent.MaxOutput * SolarPanelDefinition.MaxPowerOutput; SourceComp.SetMaxOutput(maxPowerOutput); SourceComp.SetProductionEnabledByType(MyResourceDistributorComponent.ElectricityId, maxPowerOutput > 0f); UpdateDisplay(); RaisePropertiesChanged(); }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); m_soundEmitter.Update(); if (CubeGrid.Physics == null) { return; } float maxPowerOutput = SolarComponent.MaxOutput * SolarPanelDefinition.MaxPowerOutput; if (maxPowerOutput != SourceComp.MaxOutput) { float oldPowerOutput = SourceComp.MaxOutput; SourceComp.SetMaxOutput(maxPowerOutput); if (oldPowerOutput != maxPowerOutput) { SourceComp.SetProductionEnabledByType(MyResourceDistributorComponent.ElectricityId, maxPowerOutput != 0f); UpdateDisplay(); } } }
private void UpdateMaxOutputAndEmissivity() { SourceComp.SetMaxOutput(ComputeMaxPowerOutput()); UpdateEmissivity(); }