public override bool HasBuildingMaterials(MyEntity builder) { if (MySession.Static.CreativeMode || (MySession.Static.IsAdminModeEnabled(Sync.MyId) && builder == MySession.Static.LocalCharacter)) { return(true); } if (builder == null) { return(false); } var inventory = GetBuilderInventory(builder); if (inventory == null) { return(false); } MyInventory shipInventory = null; MyCockpit cockpit = null; long identityId = MySession.Static.LocalPlayerId; if (builder is MyCharacter) {//construction cockpit? cockpit = (builder as MyCharacter).IsUsing as MyCockpit; if (cockpit != null) { shipInventory = cockpit.GetInventory(); identityId = cockpit.ControllerInfo.ControllingIdentityId; } else if ((builder as MyCharacter).ControllerInfo != null) { identityId = (builder as MyCharacter).ControllerInfo.ControllingIdentityId; } else { Debug.Fail("failed to get identityId"); } } bool result = true; foreach (var entry in m_materialList.RequiredMaterials) { result &= inventory.GetItemAmount(entry.Key) >= entry.Value; if (!result && shipInventory != null) { result = shipInventory.GetItemAmount(entry.Key) >= entry.Value; if (!result) { //MyGridConveyorSystem.ItemPullRequest((MySession.Static.ControlledEntity as MyCockpit), shipInventory, MySession.Static.LocalPlayerId, entry.Key, entry.Value); result = MyGridConveyorSystem.ConveyorSystemItemAmount(cockpit, shipInventory, identityId, entry.Key) >= entry.Value; } } if (!result) { break; } } return(result); }
public override void UpdateAfterSimulation100() { base.UpdateAfterSimulation100(); if (Sync.IsServer && IsWorking) { if (m_useConveyorSystem && m_inventory.VolumeFillFactor < 0.6f) { if (HasIce()) { MyGridConveyorSystem.PullAllRequest(this, m_inventory, OwnerId, m_inventory.Constraint); } else { MyGridConveyorSystem.PullAllRequest(this, m_inventory, OwnerId, m_oreConstraint); } } if (m_autoRefill && CanRefill()) { RefillBottles(); } } UpdateEmissivity(); if (MyFakes.ENABLE_OXYGEN_SOUNDS) { UpdateSounds(); } m_isProducing = m_producedSinceLastUpdate; m_producedSinceLastUpdate = false; }
public override void UpdateAfterSimulation100() { base.UpdateAfterSimulation100(); if (!Sync.IsServer) { return; } if (!IsWorking) { if (m_nextGasTransfer != 0f) { ExecuteGasTransfer(); } return; } if (FilledRatio > 0f && UseConveyorSystem && this.GetInventory().VolumeFillFactor < 0.6f) { MyGridConveyorSystem.PullAllRequest(this, this.GetInventory(), OwnerId, this.GetInventory().Constraint); } if (m_autoRefill && CanRefill()) { RefillBottles(); } // this is performance unfriendly // its supposed to be in Sink_CurrentInputChanged, but it dont catch slider change correctly SourceComp.Enabled = CanStore; ExecuteGasTransfer(); }
public override void UpdateAfterSimulation100() { base.UpdateAfterSimulation100(); // Will not consume anything when disabled. int timeDelta = 100 * VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS; if (Enabled && !MySession.Static.CreativeMode) { ProfilerShort.Begin("ConsumeCondition"); if ((Sync.IsServer && IsWorking && !CubeGrid.GridSystems.ControlSystem.IsControlled) || CubeGrid.GridSystems.ControlSystem.IsLocallyControlled) { ProfilerShort.Begin("ConsumeFuel"); ConsumeFuel(timeDelta); ProfilerShort.End(); } ProfilerShort.End(); } if (Sync.IsServer && IsFunctional && m_useConveyorSystem && this.GetInventory().VolumeFillFactor < 0.6f) { float consumptionPerSecond = m_reactorDefinition.MaxPowerOutput / SourceComp.ProductionToCapacityMultiplier; var consumedUranium = (60 * consumptionPerSecond); // Take enough uranium for one minute of operation consumedUranium /= m_reactorDefinition.FuelDefinition.Mass; // Convert weight to number of items ProfilerShort.Begin("PullRequest"); MyGridConveyorSystem.ItemPullRequest(this, this.GetInventory(), OwnerId, m_reactorDefinition.FuelId, (MyFixedPoint)consumedUranium); ProfilerShort.End(); } }
public MyCubeGridSystems(MyCubeGrid grid) { m_cubeGrid = grid; m_terminalSystem_GroupAdded = TerminalSystem_GroupAdded; m_terminalSystem_GroupRemoved = TerminalSystem_GroupRemoved; ThrustSystem = new MyGridThrustSystem(m_cubeGrid); GyroSystem = new MyGridGyroSystem(m_cubeGrid); WeaponSystem = new MyGridWeaponSystem(); ReflectorLightSystem = new MyGridReflectorLightSystem(m_cubeGrid); if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT) { WheelSystem = new MyGridWheelSystem(m_cubeGrid); } ConveyorSystem = new MyGridConveyorSystem(m_cubeGrid); LandingSystem = new MyGridLandingSystem(); ControlSystem = new MyGroupControlSystem(); CameraSystem = new MyGridCameraSystem(m_cubeGrid); if (MySession.Static.Settings.EnableOxygen) { OxygenSystem = new MyGridOxygenSystem(m_cubeGrid); } if (MyPerGameSettings.EnableJumpDrive) { JumpSystem = new MyGridJumpDriveSystem(m_cubeGrid); } m_cubeGrid.SyncObject.PowerProducerStateChanged += SyncObject_PowerProducerStateChanged; m_blocksRegistered = true; }
public override void UpdateAfterSimulation100() { base.UpdateAfterSimulation100(); if (!Sync.IsServer || !IsWorking) { return; } if (FilledRatio > 0f && UseConveyorSystem && m_inventory.VolumeFillFactor < 0.6f) { MyGridConveyorSystem.PullAllRequest(this, m_inventory, OwnerId, m_inventory.Constraint); } if (m_autoRefill && CanRefill()) { RefillBottles(); } int sinkUpdateFrames = (m_updateCounter - m_lastInputUpdateTime); int sourceUpdateFrames = (m_updateCounter - m_lastOutputUpdateTime); float gasInput = GasInputPerUpdate * sinkUpdateFrames; float gasOutput = GasOutputPerUpdate * sourceUpdateFrames; float totalTransfer = gasInput - gasOutput + m_nextGasTransfer; Transfer(totalTransfer); m_updateCounter = 0; m_lastOutputUpdateTime = m_updateCounter; m_lastInputUpdateTime = m_updateCounter; ResourceSink.Update(); }
public override void UpdateAfterSimulation100() { base.UpdateAfterSimulation100(); if (!Sync.IsServer) { return; } if (!IsWorking) { if (m_nextGasTransfer != 0f) { ExecuteGasTransfer(); } return; } if (FilledRatio > 0f && UseConveyorSystem && this.GetInventory().VolumeFillFactor < 0.6f) { MyGridConveyorSystem.PullAllRequest(this, this.GetInventory(), OwnerId, this.GetInventory().Constraint); } if (m_autoRefill && CanRefill()) { RefillBottles(); } ExecuteGasTransfer(); }
public MyCubeGridSystems(MyCubeGrid grid) { m_cubeGrid = grid; m_terminalSystem_GroupAdded = TerminalSystem_GroupAdded; m_terminalSystem_GroupRemoved = TerminalSystem_GroupRemoved; GyroSystem = new MyGridGyroSystem(m_cubeGrid); WeaponSystem = new MyGridWeaponSystem(); ReflectorLightSystem = new MyGridReflectorLightSystem(m_cubeGrid); if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT) { WheelSystem = new MyGridWheelSystem(m_cubeGrid); } ConveyorSystem = new MyGridConveyorSystem(m_cubeGrid); LandingSystem = new MyGridLandingSystem(); ControlSystem = new MyGroupControlSystem(); CameraSystem = new MyGridCameraSystem(m_cubeGrid); if (MySession.Static.Settings.EnableOxygen && MySession.Static.Settings.EnableOxygenPressurization) { GasSystem = new MyGridGasSystem(m_cubeGrid); } if (MyPerGameSettings.EnableJumpDrive) { JumpSystem = new MyGridJumpDriveSystem(m_cubeGrid); } if (MyPerGameSettings.EnableShipSoundSystem && (MyFakes.ENABLE_NEW_SMALL_SHIP_SOUNDS || MyFakes.ENABLE_NEW_LARGE_SHIP_SOUNDS) && MySandboxGame.IsDedicated == false) { ShipSoundComponent = new MyShipSoundComponent(); } m_blocksRegistered = true; }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (Sync.IsServer && IsWorking && m_useConveyorSystem && this.GetInventory().GetItems().Count > 0) { MyGridConveyorSystem.PushAnyRequest(this, this.GetInventory(), OwnerId); } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if ((Sync.IsServer && (base.IsWorking && (this.m_useConveyorSystem != null))) && (this.GetInventory(0).GetItems().Count > 0)) { MyGridConveyorSystem.PushAnyRequest(this, this.GetInventory(0), base.OwnerId); } }
public static void StartRecomputationThreadPrefix(ref MyGridConveyorSystem __instance) { if (!Conveyors.TryGetValue(__instance, out var companion)) { return; } companion.Reachables.Clear(); }
public static void IdleSupply(MyAssembler __instance) { if (!(__instance is MyAssembler assembler)) return; if (assembler.IsQueueEmpty && assembler.HasInventory) { //figure out how to see if assembler is even connected to conveyors cause f**k me if (//assembler.f****e) { try { var group =assembler.CubeGrid.BigOwners; var me =group.First(); MyInventory inventory = assembler.GetInventory(); if ((double) inventory.VolumeFillFactor >= 0.990000009536743) return; MyGridConveyorSystem.PullAllItemsForConnector((IMyConveyorEndpointBlock) assembler, inventory, me, AssemblerSupplyChainPlugin.Instance.MAX_ITEMS_TO_PULL_IN_ONE_TICK); } catch (Exception e) { Log.Fatal("f**k my whole life" + e); } } /*MyInventory inventory = assembler.GetInventory(); if (inventory.GetItemsCount() <= 0) return; var blocks = assembler.CubeGrid.GridSystems.ConveyorSystem. assembler.CubeGrid.GridSystems.ConveyorSystem.PullItems(_inventoryConstraint, MyFixedPoint.MaxValue, blocks, inventory );*/ // this probably just yeets the contents of the assembler //assembler.Components.Remove<MyInventory>(); /*MyGridConveyorSystem.PushAnyRequest((inventory) this, inventory); if (assembler.GetInventory() == null) { MyInventory myInventory = new MyInventory(assembler.InventorySize.Volume, this.m_conveyorSorterDefinition.InventorySize, MyInventoryFlags.CanSend); assembler.Components.Add<MyInventoryBase>((MyInventoryBase) myInventory); myInventory.Init(builderConveyorSorter.Inventory); } var a = assembler.OutputInventory.InventoryId; var i = assembler.ConveyorEndpoint.CubeBlock.InventoryCount; assembler.Components.Clear(); assembler.drainall(); MyConveyorSorter sorter; sorter.DrainAll = true;*/ } return; }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (((Sync.IsServer && (this.DrainAll && (base.Enabled && base.IsFunctional))) && base.IsWorking) && !this.GetInventory(0).IsFull) { MyFixedPoint?maxAmount = null; MyGridConveyorSystem.PullAllRequest(this, this.GetInventory(0), base.OwnerId, this.m_inventoryConstraint, maxAmount, true); } }
public override void UpdateAfterSimulation100() { base.UpdateAfterSimulation100(); if (Sync.IsServer && IsFunctional && UseConveyorSystem && Inventory.GetItems().Count > 0) { MyGridConveyorSystem.PushAnyRequest(this, Inventory, OwnerId); } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (!Sync.IsServer || !DrainAll || !Enabled || !IsFunctional || !IsWorking || !ResourceSink.IsPoweredByType(MyResourceDistributorComponent.ElectricityId)) return; if (!this.GetInventory().IsFull) { MyGridConveyorSystem.PullAllRequest(this, this.GetInventory(), OwnerId, m_inventoryConstraint); } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (Sync.IsServer && IsFunctional && (this as IMyInventoryOwner).UseConveyorSystem) { if (MySession.Static.SurvivalMode && m_ammoInventory.VolumeFillFactor < 0.5f) { MyGridConveyorSystem.ItemPullRequest(this, m_ammoInventory, OwnerId, m_gunBase.CurrentAmmoMagazineId, 1); } } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (m_useConveyorSystem) { if (MySession.Static.SurvivalMode && Sync.IsServer && IsWorking && this.GetInventory().VolumeFillFactor < 0.5f) { MyGridConveyorSystem.ItemPullRequest(this, this.GetInventory(), OwnerId, m_gunBase.CurrentAmmoMagazineId, 1); } } }
public override void UpdateAfterSimulation100() { ResourceSink.Update(); base.UpdateAfterSimulation100(); m_drillBase.UpdateSoundEmitter(); if (Sync.IsServer && IsFunctional && m_useConveyorSystem && this.GetInventory().GetItems().Count > 0) { MyGridConveyorSystem.PushAnyRequest(this, this.GetInventory(), OwnerId); } }
public override void UpdateAfterSimulation100() { base.UpdateAfterSimulation100(); if (m_rotationSpeed != 0f) { IsCloseEnough(); } if (Sync.IsServer && IsFunctional && UseConveyorSystem && this.GetInventory().GetItems().Count > 0) { MyGridConveyorSystem.PushAnyRequest(this, this.GetInventory(), OwnerId); } }
public void GetCoveyorInventoryOwners() { m_inventoryOwners.Clear(); List <IMyConveyorEndpoint> reachableVertices = new List <IMyConveyorEndpoint>(); MyGridConveyorSystem.FindReachable(this.ConveyorEndpoint, reachableVertices, (vertex) => vertex.CubeBlock != null && FriendlyWithBlock(vertex.CubeBlock) && vertex.CubeBlock.HasInventory); foreach (var vertex in reachableVertices) { m_inventoryOwners.Add(vertex.CubeBlock); } m_inventoryOwnersDirty = false; }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (!Sync.IsServer || !DrainAll || !Enabled || !IsFunctional || !IsWorking || !ResourceSink.IsPowered) { return; } if (!m_inventory.IsFull) { MyGridConveyorSystem.PullAllRequest(this, m_inventory, OwnerId, m_inventoryConstraint); } }
public override void UpdateAfterSimulation100() { base.UpdateAfterSimulation100(); /*if (MyFakes.SHOW_DAMAGE_EFFECTS) * { * if (SlimBlock.ComponentStack.IsFunctional && m_damageEffect != null) * { * m_damageEffect.Stop(); * m_damageEffect = null; * NeedsUpdate &= ~MyEntityUpdateEnum.EACH_FRAME; * } * * if (!SlimBlock.ComponentStack.IsFunctional && m_damageEffect == null) * { * if (MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.Prefab_LeakingSteamWhite, out m_damageEffect)) * { * m_damageEffect.UserScale = 0.2f; * m_damageEffect.WorldMatrix = WorldMatrix; * m_damageEffect.OnDelete += damageEffect_OnDelete; * } * NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME; * } * }*/ // Will not consume anything when disabled. int timeDelta = 100 * MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS; if (Enabled && !MySession.Static.CreativeMode) { ProfilerShort.Begin("ConsumeCondition"); if ((Sync.IsServer && IsWorking && !CubeGrid.GridSystems.ControlSystem.IsControlled) || CubeGrid.GridSystems.ControlSystem.IsLocallyControlled) { ProfilerShort.Begin("ConsumeFuel"); ConsumeFuel(timeDelta); ProfilerShort.End(); } ProfilerShort.End(); } if (Sync.IsServer && IsFunctional && m_useConveyorSystem && m_inventory.VolumeFillFactor < 0.6f) { float consumptionPerSecond = m_reactorDefinition.MaxPowerOutput / (60 * 60); var consumedUranium = (60 * consumptionPerSecond); // Take enough uranium for one minute of operation consumedUranium /= m_reactorDefinition.FuelDefinition.Mass; // Convert weight to number of items ProfilerShort.Begin("PullRequest"); MyGridConveyorSystem.ItemPullRequest(this, m_inventory, OwnerId, m_reactorDefinition.FuelId, (MyFixedPoint)consumedUranium); ProfilerShort.End(); } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if ((Sync.IsServer && base.IsWorking) && (base.m_useConveyorSystem != null)) { if ((base.InputInventory.VolumeFillFactor < 0.6f) && MyGridConveyorSystem.PullAllRequest(this, base.InputInventory, base.OwnerId, base.InputInventory.Constraint, this.m_refineryDef.OreAmountPerPullRequest, true)) { this.m_queueNeedsRebuild = true; } if (base.OutputInventory.VolumeFillFactor > 0.75f) { MyGridConveyorSystem.PushAnyRequest(this, base.OutputInventory, base.OwnerId); } } }
public override void UpdateBeforeSimulation100() { base.UpdateBeforeSimulation100(); if (Sync.IsServer && IsWorking && m_useConveyorSystem) { if (InputInventory.VolumeFillFactor < 0.6f) { MyGridConveyorSystem.PullAllRequest(this, InputInventory, OwnerId, InputInventory.Constraint); } if (OutputInventory.VolumeFillFactor > 0.75f) { Debug.Assert(OutputInventory.GetItems().Count > 0); MyGridConveyorSystem.PushAnyRequest(this, OutputInventory, OwnerId); } } }
public override void UpdateBeforeSimulation10() { base.UpdateBeforeSimulation10(); if ((Sync.IsServer && (this.DrainAll && (base.Enabled && base.IsFunctional))) && base.IsWorking) { this.m_pushRequestFrameCounter++; if (this.m_pushRequestFrameCounter >= 4) { this.m_pushRequestFrameCounter = 0; if (this.GetInventory(0).GetItems().Count > 0) { MyGridConveyorSystem.PushAnyRequest(this, this.GetInventory(0), base.OwnerId); } } } }
public override void UpdateAfterSimulation() { base.UpdateAfterSimulation(); if (Sync.IsServer) { if ((this.FilledRatio > 0.0) && this.UseConveyorSystem) { MyInventory destinationInventory = this.GetInventory(0); if (destinationInventory.VolumeFillFactor < 0.6f) { MyFixedPoint?maxAmount = null; MyGridConveyorSystem.PullAllRequest(this, destinationInventory, base.OwnerId, destinationInventory.Constraint, maxAmount, true); } } this.ExecuteGasTransfer(); } }
public override void UpdateBeforeSimulation10() { base.UpdateBeforeSimulation10(); if (!Sync.IsServer || !DrainAll || !Enabled || !IsFunctional || !IsWorking || !ResourceSink.IsPoweredByType(MyResourceDistributorComponent.ElectricityId)) return; m_pushRequestFrameCounter++; if (m_pushRequestFrameCounter >= 4) { m_pushRequestFrameCounter = 0; if (this.GetInventory().GetItems().Count > 0) { MyGridConveyorSystem.PushAnyRequest(this, this.GetInventory(), OwnerId); } } }
public override void UpdateAfterSimulation100() { base.UpdateAfterSimulation100(); if (Sync.IsServer && IsWorking) { if (FilledRatio > 0f && m_useConveyorSystem && m_inventory.VolumeFillFactor < 0.6f) { MyGridConveyorSystem.PullAllRequest(this, m_inventory, OwnerId, m_inventory.Constraint); } if (m_autoRefill && CanRefill()) { RefillBottles(); } } }
public override void UpdateAfterSimulation100() { if (Sync.IsServer && base.IsWorking) { if ((this.m_useConveyorSystem != null) && (this.GetInventory(0).VolumeFillFactor < 0.6f)) { MyFixedPoint?maxAmount = null; MyGridConveyorSystem.PullAllRequest(this, this.GetInventory(0), base.OwnerId, this.HasIce() ? this.GetInventory(0).Constraint : this.m_oreConstraint, maxAmount, false); } if (this.AutoRefill && this.CanRefill()) { this.RefillBottles(); } } this.m_isProducing = true; base.NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME; }
public override void UpdateAfterSimulation10() { base.UpdateAfterSimulation10(); if (MySession.Static.SurvivalMode && Sync.IsServer && IsWorking && m_useConveyorSystem && m_ammoInventory.VolumeFillFactor < 0.6f) { var definition = m_gunBase.CurrentAmmoMagazineDefinition; //MyDefinitionManager.Static.GetPhysicalItemDefinition(m_currentAmmoMagazineId); if (definition != null) { var maxNum = MyFixedPoint.Floor((m_ammoInventory.MaxVolume - m_ammoInventory.CurrentVolume) * (1.0f / definition.Volume)); if (maxNum == 0) { return; } MyGridConveyorSystem.ItemPullRequest(this, m_ammoInventory, OwnerId, m_gunBase.CurrentAmmoMagazineId, maxNum); } } }