public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { SyncFlag = true; base.Init(objectBuilder, cubeGrid); var builder = (MyObjectBuilder_AirVent)objectBuilder; InitializeConveyorEndpoint(); NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; SourceComp.Init(BlockDefinition.ResourceSourceGroup, new MyResourceSourceInfo { ResourceTypeId = m_oxygenGasId, DefinedOutput = BlockDefinition.VentilationCapacityPerSecond, ProductionToCapacityMultiplier = 1 }); SourceComp.OutputChanged += Source_OutputChanged; var sinkDataList = new List <MyResourceSinkInfo> { new MyResourceSinkInfo { ResourceTypeId = MyResourceDistributorComponent.ElectricityId, MaxRequiredInput = BlockDefinition.OperationalPowerConsumption, RequiredInputFunc = ComputeRequiredPower }, new MyResourceSinkInfo { ResourceTypeId = m_oxygenGasId, MaxRequiredInput = BlockDefinition.VentilationCapacityPerSecond, RequiredInputFunc = () => VentingCapacity(1f) }, }; ResourceSink.Init( BlockDefinition.ResourceSinkGroup, sinkDataList); ResourceSink.IsPoweredChanged += PowerReceiver_IsPoweredChanged; ResourceSink.CurrentInputChanged += Sink_CurrentInputChanged; m_updateCounter = 0; m_lastOutputUpdateTime = m_updateCounter; m_lastInputUpdateTime = m_updateCounter; m_nextGasTransfer = 0f; m_actionToolbar = new MyToolbar(MyToolbarType.ButtonPanel, 2, 1); m_actionToolbar.DrawNumbers = false; m_actionToolbar.Init(null, this); if (builder.OnFullAction != null) { m_onFullAction = MyToolbarItemFactory.CreateToolbarItem(builder.OnFullAction); } if (builder.OnEmptyAction != null) { m_onEmptyAction = MyToolbarItemFactory.CreateToolbarItem(builder.OnEmptyAction); } UpdateEmissivity(); UdpateTexts(); AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint)); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; IsWorkingChanged += MyAirVent_IsWorkingChanged; SetDepressurizing(builder.IsDepressurizing); }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); SyncObject = new MySyncBatteryBlock(this); MyDebug.AssertDebug(BlockDefinition.Id.TypeId == typeof(MyObjectBuilder_BatteryBlock)); m_batteryBlockDefinition = BlockDefinition as MyBatteryBlockDefinition; MyDebug.AssertDebug(m_batteryBlockDefinition != null); var sourceDataList = new List <MyResourceSourceInfo> { new MyResourceSourceInfo { ResourceTypeId = MyResourceDistributorComponent.ElectricityId, DefinedOutput = m_batteryBlockDefinition.MaxPowerOutput, ProductionToCapacityMultiplier = 60 * 60 } }; SourceComp.Init(m_batteryBlockDefinition.ResourceSourceGroup, sourceDataList); SourceComp.HasCapacityRemainingChanged += (id, source) => UpdateIsWorking(); MaxStoredPower = m_batteryBlockDefinition.MaxStoredPower; ResourceSink.Init( m_batteryBlockDefinition.ResourceSinkGroup, m_batteryBlockDefinition.RequiredPowerInput, () => (Enabled && IsFunctional && !SourceComp.ProductionEnabled && !m_isFull) ? ResourceSink.MaxRequiredInput : 0.0f); ResourceSink.Update(); var obGenerator = (MyObjectBuilder_BatteryBlock)objectBuilder; CurrentStoredPower = obGenerator.CurrentStoredPower; SourceComp.SetProductionEnabledByType(MyResourceDistributorComponent.ElectricityId, obGenerator.ProducerEnabled); SemiautoEnabled = obGenerator.SemiautoEnabled; UpdateMaxOutputAndEmissivity(); UpdateText(); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; this.IsWorkingChanged += MyBatteryBlock_IsWorkingChanged; NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; if (IsWorking) { OnStartWorking(); } }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); IsWorkingChanged += OnIsWorkingChanged; NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; InitializeConveyorEndpoint(); SourceComp.Init( BlockDefinition.ResourceSourceGroup, new MyResourceSourceInfo { ResourceTypeId = BlockDefinition.ProducedGas, DefinedOutput = BlockDefinition.MaxGasOutput, ProductionToCapacityMultiplier = 1, IsInfiniteCapacity = true, }); SourceComp.Enabled = IsWorking; ResourceSink.Init( BlockDefinition.ResourceSinkGroup, new MyResourceSinkInfo { ResourceTypeId = MyResourceDistributorComponent.ElectricityId, MaxRequiredInput = BlockDefinition.OperationalPowerConsumption, RequiredInputFunc = ComputeRequiredPower, }); ResourceSink.IsPoweredChanged += PowerReceiver_IsPoweredChanged; ResourceSink.Update(); GameLogic = new MySolarGameLogicComponent(); SolarComponent = GameLogic as MySolarGameLogicComponent; SolarComponent.Initialize(BlockDefinition.PanelOrientation, BlockDefinition.IsTwoSided, BlockDefinition.PanelOffset, this); AddDebugRenderComponent(new MyDebugRenderComponentSolarPanel(this)); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_OnIsFunctionalChanged; UpdateVisual(); UpdateDisplay(); }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { var sourceDataList = new List <MyResourceSourceInfo> { new MyResourceSourceInfo { ResourceTypeId = MyResourceDistributorComponent.ElectricityId, DefinedOutput = BlockDefinition.MaxPowerOutput, ProductionToCapacityMultiplier = 60 * 60 } }; SourceComp.Init(BlockDefinition.ResourceSourceGroup, sourceDataList); SourceComp.HasCapacityRemainingChanged += (id, source) => UpdateIsWorking(); SourceComp.ProductionEnabledChanged += Source_ProductionEnabledChanged; var batteryBuilder = (MyObjectBuilder_BatteryBlock)objectBuilder; SourceComp.SetProductionEnabledByType(MyResourceDistributorComponent.ElectricityId, batteryBuilder.ProducerEnabled); MaxStoredPower = BlockDefinition.MaxStoredPower; ResourceSink.Init( BlockDefinition.ResourceSinkGroup, BlockDefinition.RequiredPowerInput, Sink_ComputeRequiredPower); base.Init(objectBuilder, cubeGrid); ResourceSink.Update(); MyDebug.AssertDebug(BlockDefinition != null); MyDebug.AssertDebug(BlockDefinition.Id.TypeId == typeof(MyObjectBuilder_BatteryBlock)); if (batteryBuilder.CurrentStoredPower >= 0) { CurrentStoredPower = batteryBuilder.CurrentStoredPower; } else { CurrentStoredPower = BlockDefinition.InitialStoredPowerRatio * BlockDefinition.MaxStoredPower; } m_storedPower.Value = CurrentStoredPower; SemiautoEnabled = batteryBuilder.SemiautoEnabled; OnlyRecharge = !batteryBuilder.ProducerEnabled; OnlyDischarge = batteryBuilder.OnlyDischargeEnabled; UpdateMaxOutputAndEmissivity(); UpdateText(); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; IsWorkingChanged += MyBatteryBlock_IsWorkingChanged; NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; m_lastUpdateTime = MySession.Static.GameplayFrameCounter; if (IsWorking) { OnStartWorking(); } }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { SyncFlag = true; var sourceDataList = new List <MyResourceSourceInfo>(); foreach (var producedInfo in BlockDefinition.ProducedGases) { sourceDataList.Add(new MyResourceSourceInfo { ResourceTypeId = producedInfo.Id, DefinedOutput = BlockDefinition.IceConsumptionPerSecond * producedInfo.IceToGasRatio * (MySession.Static.CreativeMode ? 10f : 1f), ProductionToCapacityMultiplier = 1 }); } SourceComp.Init(BlockDefinition.ResourceSourceGroup, sourceDataList); base.Init(objectBuilder, cubeGrid); var generatorBuilder = objectBuilder as MyObjectBuilder_OxygenGenerator; InitializeConveyorEndpoint(); m_useConveyorSystem.Value = generatorBuilder.UseConveyorSystem; NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; if (this.GetInventory() == null) // can be already initialized as deserialized component { MyInventory inventory = new MyInventory(BlockDefinition.InventoryMaxVolume, BlockDefinition.InventorySize, MyInventoryFlags.CanReceive); inventory.Constraint = BlockDefinition.InputInventoryConstraint; Components.Add <MyInventoryBase>(inventory); } else { this.GetInventory().Constraint = BlockDefinition.InputInventoryConstraint; } Debug.Assert(this.GetInventory().Owner == this, "Ownership was not set!"); m_oreConstraint = new MyInventoryConstraint(this.GetInventory().Constraint.Description, this.GetInventory().Constraint.Icon, this.GetInventory().Constraint.IsWhitelist); foreach (var id in this.GetInventory().Constraint.ConstrainedIds) { if (id.TypeId != typeof(MyObjectBuilder_GasContainerObject)) { m_oreConstraint.Add(id); } } if (MyFakes.ENABLE_INVENTORY_FIX) { FixSingleInventory(); } if (this.GetInventory() != null) { this.GetInventory().Init(generatorBuilder.Inventory); } else { Debug.Fail("Trying to init inventory, but it's null!"); } AutoRefill = generatorBuilder.AutoRefill; SourceComp.Enabled = Enabled; if (Sync.IsServer) { SourceComp.OutputChanged += Source_OutputChanged; } float iceAmount = IceAmount(); foreach (var gasId in SourceComp.ResourceTypes) { var tmpGasId = gasId; m_sourceComp.SetRemainingCapacityByType(gasId, IceToGas(ref tmpGasId, iceAmount)); } m_lastSourceUpdate = MySession.Static.GameplayFrameCounter; ResourceSink.Init(BlockDefinition.ResourceSinkGroup, new MyResourceSinkInfo { ResourceTypeId = MyResourceDistributorComponent.ElectricityId, MaxRequiredInput = BlockDefinition.OperationalPowerConsumption, RequiredInputFunc = ComputeRequiredPower }); ResourceSink.IsPoweredChanged += PowerReceiver_IsPoweredChanged; ResourceSink.Update(); UpdateEmissivity(); UpdateText(); AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint)); m_useConveyorSystem.Value = generatorBuilder.UseConveyorSystem; SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; IsWorkingChanged += MyGasGenerator_IsWorkingChanged; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { SyncFlag = true; base.Init(objectBuilder, cubeGrid); var builder = (MyObjectBuilder_OxygenTank)objectBuilder; IsStockpiling = builder.IsStockpiling; InitializeConveyorEndpoint(); NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; m_inventory = new MyInventory( BlockDefinition.InventoryMaxVolume, BlockDefinition.InventorySize, MyInventoryFlags.CanReceive, this) { Constraint = BlockDefinition.InputInventoryConstraint }; m_inventory.Init(builder.Inventory); m_inventory.ContentsChanged += m_inventory_ContentsChanged; m_autoRefill = builder.AutoRefill; var sourceDataList = new List <MyResourceSourceInfo> { new MyResourceSourceInfo { ResourceTypeId = BlockDefinition.StoredGasId, DefinedOutput = 0.05f * BlockDefinition.Capacity }, }; SourceComp.Init(BlockDefinition.ResourceSourceGroup, sourceDataList); SourceComp.OutputChanged += Source_OutputChanged; var sinkDataList = new List <MyResourceSinkInfo> { new MyResourceSinkInfo { ResourceTypeId = MyResourceDistributorComponent.ElectricityId, MaxRequiredInput = BlockDefinition.OperationalPowerConsumption, RequiredInputFunc = ComputeRequiredPower }, new MyResourceSinkInfo { ResourceTypeId = BlockDefinition.StoredGasId, MaxRequiredInput = Capacity, RequiredInputFunc = ComputeRequiredGas }, }; ResourceSink.Init( BlockDefinition.ResourceSinkGroup, sinkDataList); ResourceSink.IsPoweredChanged += PowerReceiver_IsPoweredChanged; ResourceSink.CurrentInputChanged += Sink_CurrentInputChanged; m_lastOutputUpdateTime = m_updateCounter; m_lastInputUpdateTime = m_updateCounter; m_nextGasTransfer = 0f; ChangeFilledRatio(builder.FilledRatio); ResourceSink.Update(); AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint)); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; IsWorkingChanged += MyOxygenTank_IsWorkingChanged; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); PostBaseInit(); //MyDebug.AssertDebug(objectBuilder.TypeId == typeof(MyObjectBuilder_Cockpit)); var def = MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId()); m_isLargeCockpit = (def.CubeSize == MyCubeSize.Large); m_cockpitInteriorModel = BlockDefinition.InteriorModel; m_cockpitGlassModel = BlockDefinition.GlassModel; MyObjectBuilder_Cockpit cockpitOb = (MyObjectBuilder_Cockpit)objectBuilder; if (cockpitOb.Pilot != null) { MyEntity pilotEntity; MyCharacter pilot = null; if (MyEntities.TryGetEntityById(cockpitOb.Pilot.EntityId, out pilotEntity)) { //Pilot already exists, can be the case after cube grid split pilot = (MyCharacter)pilotEntity; if (pilot.IsUsing is MyShipController && pilot.IsUsing != this) { Debug.Assert(false, "Pilot already sits on another place!"); pilot = null; } } else { pilot = (MyCharacter)MyEntities.CreateFromObjectBuilder(cockpitOb.Pilot); } if (pilot != null) { AttachPilot(pilot, storeOriginalPilotWorld: false, calledFromInit: true); if (cockpitOb.PilotRelativeWorld.HasValue) { m_pilotRelativeWorld = cockpitOb.PilotRelativeWorld.Value.GetMatrix(); } else { m_pilotRelativeWorld = null; } m_singleWeaponMode = cockpitOb.UseSingleWeaponMode; } IsInFirstPersonView = cockpitOb.IsInFirstPersonView; } if (cockpitOb.Autopilot != null) { MyAutopilotBase autopilot = MyAutopilotFactory.CreateAutopilot(cockpitOb.Autopilot); autopilot.Init(cockpitOb.Autopilot); AttachAutopilot(autopilot, updateSync: false); } m_pilotGunDefinition = cockpitOb.PilotGunDefinition; // backward compatibility check for automatic rifle without subtype if (m_pilotGunDefinition.HasValue) { if (m_pilotGunDefinition.Value.TypeId == typeof(MyObjectBuilder_AutomaticRifle) && string.IsNullOrEmpty(m_pilotGunDefinition.Value.SubtypeName)) { m_pilotGunDefinition = new MyDefinitionId(typeof(MyObjectBuilder_AutomaticRifle), "RifleGun"); } } if (!string.IsNullOrEmpty(m_cockpitInteriorModel)) { if (MyModels.GetModelOnlyDummies(m_cockpitInteriorModel).Dummies.ContainsKey("head")) { m_headLocalPosition = MyModels.GetModelOnlyDummies(m_cockpitInteriorModel).Dummies["head"].Matrix.Translation; } } else { if (MyModels.GetModelOnlyDummies(BlockDefinition.Model).Dummies.ContainsKey("head")) { m_headLocalPosition = MyModels.GetModelOnlyDummies(BlockDefinition.Model).Dummies["head"].Matrix.Translation; } } AddDebugRenderComponent(new Components.MyDebugRenderComponentCockpit(this)); InitializeConveyorEndpoint(); AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint)); OxygenFillLevel = cockpitOb.OxygenLevel; ResourceSink.Init(MyStringHash.GetOrCompute("Utility"), new MyResourceSinkInfo { ResourceTypeId = MyCharacterOxygenComponent.OxygenId, MaxRequiredInput = BlockDefinition.OxygenCapacity, RequiredInputFunc = ComputeRequiredGas, }); ResourceSink.CurrentInputChanged += Sink_CurrentInputChanged; m_lastGasInputUpdateTick = MySession.Static.ElapsedGameTime.Ticks; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { SyncFlag = true; base.Init(objectBuilder, cubeGrid); var builder = (MyObjectBuilder_OxygenTank)objectBuilder; IsStockpiling = builder.IsStockpiling; InitializeConveyorEndpoint(); NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; if (MyFakes.ENABLE_INVENTORY_FIX) { FixSingleInventory(); if (this.GetInventory() != null) { this.GetInventory().Constraint = BlockDefinition.InputInventoryConstraint; } } if (this.GetInventory() == null) { MyInventory inventory = new MyInventory(BlockDefinition.InventoryMaxVolume, BlockDefinition.InventorySize, MyInventoryFlags.CanReceive); inventory.Constraint = BlockDefinition.InputInventoryConstraint; Components.Add <MyInventoryBase>(inventory); inventory.Init(builder.Inventory); } Debug.Assert(this.GetInventory().Owner == this, "Ownership was not set!"); m_autoRefill = builder.AutoRefill; var sourceDataList = new List <MyResourceSourceInfo> { new MyResourceSourceInfo { ResourceTypeId = BlockDefinition.StoredGasId, DefinedOutput = 0.05f * BlockDefinition.Capacity }, }; SourceComp.Init(BlockDefinition.ResourceSourceGroup, sourceDataList); SourceComp.OutputChanged += Source_OutputChanged; SourceComp.Enabled = Enabled; var sinkDataList = new List <MyResourceSinkInfo> { new MyResourceSinkInfo { ResourceTypeId = MyResourceDistributorComponent.ElectricityId, MaxRequiredInput = BlockDefinition.OperationalPowerConsumption, RequiredInputFunc = ComputeRequiredPower }, new MyResourceSinkInfo { ResourceTypeId = BlockDefinition.StoredGasId, MaxRequiredInput = Capacity, RequiredInputFunc = ComputeRequiredGas }, }; ResourceSink.Init( BlockDefinition.ResourceSinkGroup, sinkDataList); ResourceSink.IsPoweredChanged += PowerReceiver_IsPoweredChanged; ResourceSink.CurrentInputChanged += Sink_CurrentInputChanged; m_lastOutputUpdateTime = MySession.Static.GameplayFrameCounter; m_lastInputUpdateTime = MySession.Static.GameplayFrameCounter; m_nextGasTransfer = 0f; ChangeFilledRatio(builder.FilledRatio); ResourceSink.Update(); AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint)); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; IsWorkingChanged += MyOxygenTank_IsWorkingChanged; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { SyncFlag = true; base.Init(objectBuilder, cubeGrid); var generatorBuilder = objectBuilder as MyObjectBuilder_OxygenGenerator; InitializeConveyorEndpoint(); m_useConveyorSystem = generatorBuilder.UseConveyorSystem; NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; m_inventory = new MyInventory( BlockDefinition.InventoryMaxVolume, BlockDefinition.InventorySize, MyInventoryFlags.CanReceive, this) { Constraint = BlockDefinition.InputInventoryConstraint }; m_oreConstraint = new MyInventoryConstraint(m_inventory.Constraint.Description, m_inventory.Constraint.Icon, m_inventory.Constraint.IsWhitelist); foreach (var id in m_inventory.Constraint.ConstrainedIds) { if (id.TypeId != typeof(MyObjectBuilder_GasContainerObject)) { m_oreConstraint.Add(id); } } m_inventory.Init(generatorBuilder.Inventory); m_inventory.ContentsChanged += Inventory_ContentsChanged; AutoRefill = generatorBuilder.AutoRefill; var sourceDataList = new List <MyResourceSourceInfo>(); foreach (var producedInfo in BlockDefinition.ProducedGases) { sourceDataList.Add(new MyResourceSourceInfo { ResourceTypeId = producedInfo.Id, DefinedOutput = BlockDefinition.IceConsumptionPerSecond * producedInfo.IceToGasRatio, ProductionToCapacityMultiplier = 1 }); } SourceComp.Init(BlockDefinition.ResourceSourceGroup, sourceDataList); if (Sync.IsServer) { SourceComp.OutputChanged += Source_OutputChanged; } float iceAmount = IceAmount(); foreach (var gasId in SourceComp.ResourceTypes) { m_sourceComp.SetRemainingCapacityByType(gasId, IceToGas(gasId, iceAmount)); } m_updateCounter = 0; m_lastSourceUpdate = m_updateCounter; ResourceSink.Init(BlockDefinition.ResourceSinkGroup, new MyResourceSinkInfo { ResourceTypeId = MyResourceDistributorComponent.ElectricityId, MaxRequiredInput = BlockDefinition.OperationalPowerConsumption, RequiredInputFunc = ComputeRequiredPower }); ResourceSink.IsPoweredChanged += PowerReceiver_IsPoweredChanged; ResourceSink.Update(); UpdateEmissivity(); UpdateText(); AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint)); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; IsWorkingChanged += MyGasGenerator_IsWorkingChanged; }
public void Init(MyObjectBuilder_Battery builder, List <MyResourceSinkInfo> additionalSinks = null, List <MyResourceSourceInfo> additionalSources = null) { var defaultSinkInfo = new MyResourceSinkInfo { MaxRequiredInput = MyEnergyConstants.BATTERY_MAX_POWER_INPUT, ResourceTypeId = MyResourceDistributorComponent.ElectricityId, RequiredInputFunc = () => (ResourceSource.RemainingCapacity < MyEnergyConstants.BATTERY_MAX_CAPACITY) ? MyEnergyConstants.BATTERY_MAX_POWER_INPUT : 0f, }; if (additionalSinks != null) { additionalSinks.Insert(0, defaultSinkInfo); ResourceSink.Init(m_resourceSinkGroup, additionalSinks); } else { ResourceSink.Init(m_resourceSinkGroup, defaultSinkInfo); } ResourceSink.TemporaryConnectedEntity = m_owner; var defaultSourceInfo = new MyResourceSourceInfo { ResourceTypeId = MyResourceDistributorComponent.ElectricityId, DefinedOutput = MyEnergyConstants.BATTERY_MAX_POWER_OUTPUT, // TODO: Load max output from definitions ProductionToCapacityMultiplier = 60 * 60 }; if (additionalSources != null) { additionalSources.Insert(0, defaultSourceInfo); ResourceSource.Init(m_resourceSourceGroup, additionalSources); } else { ResourceSource.Init(m_resourceSourceGroup, defaultSourceInfo); } ResourceSource.TemporaryConnectedEntity = m_owner; m_lastUpdateTime = MySession.Static.GameplayFrameCounter; if (builder == null) { ResourceSource.SetProductionEnabledByType(MyResourceDistributorComponent.ElectricityId, true); ResourceSource.SetRemainingCapacityByType(MyResourceDistributorComponent.ElectricityId, MyEnergyConstants.BATTERY_MAX_CAPACITY); ResourceSink.Update(); return; } ResourceSource.SetProductionEnabledByType(MyResourceDistributorComponent.ElectricityId, builder.ProducerEnabled); if (MySession.Static.SurvivalMode) { ResourceSource.SetRemainingCapacityByType(MyResourceDistributorComponent.ElectricityId, MathHelper.Clamp(builder.CurrentCapacity, 0f, MyEnergyConstants.BATTERY_MAX_CAPACITY)); } else { ResourceSource.SetRemainingCapacityByType(MyResourceDistributorComponent.ElectricityId, MyEnergyConstants.BATTERY_MAX_CAPACITY); } ResourceSink.Update(); }