Vector3I?MirrorPaint(bool sync, IMyCubeGrid grid, int axis, MirrorData mirrorPlanes, bool odd, Vector3I originalPosition, PaintMaterial paint, List <Vector3I> alreadyMirrored, ulong originalSenderSteamId) { Vector3I?mirrorPosition = null; switch (axis) { case 0: if (mirrorPlanes.X.HasValue) { mirrorPosition = originalPosition + new Vector3I(((mirrorPlanes.X.Value - originalPosition.X) * 2) - (odd ? 1 : 0), 0, 0); } break; case 1: if (mirrorPlanes.Y.HasValue) { mirrorPosition = originalPosition + new Vector3I(0, ((mirrorPlanes.Y.Value - originalPosition.Y) * 2) - (odd ? 1 : 0), 0); } break; case 2: if (mirrorPlanes.Z.HasValue) { mirrorPosition = originalPosition + new Vector3I(0, 0, ((mirrorPlanes.Z.Value - originalPosition.Z) * 2) + (odd ? 1 : 0)); // reversed on odd } break; } if (mirrorPosition.HasValue && originalPosition != mirrorPosition.Value && !alreadyMirrored.Contains(mirrorPosition.Value) && grid.CubeExists(mirrorPosition.Value)) { alreadyMirrored.Add(mirrorPosition.Value); PaintBlock(sync, grid, mirrorPosition.Value, paint, originalSenderSteamId); } return(mirrorPosition); }
/// <summary> /// <param name="sync"></param> arg determines if it sends the paint request using the API, and automatically checks skin ownership. Must be false for mod-added skins. /// </summary> public void PaintBlockSymmetry(bool sync, IMyCubeGrid grid, Vector3I gridPosition, PaintMaterial paint, MirrorData mirrorData, ulong originalSenderSteamId) { PaintBlock(sync, grid, gridPosition, paint, originalSenderSteamId); List <Vector3I> alreadyMirrored = Main.Caches.AlreadyMirrored; alreadyMirrored.Clear(); Vector3I?mirrorX = MirrorPaint(sync, grid, 0, mirrorData, mirrorData.OddX, gridPosition, paint, alreadyMirrored, originalSenderSteamId); // X Vector3I?mirrorY = MirrorPaint(sync, grid, 1, mirrorData, mirrorData.OddY, gridPosition, paint, alreadyMirrored, originalSenderSteamId); // Y Vector3I?mirrorZ = MirrorPaint(sync, grid, 2, mirrorData, mirrorData.OddZ, gridPosition, paint, alreadyMirrored, originalSenderSteamId); // Z Vector3I?mirrorYZ = null; if (mirrorX.HasValue && mirrorData.Y.HasValue) // XY { MirrorPaint(sync, grid, 1, mirrorData, mirrorData.OddY, mirrorX.Value, paint, alreadyMirrored, originalSenderSteamId); } if (mirrorX.HasValue && mirrorData.Z.HasValue) // XZ { MirrorPaint(sync, grid, 2, mirrorData, mirrorData.OddZ, mirrorX.Value, paint, alreadyMirrored, originalSenderSteamId); } if (mirrorY.HasValue && mirrorData.Z.HasValue) // YZ { mirrorYZ = MirrorPaint(sync, grid, 2, mirrorData, mirrorData.OddZ, mirrorY.Value, paint, alreadyMirrored, originalSenderSteamId); } if (mirrorData.X.HasValue && mirrorYZ.HasValue) // XYZ { MirrorPaint(sync, grid, 0, mirrorData, mirrorData.OddX, mirrorYZ.Value, paint, alreadyMirrored, originalSenderSteamId); } }