public override void SendFillRequest(MyVoxelBase voxel, byte newMaterialIndex) { voxel.RequestVoxelOperationSphere(Center, Radius, newMaterialIndex, MyVoxelBase.OperationType.Fill); }
public override void SendCutOutRequest(MyVoxelBase voxel) { voxel.RequestVoxelOperationSphere(Center, Radius, 0, MyVoxelBase.OperationType.Cut); }
public override void SendPaintRequest(MyVoxelBase voxel, byte newMaterialIndex) { voxel.RequestVoxelOperationSphere(Center, Radius, newMaterialIndex, OperationType.Paint); }
private void TransferFromTarget(NaniteMiningItem target) { // Must be invoked from game thread IMyEntity entity; if (!MyAPIGateway.Entities.TryGetEntityById(target.VoxelId, out entity)) { CancelTarget(target); return; } MyAPIGateway.Parallel.Start(() => { try { if (entity == null || !IsValidVoxelTarget(target, entity)) { MyAPIGateway.Utilities.InvokeOnGameThread(() => { CancelTarget(target); }); return; } MyAPIGateway.Utilities.InvokeOnGameThread(() => { // Invocation 0 try { var def = MyDefinitionManager.Static.GetVoxelMaterialDefinition(target.VoxelMaterial); var item = MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_Ore>(def.MinedOre); var inventory = ((MyCubeBlock)m_constructionBlock.ConstructionBlock).GetInventory(); MyInventory targetInventory = ((MyCubeBlock)m_constructionBlock.ConstructionBlock).GetInventory(); if (targetInventory != null && targetInventory.CanItemsBeAdded((MyFixedPoint)(target.Amount), item.GetId())) { if (entity == null) { CancelTarget(target); return; } var ownerName = targetInventory.Owner as IMyTerminalBlock; if (ownerName != null) { Logging.Instance.WriteLine($"[Mining] Transfer - Adding {target.Amount} {item.GetId().SubtypeName} to {ownerName.CustomName}", 1); } if (!targetInventory.AddItems((MyFixedPoint)(target.Amount), item)) { Logging.Instance.WriteLine($"Error while transferring {target.Amount} {item.GetId().SubtypeName}! Aborting mining operation."); return; } IMyVoxelBase voxel = entity as IMyVoxelBase; MyVoxelBase voxelBase = voxel as MyVoxelBase; voxelBase.RequestVoxelOperationSphere(target.Position, 1f, target.VoxelMaterial, MyVoxelBase.OperationType.Cut); AddMinedPosition(target); CompleteTarget(target); return; } Logging.Instance.WriteLine("[Mining] Mined materials could not be moved. No free cargo space (probably)!", 1); CancelTarget(target); } catch (Exception e) { Logging.Instance.WriteLine($"Exception in NaniteMiningTargets.TransferFromTarget (Invocation 0):\n{e}"); } }); } catch (Exception e) { Logging.Instance.WriteLine($"Exception in NaniteMiningTargets.TransferFromTarget:\n{e}"); } }); }
public override void SendRevertRequest(MyVoxelBase voxel) { voxel.RequestVoxelOperationSphere(this.Center, this.Radius, 0, MyVoxelBase.OperationType.Revert); }