public void Load() { try { if (MyAPIGateway.Multiplayer.MultiplayerActive && !MyAPIGateway.Multiplayer.IsServer) { SyncHarvestEfficiency.Ask(); return; } string Storage = ""; //if (Tool.Storage.ContainsKey(SessionCore.StorageGuid)) if (Drill.Storage?.TryGetValue(SessionCore.StorageGuid, out Storage) == true) { try { Persistent persistent = MyAPIGateway.Utilities.SerializeFromBinary <Persistent>(Convert.FromBase64String(Storage)); SyncHarvestEfficiency.Set(persistent.HarvestMultiplier); } catch (Exception Scrap) { SessionCore.LogError($"{Drill.CustomName}.Load()", Scrap); } } else { SessionCore.DebugWrite($"{Drill.CustomName}.Load()", "Storage access failed."); } } catch (Exception Scrap) { SessionCore.LogError($"{Drill.CustomName}.Load().AccessStorage", Scrap); } }
public override void Close() { try { if (SessionCore.Settings.Debug) { DebugNote.Hide(); DebugNote.AliveTime = 0; DebugNote = null; } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Close().DebugClose", Scrap); } try { HUDModule.Close(); PersistenceModule.Close(); TermModule.Close(); GridInventoryModule.RemoveWatcher(Tool); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Close()", Scrap); } }
public static Dictionary <string, int> CalculateMissingComponents(this IMyCubeGrid Grid) { if (Grid == null) { return(new Dictionary <string, int>()); } try { Dictionary <string, int> MissingComponents = new Dictionary <string, int>(); List <IMySlimBlock> Blocks = new List <IMySlimBlock>(); Grid.GetBlocks(Blocks); foreach (IMySlimBlock Block in Blocks) { try { Block.ReadMissingComponents(MissingComponents); } catch (Exception Scrap) { SessionCore.LogError($"CalculateMissing[{Grid.CustomName}].Iterate", Scrap, DebugPrefix: "LaserWelders."); } } return(MissingComponents); } catch (Exception Scrap) { SessionCore.LogError($"CalculateMissing[{Grid.CustomName}]", Scrap, DebugPrefix: "LaserWelders."); return(new Dictionary <string, int>()); } }
public override void Close() { try { if (SessionCore.Settings.Debug) { DebugNote.Hide(); DebugNote.AliveTime = 0; DebugNote = null; } } catch (Exception Scrap) { SessionCore.LogError($"{Drill?.CustomName}.Close().DebugClose", Scrap); } try { SessionCore.SaveUnregister(Save); SyncHarvestEfficiency.GotValueFromServer -= Drill.UpdateVisual; SyncHarvestEfficiency.Close(); } catch (Exception Scrap) { SessionCore.LogError($"{Drill?.CustomName}.Close()", Scrap); } }
void ComplainMissingLocal(string Missing) { try { var Player = MyAPIGateway.Session.LocalHumanPlayer; if (Player == null) { return; } if (Player.IdentityId != Tool.OwnerId) { return; } var Dist = Player.GetPosition().DistanceTo(Tool.GetPosition()); if (Dist > 200) { //SessionCore.DebugWrite(Tool.CustomName, $"ComplainMissing() exit - local player too far ({Math.Round(Dist)}m)", WriteOnlyIfDebug: true); return; } //SessionCore.DebugWrite(Tool.CustomName, $"ComplainMissing() successfully complained. Missing length: {Missing.Length}", WriteOnlyIfDebug: true); ToolComp.MissingHUD.Text = Missing; HUDMessageUpdate = DateTime.Now; ToolComp.MissingHUD.Show(); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.ComplainMissing()", Scrap); } }
public override void Close() { try { if (SessionCore.Debug) { DebugNote.Hide(); DebugNote.AliveTime = 0; DebugNote = null; } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Close().DebugClose", Scrap); } try { SessionCore.SaveUnregister(Save); SyncBeamLength.GotValueFromServer -= Tool.UpdateVisual; SyncDistanceMode.GotValueFromServer -= Tool.UpdateVisual; SyncSpeedMultiplier.GotValueFromServer -= Tool.UpdateVisual; SyncBeamLength.Close(); SyncDistanceMode.Close(); SyncSpeedMultiplier.Close(); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Close()", Scrap); } }
public void Save() { try { Persistent persistent; persistent.HarvestMultiplier = SyncHarvestEfficiency.Get(); string Raw = Convert.ToBase64String(MyAPIGateway.Utilities.SerializeToBinary(persistent)); //MyAPIGateway.Utilities.SetVariable($"settings_{Drill.EntityId}", Raw); if (Drill.Storage != null) { if (Drill.Storage.ContainsKey(SessionCore.StorageGuid)) { Drill.Storage[SessionCore.StorageGuid] = Raw; } else { Drill.Storage.Add(SessionCore.StorageGuid, Raw); } } } catch (Exception Scrap) { SessionCore.LogError($"{Drill.CustomName}.Save()", Scrap); } }
public void Load() { try { if (MyAPIGateway.Multiplayer.MultiplayerActive && !MyAPIGateway.Multiplayer.IsServer) { ToolComp.TermModule.LoadSyncersFromServer(); return; } string Storage = ""; if (Tool.Storage == null) { SessionCore.DebugWrite($"{Tool.CustomName}.Load()", "Tool's Storage doesn't exist."); ToolComp.TermModule.BeamLength = ToolComp.BeamCtlModule.MaxBeamLengthBlocks; return; } if (!Tool.Storage.ContainsKey(SessionCore.StorageGuid)) { SessionCore.DebugWrite($"{Tool.CustomName}.Load()", "Tool's Storage is empty."); ToolComp.TermModule.BeamLength = ToolComp.BeamCtlModule.MaxBeamLengthBlocks; return; } if (Tool.Storage.TryGetValue(SessionCore.StorageGuid, out Storage) == true /* || * MyAPIGateway.Utilities.GetVariable($"settings_{Tool.EntityId}", out Storage)*/) { try { SessionCore.DebugWrite($"{Tool.CustomName}.Load()", $"Accessing storage. Raw data: {Storage}"); PersistentStruct persistent = MyAPIGateway.Utilities.SerializeFromBinary <PersistentStruct>(Convert.FromBase64String(Storage)); ToolComp.TermModule.BeamLength = (int)persistent.BeamLength; if (ToolComp.TermModule.BeamLength > ToolComp.BeamCtlModule.MaxBeamLengthBlocks) { ToolComp.TermModule.BeamLength = ToolComp.BeamCtlModule.MaxBeamLengthBlocks; } ToolComp.TermModule.DistanceMode = persistent.DistanceBased; ToolComp.TermModule.SpeedMultiplier = (int)persistent.SpeedMultiplier; SessionCore.DebugWrite($"{Tool.CustomName}.Load()", $"Loaded from storage. Persistent Beamlength: {persistent.BeamLength}; Sync Beamlength: {ToolComp.TermModule.BeamLength}"); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Load()", Scrap); } } else { ToolComp.TermModule.BeamLength = ToolComp.BeamCtlModule.MaxBeamLengthBlocks; SessionCore.DebugWrite($"{Tool.CustomName}.Load()", "Storage access failed."); } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Load().AccessStorage", Scrap); } }
public override void Init() { try { SessionCore.SaveRegister(Save); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Persistence.Init()", Scrap); } }
void Main(int ticks = 0) { try { if (ticks == 0) { ticks = SessionCore.WorkSkipTicks; } System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); if (Tool.IsToolWorking()) { watch.Start(); } try { if (IsWelder && LocalPlayerIsOwner && HUDModule.MessageExpired) { MissingHUD.Hide(); } PowerModule.SetPowerUsage(); if (Tool.IsToolWorking() && PowerModule.HasEnoughPower) { Work(ticks); BeamCtlModule.DrawBeam(); } else if (!PowerModule.HasEnoughPower) { DebugNote.Text = $"{Tool.CustomName}: not enough power"; } else { DebugNote.Text = $"{Tool.CustomName}: idle"; //UnbuiltBlocks.Clear(); } Tool.RefreshCustomInfo(); //if (SessionCore.Debug) DebugNote.Text = $"{Tool.CustomName} perf. impact: {(RunTimesAvailable ? Math.Round(AvgRunTime, 5).ToString() : "--")}/{(RunTimesAvailable ? Math.Round(MaxRunTime, 5).ToString() : "--")} ms (avg/max)"; } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Main().Work()", Scrap); } if (Tool.IsToolWorking()) { watch.Stop(); watch.Report(Tool.CustomName, "Main()"); } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Main()", Scrap); } }
public static bool HasDrillLogic(IMyTerminalBlock Block) { try { return(Block.HasComponent <LaserDrill>()); } catch (Exception Scrap) { SessionCore.LogError("IsOurBlock", Scrap); return(false); } }
public override void Close() { UnsubscribeFromEvents(); try { //InventoryList.Close(); } catch (Exception Scrap) { SessionCore.LogError($"{Grid.CustomName}.GridInventory.Close().CloseSyncer", Scrap); } }
public void Save() { try { Persistent persistent; persistent.HarvestMultiplier = SyncHarvestEfficiency.Get(); string Raw = Convert.ToBase64String(MyAPIGateway.Utilities.SerializeToBinary(persistent)); MyAPIGateway.Utilities.SetVariable($"settings_{Drill.EntityId}", Raw); Drill.Storage?.AddOrUpdate(SessionCore.StorageGuid, Raw); } catch (Exception Scrap) { SessionCore.LogError($"{Drill.CustomName}.Save()", Scrap); } }
public static void DrillAction(IMyTerminalBlock Block, Action <LaserDrill> Action) { try { LaserDrill Logic; if (!Block.TryGetComponent(out Logic)) { return; } Action(Logic); } catch (Exception Scrap) { SessionCore.LogError("BlockAction", Scrap); return; } }
public static T BlockReturn <T>(IMyTerminalBlock Block, Func <LaserToolBase, T> Getter, T Default = default(T)) { try { LaserToolBase Logic; if (!Block.TryGetComponent(out Logic)) { return(Default); } return(Getter(Logic)); } catch (Exception Scrap) { SessionCore.LogError("BlockReturn", Scrap); return(Default); } }
public void Save() { try { Persistent persistent; persistent.BeamLength = SyncBeamLength.Get(); persistent.DistanceBased = SyncDistanceMode.Get(); persistent.SpeedMultiplier = SyncSpeedMultiplier.Get(); string Raw = Convert.ToBase64String(MyAPIGateway.Utilities.SerializeToBinary(persistent)); MyAPIGateway.Utilities.SetVariable($"settings_{Tool.EntityId}", Raw); Tool.Storage?.AddOrUpdate(SessionCore.StorageGuid, Raw); SessionCore.DebugWrite($"{Tool.CustomName}.Load()", $"Set settings to storage. Saved beamlength: {persistent.BeamLength}"); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Save()", Scrap); } }
public void Load() { try { if (MyAPIGateway.Multiplayer.MultiplayerActive && !MyAPIGateway.Multiplayer.IsServer) { SyncBeamLength.Ask(); SyncDistanceMode.Ask(); SyncSpeedMultiplier.Ask(); return; } string Storage = ""; //if (Tool.Storage.ContainsKey(SessionCore.StorageGuid)) if (Tool.Storage?.TryGetValue(SessionCore.StorageGuid, out Storage) == true || MyAPIGateway.Utilities.GetVariable($"settings_{Tool.EntityId}", out Storage)) { try { Persistent persistent = MyAPIGateway.Utilities.SerializeFromBinary <Persistent>(Convert.FromBase64String(Storage)); SyncBeamLength.Set(persistent.BeamLength); SyncDistanceMode.Set(persistent.DistanceBased); SyncSpeedMultiplier.Set(persistent.SpeedMultiplier); SessionCore.DebugWrite($"{Tool.CustomName}.Load()", $"Loaded from storage. Persistent Beamlength: {persistent.BeamLength}; Sync Beamlength: {SyncBeamLength.Get()}"); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Load()", Scrap); } } else { SessionCore.DebugWrite($"{Tool.CustomName}.Load()", "Storage access failed."); } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Load().AccessStorage", Scrap); } }
public void Save() { if (Tool.Storage == null) { SessionCore.DebugWrite($"{Tool.CustomName}.Save()", "Tool's Storage doesn't exist."); return; } if (!Tool.Storage.ContainsKey(SessionCore.StorageGuid)) { SessionCore.DebugWrite($"{Tool.CustomName}.Save()", "Tool's Storage is empty."); Tool.Storage[SessionCore.StorageGuid] = ""; } try { PersistentStruct persistent; persistent.BeamLength = ToolComp.TermModule.BeamLength; persistent.DistanceBased = ToolComp.TermModule.DistanceMode; persistent.SpeedMultiplier = ToolComp.TermModule.SpeedMultiplier; string Raw = Convert.ToBase64String(MyAPIGateway.Utilities.SerializeToBinary(persistent)); //MyAPIGateway.Utilities.SetVariable($"settings_{Tool.EntityId}", Raw); if (!Tool.Storage.ContainsKey(SessionCore.StorageGuid)) { Tool.Storage.Add(SessionCore.StorageGuid, Raw); } else { Tool.Storage[SessionCore.StorageGuid] = Raw; } SessionCore.DebugWrite($"{Tool.CustomName}.Save()", $"Saved to storage. Raw data: {Raw}"); SessionCore.DebugWrite($"{Tool.CustomName}.Save()", $"Checked raw data: {Tool.Storage[SessionCore.StorageGuid]}"); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Save()", Scrap); } }
void Main(int ticks) { try { Tool.ResourceSink.SetRequiredInputByType(Electricity, PowerConsumptionFunc()); if (Tool.IsToolWorking() && HasEnoughPower) { Work(ticks); DrawBeam(); } else { DebugNote.Text = $"{Tool.CustomName}: idle"; UnbuiltBlocks.Clear(); } Tool.RefreshCustomInfo(); //if (SessionCore.Debug) DebugNote.Text = $"{Tool.CustomName} perf. impact: {(RunTimesAvailable ? Math.Round(AvgRunTime, 5).ToString() : "--")}/{(RunTimesAvailable ? Math.Round(MaxRunTime, 5).ToString() : "--")} ms (avg/max)"; } catch (Exception Scrap) { SessionCore.LogError(Tool.CustomName, Scrap); } }
public override void Init() { try { if (ToolComp.Tool == null) { throw new Exception("ToolComp.Tool is null"); } MissingText = new Syncer <string>(Tool, "Missing", ""); HUDMessageUpdate = DateTime.Now - TimeSpan.FromSeconds(10); try { MissingText.GotValueFromServer += ComplainMissingLocal; } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.HudModule.Init().Subscribe", Scrap); } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.HudModule.Init().New", Scrap); } }
public override void UpdateOnceBeforeFrame() { try { if (!Networker.Inited) { Networker.Init(SessionCore.ModID); } try { if (Tool.CubeGrid.Physics?.Enabled != true) { NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME; return; } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().PhysicsCheck", Scrap); } try { ToolCargo = Tool.GetInventory(); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().GetInventory", Scrap); } try { TermModule.Init(); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().TermModuleInit", Scrap); } try { PersistenceModule.Init(); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().PersistenceModuleInit", Scrap); } try { PersistenceModule.Load(); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().PersistenceModuleLoad", Scrap); } try { GridInventoryModule = ToolGrid.GetComponent <GridInventories>(); if (IsWelder) { GridInventoryModule.AddWatcher(Tool); } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().InventoryModule", Scrap); } try { HUDModule.Init(); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().HudModule", Scrap); } if (IsWelder && MyAPIGateway.Session.LocalHumanPlayer?.IdentityId == Tool.OwnerId) { MissingHUD = MyAPIGateway.Utilities.CreateNotification("", int.MaxValue, "Red"); } CheckInitControls(); NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; Tool.AppendingCustomInfo += Tool_AppendingCustomInfo; DebugNote = MyAPIGateway.Utilities.CreateNotification($"{Tool.CustomName}", int.MaxValue, (IsWelder ? "Blue" : "Red")); Owner = MyAPIGateway.Players.GetPlayer(Tool.OwnerId); if (SessionCore.Settings.Debug) { DebugNote.Show(); } } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame()", Scrap); } }
void Work(int ticks = 1) { if (!MyAPIGateway.Multiplayer.IsServer) { return; } if (IsDrill) { return; } LineD WeldRay = new LineD(BeamStart, BeamEnd); List <MyLineSegmentOverlapResult <MyEntity> > Overlaps = new List <MyLineSegmentOverlapResult <MyEntity> >(); MyGamePruningStructure.GetTopmostEntitiesOverlappingRay(ref WeldRay, Overlaps); HashSet <IMyCubeGrid> Grids = new HashSet <IMyCubeGrid>(); HashSet <IMyCharacter> Characters = new HashSet <IMyCharacter>(); HashSet <IMyFloatingObject> Flobjes = new HashSet <IMyFloatingObject>(); Overlaps.Select(x => x.Element as IMyEntity).SortByType(Grids, Characters, Flobjes); Grids.Remove(ToolGrid); if (SessionCore.Debug && Vector3D.Distance(BlockPosition, MyAPIGateway.Session.LocalHumanPlayer.GetPosition()) <= 200) { string GridNames = ""; foreach (var grid in Grids) { GridNames += $"{grid.DisplayName};"; } DebugNote.Text = $"{Tool.CustomName}: processing {Grids.Count} entities: {GridNames}"; GridNames = null; } foreach (IMyCubeGrid Grid in Grids) { //if (Grid.EntityId == ToolGrid.EntityId) continue; try { ProcessGrid(Grid, ticks); } catch (Exception Scrap) { SessionCore.LogError(Grid.DisplayName, Scrap); } } foreach (IMyCharacter Char in Characters) { if (Char.WorldAABB.Intersects(ref WeldRay)) { Char.DoDamage(GrinderSpeed * ticks / 2, MyDamageType.Grind, true, null, Tool.EntityId); } } foreach (IMyFloatingObject Flobj in Flobjes) { if ((double)ToolCargo.CurrentVolume / (double)ToolCargo.MaxVolume < 0.75) { ToolCargo.PickupItem(Flobj); } } /*if (Tool is IMyShipDrill) * { * List<MyLineSegmentOverlapResult<MyVoxelBase>> VoxelOverlaps = new List<MyLineSegmentOverlapResult<MyVoxelBase>>(); * MyGamePruningStructure.GetVoxelMapsOverlappingRay(ref WeldRay, VoxelOverlaps); * MyVoxelBase Voxel = VoxelOverlaps.OrderBy(x => Vector3D.DistanceSquared(BlockPosition, x.Element.PositionComp.GetPosition())).First().Element; * ProcessVoxel(Voxel, ticks); * }*/ }
void Place(ICollection <IMySlimBlock> _Blocks) { try { if (_Blocks.Count == 0) { return; } HashSet <IMySlimBlock> Blocks = new HashSet <IMySlimBlock>(_Blocks); HashSet <IMySlimBlock> unbuilt = new HashSet <IMySlimBlock>(); var Projector = ((Blocks.First().CubeGrid as MyCubeGrid).Projector as IMyProjector); if (MyAPIGateway.Session.CreativeMode) { foreach (IMySlimBlock Block in Blocks) { Projector.Build(Block, Tool.OwnerId, Tool.EntityId, false); } return; } Dictionary <string, int> ToPull = new Dictionary <string, int>(); if (Welder.UseConveyorSystem) { foreach (IMySlimBlock Block in Blocks) { var FirstItem = ((MyCubeBlockDefinition)Block.BlockDefinition).Components[0].Definition.Id; if (!ToPull.ContainsKey(FirstItem.SubtypeName)) { ToPull.Add(FirstItem.SubtypeName, 1); } else { ToPull[FirstItem.SubtypeName] += 1; } } lock (GridInventoryModule.InventoryLock) { GridInventoryModule.PullIn(Welder, Reduce(ToPull), "Component"); } } foreach (IMySlimBlock Block in Blocks) { var FirstItem = ((MyCubeBlockDefinition)Block.BlockDefinition).Components[0].Definition.Id; if (ToolCargo.GetItemAmount(FirstItem) >= 1) { Projector.Build(Block, Tool.OwnerId, Tool.EntityId, false); ToolCargo.RemoveItemsOfType(1, FirstItem); } else { unbuilt.Add(Block); } } SessionCore.DebugAsync(Tool.CustomName, $"Place failed for {unbuilt.Count} blocks: can't pull first component", WriteOnlyIfDebug: true); UnbuiltBlocks.UnionWith(unbuilt); ComplainUnbuilt(); } catch (Exception Scrap) { SessionCore.LogError($"{Tool.CustomName}.Place()", Scrap); } }
void Work(int ticks = 1) { if (IsDrill) { return; } LineD WeldRay = new LineD(BeamCtlModule.BeamStart, BeamCtlModule.BeamEnd); List <MyLineSegmentOverlapResult <MyEntity> > Overlaps = new List <MyLineSegmentOverlapResult <MyEntity> >(); MyGamePruningStructure.GetTopmostEntitiesOverlappingRay(ref WeldRay, Overlaps); HashSet <IMyCubeGrid> Grids = new HashSet <IMyCubeGrid>(); HashSet <IMyCharacter> Characters = new HashSet <IMyCharacter>(); HashSet <IMyFloatingObject> Flobjes = new HashSet <IMyFloatingObject>(); Overlaps.Select(x => x.Element as IMyEntity).SortByType(Grids, Characters, Flobjes); Grids.Remove(ToolGrid); if (SessionCore.Settings.Debug && Vector3D.Distance(Tool.GetPosition(), MyAPIGateway.Session.LocalHumanPlayer.GetPosition()) <= 200) { string GridNames = ""; foreach (var grid in Grids) { GridNames += $"{grid.DisplayName};"; } DebugNote.Text = $"{Tool.CustomName}: processing {Grids.Count} entities: {GridNames}{(IsWelder ? $" sup.invs: {GridInventoryModule.GetAccessibleInventories(Tool).Count}; unbuilt: {(this as LaserWelder).UnbuiltBlocks.Count}" : "")}"; GridNames = null; } foreach (IMyCubeGrid Grid in Grids) { //if (Grid.EntityId == ToolGrid.EntityId) continue; try { ProcessGrid(Grid, ticks); } catch (Exception Scrap) { SessionCore.LogError(Grid.DisplayName, Scrap); } } if (MyAPIGateway.Session.IsServer) { foreach (IMyCharacter Char in Characters) { if (Char.WorldAABB.Intersects(ref WeldRay)) { Char.DoDamage(VanillaToolConstants.GrinderSpeed * ticks / 2, MyDamageType.Grind, true, null, Tool.EntityId); } } foreach (IMyFloatingObject Flobj in Flobjes) { if (CargoFillRatio < 0.75) { ToolCargo.PickupItem(Flobj); } else { break; } } } }